From fba8c776e16d87e3e5b944cd156ec94e3c1aff6a Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 23 Nov 2012 00:30:11 +0100 Subject: plugin mechanism implemented --- lib/public/contacts.php | 221 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 158 insertions(+), 63 deletions(-) (limited to 'lib') diff --git a/lib/public/contacts.php b/lib/public/contacts.php index 5762fd28e02..51d4e03f006 100644 --- a/lib/public/contacts.php +++ b/lib/public/contacts.php @@ -26,78 +26,173 @@ * */ +namespace OC { + interface AddressBook { + + /** + * @return string defining the technical unique key + */ + public function getKey(); + + /** + * In comparison to getKey() this function returns a human readable (maybe translated) name + * @return mixed + */ + public function getDisplayName(); + + /** + * @param $pattern + * @param $searchProperties + * @param $options + * @return mixed + */ + public function search($pattern, $searchProperties, $options); +// // dummy results +// return array( +// array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), +// array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), +// ); + + /** + * @param $properties + * @return mixed + */ + public function createOrUpdate($properties); +// // dummy +// return array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', +// 'PHOTO' => 'VALUE=uri:http://www.abc.com/pub/photos/jqpublic.gif', +// 'ADR' => ';;123 Main Street;Any Town;CA;91921-1234' +// ); + + /** + * @return mixed + */ + public function isReadOnly(); + + /** + * @param $id + * @return mixed + */ + public function delete($id); + } +} + // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes -namespace OCP; +namespace OCP { -/** - * This class provides access to the contacts app. Use this class exclusively if you want to access contacts. - * - * Contacts in general will be expressed as an array of key-value-pairs. - * The keys will match the property names defined in https://tools.ietf.org/html/rfc2426#section-1 - * - * Proposed workflow for working with contacts: - * - search for the contacts - * - manipulate the results array - * - createOrUpdate will save the given contacts overwriting the existing data - * - * For updating it is mandatory to keep the id. - * Without an id a new contact will be created. - * - */ -class Contacts -{ /** - * This function is used to search and find contacts within the users address books. - * In case $pattern is empty all contacts will be returned. + * This class provides access to the contacts app. Use this class exclusively if you want to access contacts. + * + * Contacts in general will be expressed as an array of key-value-pairs. + * The keys will match the property names defined in https://tools.ietf.org/html/rfc2426#section-1 + * + * Proposed workflow for working with contacts: + * - search for the contacts + * - manipulate the results array + * - createOrUpdate will save the given contacts overwriting the existing data + * + * For updating it is mandatory to keep the id. + * Without an id a new contact will be created. * - * @param string $pattern which should match within the $searchProperties - * @param array $searchProperties defines the properties within the query pattern should match - * @param array $options - for future use. One should always have options! - * @return array of contacts which are arrays of key-value-pairs */ - public static function search($pattern, $searchProperties = array(), $options = array()) { + class Contacts { - // dummy results - return array( - array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), - array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), - ); - } + /** + * This function is used to search and find contacts within the users address books. + * In case $pattern is empty all contacts will be returned. + * + * @param string $pattern which should match within the $searchProperties + * @param array $searchProperties defines the properties within the query pattern should match + * @param array $options - for future use. One should always have options! + * @return array of contacts which are arrays of key-value-pairs + */ + public static function search($pattern, $searchProperties = array(), $options = array()) { - /** - * This function can be used to delete the contact identified by the given id - * - * @param object $id the unique identifier to a contact - * @return bool successful or not - */ - public static function delete($id) { - return false; - } + $result = array(); + foreach(self::$address_books as $address_book) { + $result = $result + $address_book->search($pattern, $searchProperties, $options); + } - /** - * This function is used to create a new contact if 'id' is not given or not present. - * Otherwise the contact will be updated by replacing the entire data set. - * - * @param array $properties this array if key-value-pairs defines a contact - * @return array representing the contact just created or updated - */ - public static function createOrUpdate($properties) { + return $result; + } - // dummy - return array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', - 'PHOTO' => 'VALUE=uri:http://www.abc.com/pub/photos/jqpublic.gif', - 'ADR' => ';;123 Main Street;Any Town;CA;91921-1234' - ); - } + /** + * This function can be used to delete the contact identified by the given id + * + * @param object $id the unique identifier to a contact + * @param $address_book_key + * @return bool successful or not + */ + public static function delete($id, $address_book_key) { + if (!array_key_exists($address_book_key, self::$address_books)) + return null; - /** - * Check if contacts are available (e.g. contacts app enabled) - * - * @return bool true if enabled, false if not - */ - public static function isEnabled() { - return false; - } + $address_book = self::$address_books[$address_book_key]; + if ($address_book->isReadOnly()) + return null; -} + return $address_book->delete($id); + } + + /** + * This function is used to create a new contact if 'id' is not given or not present. + * Otherwise the contact will be updated by replacing the entire data set. + * + * @param array $properties this array if key-value-pairs defines a contact + * @param $address_book_key string to identify the address book in which the contact shall be created or updated + * @return array representing the contact just created or updated + */ + public static function createOrUpdate($properties, $address_book_key) { + + if (!array_key_exists($address_book_key, self::$address_books)) + return null; + + $address_book = self::$address_books[$address_book_key]; + if ($address_book->isReadOnly()) + return null; + + return $address_book->createOrUpdate($properties); + } + + /** + * Check if contacts are available (e.g. contacts app enabled) + * + * @return bool true if enabled, false if not + */ + public static function isEnabled() { + return !empty(self::$address_books); + } + + /** + * @param \OC\AddressBook $address_book + */ + public static function registerAddressBook(\OC\AddressBook $address_book) { + self::$address_books[$address_book->getKey()] = $address_book; + } + + /** + * @param \OC\AddressBook $address_book + */ + public static function unregisterAddressBook(\OC\AddressBook $address_book) { + unset(self::$address_books[$address_book->getKey()]); + } + + /** + * @return array + */ + public static function getAddressBooks() { + $result = array(); + foreach(self::$address_books as $address_book) { + $result[$address_book->getKey()] = $address_book->getDisplayName(); + } + + return $result; + } + + /** + * @var \OC\AddressBook[] which holds all registered address books + */ + private static $address_books = array(); + } +} \ No newline at end of file -- cgit v1.2.3 From 5b1dea56e551df1306bd2046c3d06f1e589b4c03 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 23 Nov 2012 21:48:39 +0100 Subject: change name to IAddressBook --- lib/public/contacts.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/public/contacts.php b/lib/public/contacts.php index 51d4e03f006..36195ef9c24 100644 --- a/lib/public/contacts.php +++ b/lib/public/contacts.php @@ -27,7 +27,7 @@ */ namespace OC { - interface AddressBook { + interface IAddressBook { /** * @return string defining the technical unique key @@ -165,16 +165,16 @@ namespace OCP { } /** - * @param \OC\AddressBook $address_book + * @param \OC\IAddressBook $address_book */ - public static function registerAddressBook(\OC\AddressBook $address_book) { + public static function registerAddressBook(\OC\IAddressBook $address_book) { self::$address_books[$address_book->getKey()] = $address_book; } /** - * @param \OC\AddressBook $address_book + * @param \OC\IAddressBook $address_book */ - public static function unregisterAddressBook(\OC\AddressBook $address_book) { + public static function unregisterAddressBook(\OC\IAddressBook $address_book) { unset(self::$address_books[$address_book->getKey()]); } @@ -191,7 +191,7 @@ namespace OCP { } /** - * @var \OC\AddressBook[] which holds all registered address books + * @var \OC\IAddressBook[] which holds all registered address books */ private static $address_books = array(); } -- cgit v1.2.3 From 2d597c2238c40ff0291fc80a4807aee6fc7bc4fc Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Sat, 24 Nov 2012 00:01:58 +0100 Subject: first unit tests implemented --- lib/public/contacts.php | 15 +++++--- tests/lib/public/contacts.php | 80 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 tests/lib/public/contacts.php (limited to 'lib') diff --git a/lib/public/contacts.php b/lib/public/contacts.php index 36195ef9c24..d14806bd0c4 100644 --- a/lib/public/contacts.php +++ b/lib/public/contacts.php @@ -67,7 +67,7 @@ namespace OC { /** * @return mixed */ - public function isReadOnly(); + public function getPermissions(); /** * @param $id @@ -129,7 +129,7 @@ namespace OCP { return null; $address_book = self::$address_books[$address_book_key]; - if ($address_book->isReadOnly()) + if ($address_book->getPermissions() & \OCP\PERMISSION_DELETE) return null; return $address_book->delete($id); @@ -149,7 +149,7 @@ namespace OCP { return null; $address_book = self::$address_books[$address_book_key]; - if ($address_book->isReadOnly()) + if ($address_book->getPermissions() & \OCP\PERMISSION_CREATE) return null; return $address_book->createOrUpdate($properties); @@ -190,9 +190,16 @@ namespace OCP { return $result; } + /** + * removes all registered address book instances + */ + public static function clear() { + self::$address_books = array(); + } + /** * @var \OC\IAddressBook[] which holds all registered address books */ private static $address_books = array(); } -} \ No newline at end of file +} diff --git a/tests/lib/public/contacts.php b/tests/lib/public/contacts.php new file mode 100644 index 00000000000..abe0e1f6250 --- /dev/null +++ b/tests/lib/public/contacts.php @@ -0,0 +1,80 @@ +. + */ + +OC::autoload('OCP\Contacts'); + +class Test_Contacts extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + + OCP\Contacts::clear(); + } + + public function tearDown() { + } + + public function testDisabledIfEmpty() { + // pretty simple + $this->assertFalse(OCP\Contacts::isEnabled()); + } + + public function testEnabledAfterRegister() { + // create mock for the addressbook + $stub = $this->getMock("SimpleAddressBook", array('getKey')); + + // we expect getKey to be called once + $stub->expects($this->once()) + ->method('getKey'); + + // not enabled before register + $this->assertFalse(OCP\Contacts::isEnabled()); + + // register the address book + OCP\Contacts::registerAddressBook($stub); + + // contacts api shall be enabled + $this->assertTrue(OCP\Contacts::isEnabled()); + } + + // + // TODO: test unregister + // + + public function testAddressBookEnumeration() { + // create mock for the addressbook + $stub = $this->getMock("SimpleAddressBook", array('getKey', 'getDisplayName')); + + // setup return for method calls + $stub->expects($this->any()) + ->method('getKey') + ->will($this->returnValue('SIMPLE_ADDRESS_BOOK')); + $stub->expects($this->any()) + ->method('getDisplayName') + ->will($this->returnValue('A very simple Addressbook')); + + // register the address book + OCP\Contacts::registerAddressBook($stub); + $all_books = OCP\Contacts::getAddressBooks(); + + $this->assertEquals(1, count($all_books)); + } +} -- cgit v1.2.3 From f99497a05a14ccf3c96ece71ae963a2eb482f4b6 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Sun, 25 Nov 2012 13:29:58 +0100 Subject: test for search and unregister added --- lib/public/contacts.php | 4 +-- tests/lib/public/contacts.php | 57 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/public/contacts.php b/lib/public/contacts.php index d14806bd0c4..412600dd7f6 100644 --- a/lib/public/contacts.php +++ b/lib/public/contacts.php @@ -108,10 +108,10 @@ namespace OCP { * @return array of contacts which are arrays of key-value-pairs */ public static function search($pattern, $searchProperties = array(), $options = array()) { - $result = array(); foreach(self::$address_books as $address_book) { - $result = $result + $address_book->search($pattern, $searchProperties, $options); + $r = $address_book->search($pattern, $searchProperties, $options); + $result = array_merge($result, $r); } return $result; diff --git a/tests/lib/public/contacts.php b/tests/lib/public/contacts.php index abe0e1f6250..23994667a26 100644 --- a/tests/lib/public/contacts.php +++ b/tests/lib/public/contacts.php @@ -41,8 +41,10 @@ class Test_Contacts extends PHPUnit_Framework_TestCase // create mock for the addressbook $stub = $this->getMock("SimpleAddressBook", array('getKey')); - // we expect getKey to be called once - $stub->expects($this->once()) + // we expect getKey to be called twice: + // first time on register + // second time on un-register + $stub->expects($this->exactly(2)) ->method('getKey'); // not enabled before register @@ -53,11 +55,13 @@ class Test_Contacts extends PHPUnit_Framework_TestCase // contacts api shall be enabled $this->assertTrue(OCP\Contacts::isEnabled()); - } - // - // TODO: test unregister - // + // unregister the address book + OCP\Contacts::unregisterAddressBook($stub); + + // not enabled after register + $this->assertFalse(OCP\Contacts::isEnabled()); + } public function testAddressBookEnumeration() { // create mock for the addressbook @@ -76,5 +80,46 @@ class Test_Contacts extends PHPUnit_Framework_TestCase $all_books = OCP\Contacts::getAddressBooks(); $this->assertEquals(1, count($all_books)); + $this->assertEquals('A very simple Addressbook', $all_books['SIMPLE_ADDRESS_BOOK']); + } + + public function testSearchInAddressBook() { + // create mock for the addressbook + $stub1 = $this->getMock("SimpleAddressBook1", array('getKey', 'getDisplayName', 'search')); + $stub2 = $this->getMock("SimpleAddressBook2", array('getKey', 'getDisplayName', 'search')); + + $searchResult1 = array( + array('id' => 0, 'FN' => 'Frank Karlitschek', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), + array('id' => 5, 'FN' => 'Klaas Freitag', 'EMAIL' => array('d@e.f', 'g@h.i')), + ); + $searchResult2 = array( + array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c'), + array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), + ); + + // setup return for method calls for $stub1 + $stub1->expects($this->any())->method('getKey')->will($this->returnValue('SIMPLE_ADDRESS_BOOK1')); + $stub1->expects($this->any())->method('getDisplayName')->will($this->returnValue('Address book ownCloud Inc')); + $stub1->expects($this->any())->method('search')->will($this->returnValue($searchResult1)); + + // setup return for method calls for $stub2 + $stub2->expects($this->any())->method('getKey')->will($this->returnValue('SIMPLE_ADDRESS_BOOK2')); + $stub2->expects($this->any())->method('getDisplayName')->will($this->returnValue('Address book ownCloud Community')); + $stub2->expects($this->any())->method('search')->will($this->returnValue($searchResult2)); + + // register the address books + OCP\Contacts::registerAddressBook($stub1); + OCP\Contacts::registerAddressBook($stub2); + $all_books = OCP\Contacts::getAddressBooks(); + + // assert the count - doesn't hurt + $this->assertEquals(2, count($all_books)); + + // perform the search + $result = OCP\Contacts::search('x', array()); + + // we expect 4 hits + $this->assertEquals(4, count($result)); + } } -- cgit v1.2.3 From 35e55214e24116a4501260ff4ce94c171404737b Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Sun, 2 Dec 2012 11:54:30 +0100 Subject: [Contacts API] example for searching added --- lib/public/contacts.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'lib') diff --git a/lib/public/contacts.php b/lib/public/contacts.php index 412600dd7f6..6842f40f1b3 100644 --- a/lib/public/contacts.php +++ b/lib/public/contacts.php @@ -102,6 +102,38 @@ namespace OCP { * This function is used to search and find contacts within the users address books. * In case $pattern is empty all contacts will be returned. * + * Example: + * Following function shows how to search for contacts for the name and the email address. + * + * public static function getMatchingRecipient($term) { + * // The API is not active -> nothing to do + * if (!\OCP\Contacts::isEnabled()) { + * return array(); + * } + * + * $result = \OCP\Contacts::search($term, array('FN', 'EMAIL')); + * $receivers = array(); + * foreach ($result as $r) { + * $id = $r['id']; + * $fn = $r['FN']; + * $email = $r['EMAIL']; + * if (!is_array($email)) { + * $email = array($email); + * } + * + * // loop through all email addresses of this contact + * foreach ($email as $e) { + * $displayName = $fn . " <$e>"; + * $receivers[] = array('id' => $id, + * 'label' => $displayName, + * 'value' => $displayName); + * } + * } + * + * return $receivers; + * } + * + * * @param string $pattern which should match within the $searchProperties * @param array $searchProperties defines the properties within the query pattern should match * @param array $options - for future use. One should always have options! -- cgit v1.2.3 From 4327ed83820f045395bbf1431cdddbdedfa19555 Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Mon, 3 Dec 2012 20:20:17 +0000 Subject: Revoke DB rights on install only if the db is newly created --- lib/setup.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/setup.php b/lib/setup.php index 264cd55795e..fdd10be6824 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -319,9 +319,11 @@ class OC_Setup { $entry.='Offending command was: '.$query.'
'; echo($entry); } + else { + $query = "REVOKE ALL PRIVILEGES ON DATABASE \"$e_name\" FROM PUBLIC"; + $result = pg_query($connection, $query); + } } - $query = "REVOKE ALL PRIVILEGES ON DATABASE \"$e_name\" FROM PUBLIC"; - $result = pg_query($connection, $query); } private static function pg_createDBUser($name, $password, $connection) { -- cgit v1.2.3 From 889e55fdac56ab3eecd6ce65db19e3dfeeff44ea Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Thu, 6 Dec 2012 23:51:35 +0100 Subject: [contacts_api] update documentation --- lib/public/contacts.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/public/contacts.php b/lib/public/contacts.php index 6842f40f1b3..ca0b15b2c78 100644 --- a/lib/public/contacts.php +++ b/lib/public/contacts.php @@ -41,10 +41,10 @@ namespace OC { public function getDisplayName(); /** - * @param $pattern - * @param $searchProperties - * @param $options - * @return mixed + * @param string $pattern which should match within the $searchProperties + * @param array $searchProperties defines the properties within the query pattern should match + * @param array $options - for future use. One should always have options! + * @return array of contacts which are arrays of key-value-pairs */ public function search($pattern, $searchProperties, $options); // // dummy results @@ -54,8 +54,8 @@ namespace OC { // ); /** - * @param $properties - * @return mixed + * @param array $properties this array if key-value-pairs defines a contact + * @return array representing the contact just created or updated */ public function createOrUpdate($properties); // // dummy @@ -70,8 +70,8 @@ namespace OC { public function getPermissions(); /** - * @param $id - * @return mixed + * @param object $id the unique identifier to a contact + * @return bool successful or not */ public function delete($id); } -- cgit v1.2.3 From 15afbfd198f9f54cee8717776b4f45f73d9b1cbf Mon Sep 17 00:00:00 2001 From: "Lorenzo M. Catucci" Date: Thu, 6 Dec 2012 18:09:47 +0100 Subject: Add an $excludingBackend optional parameter to the userExists method both in OCP\User and in OC_User. --- lib/public/user.php | 6 +++--- lib/user.php | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/public/user.php b/lib/public/user.php index b320ce8ea0c..9e50115ab70 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -65,12 +65,12 @@ class User { /** * @brief check if a user exists * @param string $uid the username + * @param string $excludingBackend (default none) * @return boolean */ - public static function userExists( $uid ) { - return \OC_USER::userExists( $uid ); + public static function userExists( $uid, $excludingBackend = null ) { + return \OC_USER::userExists( $uid, $excludingBackend ); } - /** * @brief Loggs the user out including all the session data * @returns true diff --git a/lib/user.php b/lib/user.php index 31c93740d77..d55c6165a09 100644 --- a/lib/user.php +++ b/lib/user.php @@ -407,10 +407,15 @@ class OC_User { /** * @brief check if a user exists * @param string $uid the username + * @param string $excludingBackend (default none) * @return boolean */ - public static function userExists($uid) { + public static function userExists($uid, $excludingBackend=null) { foreach(self::$_usedBackends as $backend) { + if (!is_null($excludingBackend) && !strcmp(get_class($backend),$excludingBackend)) { + OC_Log::write('OC_User', $excludingBackend . 'excluded from user existance check.', OC_Log::DEBUG); + continue; + } $result=$backend->userExists($uid); if($result===true) { return true; -- cgit v1.2.3 From b810e42cc70beb817de466835dcdc9de9d092bdc Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Fri, 7 Dec 2012 20:34:17 +0100 Subject: Improve autodetection of language. Fixes #730. --- lib/l10n.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/l10n.php b/lib/l10n.php index f172710e5d7..4f9c3a0edef 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -294,8 +294,14 @@ class OC_L10N{ } foreach($accepted_languages as $i) { $temp = explode(';', $i); - if(array_search($temp[0], $available) !== false) { - return $temp[0]; + $temp[0] = str_replace('-','_',$temp[0]); + if( ($key = array_search($temp[0], $available)) !== false) { + return $available[$key]; + } + } + foreach($available as $l) { + if ( $temp[0] == substr($l,0,2) ) { + return $l; } } } -- cgit v1.2.3 From 4cc895aa0a7d73e6817bfcc9f1fc4d76740b0513 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Sat, 8 Dec 2012 16:42:54 +0100 Subject: [contacts_api] move addressbook to it's own file --- lib/iaddressbook.php | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/public/contacts.php | 51 ----------------------------------- 2 files changed, 72 insertions(+), 51 deletions(-) create mode 100644 lib/iaddressbook.php (limited to 'lib') diff --git a/lib/iaddressbook.php b/lib/iaddressbook.php new file mode 100644 index 00000000000..39205140361 --- /dev/null +++ b/lib/iaddressbook.php @@ -0,0 +1,72 @@ +. + * + */ + +namespace OC { + interface IAddressBook { + + /** + * @return string defining the technical unique key + */ + public function getKey(); + + /** + * In comparison to getKey() this function returns a human readable (maybe translated) name + * @return mixed + */ + public function getDisplayName(); + + /** + * @param string $pattern which should match within the $searchProperties + * @param array $searchProperties defines the properties within the query pattern should match + * @param array $options - for future use. One should always have options! + * @return array of contacts which are arrays of key-value-pairs + */ + public function search($pattern, $searchProperties, $options); +// // dummy results +// return array( +// array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), +// array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), +// ); + + /** + * @param array $properties this array if key-value-pairs defines a contact + * @return array representing the contact just created or updated + */ + public function createOrUpdate($properties); +// // dummy +// return array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', +// 'PHOTO' => 'VALUE=uri:http://www.abc.com/pub/photos/jqpublic.gif', +// 'ADR' => ';;123 Main Street;Any Town;CA;91921-1234' +// ); + + /** + * @return mixed + */ + public function getPermissions(); + + /** + * @param object $id the unique identifier to a contact + * @return bool successful or not + */ + public function delete($id); + } +} diff --git a/lib/public/contacts.php b/lib/public/contacts.php index ca0b15b2c78..ab46614c8fd 100644 --- a/lib/public/contacts.php +++ b/lib/public/contacts.php @@ -26,57 +26,6 @@ * */ -namespace OC { - interface IAddressBook { - - /** - * @return string defining the technical unique key - */ - public function getKey(); - - /** - * In comparison to getKey() this function returns a human readable (maybe translated) name - * @return mixed - */ - public function getDisplayName(); - - /** - * @param string $pattern which should match within the $searchProperties - * @param array $searchProperties defines the properties within the query pattern should match - * @param array $options - for future use. One should always have options! - * @return array of contacts which are arrays of key-value-pairs - */ - public function search($pattern, $searchProperties, $options); -// // dummy results -// return array( -// array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), -// array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), -// ); - - /** - * @param array $properties this array if key-value-pairs defines a contact - * @return array representing the contact just created or updated - */ - public function createOrUpdate($properties); -// // dummy -// return array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', -// 'PHOTO' => 'VALUE=uri:http://www.abc.com/pub/photos/jqpublic.gif', -// 'ADR' => ';;123 Main Street;Any Town;CA;91921-1234' -// ); - - /** - * @return mixed - */ - public function getPermissions(); - - /** - * @param object $id the unique identifier to a contact - * @return bool successful or not - */ - public function delete($id); - } -} - // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes namespace OCP { -- cgit v1.2.3 From 7b0e2b348b3ad5b4351c37cc91531718773c3864 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Sun, 9 Dec 2012 20:21:04 +0100 Subject: Fix the loop to search al the available languages, not only the las element. --- lib/l10n.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/l10n.php b/lib/l10n.php index 4f9c3a0edef..b83d8ff86db 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -298,10 +298,10 @@ class OC_L10N{ if( ($key = array_search($temp[0], $available)) !== false) { return $available[$key]; } - } - foreach($available as $l) { - if ( $temp[0] == substr($l,0,2) ) { - return $l; + foreach($available as $l) { + if ( $temp[0] == substr($l,0,2) ) { + return $l; + } } } } -- cgit v1.2.3 From 8126b09bfe28a2af07d38aa907dc574c6819ecfc Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Tue, 11 Dec 2012 14:56:04 +0100 Subject: add debug logging for user backend registration --- lib/user.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/user.php b/lib/user.php index 31c93740d77..94ea899b841 100644 --- a/lib/user.php +++ b/lib/user.php @@ -86,8 +86,9 @@ class OC_User { */ public static function useBackend( $backend = 'database' ) { if($backend instanceof OC_User_Interface) { + OC_Log::write('core', 'Adding user backend instance of '.get_class($backend).'.', OC_Log::DEBUG); self::$_usedBackends[get_class($backend)]=$backend; - }else{ + } else { // You'll never know what happens if( null === $backend OR !is_string( $backend )) { $backend = 'database'; @@ -98,15 +99,17 @@ class OC_User { case 'database': case 'mysql': case 'sqlite': + OC_Log::write('core', 'Adding user backend '.$backend.'.', OC_Log::DEBUG); self::$_usedBackends[$backend] = new OC_User_Database(); break; default: + OC_Log::write('core', 'Adding default user backend '.$backend.'.', OC_Log::DEBUG); $className = 'OC_USER_' . strToUpper($backend); self::$_usedBackends[$backend] = new $className(); break; } } - true; + return true; } /** @@ -124,15 +127,19 @@ class OC_User { foreach($backends as $i=>$config) { $class=$config['class']; $arguments=$config['arguments']; - if(class_exists($class) and array_search($i, self::$_setupedBackends)===false) { - // make a reflection object - $reflectionObj = new ReflectionClass($class); - - // use Reflection to create a new instance, using the $args - $backend = $reflectionObj->newInstanceArgs($arguments); - self::useBackend($backend); - $_setupedBackends[]=$i; - }else{ + if(class_exists($class)) { + if(array_search($i, self::$_setupedBackends)===false) { + // make a reflection object + $reflectionObj = new ReflectionClass($class); + + // use Reflection to create a new instance, using the $args + $backend = $reflectionObj->newInstanceArgs($arguments); + self::useBackend($backend); + $_setupedBackends[]=$i; + } else { + OC_Log::write('core', 'User backend '.$class.' already initialized.', OC_Log::DEBUG); + } + } else { OC_Log::write('core', 'User backend '.$class.' not found.', OC_Log::ERROR); } } -- cgit v1.2.3 From af12b0f5da25d2c01bf57ef1af882b92c77f934e Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 11 Dec 2012 16:00:48 +0100 Subject: Autoload classes with 'OC' namespace prefix. --- lib/base.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/base.php b/lib/base.php index bde65dcc7d1..88628452613 100644 --- a/lib/base.php +++ b/lib/base.php @@ -90,6 +90,9 @@ class OC{ elseif(strpos($className, 'OC_')===0) { $path = strtolower(str_replace('_', '/', substr($className, 3)) . '.php'); } + elseif(strpos($className, 'OC\\')===0) { + $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php'); + } elseif(strpos($className, 'OCP\\')===0) { $path = 'public/'.strtolower(str_replace('\\', '/', substr($className, 3)) . '.php'); } -- cgit v1.2.3 From 8ed0ce7801985d6d7e07af8eb21de480a4422f2c Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Tue, 11 Dec 2012 17:42:09 +0100 Subject: [contacts_api] IAddressBook moved to OCP as it's used by apps to provide access to their contact data --- lib/iaddressbook.php | 72 ------------------------------------------- lib/public/contacts.php | 10 +++--- lib/public/iaddressbook.php | 74 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 77 deletions(-) delete mode 100644 lib/iaddressbook.php create mode 100644 lib/public/iaddressbook.php (limited to 'lib') diff --git a/lib/iaddressbook.php b/lib/iaddressbook.php deleted file mode 100644 index 39205140361..00000000000 --- a/lib/iaddressbook.php +++ /dev/null @@ -1,72 +0,0 @@ -. - * - */ - -namespace OC { - interface IAddressBook { - - /** - * @return string defining the technical unique key - */ - public function getKey(); - - /** - * In comparison to getKey() this function returns a human readable (maybe translated) name - * @return mixed - */ - public function getDisplayName(); - - /** - * @param string $pattern which should match within the $searchProperties - * @param array $searchProperties defines the properties within the query pattern should match - * @param array $options - for future use. One should always have options! - * @return array of contacts which are arrays of key-value-pairs - */ - public function search($pattern, $searchProperties, $options); -// // dummy results -// return array( -// array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), -// array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), -// ); - - /** - * @param array $properties this array if key-value-pairs defines a contact - * @return array representing the contact just created or updated - */ - public function createOrUpdate($properties); -// // dummy -// return array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', -// 'PHOTO' => 'VALUE=uri:http://www.abc.com/pub/photos/jqpublic.gif', -// 'ADR' => ';;123 Main Street;Any Town;CA;91921-1234' -// ); - - /** - * @return mixed - */ - public function getPermissions(); - - /** - * @param object $id the unique identifier to a contact - * @return bool successful or not - */ - public function delete($id); - } -} diff --git a/lib/public/contacts.php b/lib/public/contacts.php index ab46614c8fd..4cf57ed8ff2 100644 --- a/lib/public/contacts.php +++ b/lib/public/contacts.php @@ -146,16 +146,16 @@ namespace OCP { } /** - * @param \OC\IAddressBook $address_book + * @param \OCP\IAddressBook $address_book */ - public static function registerAddressBook(\OC\IAddressBook $address_book) { + public static function registerAddressBook(\OCP\IAddressBook $address_book) { self::$address_books[$address_book->getKey()] = $address_book; } /** - * @param \OC\IAddressBook $address_book + * @param \OCP\IAddressBook $address_book */ - public static function unregisterAddressBook(\OC\IAddressBook $address_book) { + public static function unregisterAddressBook(\OCP\IAddressBook $address_book) { unset(self::$address_books[$address_book->getKey()]); } @@ -179,7 +179,7 @@ namespace OCP { } /** - * @var \OC\IAddressBook[] which holds all registered address books + * @var \OCP\IAddressBook[] which holds all registered address books */ private static $address_books = array(); } diff --git a/lib/public/iaddressbook.php b/lib/public/iaddressbook.php new file mode 100644 index 00000000000..14943747f48 --- /dev/null +++ b/lib/public/iaddressbook.php @@ -0,0 +1,74 @@ +. + * + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP { + interface IAddressBook { + + /** + * @return string defining the technical unique key + */ + public function getKey(); + + /** + * In comparison to getKey() this function returns a human readable (maybe translated) name + * @return mixed + */ + public function getDisplayName(); + + /** + * @param string $pattern which should match within the $searchProperties + * @param array $searchProperties defines the properties within the query pattern should match + * @param array $options - for future use. One should always have options! + * @return array of contacts which are arrays of key-value-pairs + */ + public function search($pattern, $searchProperties, $options); +// // dummy results +// return array( +// array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), +// array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), +// ); + + /** + * @param array $properties this array if key-value-pairs defines a contact + * @return array representing the contact just created or updated + */ + public function createOrUpdate($properties); +// // dummy +// return array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', +// 'PHOTO' => 'VALUE=uri:http://www.abc.com/pub/photos/jqpublic.gif', +// 'ADR' => ';;123 Main Street;Any Town;CA;91921-1234' +// ); + + /** + * @return mixed + */ + public function getPermissions(); + + /** + * @param object $id the unique identifier to a contact + * @return bool successful or not + */ + public function delete($id); + } +} -- cgit v1.2.3 From b8b64d6ffc0645f5806d7120e337c2652e49c2e7 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Wed, 12 Dec 2012 11:46:43 +0100 Subject: set the session name to the instance id - which is unique Conflicts: lib/base.php --- lib/base.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/base.php b/lib/base.php index 88628452613..0b75f6f085e 100644 --- a/lib/base.php +++ b/lib/base.php @@ -289,6 +289,9 @@ class OC{ // prevents javascript from accessing php session cookies ini_set('session.cookie_httponly', '1;'); + // set the session name to the instance id - which is unique + session_name(OC_Util::getInstanceId()); + // (re)-initialize session session_start(); -- cgit v1.2.3 From 84420035dfa1176a156b837e55bc3ac4ca946840 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Wed, 12 Dec 2012 20:09:57 +0100 Subject: throwing InsufficientStorage in case the quota is reached --- lib/connector/sabre/quotaplugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/connector/sabre/quotaplugin.php b/lib/connector/sabre/quotaplugin.php index a56a65ad863..fbbb4a3cf6f 100644 --- a/lib/connector/sabre/quotaplugin.php +++ b/lib/connector/sabre/quotaplugin.php @@ -51,7 +51,7 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin { } list($parentUri, $newName) = Sabre_DAV_URLUtil::splitPath($uri); if ($length > OC_Filesystem::free_space($parentUri)) { - throw new Sabre_DAV_Exception('Quota exceeded. File is too big.'); + throw new Sabre_DAV_Exception_InsufficientStorage(); } } return true; -- cgit v1.2.3 From 4466e06e7d9413a27d462570066254e2d33d76ef Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 13 Dec 2012 01:30:25 +0100 Subject: use username, not passed loginname, might differ --- lib/connector/sabre/auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/connector/sabre/auth.php b/lib/connector/sabre/auth.php index db8f005745a..4224dbbb14e 100644 --- a/lib/connector/sabre/auth.php +++ b/lib/connector/sabre/auth.php @@ -32,7 +32,7 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic { */ protected function validateUserPass($username, $password) { if (OC_User::isLoggedIn()) { - OC_Util::setupFS($username); + OC_Util::setupFS(OC_User::getUser()); return true; } else { OC_Util::setUpFS();//login hooks may need early access to the filesystem -- cgit v1.2.3 From 627da205b32f0733e73e92c3c9702ed5b4f863f7 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 13 Dec 2012 01:30:34 +0100 Subject: implement getCurrentUser in Sabre Auth Connector, fixes #508 --- lib/connector/sabre/auth.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib') diff --git a/lib/connector/sabre/auth.php b/lib/connector/sabre/auth.php index 4224dbbb14e..6990d928cff 100644 --- a/lib/connector/sabre/auth.php +++ b/lib/connector/sabre/auth.php @@ -45,4 +45,19 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic { } } } + + /** + * Returns information about the currently logged in username. + * + * If nobody is currently logged in, this method should return null. + * + * @return string|null + */ + public function getCurrentUser() { + $user = OC_User::getUser(); + if(!$user) { + return null; + } + return $user; + } } -- cgit v1.2.3 From 8256650da881214e652353c9b79a5ba7964965e5 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 22:52:40 +0100 Subject: Fix "No space found after comma in function call" --- apps/files_external/personal.php | 2 +- apps/files_external/settings.php | 2 +- apps/user_ldap/lib/access.php | 2 +- lib/helper.php | 2 +- lib/l10n.php | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/apps/files_external/personal.php b/apps/files_external/personal.php index 509c2977622..4215b28787e 100755 --- a/apps/files_external/personal.php +++ b/apps/files_external/personal.php @@ -29,6 +29,6 @@ $tmpl = new OCP\Template('files_external', 'settings'); $tmpl->assign('isAdminPage', false, false); $tmpl->assign('mounts', OC_Mount_Config::getPersonalMountPoints()); $tmpl->assign('certs', OC_Mount_Config::getCertificates()); -$tmpl->assign('dependencies', OC_Mount_Config::checkDependencies(),false); +$tmpl->assign('dependencies', OC_Mount_Config::checkDependencies(), false); $tmpl->assign('backends', $backends); return $tmpl->fetchPage(); diff --git a/apps/files_external/settings.php b/apps/files_external/settings.php index 94222149a38..2f239f7cb95 100644 --- a/apps/files_external/settings.php +++ b/apps/files_external/settings.php @@ -30,6 +30,6 @@ $tmpl->assign('mounts', OC_Mount_Config::getSystemMountPoints()); $tmpl->assign('backends', OC_Mount_Config::getBackends()); $tmpl->assign('groups', OC_Group::getGroups()); $tmpl->assign('users', OCP\User::getUsers()); -$tmpl->assign('dependencies', OC_Mount_Config::checkDependencies(),false); +$tmpl->assign('dependencies', OC_Mount_Config::checkDependencies(), false); $tmpl->assign('allowUserMounting', OCP\Config::getAppValue('files_external', 'allow_user_mounting', 'yes')); return $tmpl->fetchPage(); diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index 00183ac181b..91f56ad882e 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -133,7 +133,7 @@ abstract class Access { '\"' => '\5c22', '\#' => '\5c23', ); - $dn = str_replace(array_keys($replacements),array_values($replacements), $dn); + $dn = str_replace(array_keys($replacements), array_values($replacements), $dn); return $dn; } diff --git a/lib/helper.php b/lib/helper.php index 5dec7fadfb4..be4e4e52677 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -540,7 +540,7 @@ class OC_Helper { mkdir($tmpDirNoClean); } $file=$tmpDirNoClean.md5(time().rand()).$postfix; - $fh=fopen($file,'w'); + $fh=fopen($file, 'w'); fclose($fh); return $file; } diff --git a/lib/l10n.php b/lib/l10n.php index b83d8ff86db..cb67cfd4ed6 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -294,12 +294,12 @@ class OC_L10N{ } foreach($accepted_languages as $i) { $temp = explode(';', $i); - $temp[0] = str_replace('-','_',$temp[0]); + $temp[0] = str_replace('-', '_', $temp[0]); if( ($key = array_search($temp[0], $available)) !== false) { return $available[$key]; } foreach($available as $l) { - if ( $temp[0] == substr($l,0,2) ) { + if ( $temp[0] == substr($l, 0, 2) ) { return $l; } } -- cgit v1.2.3 From f39454ed12018402f38a8f6bf99fc94d676a0a3a Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 23:04:42 +0100 Subject: Fix "Line indented incorrectly" --- apps/files_versions/history.php | 4 +-- apps/user_ldap/lib/access.php | 2 +- apps/user_ldap/lib/connection.php | 8 +++--- apps/user_webdavauth/settings.php | 6 ++-- lib/db.php | 6 ++-- lib/migrate.php | 2 +- lib/ocsclient.php | 8 +++--- lib/request.php | 2 +- lib/templatelayout.php | 10 +++---- lib/updater.php | 18 ++++++------ lib/util.php | 58 +++++++++++++++++++-------------------- 11 files changed, 62 insertions(+), 62 deletions(-) (limited to 'lib') diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php index deff735cedc..d4c278ebd85 100644 --- a/apps/files_versions/history.php +++ b/apps/files_versions/history.php @@ -33,7 +33,7 @@ if ( isset( $_GET['path'] ) ) { $versions = new OCA_Versions\Storage(); // roll back to old version if button clicked - if( isset( $_GET['revert'] ) ) { + if( isset( $_GET['revert'] ) ) { if( $versions->rollback( $path, $_GET['revert'] ) ) { @@ -52,7 +52,7 @@ if ( isset( $_GET['path'] ) ) { } // show the history only if there is something to show - if( OCA_Versions\Storage::isversioned( $path ) ) { + if( OCA_Versions\Storage::isversioned( $path ) ) { $count = 999; //show the newest revisions $versions = OCA_Versions\Storage::getVersions( $path, $count); diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index 91f56ad882e..e1eea2f46c0 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -356,7 +356,7 @@ abstract class Access { ); } $res = $query->execute(array($dn))->fetchOne(); - if($res) { + if($res) { return $res; } return false; diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 687e2692270..b14cdafff89 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -338,11 +338,11 @@ class Connection { } $this->ldapConnectionRes = ldap_connect($this->config['ldapHost'], $this->config['ldapPort']); if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) { - if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) { - if($this->config['ldapTLS']) { - ldap_start_tls($this->ldapConnectionRes); - } + if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) { + if($this->config['ldapTLS']) { + ldap_start_tls($this->ldapConnectionRes); } + } } return $this->bind(); diff --git a/apps/user_webdavauth/settings.php b/apps/user_webdavauth/settings.php index 497a3385caa..910073c7841 100755 --- a/apps/user_webdavauth/settings.php +++ b/apps/user_webdavauth/settings.php @@ -23,9 +23,9 @@ if($_POST) { - if(isset($_POST['webdav_url'])) { - OC_CONFIG::setValue('user_webdavauth_url', strip_tags($_POST['webdav_url'])); - } + if(isset($_POST['webdav_url'])) { + OC_CONFIG::setValue('user_webdavauth_url', strip_tags($_POST['webdav_url'])); + } } // fill template diff --git a/lib/db.php b/lib/db.php index 6524db7581a..7e60b41d230 100644 --- a/lib/db.php +++ b/lib/db.php @@ -445,9 +445,9 @@ class OC_DB { * http://www.sqlite.org/lang_createtable.html * http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm */ - if( $CONFIG_DBTYPE == 'pgsql' ) { //mysql support it too but sqlite doesn't - $content = str_replace( '0000-00-00 00:00:00', 'CURRENT_TIMESTAMP', $content ); - } + if( $CONFIG_DBTYPE == 'pgsql' ) { //mysql support it too but sqlite doesn't + $content = str_replace( '0000-00-00 00:00:00', 'CURRENT_TIMESTAMP', $content ); + } file_put_contents( $file2, $content ); diff --git a/lib/migrate.php b/lib/migrate.php index 2cc0a3067b8..f41441bedbb 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -78,7 +78,7 @@ class OC_Migrate{ * @param otional $path string path to zip output folder * @return false on error, path to zip on success */ - public static function export( $uid=null, $type='user', $path=null ) { + public static function export( $uid=null, $type='user', $path=null ) { $datadir = OC_Config::getValue( 'datadirectory' ); // Validate export type $types = array( 'user', 'instance', 'system', 'userfiles' ); diff --git a/lib/ocsclient.php b/lib/ocsclient.php index 12e5026a877..24081425f1e 100644 --- a/lib/ocsclient.php +++ b/lib/ocsclient.php @@ -44,10 +44,10 @@ class OC_OCSClient{ * @returns string of the KB server * This function returns the url of the OCS knowledge base server. It´s possible to set it in the config file or it will fallback to the default */ - private static function getKBURL() { - $url = OC_Config::getValue('knowledgebaseurl', 'http://api.apps.owncloud.com/v1'); - return($url); - } + private static function getKBURL() { + $url = OC_Config::getValue('knowledgebaseurl', 'http://api.apps.owncloud.com/v1'); + return($url); + } /** * @brief Get the content of an OCS url call. diff --git a/lib/request.php b/lib/request.php index c975c84a711..782ed26a415 100755 --- a/lib/request.php +++ b/lib/request.php @@ -74,7 +74,7 @@ class OC_Request { switch($encoding) { case 'ISO-8859-1' : - $path_info = utf8_encode($path_info); + $path_info = utf8_encode($path_info); } // end copy diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 1a0570a270d..87b5620932c 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -97,13 +97,13 @@ class OC_TemplateLayout extends OC_Template { * @param $web base for path * @param $file the filename */ - static public function appendIfExist(&$files, $root, $webroot, $file) { - if (is_file($root.'/'.$file)) { + static public function appendIfExist(&$files, $root, $webroot, $file) { + if (is_file($root.'/'.$file)) { $files[] = array($root, $webroot, $file); return true; - } - return false; - } + } + return false; + } static public function findStylesheetFiles($styles) { // Read the selected theme from the config file diff --git a/lib/updater.php b/lib/updater.php index 11081eded63..d44ac108380 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -52,18 +52,18 @@ class OC_Updater{ ) ); $xml=@file_get_contents($url, 0, $ctx); - if($xml==false) { - return array(); - } - $data=@simplexml_load_string($xml); + if($xml==false) { + return array(); + } + $data=@simplexml_load_string($xml); $tmp=array(); - $tmp['version'] = $data->version; - $tmp['versionstring'] = $data->versionstring; - $tmp['url'] = $data->url; - $tmp['web'] = $data->web; + $tmp['version'] = $data->version; + $tmp['versionstring'] = $data->versionstring; + $tmp['url'] = $data->url; + $tmp['web'] = $data->web; - return $tmp; + return $tmp; } public static function ShowUpdatingHint() { diff --git a/lib/util.php b/lib/util.php index 34c4d4f9b11..fc1c889c31d 100755 --- a/lib/util.php +++ b/lib/util.php @@ -586,7 +586,7 @@ class OC_Util { /** * Check if the ownCloud server can connect to the internet */ - public static function isinternetconnectionworking() { + public static function isinternetconnectionworking() { // try to connect to owncloud.org to see if http connections to the internet are possible. $connected = @fsockopen("www.owncloud.org", 80); @@ -685,34 +685,34 @@ class OC_Util { * If not, file_get_element is used. */ - public static function getUrlContent($url){ + public static function getUrlContent($url){ - if (function_exists('curl_init')) { - - $curl = curl_init(); - - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); - curl_setopt($curl, CURLOPT_URL, $url); - curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); - $data = curl_exec($curl); - curl_close($curl); - - } else { - - $ctx = stream_context_create( - array( - 'http' => array( - 'timeout' => 10 - ) - ) - ); - $data=@file_get_contents($url, 0, $ctx); - - } - - return $data; - } + if (function_exists('curl_init')) { + + $curl = curl_init(); + + curl_setopt($curl, CURLOPT_HEADER, 0); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); + $data = curl_exec($curl); + curl_close($curl); + + } else { + + $ctx = stream_context_create( + array( + 'http' => array( + 'timeout' => 10 + ) + ) + ); + $data=@file_get_contents($url, 0, $ctx); + + } + + return $data; + } } -- cgit v1.2.3 From 85bd28c5081e7c2fea236c4528c23be283aa7350 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 23:22:46 +0100 Subject: Fix some of "Closing brace must be on a line by itself" --- apps/files_versions/templates/history.php | 4 +++- lib/files.php | 4 +++- lib/templatelayout.php | 20 ++++++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/apps/files_versions/templates/history.php b/apps/files_versions/templates/history.php index 854d032da62..cc5a494f19e 100644 --- a/apps/files_versions/templates/history.php +++ b/apps/files_versions/templates/history.php @@ -23,7 +23,9 @@ if( isset( $_['message'] ) ) { echo ' '; echo OCP\Util::formatDate( doubleval($v['version']) ); echo ' Revert

'; - if ( $v['cur'] ) { echo ' (Current)'; } + if ( $v['cur'] ) { + echo ' (Current)'; + } echo '

'; } diff --git a/lib/files.php b/lib/files.php index b4a4145a493..152ed8f34a7 100644 --- a/lib/files.php +++ b/lib/files.php @@ -492,7 +492,9 @@ class OC_Files { if(is_writable(OC::$SERVERROOT.'/.htaccess')) { file_put_contents(OC::$SERVERROOT.'/.htaccess', $htaccess); return OC_Helper::computerFileSize($size); - } else { OC_Log::write('files', 'Can\'t write upload limit to '.OC::$SERVERROOT.'/.htaccess. Please check the file permissions', OC_Log::WARN); } + } else { + OC_Log::write('files', 'Can\'t write upload limit to '.OC::$SERVERROOT.'/.htaccess. Please check the file permissions', OC_Log::WARN); + } return false; } diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 87b5620932c..4173e008ba7 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -130,8 +130,14 @@ class OC_TemplateLayout extends OC_Template { // or in apps? foreach( OC::$APPSROOTS as $apps_dir) { - if(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style$fext.css")) { $append =true; break; } - elseif(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style.css")) { $append =true; break; } + if(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style$fext.css")) { + $append = true; + break; + } + elseif(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style.css")) { + $append = true; + break; + } } if(! $append) { echo('css file not found: style:'.$style.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); @@ -192,8 +198,14 @@ class OC_TemplateLayout extends OC_Template { // Is it part of an app? $append = false; foreach( OC::$APPSROOTS as $apps_dir) { - if(self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT.$apps_dir['url'], "$script$fext.js")) { $append =true; break; } - elseif(self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT.$apps_dir['url'], "$script.js")) { $append =true; break; } + if(self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT.$apps_dir['url'], "$script$fext.js")) { + $append = true; + break; + } + elseif(self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT.$apps_dir['url'], "$script.js")) { + $append = true; + break; + } } if(! $append) { echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); -- cgit v1.2.3 From 2ef2dc4ddabc8b5d86d7a9a5a936ecf3901615cc Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 23:38:38 +0100 Subject: Fix "There must be a single space between the closing parenthesis and the opening brace" --- apps/files_sharing/public.php | 2 +- lib/filecache.php | 6 +++--- lib/request.php | 4 ++-- settings/ajax/togglegroups.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 71c18380a3b..fef0ed8a8c2 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -160,7 +160,7 @@ if ($linkItem) { exit(); } } - $basePath = substr($pathAndUser['path'] , strlen('/'.$fileOwner.'/files')); + $basePath = substr($pathAndUser['path'], strlen('/'.$fileOwner.'/files')); $path = $basePath; if (isset($_GET['path'])) { $path .= $_GET['path']; diff --git a/lib/filecache.php b/lib/filecache.php index bbf55bc1f86..c3256c783e6 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -355,7 +355,7 @@ class OC_FileCache{ if($sizeDiff==0) return; $item = OC_FileCache_Cached::get($path); //stop walking up the filetree if we hit a non-folder or reached to root folder - if($path == '/' || $path=='' || $item['mimetype'] !== 'httpd/unix-directory'){ + if($path == '/' || $path=='' || $item['mimetype'] !== 'httpd/unix-directory') { return; } $id = $item['id']; @@ -363,13 +363,13 @@ class OC_FileCache{ $query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `size`=`size`+? WHERE `id`=?'); $query->execute(array($sizeDiff, $id)); $path=dirname($path); - if($path == '' or $path =='/'){ + if($path == '' or $path =='/') { return; } $parent = OC_FileCache_Cached::get($path); $id = $parent['id']; //stop walking up the filetree if we hit a non-folder - if($parent['mimetype'] !== 'httpd/unix-directory'){ + if($parent['mimetype'] !== 'httpd/unix-directory') { return; } } diff --git a/lib/request.php b/lib/request.php index 782ed26a415..99a77e1b59e 100755 --- a/lib/request.php +++ b/lib/request.php @@ -18,7 +18,7 @@ class OC_Request { if(OC::$CLI) { return 'localhost'; } - if(OC_Config::getValue('overwritehost', '')<>''){ + if(OC_Config::getValue('overwritehost', '')<>'') { return OC_Config::getValue('overwritehost'); } if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { @@ -43,7 +43,7 @@ class OC_Request { * Returns the server protocol. It respects reverse proxy servers and load balancers */ public static function serverProtocol() { - if(OC_Config::getValue('overwriteprotocol', '')<>''){ + if(OC_Config::getValue('overwriteprotocol', '')<>'') { return OC_Config::getValue('overwriteprotocol'); } if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) { diff --git a/settings/ajax/togglegroups.php b/settings/ajax/togglegroups.php index f82ece4aee1..83d455550ae 100644 --- a/settings/ajax/togglegroups.php +++ b/settings/ajax/togglegroups.php @@ -7,7 +7,7 @@ $success = true; $username = $_POST["username"]; $group = $_POST["group"]; -if($username == OC_User::getUser() && $group == "admin" && OC_Group::inGroup($username, 'admin')){ +if($username == OC_User::getUser() && $group == "admin" && OC_Group::inGroup($username, 'admin')) { $l = OC_L10N::get('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Admins can\'t remove themself from the admin group')))); exit(); -- cgit v1.2.3 From 68562dafb4a814072aa0cd537b0d035f75e7a70f Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 23:16:32 +0100 Subject: More whitespace fixes --- apps/user_ldap/lib/access.php | 18 ++--- lib/app.php | 20 +++--- lib/migrate.php | 160 +++++++++++++++++++++--------------------- lib/public/contacts.php | 33 ++++----- settings/js/users.js | 2 +- 5 files changed, 117 insertions(+), 116 deletions(-) (limited to 'lib') diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index e1eea2f46c0..a4123cde57a 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -347,20 +347,20 @@ abstract class Access { } private function findMappedGroup($dn) { - static $query = null; + static $query = null; if(is_null($query)) { $query = \OCP\DB::prepare(' - SELECT `owncloud_name` - FROM `'.$this->getMapTable(false).'` - WHERE `ldap_dn` = ?' - ); + SELECT `owncloud_name` + FROM `'.$this->getMapTable(false).'` + WHERE `ldap_dn` = ?' + ); } - $res = $query->execute(array($dn))->fetchOne(); + $res = $query->execute(array($dn))->fetchOne(); if($res) { - return $res; - } + return $res; + } return false; - } + } private function ldap2ownCloudNames($ldapObjects, $isUsers) { diff --git a/lib/app.php b/lib/app.php index 5d4fbbd9c23..be6d5ab3dd3 100755 --- a/lib/app.php +++ b/lib/app.php @@ -597,16 +597,16 @@ class OC_App{ $app1[$i]['internal'] = $app1[$i]['active'] = 0; // rating img - if($app['score']>=0 and $app['score']<5) $img=OC_Helper::imagePath( "core", "rating/s1.png" ); - elseif($app['score']>=5 and $app['score']<15) $img=OC_Helper::imagePath( "core", "rating/s2.png" ); - elseif($app['score']>=15 and $app['score']<25) $img=OC_Helper::imagePath( "core", "rating/s3.png" ); - elseif($app['score']>=25 and $app['score']<35) $img=OC_Helper::imagePath( "core", "rating/s4.png" ); - elseif($app['score']>=35 and $app['score']<45) $img=OC_Helper::imagePath( "core", "rating/s5.png" ); - elseif($app['score']>=45 and $app['score']<55) $img=OC_Helper::imagePath( "core", "rating/s6.png" ); - elseif($app['score']>=55 and $app['score']<65) $img=OC_Helper::imagePath( "core", "rating/s7.png" ); - elseif($app['score']>=65 and $app['score']<75) $img=OC_Helper::imagePath( "core", "rating/s8.png" ); - elseif($app['score']>=75 and $app['score']<85) $img=OC_Helper::imagePath( "core", "rating/s9.png" ); - elseif($app['score']>=85 and $app['score']<95) $img=OC_Helper::imagePath( "core", "rating/s10.png" ); + if($app['score']>=0 and $app['score']<5) $img=OC_Helper::imagePath( "core", "rating/s1.png" ); + elseif($app['score']>=5 and $app['score']<15) $img=OC_Helper::imagePath( "core", "rating/s2.png" ); + elseif($app['score']>=15 and $app['score']<25) $img=OC_Helper::imagePath( "core", "rating/s3.png" ); + elseif($app['score']>=25 and $app['score']<35) $img=OC_Helper::imagePath( "core", "rating/s4.png" ); + elseif($app['score']>=35 and $app['score']<45) $img=OC_Helper::imagePath( "core", "rating/s5.png" ); + elseif($app['score']>=45 and $app['score']<55) $img=OC_Helper::imagePath( "core", "rating/s6.png" ); + elseif($app['score']>=55 and $app['score']<65) $img=OC_Helper::imagePath( "core", "rating/s7.png" ); + elseif($app['score']>=65 and $app['score']<75) $img=OC_Helper::imagePath( "core", "rating/s8.png" ); + elseif($app['score']>=75 and $app['score']<85) $img=OC_Helper::imagePath( "core", "rating/s9.png" ); + elseif($app['score']>=85 and $app['score']<95) $img=OC_Helper::imagePath( "core", "rating/s10.png" ); elseif($app['score']>=95 and $app['score']<100) $img=OC_Helper::imagePath( "core", "rating/s11.png" ); $app1[$i]['score'] = ' Score: '.$app['score'].'%'; diff --git a/lib/migrate.php b/lib/migrate.php index f41441bedbb..5ff8e338a44 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -80,65 +80,65 @@ class OC_Migrate{ */ public static function export( $uid=null, $type='user', $path=null ) { $datadir = OC_Config::getValue( 'datadirectory' ); - // Validate export type - $types = array( 'user', 'instance', 'system', 'userfiles' ); - if( !in_array( $type, $types ) ) { - OC_Log::write( 'migration', 'Invalid export type', OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); - } - self::$exporttype = $type; - // Userid? - if( self::$exporttype == 'user' ) { - // Check user exists - self::$uid = is_null($uid) ? OC_User::getUser() : $uid; - if(!OC_User::userExists(self::$uid)) { - return json_encode( array( 'success' => false) ); - } - } - // Calculate zipname - if( self::$exporttype == 'user' ) { - $zipname = 'oc_export_' . self::$uid . '_' . date("y-m-d_H-i-s") . '.zip'; - } else { - $zipname = 'oc_export_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '.zip'; - } - // Calculate path - if( self::$exporttype == 'user' ) { - self::$zippath = $datadir . '/' . self::$uid . '/' . $zipname; - } else { - if( !is_null( $path ) ) { - // Validate custom path - if( !file_exists( $path ) || !is_writeable( $path ) ) { - OC_Log::write( 'migration', 'Path supplied is invalid.', OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); - } - self::$zippath = $path . $zipname; - } else { - // Default path - self::$zippath = get_temp_dir() . '/' . $zipname; - } - } - // Create the zip object - if( !self::createZip() ) { - return json_encode( array( 'success' => false ) ); - } - // Do the export - self::findProviders(); - $exportdata = array(); - switch( self::$exporttype ) { - case 'user': - // Connect to the db - self::$dbpath = $datadir . '/' . self::$uid . '/migration.db'; - if( !self::connectDB() ) { - return json_encode( array( 'success' => false ) ); - } - self::$content = new OC_Migration_Content( self::$zip, self::$MDB2 ); - // Export the app info - $exportdata = self::exportAppData(); + // Validate export type + $types = array( 'user', 'instance', 'system', 'userfiles' ); + if( !in_array( $type, $types ) ) { + OC_Log::write( 'migration', 'Invalid export type', OC_Log::ERROR ); + return json_encode( array( 'success' => false ) ); + } + self::$exporttype = $type; + // Userid? + if( self::$exporttype == 'user' ) { + // Check user exists + self::$uid = is_null($uid) ? OC_User::getUser() : $uid; + if(!OC_User::userExists(self::$uid)) { + return json_encode( array( 'success' => false) ); + } + } + // Calculate zipname + if( self::$exporttype == 'user' ) { + $zipname = 'oc_export_' . self::$uid . '_' . date("y-m-d_H-i-s") . '.zip'; + } else { + $zipname = 'oc_export_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '.zip'; + } + // Calculate path + if( self::$exporttype == 'user' ) { + self::$zippath = $datadir . '/' . self::$uid . '/' . $zipname; + } else { + if( !is_null( $path ) ) { + // Validate custom path + if( !file_exists( $path ) || !is_writeable( $path ) ) { + OC_Log::write( 'migration', 'Path supplied is invalid.', OC_Log::ERROR ); + return json_encode( array( 'success' => false ) ); + } + self::$zippath = $path . $zipname; + } else { + // Default path + self::$zippath = get_temp_dir() . '/' . $zipname; + } + } + // Create the zip object + if( !self::createZip() ) { + return json_encode( array( 'success' => false ) ); + } + // Do the export + self::findProviders(); + $exportdata = array(); + switch( self::$exporttype ) { + case 'user': + // Connect to the db + self::$dbpath = $datadir . '/' . self::$uid . '/migration.db'; + if( !self::connectDB() ) { + return json_encode( array( 'success' => false ) ); + } + self::$content = new OC_Migration_Content( self::$zip, self::$MDB2 ); + // Export the app info + $exportdata = self::exportAppData(); // Add the data dir to the zip self::$content->addDir(OC_User::getHome(self::$uid), true, '/' ); - break; - case 'instance': - self::$content = new OC_Migration_Content( self::$zip ); + break; + case 'instance': + self::$content = new OC_Migration_Content( self::$zip ); // Creates a zip that is compatable with the import function $dbfile = tempnam( get_temp_dir(), "owncloud_export_data_" ); OC_DB::getDbStructure( $dbfile, 'MDB2_SCHEMA_DUMP_ALL'); @@ -155,32 +155,32 @@ class OC_Migrate{ foreach(OC_User::getUsers() as $user) { self::$content->addDir(OC_User::getHome($user), true, "/userdata/" ); } - break; + break; case 'userfiles': self::$content = new OC_Migration_Content( self::$zip ); // Creates a zip with all of the users files foreach(OC_User::getUsers() as $user) { self::$content->addDir(OC_User::getHome($user), true, "/" ); } - break; + break; case 'system': self::$content = new OC_Migration_Content( self::$zip ); // Creates a zip with the owncloud system files self::$content->addDir( OC::$SERVERROOT . '/', false, '/'); foreach (array(".git", "3rdparty", "apps", "core", "files", "l10n", "lib", "ocs", "search", "settings", "tests") as $dir) { - self::$content->addDir( OC::$SERVERROOT . '/' . $dir, true, "/"); + self::$content->addDir( OC::$SERVERROOT . '/' . $dir, true, "/"); } - break; - } - if( !$info = self::getExportInfo( $exportdata ) ) { - return json_encode( array( 'success' => false ) ); - } - // Add the export info json to the export zip - self::$content->addFromString( $info, 'export_info.json' ); - if( !self::$content->finish() ) { - return json_encode( array( 'success' => false ) ); - } - return json_encode( array( 'success' => true, 'data' => self::$zippath ) ); + break; + } + if( !$info = self::getExportInfo( $exportdata ) ) { + return json_encode( array( 'success' => false ) ); + } + // Add the export info json to the export zip + self::$content->addFromString( $info, 'export_info.json' ); + if( !self::$content->finish() ) { + return json_encode( array( 'success' => false ) ); + } + return json_encode( array( 'success' => true, 'data' => self::$zippath ) ); } /** @@ -254,7 +254,7 @@ class OC_Migrate{ OC_Log::write( 'migration', 'Failed to delete the extracted zip', OC_Log::ERROR ); } return json_encode( array( 'success' => true, 'data' => $appsimported ) ); - break; + break; case 'instance': /* * EXPERIMENTAL @@ -281,7 +281,7 @@ class OC_Migrate{ // Done return json_encode( array( 'success' => true ) ); */ - break; + break; } } @@ -319,10 +319,10 @@ class OC_Migrate{ static private function extractZip( $path ) { self::$zip = new ZipArchive; // Validate path - if( !file_exists( $path ) ) { - OC_Log::write( 'migration', 'Zip not found', OC_Log::ERROR ); - return false; - } + if( !file_exists( $path ) ) { + OC_Log::write( 'migration', 'Zip not found', OC_Log::ERROR ); + return false; + } if ( self::$zip->open( $path ) != true ) { OC_Log::write( 'migration', "Failed to open zip file", OC_Log::ERROR ); return false; @@ -555,9 +555,9 @@ class OC_Migrate{ if ( self::$zip->open( self::$zippath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ) !== true ) { OC_Log::write('migration', 'Failed to create the zip with error: '.self::$zip->getStatusString(), OC_Log::ERROR); return false; - } else { - return true; - } + } else { + return true; + } } /** diff --git a/lib/public/contacts.php b/lib/public/contacts.php index 4cf57ed8ff2..88d812e735a 100644 --- a/lib/public/contacts.php +++ b/lib/public/contacts.php @@ -54,29 +54,30 @@ namespace OCP { * Example: * Following function shows how to search for contacts for the name and the email address. * - * public static function getMatchingRecipient($term) { - * // The API is not active -> nothing to do + * public static function getMatchingRecipient($term) { + * // The API is not active -> nothing to do * if (!\OCP\Contacts::isEnabled()) { - * return array(); + * return array(); * } * * $result = \OCP\Contacts::search($term, array('FN', 'EMAIL')); * $receivers = array(); * foreach ($result as $r) { - * $id = $r['id']; - * $fn = $r['FN']; - * $email = $r['EMAIL']; - * if (!is_array($email)) { - * $email = array($email); - * } + * $id = $r['id']; + * $fn = $r['FN']; + * $email = $r['EMAIL']; + * if (!is_array($email)) { + * $email = array($email); + * } * - * // loop through all email addresses of this contact - * foreach ($email as $e) { - * $displayName = $fn . " <$e>"; - * $receivers[] = array('id' => $id, - * 'label' => $displayName, - * 'value' => $displayName); - * } + * // loop through all email addresses of this contact + * foreach ($email as $e) { + * $displayName = $fn . " <$e>"; + * $receivers[] = array( + * 'id' => $id, + * 'label' => $displayName, + * 'value' => $displayName); + * } * } * * return $receivers; diff --git a/settings/js/users.js b/settings/js/users.js index f2ce69cf311..f148a43a480 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -64,7 +64,7 @@ var UserList={ } } }); - } + } }, add:function(username, groups, subadmin, quota, sort) { -- cgit v1.2.3 From df7d6cb26c0e54e9df509b4a739b4d41c87fcb98 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 23:50:21 +0100 Subject: More style fixes --- apps/user_ldap/lib/access.php | 2 +- core/templates/logout.php | 2 +- lib/l10n.php | 10 ++++++---- lib/util.php | 3 +-- settings/templates/settings.php | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index a4123cde57a..f888577aedb 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -619,7 +619,7 @@ abstract class Access { //a) paged search insuccessful, though attempted //b) no paged search, but limit set if((!$this->pagedSearchedSuccessful - && $pagedSearchOK) + && $pagedSearchOK) || ( !$pagedSearchOK && !is_null($limit) diff --git a/core/templates/logout.php b/core/templates/logout.php index 8cbbdd9cc8d..2247ed8e70f 100644 --- a/core/templates/logout.php +++ b/core/templates/logout.php @@ -1 +1 @@ -t( 'You are logged out.' ); ?> \ No newline at end of file +t( 'You are logged out.' ); diff --git a/lib/l10n.php b/lib/l10n.php index cb67cfd4ed6..f70dfa5e34e 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -115,10 +115,12 @@ class OC_L10N{ $i18ndir = self::findI18nDir($app); // Localization is in /l10n, Texts are in $i18ndir // (Just no need to define date/time format etc. twice) - if((OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC_App::getAppPath($app).'/l10n/') || - OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/core/l10n/') || - OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/lib/l10n/') || - OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/settings')) && file_exists($i18ndir.$lang.'.php')) { + if((OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC_App::getAppPath($app).'/l10n/') + || OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/core/l10n/') + || OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/lib/l10n/') + || OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/settings') + ) + && file_exists($i18ndir.$lang.'.php')) { // Include the file, save the data from $CONFIG include strip_tags($i18ndir).strip_tags($lang).'.php'; if(isset($TRANSLATIONS) && is_array($TRANSLATIONS)) { diff --git a/lib/util.php b/lib/util.php index fc1c889c31d..fc50123b4fe 100755 --- a/lib/util.php +++ b/lib/util.php @@ -331,8 +331,7 @@ class OC_Util { $parameters[$value] = true; } if (!empty($_POST['user'])) { - $parameters["username"] = - OC_Util::sanitizeHTML($_POST['user']).'"'; + $parameters["username"] = OC_Util::sanitizeHTML($_POST['user']).'"'; $parameters['user_autofocus'] = false; } else { $parameters["username"] = ''; diff --git a/settings/templates/settings.php b/settings/templates/settings.php index 12368a1cdb6..de8092eeaff 100644 --- a/settings/templates/settings.php +++ b/settings/templates/settings.php @@ -6,4 +6,4 @@ \ No newline at end of file +}; -- cgit v1.2.3