diff --git a/3rdparty/Sabre.includes.php b/3rdparty/Sabre.includes.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Backend/Abstract.php b/3rdparty/Sabre/CalDAV/Backend/Abstract.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Backend/PDO.php b/3rdparty/Sabre/CalDAV/Backend/PDO.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Calendar.php b/3rdparty/Sabre/CalDAV/Calendar.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/CalendarObject.php b/3rdparty/Sabre/CalDAV/CalendarObject.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/CalendarQueryParser.php b/3rdparty/Sabre/CalDAV/CalendarQueryParser.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/CalendarQueryValidator.php b/3rdparty/Sabre/CalDAV/CalendarQueryValidator.php old mode 100644 new mode 100755 index 1bb6b5d53f..4bcd32cdf8 --- a/3rdparty/Sabre/CalDAV/CalendarQueryValidator.php +++ b/3rdparty/Sabre/CalDAV/CalendarQueryValidator.php @@ -294,6 +294,7 @@ class Sabre_CalDAV_CalendarQueryValidator { // in the VALARM component code, so this is a hack, and an // expensive one too. if ($component->parent->name === 'VEVENT' && $component->parent->RRULE) { + // Fire up the iterator! $it = new Sabre_VObject_RecurrenceIterator($component->parent->parent, (string)$component->parent->UID); while($it->valid()) { @@ -304,14 +305,35 @@ class Sabre_CalDAV_CalendarQueryValidator { // determine if we can 'give up' expanding events. $firstAlarm = null; foreach($expandedEvent->VALARM as $expandedAlarm) { + $effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime(); - if (!$firstAlarm || $effectiveTrigger < $firstAlarm) { - $firstAlarm = $effectiveTrigger; - } if ($expandedAlarm->isInTimeRange($start, $end)) { return true; } + if ((string)$expandedAlarm->TRIGGER['VALUE'] === 'DATE-TIME') { + // This is an alarm with a non-relative trigger + // time, likely created by a buggy client. The + // implication is that every alarm in this + // recurring event trigger at the exact same + // time. It doesn't make sense to traverse + // further. + } else { + // We store the first alarm as a means to + // figure out when we can stop traversing. + if (!$firstAlarm || $effectiveTrigger < $firstAlarm) { + $firstAlarm = $effectiveTrigger; + } + } + + } + if (is_null($firstAlarm)) { + // No alarm was found. + // + // Or technically: No alarm that will change for + // every instance of the recurrence was found, + // which means we can assume there was no match. + return false; } if ($firstAlarm > $end) { return false; diff --git a/3rdparty/Sabre/CalDAV/CalendarRootNode.php b/3rdparty/Sabre/CalDAV/CalendarRootNode.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/ICSExportPlugin.php b/3rdparty/Sabre/CalDAV/ICSExportPlugin.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/ICalendar.php b/3rdparty/Sabre/CalDAV/ICalendar.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/ICalendarObject.php b/3rdparty/Sabre/CalDAV/ICalendarObject.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Plugin.php b/3rdparty/Sabre/CalDAV/Plugin.php old mode 100644 new mode 100755 index d7d1d97051..5903968c00 --- a/3rdparty/Sabre/CalDAV/Plugin.php +++ b/3rdparty/Sabre/CalDAV/Plugin.php @@ -672,6 +672,42 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { } + if ($vobj->name !== 'VCALENDAR') { + throw new Sabre_DAV_Exception_UnsupportedMediaType('This collection can only support iCalendar objects.'); + } + + $foundType = null; + $foundUID = null; + foreach($vobj->getComponents() as $component) { + switch($component->name) { + case 'VTIMEZONE' : + continue 2; + case 'VEVENT' : + case 'VTODO' : + case 'VJOURNAL' : + if (is_null($foundType)) { + $foundType = $component->name; + if (!isset($component->UID)) { + throw new Sabre_DAV_Exception_BadRequest('Every ' . $component->name . ' component must have an UID'); + } + $foundUID = (string)$component->UID; + } else { + if ($foundType !== $component->name) { + throw new Sabre_DAV_Exception_BadRequest('A calendar object must only contain 1 component. We found a ' . $component->name . ' as well as a ' . $foundType); + } + if ($foundUID !== (string)$component->UID) { + throw new Sabre_DAV_Exception_BadRequest('Every ' . $component->name . ' in this object must have identical UIDs'); + } + } + break; + default : + throw new Sabre_DAV_Exception_BadRequest('You are not allowed to create components of type: ' . $component->name . ' here'); + + } + } + if (!$foundType) + throw new Sabre_DAV_Exception_BadRequest('iCalendar object must contain at least 1 of VEVENT, VTODO or VJOURNAL'); + } /** diff --git a/3rdparty/Sabre/CalDAV/Principal/Collection.php b/3rdparty/Sabre/CalDAV/Principal/Collection.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Principal/ProxyRead.php b/3rdparty/Sabre/CalDAV/Principal/ProxyRead.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Principal/ProxyWrite.php b/3rdparty/Sabre/CalDAV/Principal/ProxyWrite.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Principal/User.php b/3rdparty/Sabre/CalDAV/Principal/User.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php b/3rdparty/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Property/SupportedCalendarData.php b/3rdparty/Sabre/CalDAV/Property/SupportedCalendarData.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Property/SupportedCollationSet.php b/3rdparty/Sabre/CalDAV/Property/SupportedCollationSet.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Schedule/IMip.php b/3rdparty/Sabre/CalDAV/Schedule/IMip.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Schedule/IOutbox.php b/3rdparty/Sabre/CalDAV/Schedule/IOutbox.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Schedule/Outbox.php b/3rdparty/Sabre/CalDAV/Schedule/Outbox.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Server.php b/3rdparty/Sabre/CalDAV/Server.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/UserCalendars.php b/3rdparty/Sabre/CalDAV/UserCalendars.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CalDAV/Version.php b/3rdparty/Sabre/CalDAV/Version.php old mode 100644 new mode 100755 index 939e903c89..289a0c83a3 --- a/3rdparty/Sabre/CalDAV/Version.php +++ b/3rdparty/Sabre/CalDAV/Version.php @@ -14,7 +14,7 @@ class Sabre_CalDAV_Version { /** * Full version number */ - const VERSION = '1.6.2'; + const VERSION = '1.6.3'; /** * Stability : alpha, beta, stable diff --git a/3rdparty/Sabre/CalDAV/includes.php b/3rdparty/Sabre/CalDAV/includes.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CardDAV/AddressBook.php b/3rdparty/Sabre/CardDAV/AddressBook.php old mode 100644 new mode 100755 index 3b381e1eea..12297175a8 --- a/3rdparty/Sabre/CardDAV/AddressBook.php +++ b/3rdparty/Sabre/CardDAV/AddressBook.php @@ -108,7 +108,9 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca */ public function createFile($name,$vcardData = null) { - $vcardData = stream_get_contents($vcardData); + if (is_resource($vcardData)) { + $vcardData = stream_get_contents($vcardData); + } // Converting to UTF-8, if needed $vcardData = Sabre_DAV_StringUtil::ensureUTF8($vcardData); diff --git a/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php b/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php old mode 100644 new mode 100755 index 85a4963127..46bb8ff18d --- a/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php +++ b/3rdparty/Sabre/CardDAV/AddressBookQueryParser.php @@ -9,7 +9,7 @@ * @package Sabre * @subpackage CardDAV * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ class Sabre_CardDAV_AddressBookQueryParser { @@ -88,12 +88,22 @@ class Sabre_CardDAV_AddressBookQueryParser { if (is_nan($limit)) $limit = null; $filter = $this->xpath->query('/card:addressbook-query/card:filter'); - if ($filter->length !== 1) { + + // According to the CardDAV spec there needs to be exactly 1 filter + // element. However, KDE 4.8.2 contains a bug that will encode 0 filter + // elements, so this is a workaround for that. + // + // See: https://bugs.kde.org/show_bug.cgi?id=300047 + if ($filter->length === 0) { + $test = null; + $filter = null; + } elseif ($filter->length === 1) { + $filter = $filter->item(0); + $test = $this->xpath->evaluate('string(@test)', $filter); + } else { throw new Sabre_DAV_Exception_BadRequest('Only one filter element is allowed'); } - $filter = $filter->item(0); - $test = $this->xpath->evaluate('string(@test)', $filter); if (!$test) $test = self::TEST_ANYOF; if ($test !== self::TEST_ANYOF && $test !== self::TEST_ALLOF) { throw new Sabre_DAV_Exception_BadRequest('The test attribute must either hold "anyof" or "allof"'); diff --git a/3rdparty/Sabre/CardDAV/AddressBookRoot.php b/3rdparty/Sabre/CardDAV/AddressBookRoot.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CardDAV/Backend/Abstract.php b/3rdparty/Sabre/CardDAV/Backend/Abstract.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CardDAV/Backend/PDO.php b/3rdparty/Sabre/CardDAV/Backend/PDO.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CardDAV/Card.php b/3rdparty/Sabre/CardDAV/Card.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CardDAV/IAddressBook.php b/3rdparty/Sabre/CardDAV/IAddressBook.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CardDAV/ICard.php b/3rdparty/Sabre/CardDAV/ICard.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CardDAV/IDirectory.php b/3rdparty/Sabre/CardDAV/IDirectory.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CardDAV/Plugin.php b/3rdparty/Sabre/CardDAV/Plugin.php old mode 100644 new mode 100755 index 9ebec243eb..ca20e46849 --- a/3rdparty/Sabre/CardDAV/Plugin.php +++ b/3rdparty/Sabre/CardDAV/Plugin.php @@ -52,6 +52,8 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin { $server->subscribeEvent('report', array($this,'report')); $server->subscribeEvent('onHTMLActionsPanel', array($this,'htmlActionsPanel')); $server->subscribeEvent('onBrowserPostAction', array($this,'browserPostAction')); + $server->subscribeEvent('beforeWriteContent', array($this, 'beforeWriteContent')); + $server->subscribeEvent('beforeCreateFile', array($this, 'beforeCreateFile')); /* Namespaces */ $server->xmlNamespaces[self::NS_CARDDAV] = 'card'; @@ -283,6 +285,81 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin { } + /** + * This method is triggered before a file gets updated with new content. + * + * This plugin uses this method to ensure that Card nodes receive valid + * vcard data. + * + * @param string $path + * @param Sabre_DAV_IFile $node + * @param resource $data + * @return void + */ + public function beforeWriteContent($path, Sabre_DAV_IFile $node, &$data) { + + if (!$node instanceof Sabre_CardDAV_ICard) + return; + + $this->validateVCard($data); + + } + + /** + * This method is triggered before a new file is created. + * + * This plugin uses this method to ensure that Card nodes receive valid + * vcard data. + * + * @param string $path + * @param resource $data + * @param Sabre_DAV_ICollection $parentNode + * @return void + */ + public function beforeCreateFile($path, &$data, Sabre_DAV_ICollection $parentNode) { + + if (!$parentNode instanceof Sabre_CardDAV_IAddressBook) + return; + + $this->validateVCard($data); + + } + + /** + * Checks if the submitted iCalendar data is in fact, valid. + * + * An exception is thrown if it's not. + * + * @param resource|string $data + * @return void + */ + protected function validateVCard(&$data) { + + // If it's a stream, we convert it to a string first. + if (is_resource($data)) { + $data = stream_get_contents($data); + } + + // Converting the data to unicode, if needed. + $data = Sabre_DAV_StringUtil::ensureUTF8($data); + + try { + + $vobj = Sabre_VObject_Reader::read($data); + + } catch (Sabre_VObject_ParseException $e) { + + throw new Sabre_DAV_Exception_UnsupportedMediaType('This resource only supports valid vcard data. Parse error: ' . $e->getMessage()); + + } + + if ($vobj->name !== 'VCARD') { + throw new Sabre_DAV_Exception_UnsupportedMediaType('This collection can only support vcard objects.'); + } + + } + + /** * This function handles the addressbook-query REPORT * @@ -362,6 +439,8 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin { $vcard = Sabre_VObject_Reader::read($vcardData); + if (!$filters) return true; + foreach($filters as $filter) { $isDefined = isset($vcard->{$filter['name']}); diff --git a/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php b/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CardDAV/UserAddressBooks.php b/3rdparty/Sabre/CardDAV/UserAddressBooks.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/CardDAV/Version.php b/3rdparty/Sabre/CardDAV/Version.php old mode 100644 new mode 100755 index 811b929e39..d0623f0d3e --- a/3rdparty/Sabre/CardDAV/Version.php +++ b/3rdparty/Sabre/CardDAV/Version.php @@ -16,7 +16,7 @@ class Sabre_CardDAV_Version { /** * Full version number */ - const VERSION = '1.6.1'; + const VERSION = '1.6.3'; /** * Stability : alpha, beta, stable diff --git a/3rdparty/Sabre/CardDAV/includes.php b/3rdparty/Sabre/CardDAV/includes.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Auth/Backend/AbstractBasic.php b/3rdparty/Sabre/DAV/Auth/Backend/AbstractBasic.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Auth/Backend/AbstractDigest.php b/3rdparty/Sabre/DAV/Auth/Backend/AbstractDigest.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Auth/Backend/Apache.php b/3rdparty/Sabre/DAV/Auth/Backend/Apache.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Auth/Backend/File.php b/3rdparty/Sabre/DAV/Auth/Backend/File.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Auth/Backend/PDO.php b/3rdparty/Sabre/DAV/Auth/Backend/PDO.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Auth/IBackend.php b/3rdparty/Sabre/DAV/Auth/IBackend.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Auth/Plugin.php b/3rdparty/Sabre/DAV/Auth/Plugin.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Browser/GuessContentType.php b/3rdparty/Sabre/DAV/Browser/GuessContentType.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Browser/MapGetToPropFind.php b/3rdparty/Sabre/DAV/Browser/MapGetToPropFind.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Browser/Plugin.php b/3rdparty/Sabre/DAV/Browser/Plugin.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Browser/assets/favicon.ico b/3rdparty/Sabre/DAV/Browser/assets/favicon.ico old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Browser/assets/icons/addressbook.png b/3rdparty/Sabre/DAV/Browser/assets/icons/addressbook.png old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Browser/assets/icons/calendar.png b/3rdparty/Sabre/DAV/Browser/assets/icons/calendar.png old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Browser/assets/icons/card.png b/3rdparty/Sabre/DAV/Browser/assets/icons/card.png old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Browser/assets/icons/collection.png b/3rdparty/Sabre/DAV/Browser/assets/icons/collection.png old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Browser/assets/icons/file.png b/3rdparty/Sabre/DAV/Browser/assets/icons/file.png old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Browser/assets/icons/parent.png b/3rdparty/Sabre/DAV/Browser/assets/icons/parent.png old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Browser/assets/icons/principal.png b/3rdparty/Sabre/DAV/Browser/assets/icons/principal.png old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Client.php b/3rdparty/Sabre/DAV/Client.php old mode 100644 new mode 100755 index 075e84caa1..9a428765e9 --- a/3rdparty/Sabre/DAV/Client.php +++ b/3rdparty/Sabre/DAV/Client.php @@ -11,7 +11,7 @@ * @package Sabre * @subpackage DAVClient * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ class Sabre_DAV_Client { @@ -23,6 +23,28 @@ class Sabre_DAV_Client { protected $password; protected $proxy; + /** + * Basic authentication + */ + const AUTH_BASIC = 1; + + /** + * Digest authentication + */ + const AUTH_DIGEST = 2; + + /** + * The authentication type we're using. + * + * This is a bitmask of AUTH_BASIC and AUTH_DIGEST. + * + * If DIGEST is used, the client makes 1 extra request per request, to get + * the authentication tokens. + * + * @var int + */ + protected $authType; + /** * Constructor * @@ -46,16 +68,21 @@ class Sabre_DAV_Client { 'baseUri', 'userName', 'password', - 'proxy' + 'proxy', ); - foreach($validSettings as $validSetting) { if (isset($settings[$validSetting])) { $this->$validSetting = $settings[$validSetting]; } } + if (isset($settings['authType'])) { + $this->authType = $settings['authType']; + } else { + $this->authType = self::AUTH_BASIC | self::AUTH_DIGEST; + } + $this->propertyMap['{DAV:}resourcetype'] = 'Sabre_DAV_Property_ResourceType'; } @@ -250,14 +277,9 @@ class Sabre_DAV_Client { // Automatically follow redirects CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 5, - CURLOPT_SSL_VERIFYPEER => true, - //CURLOPT_SSL_VERIFYPEER => false, ); switch ($method) { - case 'PUT': - $curlSettings[CURLOPT_PUT] = true; - break; case 'HEAD' : // do not read body with HEAD requests (this is neccessary because cURL does not ignore the body with HEAD @@ -288,8 +310,15 @@ class Sabre_DAV_Client { $curlSettings[CURLOPT_PROXY] = $this->proxy; } - if ($this->userName) { - $curlSettings[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC | CURLAUTH_DIGEST; + if ($this->userName && $this->authType) { + $curlType = 0; + if ($this->authType & self::AUTH_BASIC) { + $curlType |= CURLAUTH_BASIC; + } + if ($this->authType & self::AUTH_DIGEST) { + $curlType |= CURLAUTH_DIGEST; + } + $curlSettings[CURLOPT_HTTPAUTH] = $curlType; $curlSettings[CURLOPT_USERPWD] = $this->userName . ':' . $this->password; } diff --git a/3rdparty/Sabre/DAV/Collection.php b/3rdparty/Sabre/DAV/Collection.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Directory.php b/3rdparty/Sabre/DAV/Directory.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception.php b/3rdparty/Sabre/DAV/Exception.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/BadRequest.php b/3rdparty/Sabre/DAV/Exception/BadRequest.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/Conflict.php b/3rdparty/Sabre/DAV/Exception/Conflict.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/ConflictingLock.php b/3rdparty/Sabre/DAV/Exception/ConflictingLock.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/FileNotFound.php b/3rdparty/Sabre/DAV/Exception/FileNotFound.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/Forbidden.php b/3rdparty/Sabre/DAV/Exception/Forbidden.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/InsufficientStorage.php b/3rdparty/Sabre/DAV/Exception/InsufficientStorage.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/InvalidResourceType.php b/3rdparty/Sabre/DAV/Exception/InvalidResourceType.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/LockTokenMatchesRequestUri.php b/3rdparty/Sabre/DAV/Exception/LockTokenMatchesRequestUri.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/Locked.php b/3rdparty/Sabre/DAV/Exception/Locked.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/MethodNotAllowed.php b/3rdparty/Sabre/DAV/Exception/MethodNotAllowed.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/NotAuthenticated.php b/3rdparty/Sabre/DAV/Exception/NotAuthenticated.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/NotFound.php b/3rdparty/Sabre/DAV/Exception/NotFound.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/NotImplemented.php b/3rdparty/Sabre/DAV/Exception/NotImplemented.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/PaymentRequired.php b/3rdparty/Sabre/DAV/Exception/PaymentRequired.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/PreconditionFailed.php b/3rdparty/Sabre/DAV/Exception/PreconditionFailed.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/ReportNotImplemented.php b/3rdparty/Sabre/DAV/Exception/ReportNotImplemented.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php b/3rdparty/Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Exception/UnsupportedMediaType.php b/3rdparty/Sabre/DAV/Exception/UnsupportedMediaType.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/FS/Directory.php b/3rdparty/Sabre/DAV/FS/Directory.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/FS/File.php b/3rdparty/Sabre/DAV/FS/File.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/FS/Node.php b/3rdparty/Sabre/DAV/FS/Node.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/FSExt/Directory.php b/3rdparty/Sabre/DAV/FSExt/Directory.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/FSExt/File.php b/3rdparty/Sabre/DAV/FSExt/File.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/FSExt/Node.php b/3rdparty/Sabre/DAV/FSExt/Node.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/File.php b/3rdparty/Sabre/DAV/File.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/ICollection.php b/3rdparty/Sabre/DAV/ICollection.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/IExtendedCollection.php b/3rdparty/Sabre/DAV/IExtendedCollection.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/IFile.php b/3rdparty/Sabre/DAV/IFile.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/INode.php b/3rdparty/Sabre/DAV/INode.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/IProperties.php b/3rdparty/Sabre/DAV/IProperties.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/IQuota.php b/3rdparty/Sabre/DAV/IQuota.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Locks/Backend/Abstract.php b/3rdparty/Sabre/DAV/Locks/Backend/Abstract.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Locks/Backend/FS.php b/3rdparty/Sabre/DAV/Locks/Backend/FS.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Locks/Backend/File.php b/3rdparty/Sabre/DAV/Locks/Backend/File.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Locks/Backend/PDO.php b/3rdparty/Sabre/DAV/Locks/Backend/PDO.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Locks/LockInfo.php b/3rdparty/Sabre/DAV/Locks/LockInfo.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Locks/Plugin.php b/3rdparty/Sabre/DAV/Locks/Plugin.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Mount/Plugin.php b/3rdparty/Sabre/DAV/Mount/Plugin.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Node.php b/3rdparty/Sabre/DAV/Node.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/ObjectTree.php b/3rdparty/Sabre/DAV/ObjectTree.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Property.php b/3rdparty/Sabre/DAV/Property.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Property/GetLastModified.php b/3rdparty/Sabre/DAV/Property/GetLastModified.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Property/Href.php b/3rdparty/Sabre/DAV/Property/Href.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Property/HrefList.php b/3rdparty/Sabre/DAV/Property/HrefList.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Property/IHref.php b/3rdparty/Sabre/DAV/Property/IHref.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Property/LockDiscovery.php b/3rdparty/Sabre/DAV/Property/LockDiscovery.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Property/ResourceType.php b/3rdparty/Sabre/DAV/Property/ResourceType.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Property/Response.php b/3rdparty/Sabre/DAV/Property/Response.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Property/ResponseList.php b/3rdparty/Sabre/DAV/Property/ResponseList.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Property/SupportedLock.php b/3rdparty/Sabre/DAV/Property/SupportedLock.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Property/SupportedReportSet.php b/3rdparty/Sabre/DAV/Property/SupportedReportSet.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Server.php b/3rdparty/Sabre/DAV/Server.php old mode 100644 new mode 100755 index 50b190e8fa..0dfac8b0c7 --- a/3rdparty/Sabre/DAV/Server.php +++ b/3rdparty/Sabre/DAV/Server.php @@ -215,7 +215,7 @@ class Sabre_DAV_Server { $DOM->appendChild($error); $error->appendChild($DOM->createElement('s:exception',get_class($e))); - $error->appendChild($DOM->createElement('s:message',htmlentities($e->getMessage()))); + $error->appendChild($DOM->createElement('s:message',$e->getMessage())); if ($this->debugExceptions) { $error->appendChild($DOM->createElement('s:file',$e->getFile())); $error->appendChild($DOM->createElement('s:line',$e->getLine())); @@ -1784,7 +1784,14 @@ class Sabre_DAV_Server { $etag = $node->getETag(); if ($etag===$ifMatchItem) { $haveMatch = true; + } else { + // Evolution has a bug where it sometimes prepends the " + // with a \. This is our workaround. + if (str_replace('\\"','"', $ifMatchItem) === $etag) { + $haveMatch = true; + } } + } if (!$haveMatch) { throw new Sabre_DAV_Exception_PreconditionFailed('An If-Match header was specified, but none of the specified the ETags matched.','If-Match'); diff --git a/3rdparty/Sabre/DAV/ServerPlugin.php b/3rdparty/Sabre/DAV/ServerPlugin.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/SimpleCollection.php b/3rdparty/Sabre/DAV/SimpleCollection.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/SimpleDirectory.php b/3rdparty/Sabre/DAV/SimpleDirectory.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/SimpleFile.php b/3rdparty/Sabre/DAV/SimpleFile.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/StringUtil.php b/3rdparty/Sabre/DAV/StringUtil.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/TemporaryFileFilterPlugin.php b/3rdparty/Sabre/DAV/TemporaryFileFilterPlugin.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Tree.php b/3rdparty/Sabre/DAV/Tree.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Tree/Filesystem.php b/3rdparty/Sabre/DAV/Tree/Filesystem.php old mode 100644 new mode 100755 index 85a9ee317b..40580ae366 --- a/3rdparty/Sabre/DAV/Tree/Filesystem.php +++ b/3rdparty/Sabre/DAV/Tree/Filesystem.php @@ -42,9 +42,9 @@ class Sabre_DAV_Tree_Filesystem extends Sabre_DAV_Tree { $realPath = $this->getRealPath($path); if (!file_exists($realPath)) throw new Sabre_DAV_Exception_NotFound('File at location ' . $realPath . ' not found'); if (is_dir($realPath)) { - return new Sabre_DAV_FS_Directory($path); + return new Sabre_DAV_FS_Directory($realPath); } else { - return new Sabre_DAV_FS_File($path); + return new Sabre_DAV_FS_File($realPath); } } diff --git a/3rdparty/Sabre/DAV/URLUtil.php b/3rdparty/Sabre/DAV/URLUtil.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/UUIDUtil.php b/3rdparty/Sabre/DAV/UUIDUtil.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/Version.php b/3rdparty/Sabre/DAV/Version.php old mode 100644 new mode 100755 index 5e5d15e403..40cfe81b34 --- a/3rdparty/Sabre/DAV/Version.php +++ b/3rdparty/Sabre/DAV/Version.php @@ -14,7 +14,7 @@ class Sabre_DAV_Version { /** * Full version number */ - const VERSION = '1.6.2'; + const VERSION = '1.6.3'; /** * Stability : alpha, beta, stable diff --git a/3rdparty/Sabre/DAV/XMLUtil.php b/3rdparty/Sabre/DAV/XMLUtil.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAV/includes.php b/3rdparty/Sabre/DAV/includes.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/AbstractPrincipalCollection.php b/3rdparty/Sabre/DAVACL/AbstractPrincipalCollection.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Exception/AceConflict.php b/3rdparty/Sabre/DAVACL/Exception/AceConflict.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Exception/NeedPrivileges.php b/3rdparty/Sabre/DAVACL/Exception/NeedPrivileges.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Exception/NoAbstract.php b/3rdparty/Sabre/DAVACL/Exception/NoAbstract.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Exception/NotRecognizedPrincipal.php b/3rdparty/Sabre/DAVACL/Exception/NotRecognizedPrincipal.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Exception/NotSupportedPrivilege.php b/3rdparty/Sabre/DAVACL/Exception/NotSupportedPrivilege.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/IACL.php b/3rdparty/Sabre/DAVACL/IACL.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/IPrincipal.php b/3rdparty/Sabre/DAVACL/IPrincipal.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/IPrincipalBackend.php b/3rdparty/Sabre/DAVACL/IPrincipalBackend.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Plugin.php b/3rdparty/Sabre/DAVACL/Plugin.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Principal.php b/3rdparty/Sabre/DAVACL/Principal.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/PrincipalBackend/PDO.php b/3rdparty/Sabre/DAVACL/PrincipalBackend/PDO.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/PrincipalCollection.php b/3rdparty/Sabre/DAVACL/PrincipalCollection.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Property/Acl.php b/3rdparty/Sabre/DAVACL/Property/Acl.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Property/AclRestrictions.php b/3rdparty/Sabre/DAVACL/Property/AclRestrictions.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Property/CurrentUserPrivilegeSet.php b/3rdparty/Sabre/DAVACL/Property/CurrentUserPrivilegeSet.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Property/Principal.php b/3rdparty/Sabre/DAVACL/Property/Principal.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Property/SupportedPrivilegeSet.php b/3rdparty/Sabre/DAVACL/Property/SupportedPrivilegeSet.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/Version.php b/3rdparty/Sabre/DAVACL/Version.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/DAVACL/includes.php b/3rdparty/Sabre/DAVACL/includes.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/HTTP/AWSAuth.php b/3rdparty/Sabre/HTTP/AWSAuth.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/HTTP/AbstractAuth.php b/3rdparty/Sabre/HTTP/AbstractAuth.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/HTTP/BasicAuth.php b/3rdparty/Sabre/HTTP/BasicAuth.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/HTTP/DigestAuth.php b/3rdparty/Sabre/HTTP/DigestAuth.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/HTTP/Request.php b/3rdparty/Sabre/HTTP/Request.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/HTTP/Response.php b/3rdparty/Sabre/HTTP/Response.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/HTTP/Util.php b/3rdparty/Sabre/HTTP/Util.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/HTTP/Version.php b/3rdparty/Sabre/HTTP/Version.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/HTTP/includes.php b/3rdparty/Sabre/HTTP/includes.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Component.php b/3rdparty/Sabre/VObject/Component.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Component/VAlarm.php b/3rdparty/Sabre/VObject/Component/VAlarm.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Component/VCalendar.php b/3rdparty/Sabre/VObject/Component/VCalendar.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Component/VEvent.php b/3rdparty/Sabre/VObject/Component/VEvent.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Component/VJournal.php b/3rdparty/Sabre/VObject/Component/VJournal.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Component/VTodo.php b/3rdparty/Sabre/VObject/Component/VTodo.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/DateTimeParser.php b/3rdparty/Sabre/VObject/DateTimeParser.php old mode 100644 new mode 100755 index 1e2d54ef3a..23a4bb6991 --- a/3rdparty/Sabre/VObject/DateTimeParser.php +++ b/3rdparty/Sabre/VObject/DateTimeParser.php @@ -125,6 +125,9 @@ class Sabre_VObject_DateTimeParser { } + if ($duration==='P') { + $duration = 'PT0S'; + } $iv = new DateInterval($duration); if ($invert) $iv->invert = true; @@ -150,6 +153,7 @@ class Sabre_VObject_DateTimeParser { } $newDur = ($matches['plusminus']==='-'?'-':'+') . trim($newDur); + if ($newDur === '+') { $newDur = '+0 seconds'; }; return $newDur; } diff --git a/3rdparty/Sabre/VObject/Element.php b/3rdparty/Sabre/VObject/Element.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Element/DateTime.php b/3rdparty/Sabre/VObject/Element/DateTime.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Element/MultiDateTime.php b/3rdparty/Sabre/VObject/Element/MultiDateTime.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/ElementList.php b/3rdparty/Sabre/VObject/ElementList.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/FreeBusyGenerator.php b/3rdparty/Sabre/VObject/FreeBusyGenerator.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Node.php b/3rdparty/Sabre/VObject/Node.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Parameter.php b/3rdparty/Sabre/VObject/Parameter.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/ParseException.php b/3rdparty/Sabre/VObject/ParseException.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Property.php b/3rdparty/Sabre/VObject/Property.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Property/DateTime.php b/3rdparty/Sabre/VObject/Property/DateTime.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Property/MultiDateTime.php b/3rdparty/Sabre/VObject/Property/MultiDateTime.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Reader.php b/3rdparty/Sabre/VObject/Reader.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/RecurrenceIterator.php b/3rdparty/Sabre/VObject/RecurrenceIterator.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/Version.php b/3rdparty/Sabre/VObject/Version.php old mode 100644 new mode 100755 index 00110febc0..2617c7b129 --- a/3rdparty/Sabre/VObject/Version.php +++ b/3rdparty/Sabre/VObject/Version.php @@ -14,7 +14,7 @@ class Sabre_VObject_Version { /** * Full version number */ - const VERSION = '1.3.2'; + const VERSION = '1.3.3'; /** * Stability : alpha, beta, stable diff --git a/3rdparty/Sabre/VObject/WindowsTimezoneMap.php b/3rdparty/Sabre/VObject/WindowsTimezoneMap.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/VObject/includes.php b/3rdparty/Sabre/VObject/includes.php old mode 100644 new mode 100755 diff --git a/3rdparty/Sabre/autoload.php b/3rdparty/Sabre/autoload.php old mode 100644 new mode 100755 diff --git a/apps/calendar/ajax/calendar/activation.php b/apps/calendar/ajax/calendar/activation.php index e31908beb1..f4aadc5b01 100644 --- a/apps/calendar/ajax/calendar/activation.php +++ b/apps/calendar/ajax/calendar/activation.php @@ -9,6 +9,8 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::callCheck(); + $calendarid = $_POST['calendarid']; $calendar = OC_Calendar_App::getCalendar($calendarid, true); if(!$calendar){ diff --git a/apps/calendar/ajax/calendar/delete.php b/apps/calendar/ajax/calendar/delete.php index 4d6706f600..089255cae3 100644 --- a/apps/calendar/ajax/calendar/delete.php +++ b/apps/calendar/ajax/calendar/delete.php @@ -9,6 +9,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::callCheck(); $cal = $_POST["calendarid"]; $calendar = OC_Calendar_App::getCalendar($cal, true); diff --git a/apps/calendar/ajax/calendar/new.php b/apps/calendar/ajax/calendar/new.php index e77d4ebff0..67d1282237 100644 --- a/apps/calendar/ajax/calendar/new.php +++ b/apps/calendar/ajax/calendar/new.php @@ -6,11 +6,10 @@ * See the COPYING-README file. */ - - // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::callCheck(); if(trim($_POST['name']) == ''){ OCP\JSON::error(array('message'=>'empty')); diff --git a/apps/calendar/ajax/calendar/update.php b/apps/calendar/ajax/calendar/update.php index a2c898c807..c09b1008c9 100644 --- a/apps/calendar/ajax/calendar/update.php +++ b/apps/calendar/ajax/calendar/update.php @@ -11,6 +11,7 @@ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::callCheck(); if(trim($_POST['name']) == ''){ OCP\JSON::error(array('message'=>'empty')); diff --git a/apps/calendar/ajax/categories/rescan.php b/apps/calendar/ajax/categories/rescan.php index f0060cb23b..08c32865b6 100644 --- a/apps/calendar/ajax/categories/rescan.php +++ b/apps/calendar/ajax/categories/rescan.php @@ -9,6 +9,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::callCheck(); foreach ($_POST as $key=>$element) { debug('_POST: '.$key.'=>'.print_r($element, true)); diff --git a/apps/calendar/ajax/event/delete.php b/apps/calendar/ajax/event/delete.php index f183d431af..17e45c001e 100644 --- a/apps/calendar/ajax/event/delete.php +++ b/apps/calendar/ajax/event/delete.php @@ -9,6 +9,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::callCheck(); $id = $_POST['id']; $access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); diff --git a/apps/calendar/ajax/event/edit.php b/apps/calendar/ajax/event/edit.php index 1c3babc3d9..db78bf6e5e 100644 --- a/apps/calendar/ajax/event/edit.php +++ b/apps/calendar/ajax/event/edit.php @@ -9,6 +9,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::callCheck(); $id = $_POST['id']; diff --git a/apps/calendar/ajax/event/move.php b/apps/calendar/ajax/event/move.php index 04cf2fb051..f4e2b36376 100644 --- a/apps/calendar/ajax/event/move.php +++ b/apps/calendar/ajax/event/move.php @@ -7,6 +7,7 @@ */ OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); $id = $_POST['id']; $access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); diff --git a/apps/calendar/ajax/event/new.form.php b/apps/calendar/ajax/event/new.form.php index 0b19e7e92f..db04cdf2d4 100644 --- a/apps/calendar/ajax/event/new.form.php +++ b/apps/calendar/ajax/event/new.form.php @@ -27,7 +27,7 @@ if (!$end){ } $start = new DateTime('@'.$start); $end = new DateTime('@'.$end); -$timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +$timezone = OC_Calendar_App::getTimezone(); $start->setTimezone(new DateTimeZone($timezone)); $end->setTimezone(new DateTimeZone($timezone)); diff --git a/apps/calendar/ajax/event/new.php b/apps/calendar/ajax/event/new.php index 30e2b0cae3..bc0439cc31 100644 --- a/apps/calendar/ajax/event/new.php +++ b/apps/calendar/ajax/event/new.php @@ -10,6 +10,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::callCheck(); $errarr = OC_Calendar_Object::validateRequest($_POST); if($errarr){ diff --git a/apps/calendar/ajax/event/resize.php b/apps/calendar/ajax/event/resize.php index 56b83205e8..15b687b55d 100644 --- a/apps/calendar/ajax/event/resize.php +++ b/apps/calendar/ajax/event/resize.php @@ -7,6 +7,7 @@ */ OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); $id = $_POST['id']; diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php index cbb4b55056..b1dfc464d0 100644 --- a/apps/calendar/ajax/import/import.php +++ b/apps/calendar/ajax/import/import.php @@ -7,6 +7,7 @@ */ OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('calendar'); +OCP\JSON::callCheck(); session_write_close(); if (isset($_POST['progresskey']) && isset($_POST['getprogress'])) { echo OCP\JSON::success(array('percent'=>OC_Cache::get($_POST['progresskey']))); @@ -147,4 +148,4 @@ foreach($uids as $uid) { writeProgress('100'); sleep(3); OC_Cache::remove($progresskey); -OCP\JSON::success();*/ \ No newline at end of file +OCP\JSON::success();*/ diff --git a/apps/calendar/ajax/settings/setfirstday.php b/apps/calendar/ajax/settings/setfirstday.php index 056a603752..73cf0c19b7 100644 --- a/apps/calendar/ajax/settings/setfirstday.php +++ b/apps/calendar/ajax/settings/setfirstday.php @@ -7,6 +7,7 @@ */ OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); if(isset($_POST["firstday"])){ OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'firstday', $_POST["firstday"]); OCP\JSON::success(); diff --git a/apps/calendar/ajax/settings/settimeformat.php b/apps/calendar/ajax/settings/settimeformat.php index 8e95f6f3bf..6136857e2f 100644 --- a/apps/calendar/ajax/settings/settimeformat.php +++ b/apps/calendar/ajax/settings/settimeformat.php @@ -7,6 +7,7 @@ */ OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); if(isset($_POST["timeformat"])){ OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]); OCP\JSON::success(); diff --git a/apps/calendar/ajax/settings/settimezone.php b/apps/calendar/ajax/settings/settimezone.php index 6d029a6643..06db66d578 100644 --- a/apps/calendar/ajax/settings/settimezone.php +++ b/apps/calendar/ajax/settings/settimezone.php @@ -14,6 +14,7 @@ $l=OC_L10N::get('calendar'); // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::callCheck(); // Get data if( isset( $_POST['timezone'] ) ){ diff --git a/apps/calendar/ajax/share/changepermission.php b/apps/calendar/ajax/share/changepermission.php index e807c164a2..5aff7666f7 100644 --- a/apps/calendar/ajax/share/changepermission.php +++ b/apps/calendar/ajax/share/changepermission.php @@ -5,7 +5,9 @@ * later. * See the COPYING-README file. */ - + +OCP\JSON::callCheck(); + $id = strip_tags($_POST['id']); $idtype = strip_tags($_POST['idtype']); $permission = (int) strip_tags($_POST['permission']); diff --git a/apps/calendar/ajax/share/share.php b/apps/calendar/ajax/share/share.php index 838db619f6..77e1ab9d65 100644 --- a/apps/calendar/ajax/share/share.php +++ b/apps/calendar/ajax/share/share.php @@ -6,6 +6,8 @@ * See the COPYING-README file. */ +OCP\JSON::callCheck(); + $id = strip_tags($_POST['id']); $idtype = strip_tags($_POST['idtype']); switch($idtype){ diff --git a/apps/calendar/ajax/share/unshare.php b/apps/calendar/ajax/share/unshare.php index 1ce04677fb..c7c0611318 100644 --- a/apps/calendar/ajax/share/unshare.php +++ b/apps/calendar/ajax/share/unshare.php @@ -5,7 +5,9 @@ * later. * See the COPYING-README file. */ - + +OCP\JSON::callCheck(); + $id = strip_tags($_POST['id']); $idtype = strip_tags($_POST['idtype']); switch($idtype){ diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index 09b18ed397..4fdba29126 100644 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -11,6 +11,7 @@ OC::$CLASSPATH['OC_Search_Provider_Calendar'] = 'apps/calendar/lib/search.php'; OC::$CLASSPATH['OC_Calendar_Export'] = 'apps/calendar/lib/export.php'; OC::$CLASSPATH['OC_Calendar_Import'] = 'apps/calendar/lib/import.php'; //General Hooks +OCP\Util::connectHook('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'createUser'); OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser'); //Repeating Events Hooks OCP\Util::connectHook('OC_Calendar', 'addEvent', 'OC_Calendar_Repeat', 'generate'); diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js index 03e4217573..60741f2b6f 100644 --- a/apps/calendar/js/settings.js +++ b/apps/calendar/js/settings.js @@ -34,6 +34,7 @@ $(document).ready(function(){ $.getJSON(OC.filePath('calendar', 'ajax/settings', 'timeformat.php'), function(jsondata, status) { $('#' + jsondata.timeformat).attr('selected',true); $('#timeformat').chosen(); + $('#timeformat_chzn').css('width', '100px'); }); $.getJSON(OC.filePath('calendar', 'ajax/settings', 'gettimezonedetection.php'), function(jsondata, status){ if(jsondata.detection == 'true'){ @@ -43,6 +44,7 @@ $(document).ready(function(){ $.getJSON(OC.filePath('calendar', 'ajax/settings', 'getfirstday.php'), function(jsondata, status) { $('#' + jsondata.firstday).attr('selected',true); $('#firstday').chosen(); + $('#firstday_chzn').css('width', '100px'); }); $('#cleancalendarcache').click(function(){ $.getJSON(OC.filePath('calendar', 'ajax/cache', 'rescan.php'), function(){ @@ -55,7 +57,7 @@ function calendarcachecheck(){ $.getJSON(OC.filePath('calendar', 'ajax/cache', 'status.php'), function(jsondata, status) { $('#cleancalendarcache').attr('title', jsondata.l10n.text); if(jsondata.status == 'success'){ - $('#cleancalendarcache').css('background', '#90EE90'); + $('#cleancalendarcache').css('background', '#F8F8F8'); $('#cleancalendarcache').css('color', '#333'); $('#cleancalendarcache').css('text-shadow', '#fff 0 1px 0'); }else{ diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 1a13f2958c..29e5ab5b0c 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -9,7 +9,7 @@ * This class manages our app actions */ OC_Calendar_App::$l10n = new OC_L10N('calendar'); -OC_Calendar_App::$tz = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +OC_Calendar_App::$tz = OC_Calendar_App::getTimezone(); class OC_Calendar_App{ const CALENDAR = 'calendar'; const EVENT = 'event'; @@ -282,7 +282,17 @@ class OC_Calendar_App{ public static function getWeekofMonth(){ return OC_Calendar_Object::getWeekofMonth(self::$l10n); } - + + /** + * @return (string) $timezone as set by user or the default timezone + */ + public static function getTimezone() { + return OCP\Config::getUserValue(OCP\User::getUser(), + 'calendar', + 'timezone', + date_default_timezone_get()); + } + /** * @brief checks the access for a calendar / an event * @param (int) $id - id of the calendar / event diff --git a/apps/calendar/lib/hooks.php b/apps/calendar/lib/hooks.php index 328d2951d2..bc0b02c62b 100644 --- a/apps/calendar/lib/hooks.php +++ b/apps/calendar/lib/hooks.php @@ -11,7 +11,18 @@ */ class OC_Calendar_Hooks{ /** - * @brief Deletes all Addressbooks of a certain user + * @brief Creates default calendar for a user + * @param paramters parameters from postCreateUser-Hook + * @return array + */ + public static function createUser($parameters) { + OC_Calendar_Calendar::addCalendar($parameters['uid'],'Default calendar'); + + return true; + } + + /** + * @brief Deletes all calendars of a certain user * @param paramters parameters from postDeleteUser-Hook * @return array */ diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index 140542bf4f..3467683020 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -856,7 +856,7 @@ class OC_Calendar_Object{ $vevent->setDateTime('DTSTART', $start, Sabre_VObject_Property_DateTime::DATE); $vevent->setDateTime('DTEND', $end, Sabre_VObject_Property_DateTime::DATE); }else{ - $timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $timezone = OC_Calendar_App::getTimezone(); $timezone = new DateTimeZone($timezone); $start = new DateTime($from.' '.$fromtime, $timezone); $end = new DateTime($to.' '.$totime, $timezone); diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php index 560330f65e..551489672b 100644 --- a/apps/calendar/lib/search.php +++ b/apps/calendar/lib/search.php @@ -12,7 +12,7 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{ }else{ $searchquery[] = $query; } - $user_timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $user_timezone = OC_Calendar_App::getTimezone(); $l = new OC_l10n('calendar'); foreach($calendars as $calendar){ $objects = OC_Calendar_Object::all($calendar['id']); diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index 2246a0178e..29b9bf6bc5 100644 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -2,10 +2,10 @@ var defaultView = ''; var eventSources = ; var categories = ; - var dayNames = tA(array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'))) ?>; - var dayNamesShort = tA(array('Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.'))) ?>; - var monthNames = tA(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'))) ?>; - var monthNamesShort = tA(array('Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'))) ?>; + var dayNames = new Array(" t("Sunday");?>", " t("Monday");?>", " t("Tuesday");?>", " t("Wednesday");?>", " t("Thursday");?>", " t("Friday");?>", " t("Saturday");?>"); + var dayNamesShort = new Array(" t("Sun.");?>", " t("Mon.");?>", " t("Tue.");?>", " t("Wed.");?>", " t("Thu.");?>", " t("Fri.");?>", " t("Sat.");?>"); + var monthNames = new Array(" t("January");?>", " t("February");?>", " t("March");?>", " t("April");?>", " t("May");?>", " t("June");?>", " t("July");?>", " t("August");?>", " t("September");?>", " t("October");?>", " t("November");?>", " t("December");?>"); + var monthNamesShort = new Array(" t("Jan.");?>", " t("Feb.");?>", " t("Mar.");?>", " t("Apr.");?>", " t("May.");?>", " t("Jun.");?>", " t("Jul.");?>", " t("Aug.");?>", " t("Sep.");?>", " t("Oct.");?>", " t("Nov.");?>", " t("Dec.");?>"); var agendatime = '{ - }'; var defaulttime = ''; var allDayText = 't('All day')) ?>'; diff --git a/apps/contacts/ajax/activation.php b/apps/contacts/ajax/activation.php index 74cb738ab8..69173c54c4 100644 --- a/apps/contacts/ajax/activation.php +++ b/apps/contacts/ajax/activation.php @@ -16,8 +16,12 @@ $bookid = $_POST['bookid']; $book = OC_Contacts_App::getAddressbook($bookid);// is owner access check if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { - OCP\Util::writeLog('contacts','ajax/activation.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR); - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.')))); + OCP\Util::writeLog('contacts', + 'ajax/activation.php: Error activating addressbook: '. $bookid, + OCP\Util::ERROR); + OCP\JSON::error(array( + 'data' => array( + 'message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.')))); exit(); } diff --git a/apps/contacts/ajax/addaddressbook.php b/apps/contacts/ajax/addaddressbook.php index 3d7885fe46..40773704bb 100644 --- a/apps/contacts/ajax/addaddressbook.php +++ b/apps/contacts/ajax/addaddressbook.php @@ -12,13 +12,15 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); -require_once('loghandler.php'); +require_once 'loghandler.php'; debug('name: '.$_POST['name']); $userid = OCP\USER::getUser(); $name = isset($_POST['name'])?trim(strip_tags($_POST['name'])):null; -$description = isset($_POST['description'])?trim(strip_tags($_POST['description'])):null; +$description = isset($_POST['description']) + ? trim(strip_tags($_POST['description'])) + : null; if(is_null($name)) { bailOut('Cannot add addressbook with an empty name.'); diff --git a/apps/contacts/ajax/addcontact.php b/apps/contacts/ajax/addcontact.php index 12f7bb9db9..6aaf5a9df3 100644 --- a/apps/contacts/ajax/addcontact.php +++ b/apps/contacts/ajax/addcontact.php @@ -37,13 +37,15 @@ $n = trim($_POST['n']); $vcard = new OC_VObject('VCARD'); $vcard->setUID(); -$vcard->setString('FN',$fn); -$vcard->setString('N',$n); +$vcard->setString('FN', $fn); +$vcard->setString('N', $n); $id = OC_Contacts_VCard::add($aid, $vcard, null, $isnew); if(!$id) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.')))); - OCP\Util::writeLog('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR); + OCP\JSON::error(array( + 'data' => array( + 'message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.')))); + OCP\Util::writeLog('contacts', 'ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR); exit(); } diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index 1b6db0c8f8..58b857547f 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -25,7 +25,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); -require_once('loghandler.php'); +require_once 'loghandler.php'; $id = isset($_POST['id'])?$_POST['id']:null; $name = isset($_POST['name'])?$_POST['name']:null; @@ -33,22 +33,27 @@ $value = isset($_POST['value'])?$_POST['value']:null; $parameters = isset($_POST['parameters'])?$_POST['parameters']:array(); $vcard = OC_Contacts_App::getContactVCard($id); +$l10n = OC_Contacts_App::$l10n; if(!$name) { - bailOut(OC_Contacts_App::$l10n->t('element name is not set.')); + bailOut($l10n->t('element name is not set.')); } if(!$id) { - bailOut(OC_Contacts_App::$l10n->t('id is not set.')); + bailOut($l10n->t('id is not set.')); } if(!$vcard) { - bailOut(OC_Contacts_App::$l10n->t('Could not parse contact: ').$id); + bailOut($l10n->t('Could not parse contact: ').$id); } -if(!is_array($value)){ +if(!is_array($value)) { $value = trim($value); - if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG', 'BDAY', 'URL', 'NICKNAME', 'NOTE'))) { - bailOut(OC_Contacts_App::$l10n->t('Cannot add empty property.')); + if(!$value + && in_array( + $name, + array('TEL', 'EMAIL', 'ORG', 'BDAY', 'URL', 'NICKNAME', 'NOTE')) + ) { + bailOut($l10n->t('Cannot add empty property.')); } } elseif($name === 'ADR') { // only add if non-empty elements. $empty = true; @@ -59,7 +64,7 @@ if(!is_array($value)){ } } if($empty) { - bailOut(OC_Contacts_App::$l10n->t('At least one of the address fields has to be filled out.')); + bailOut($l10n->t('At least one of the address fields has to be filled out.')); } } @@ -68,12 +73,14 @@ $current = $vcard->select($name); foreach($current as $item) { $tmpvalue = (is_array($value)?implode(';', $value):$value); if($tmpvalue == $item->value) { - bailOut(OC_Contacts_App::$l10n->t('Trying to add duplicate property: '.$name.': '.$tmpvalue)); + bailOut($l10n->t('Trying to add duplicate property: '.$name.': '.$tmpvalue)); } } if(is_array($value)) { - ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! + // NOTE: Important, otherwise the compound value will + // be set in the order the fields appear in the form! + ksort($value); $value = array_map('strip_tags', $value); } else { $value = strip_tags($value); @@ -116,24 +123,25 @@ switch($name) { $line = count($vcard->children) - 1; -// Apparently Sabre_VObject_Parameter doesn't do well with multiple values or I don't know how to do it. Tanghus. +// Apparently Sabre_VObject_Parameter doesn't do well with +// multiple values or I don't know how to do it. Tanghus. foreach ($parameters as $key=>$element) { if(is_array($element) && strtoupper($key) == 'TYPE') { // NOTE: Maybe this doesn't only apply for TYPE? // And it probably shouldn't be done here anyways :-/ - foreach($element as $e){ - if($e != '' && !is_null($e)){ - $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$e); + foreach($element as $e) { + if($e != '' && !is_null($e)) { + $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $e); } } } else { - $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$element); + $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $element); } } $checksum = md5($vcard->children[$line]->serialize()); -if(!OC_Contacts_VCard::edit($id,$vcard)) { - bailOut(OC_Contacts_App::$l10n->t('Error adding contact property: '.$name)); +if(!OC_Contacts_VCard::edit($id, $vcard)) { + bailOut($l10n->t('Error adding contact property: '.$name)); } OCP\JSON::success(array('data' => array( 'checksum' => $checksum ))); diff --git a/apps/contacts/ajax/categories/categoriesfor.php b/apps/contacts/ajax/categories/categoriesfor.php index 6b6fcad0eb..8391b14b54 100644 --- a/apps/contacts/ajax/categories/categoriesfor.php +++ b/apps/contacts/ajax/categories/categoriesfor.php @@ -12,16 +12,23 @@ OCP\JSON::checkAppEnabled('contacts'); $id = isset($_GET['id'])?$_GET['id']:null; if(is_null($id)) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('No ID provided')))); + OCP\JSON::error(array( + 'data' => array( + 'message' => OC_Contacts_App::$l10n->t('No ID provided')))); exit(); } $vcard = OC_Contacts_App::getContactVCard( $id ); foreach($vcard->children as $property){ - //OCP\Util::writeLog('contacts','ajax/categories/checksumfor.php: '.$property->name, OCP\Util::DEBUG); if($property->name == 'CATEGORIES') { $checksum = md5($property->serialize()); - OCP\JSON::success(array('data' => array('value'=>$property->value, 'checksum'=>$checksum))); + OCP\JSON::success(array( + 'data' => array( + 'value' => $property->value, + 'checksum' => $checksum, + ))); exit(); } } -OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error setting checksum.')))); +OCP\JSON::error(array( + 'data' => array( + 'message' => OC_Contacts_App::$l10n->t('Error setting checksum.')))); diff --git a/apps/contacts/ajax/categories/delete.php b/apps/contacts/ajax/categories/delete.php index 7c3261446b..bc9f3e14e8 100644 --- a/apps/contacts/ajax/categories/delete.php +++ b/apps/contacts/ajax/categories/delete.php @@ -9,8 +9,9 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); +OCP\JSON::callCheck(); -require_once('../loghandler.php'); +require_once __DIR__.'/../loghandler.php'; $categories = isset($_POST['categories'])?$_POST['categories']:null; diff --git a/apps/contacts/ajax/categories/rescan.php b/apps/contacts/ajax/categories/rescan.php index fd875a965d..a06e780395 100644 --- a/apps/contacts/ajax/categories/rescan.php +++ b/apps/contacts/ajax/categories/rescan.php @@ -9,6 +9,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); +OCP\JSON::callCheck(); OC_Contacts_App::scanCategories(); $categories = OC_Contacts_App::getCategories(); diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php index b697b1a8e5..27d7611ade 100644 --- a/apps/contacts/ajax/contactdetails.php +++ b/apps/contacts/ajax/contactdetails.php @@ -20,7 +20,7 @@ * */ -require_once('loghandler.php'); +require_once 'loghandler.php'; // Check if we are a user OCP\JSON::checkLoggedIn(); @@ -30,6 +30,7 @@ $id = isset($_GET['id'])?$_GET['id']:null; if(is_null($id)) { bailOut(OC_Contacts_App::$l10n->t('Missing ID')); } +$card = OC_Contacts_VCard::find($id); $vcard = OC_Contacts_App::getContactVCard( $id ); if(is_null($vcard)) { bailOut(OC_Contacts_App::$l10n->t('Error parsing VCard for ID: "'.$id.'"')); @@ -50,5 +51,7 @@ if(isset($details['PHOTO'])) { $details['PHOTO'] = false; } $details['id'] = $id; +$details['displayname'] = $card['fullname']; +$details['addressbookid'] = $card['addressbookid']; OC_Contacts_App::setLastModifiedHeader($vcard); OCP\JSON::success(array('data' => $details)); diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php index 2ec5f542bb..8dbd63f642 100644 --- a/apps/contacts/ajax/createaddressbook.php +++ b/apps/contacts/ajax/createaddressbook.php @@ -12,7 +12,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); -require_once('loghandler.php'); +require_once 'loghandler.php'; $userid = OCP\USER::getUser(); $name = trim(strip_tags($_POST['name'])); diff --git a/apps/contacts/ajax/currentphoto.php b/apps/contacts/ajax/currentphoto.php index 8f60eca08e..96080e661e 100644 --- a/apps/contacts/ajax/currentphoto.php +++ b/apps/contacts/ajax/currentphoto.php @@ -24,7 +24,7 @@ OCP\JSON::setContentTypeHeader('text/plain'); OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -require_once('loghandler.php'); +require_once 'loghandler.php'; if (!isset($_GET['id'])) { bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.')); diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php index 1161c18abd..9777046fc8 100644 --- a/apps/contacts/ajax/deletecard.php +++ b/apps/contacts/ajax/deletecard.php @@ -23,17 +23,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); -require_once('loghandler.php'); - -// foreach($_SERVER as $key=>$value) { -// OCP\Util::writeLog('contacts','ajax/saveproperty.php: _SERVER: '.$key.'=>'.$value, OCP\Util::DEBUG); -// } -// foreach($_POST as $key=>$value) { -// debug($key.'=>'.print_r($value, true)); -// } -// foreach($_GET as $key=>$value) { -// debug($key.'=>'.print_r($value, true)); -// } +require_once 'loghandler.php'; $id = isset($_POST['id'])?$_POST['id']:null; if(!$id) { diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php index 90e5e64903..205df8bc18 100644 --- a/apps/contacts/ajax/deleteproperty.php +++ b/apps/contacts/ajax/deleteproperty.php @@ -24,22 +24,23 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); -require_once('loghandler.php'); +require_once 'loghandler.php'; $id = $_POST['id']; $checksum = $_POST['checksum']; +$l10n = OC_Contacts_App::$l10n; $vcard = OC_Contacts_App::getContactVCard( $id ); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); -if(is_null($line)){ - bailOut(OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.')); +if(is_null($line)) { + bailOut($l10n->t('Information about vCard is incorrect. Please reload the page.')); exit(); } unset($vcard->children[$line]); -if(!OC_Contacts_VCard::edit($id,$vcard)) { - bailOut(OC_Contacts_App::$l10n->t('Error deleting contact property.')); +if(!OC_Contacts_VCard::edit($id, $vcard)) { + bailOut($l10n->t('Error deleting contact property.')); } OCP\JSON::success(array('data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/editaddress.php b/apps/contacts/ajax/editaddress.php index 1eb9429d79..b5e4b72ed5 100644 --- a/apps/contacts/ajax/editaddress.php +++ b/apps/contacts/ajax/editaddress.php @@ -34,8 +34,8 @@ if($checksum) { $tmpl->assign('adr', $adr, false); } -$tmpl->assign('id',$id); -$tmpl->assign('adr_types',$adr_types); +$tmpl->assign('id', $id); +$tmpl->assign('adr_types', $adr_types); $page = $tmpl->fetchPage(); OCP\JSON::success(array('data' => array('page'=>$page, 'checksum'=>$checksum))); diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php index 9e7c090eee..eb55634011 100644 --- a/apps/contacts/ajax/editname.php +++ b/apps/contacts/ajax/editname.php @@ -9,7 +9,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -require_once('loghandler.php'); +require_once 'loghandler.php'; $tmpl = new OCP\Template("contacts", "part.edit_name_dialog"); @@ -25,8 +25,8 @@ if($id) { } } $name = array_map('htmlspecialchars', $name['value']); - $tmpl->assign('name',$name, false); - $tmpl->assign('id',$id, false); + $tmpl->assign('name', $name, false); + $tmpl->assign('id', $id, false); } else { bailOut(OC_Contacts_App::$l10n->t('Contact ID is missing.')); } diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php index 1309faaa7a..75fe33ada6 100644 --- a/apps/contacts/ajax/loadcard.php +++ b/apps/contacts/ajax/loadcard.php @@ -30,20 +30,20 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size); $requesttoken = $_GET['requesttoken']; $freeSpace=OC_Filesystem::free_space('/'); -$freeSpace=max($freeSpace,0); -$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace); +$freeSpace=max($freeSpace, 0); +$maxUploadFilesize = min($maxUploadFilesize, $freeSpace); $adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); $phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); $email_types = OC_Contacts_App::getTypesOfProperty('EMAIL'); -$tmpl = new OCP\Template('contacts','part.contact'); +$tmpl = new OCP\Template('contacts', 'part.contact'); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); -$tmpl->assign('adr_types',$adr_types); -$tmpl->assign('phone_types',$phone_types); -$tmpl->assign('email_types',$email_types); +$tmpl->assign('adr_types', $adr_types); +$tmpl->assign('phone_types', $phone_types); +$tmpl->assign('email_types', $email_types); $tmpl->assign('requesttoken', $requesttoken); -$tmpl->assign('id',''); +$tmpl->assign('id', ''); $page = $tmpl->fetchPage(); OCP\JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/loadintro.php b/apps/contacts/ajax/loadintro.php index 6e8fcc4b04..1da08950ca 100644 --- a/apps/contacts/ajax/loadintro.php +++ b/apps/contacts/ajax/loadintro.php @@ -25,7 +25,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -$tmpl = new OCP\Template('contacts','part.no_contacts'); +$tmpl = new OCP\Template('contacts', 'part.no_contacts'); $page = $tmpl->fetchPage(); OCP\JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php index a35631055e..be924b5db4 100644 --- a/apps/contacts/ajax/loadphoto.php +++ b/apps/contacts/ajax/loadphoto.php @@ -24,7 +24,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -require_once('loghandler.php'); +require_once 'loghandler.php'; $id = isset($_GET['id']) ? $_GET['id'] : ''; $refresh = isset($_GET['refresh']) ? true : false; diff --git a/apps/contacts/ajax/loghandler.php b/apps/contacts/ajax/loghandler.php index 831b2e50c1..be4b98c111 100644 --- a/apps/contacts/ajax/loghandler.php +++ b/apps/contacts/ajax/loghandler.php @@ -20,13 +20,15 @@ * */ -function bailOut($msg, $tracelevel=1, $debuglevel=OCP\Util::ERROR) { +function bailOut($msg, $tracelevel=1, $debuglevel=OCP\Util::ERROR) +{ OCP\JSON::error(array('data' => array('message' => $msg))); debug($msg, $tracelevel, $debuglevel); exit(); } -function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) { +function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) +{ if(PHP_VERSION >= "5.4") { $call = debug_backtrace(false, $tracelevel+1); } else { @@ -35,6 +37,8 @@ function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) { error_log('trace: '.print_r($call, true)); $call = $call[$tracelevel]; if($debuglevel !== false) { - OCP\Util::writeLog('contacts', $call['file'].'. Line: '.$call['line'].': '.$msg, $debuglevel); + OCP\Util::writeLog('contacts', + $call['file'].'. Line: '.$call['line'].': '.$msg, + $debuglevel); } } diff --git a/apps/contacts/ajax/oc_photo.php b/apps/contacts/ajax/oc_photo.php index 710179fffc..fe37b530f8 100644 --- a/apps/contacts/ajax/oc_photo.php +++ b/apps/contacts/ajax/oc_photo.php @@ -22,7 +22,7 @@ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -require_once('loghandler.php'); +require_once 'loghandler.php'; if(!isset($_GET['id'])) { bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.')); @@ -50,7 +50,9 @@ if($image->width() > 400 || $image->height() > 400) { $image->resize(400); // Prettier resizing than with browser and saves bandwidth. } if(!$image->fixOrientation()) { // No fatal error so we don't bail out. - OCP\Util::writeLog('contacts','ajax/oc_photo.php: Couldn\'t save correct image orientation: '.$localpath, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', + 'ajax/oc_photo.php: Couldn\'t save correct image orientation: '.$localpath, + OCP\Util::DEBUG); } if(OC_Cache::set($tmpkey, $image->data(), 600)) { OCP\JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpkey))); diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php index adce6be3b3..8ee2e46bf0 100644 --- a/apps/contacts/ajax/savecrop.php +++ b/apps/contacts/ajax/savecrop.php @@ -27,7 +27,7 @@ OCP\JSON::callCheck(); // Firefox and Konqueror tries to download application/json for me. --Arthur OCP\JSON::setContentTypeHeader('text/plain'); -require_once('loghandler.php'); +require_once 'loghandler.php'; $image = null; @@ -48,7 +48,7 @@ if($id == '') { bailOut('Missing contact id.'); } -OCP\Util::writeLog('contacts','savecrop.php: key: '.$tmpkey, OCP\Util::DEBUG); +OCP\Util::writeLog('contacts', 'savecrop.php: key: '.$tmpkey, OCP\Util::DEBUG); $data = OC_Cache::get($tmpkey); if($data) { @@ -56,7 +56,9 @@ if($data) { if($image->loadFromdata($data)) { $w = ($w != -1 ? $w : $image->width()); $h = ($h != -1 ? $h : $image->height()); - OCP\Util::writeLog('contacts','savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', + 'savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, + OCP\Util::DEBUG); if($image->crop($x1, $y1, $w, $h)) { if(($image->width() <= 200 && $image->height() <= 200) || $image->resize(200)) { $card = OC_Contacts_App::getContactVCard($id); @@ -65,7 +67,9 @@ if($data) { bailOut(OC_Contacts_App::$l10n->t('Error getting contact object.')); } if($card->__isset('PHOTO')) { - OCP\Util::writeLog('contacts','savecrop.php: PHOTO property exists.', OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', + 'savecrop.php: PHOTO property exists.', + OCP\Util::DEBUG); $property = $card->__get('PHOTO'); if(!$property) { OC_Cache::remove($tmpkey); @@ -76,12 +80,16 @@ if($data) { $property->parameters[] = new Sabre_VObject_Parameter('TYPE', $image->mimeType()); $card->__set('PHOTO', $property); } else { - OCP\Util::writeLog('contacts','savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG); - $card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType())); + OCP\Util::writeLog('contacts', + 'savecrop.php: files: Adding PHOTO property.', + OCP\Util::DEBUG); + $card->addProperty('PHOTO', + $image->__toString(), array('ENCODING' => 'b', + 'TYPE' => $image->mimeType())); } $now = new DateTime; $card->setString('REV', $now->format(DateTime::W3C)); - if(!OC_Contacts_VCard::edit($id,$card)) { + if(!OC_Contacts_VCard::edit($id, $card)) { bailOut(OC_Contacts_App::$l10n->t('Error saving contact.')); } $tmpl = new OCP\Template("contacts", "part.contactphoto"); diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php index 34fc3cc535..5d743c99df 100644 --- a/apps/contacts/ajax/saveproperty.php +++ b/apps/contacts/ajax/saveproperty.php @@ -19,7 +19,7 @@ * License along with this library. If not, see . * */ -require_once('loghandler.php'); +require_once 'loghandler.php'; // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); @@ -39,9 +39,11 @@ if(!$id) { if(!$checksum) { bailOut(OC_Contacts_App::$l10n->t('checksum is not set.')); } -if(is_array($value)){ +if(is_array($value)) { $value = array_map('strip_tags', $value); - ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! + // NOTE: Important, otherwise the compound value will be + // set in the order the fields appear in the form! + ksort($value); //if($name == 'CATEGORIES') { // $value = OC_Contacts_VCard::escapeDelimiters($value, ','); //} else { @@ -66,8 +68,7 @@ if($element != $name) { switch($element) { case 'BDAY': $date = New DateTime($value); - //$vcard->setDateTime('BDAY', $date, Sabre_VObject_Element_DateTime::DATE); - $value = $date->format(DateTime::ATOM); + $value = $date->format('Y-m-d'); break; case 'FN': if(!$value) { @@ -89,6 +90,14 @@ if(!$value) { } else { /* setting value */ switch($element) { + case 'BDAY': + // I don't use setDateTime() because that formats it as YYYYMMDD instead of YYYY-MM-DD + // which is what the RFC recommends. + $vcard->children[$line]->setValue($value); + $vcard->children[$line]->parameters = array(); + $vcard->children[$line]->add(new Sabre_VObject_Parameter('VALUE', 'DATE')); + debug('Setting value:'.$name.' '.$vcard->children[$line]); + break; case 'CATEGORIES': debug('Setting string:'.$name.' '.$value); $vcard->children[$line]->setValue($value); @@ -120,7 +129,7 @@ if(!$value) { } //debug('New checksum: '.$checksum); -if(!OC_Contacts_VCard::edit($id,$vcard)) { +if(!OC_Contacts_VCard::edit($id, $vcard)) { bailOut(OC_Contacts_App::$l10n->t('Error updating contact property.')); exit(); } diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php index d3a772c727..a14b215843 100644 --- a/apps/contacts/ajax/updateaddressbook.php +++ b/apps/contacts/ajax/updateaddressbook.php @@ -11,7 +11,7 @@ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -require_once('loghandler.php'); +require_once 'loghandler.php'; $bookid = $_POST['id']; OC_Contacts_App::getAddressbook($bookid); // is owner access check diff --git a/apps/contacts/ajax/uploadimport.php b/apps/contacts/ajax/uploadimport.php index 3c5a2d750e..87032b731a 100644 --- a/apps/contacts/ajax/uploadimport.php +++ b/apps/contacts/ajax/uploadimport.php @@ -24,7 +24,9 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); -require_once('loghandler.php'); +require_once 'loghandler.php'; + +$l10n = OC_Contacts_App::$l10n; $view = OCP\Files::getStorage('contacts'); if(!$view->file_exists('imports')) { @@ -39,25 +41,29 @@ if($fn) { OCP\JSON::success(array('data' => array('file'=>$tmpfile, 'name'=>$fn))); exit(); } else { - bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.')); + bailOut($l10n->t('Error uploading contacts to storage.')); } } // File input transfers are handled here if (!isset($_FILES['importfile'])) { - OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OCP\Util::DEBUG); - OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' ))); + OCP\Util::writeLog('contacts', + 'ajax/uploadphoto.php: No file was uploaded. Unknown error.', + OCP\Util::DEBUG); + OCP\JSON::error(array(' + data' => array( + 'message' => 'No file was uploaded. Unknown error' ))); exit(); } $error = $_FILES['importfile']['error']; if($error !== UPLOAD_ERR_OK) { $errors = array( - 0=>OC_Contacts_App::$l10n->t("There is no error, the file uploaded with success"), - 1=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'), - 2=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), - 3=>OC_Contacts_App::$l10n->t("The uploaded file was only partially uploaded"), - 4=>OC_Contacts_App::$l10n->t("No file was uploaded"), - 6=>OC_Contacts_App::$l10n->t("Missing a temporary folder") + 0=>$l10n->t("There is no error, the file uploaded with success"), + 1=>$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'), + 2=>$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), + 3=>$l10n->t("The uploaded file was only partially uploaded"), + 4=>$l10n->t("No file was uploaded"), + 6=>$l10n->t("Missing a temporary folder") ); bailOut($errors[$error]); } @@ -67,7 +73,7 @@ if(file_exists($file['tmp_name'])) { if($view->file_put_contents('/imports/'.$file['name'], file_get_contents($file['tmp_name']))) { OCP\JSON::success(array('data' => array('file'=>$file['name'], 'name'=>$file['name']))); } else { - bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.')); + bailOut($l10n->t('Error uploading contacts to storage.')); } } else { bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?'); diff --git a/apps/contacts/ajax/uploadphoto.php b/apps/contacts/ajax/uploadphoto.php index 6bb3fe8a5e..4cd38db8c7 100644 --- a/apps/contacts/ajax/uploadphoto.php +++ b/apps/contacts/ajax/uploadphoto.php @@ -27,13 +27,13 @@ OCP\JSON::callCheck(); // Firefox and Konqueror tries to download application/json for me. --Arthur OCP\JSON::setContentTypeHeader('text/plain'); -require_once('loghandler.php'); - +require_once 'loghandler.php'; +$l10n = OC_Contacts_App::$l10n; // If it is a Drag'n'Drop transfer it's handled here. $fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : false); if ($fn) { if (!isset($_GET['id'])) { - bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.')); + bailOut($l10n->t('No contact ID was submitted.')); } $id = $_GET['id']; $tmpkey = 'contact-photo-'.md5($fn); @@ -48,33 +48,38 @@ if ($fn) { debug('Couldn\'t save correct image orientation: '.$tmpkey); } if(OC_Cache::set($tmpkey, $image->data(), 600)) { - OCP\JSON::success(array('data' => array('mime'=>$_SERVER['CONTENT_TYPE'], 'name'=>$fn, 'id'=>$id, 'tmp'=>$tmpkey))); + OCP\JSON::success(array( + 'data' => array( + 'mime'=>$_SERVER['CONTENT_TYPE'], + 'name'=>$fn, + 'id'=>$id, + 'tmp'=>$tmpkey))); exit(); } else { - bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey); + bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey); } } else { - bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$tmpkey); + bailOut($l10n->t('Couldn\'t load temporary image: ').$tmpkey); } } // Uploads from file dialog are handled here. if (!isset($_POST['id'])) { - bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.')); + bailOut($l10n->t('No contact ID was submitted.')); } if (!isset($_FILES['imagefile'])) { - bailOut(OC_Contacts_App::$l10n->t('No file was uploaded. Unknown error')); + bailOut($l10n->t('No file was uploaded. Unknown error')); } $error = $_FILES['imagefile']['error']; if($error !== UPLOAD_ERR_OK) { $errors = array( - 0=>OC_Contacts_App::$l10n->t("There is no error, the file uploaded with success"), - 1=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'), - 2=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), - 3=>OC_Contacts_App::$l10n->t("The uploaded file was only partially uploaded"), - 4=>OC_Contacts_App::$l10n->t("No file was uploaded"), - 6=>OC_Contacts_App::$l10n->t("Missing a temporary folder") + 0=>$l10n->t("There is no error, the file uploaded with success"), + 1=>$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'), + 2=>$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), + 3=>$l10n->t("The uploaded file was only partially uploaded"), + 4=>$l10n->t("No file was uploaded"), + 6=>$l10n->t("Missing a temporary folder") ); bailOut($errors[$error]); } @@ -91,13 +96,20 @@ if(file_exists($file['tmp_name'])) { debug('Couldn\'t save correct image orientation: '.$tmpkey); } if(OC_Cache::set($tmpkey, $image->data(), 600)) { - OCP\JSON::success(array('data' => array('mime'=>$file['type'],'size'=>$file['size'],'name'=>$file['name'], 'id'=>$_POST['id'], 'tmp'=>$tmpkey))); + OCP\JSON::success(array( + 'data' => array( + 'mime'=>$file['type'], + 'size'=>$file['size'], + 'name'=>$file['name'], + 'id'=>$_POST['id'], + 'tmp'=>$tmpkey, + ))); exit(); } else { - bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey); + bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey); } } else { - bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$file['tmp_name']); + bailOut($l10n->t('Couldn\'t load temporary image: ').$file['tmp_name']); } } else { bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?'); diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php index 33e89c3e9b..cbbbbc79e5 100644 --- a/apps/contacts/appinfo/app.php +++ b/apps/contacts/appinfo/app.php @@ -19,6 +19,6 @@ OCP\App::addNavigationEntry( array( 'name' => OC_L10N::get('contacts')->t('Contacts') )); -OCP\App::registerPersonal('contacts','settings'); +OCP\App::registerPersonal('contacts', 'settings'); OCP\Util::addscript('contacts', 'loader'); OC_Search::registerProvider('OC_Search_Provider_Contacts'); diff --git a/apps/contacts/appinfo/database.xml b/apps/contacts/appinfo/database.xml index 9b269d765d..b814b0f151 100644 --- a/apps/contacts/appinfo/database.xml +++ b/apps/contacts/appinfo/database.xml @@ -44,7 +44,7 @@ text false - 100 + 200 @@ -118,7 +118,7 @@ text false - 100 + 200 diff --git a/apps/contacts/appinfo/migrate.php b/apps/contacts/appinfo/migrate.php index 02026c5979..2559b4ea45 100644 --- a/apps/contacts/appinfo/migrate.php +++ b/apps/contacts/appinfo/migrate.php @@ -2,7 +2,7 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{ // Create the xml for the user supplied - function export( ){ + function export( ) { $options = array( 'table'=>'contacts_addressbooks', 'matchcol'=>'userid', @@ -21,9 +21,8 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{ $ids2 = $this->content->copyRows( $options ); // If both returned some ids then they worked - if( is_array( $ids ) && is_array( $ids2 ) ) - { - return true; + if(is_array($ids) && is_array($ids2)) { + return true; } else { return false; } @@ -31,14 +30,14 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{ } // Import function for contacts - function import( ){ - switch( $this->appinfo->version ){ + function import( ) { + switch( $this->appinfo->version ) { default: // All versions of the app have had the same db structure, so all can use the same import function $query = $this->content->prepare( "SELECT * FROM contacts_addressbooks WHERE userid LIKE ?" ); $results = $query->execute( array( $this->olduid ) ); $idmap = array(); - while( $row = $results->fetchRow() ){ + while( $row = $results->fetchRow() ) { // Import each addressbook $addressbookquery = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_addressbooks (`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)" ); $addressbookquery->execute( array( $this->uid, $row['displayname'], $row['uri'], $row['description'], $row['ctag'] ) ); @@ -48,7 +47,7 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{ OC_Contacts_Addressbook::setActive($idmap[$row['id']], true); } // Now tags - foreach($idmap as $oldid => $newid){ + foreach($idmap as $oldid => $newid) { $query = $this->content->prepare( "SELECT * FROM contacts_cards WHERE addressbookid LIKE ?" ); $results = $query->execute( array( $oldid ) ); diff --git a/apps/contacts/appinfo/remote.php b/apps/contacts/appinfo/remote.php index 09c2de1799..fd5604aec6 100644 --- a/apps/contacts/appinfo/remote.php +++ b/apps/contacts/appinfo/remote.php @@ -22,7 +22,7 @@ OCP\App::checkAppEnabled('contacts'); -if(substr($_SERVER["REQUEST_URI"],0,strlen(OC_App::getAppWebPath('contacts').'/carddav.php')) == OC_App::getAppWebPath('contacts').'/carddav.php'){ +if(substr($_SERVER["REQUEST_URI"], 0, strlen(OC_App::getAppWebPath('contacts').'/carddav.php')) == OC_App::getAppWebPath('contacts').'/carddav.php') { $baseuri = OC_App::getAppWebPath('contacts').'/carddav.php'; } @@ -45,7 +45,7 @@ $nodes = array( $server = new Sabre_DAV_Server($nodes); $server->setBaseUri($baseuri); // Add plugins -$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud')); +$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud')); $server->addPlugin(new Sabre_CardDAV_Plugin()); $server->addPlugin(new Sabre_DAVACL_Plugin()); $server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload diff --git a/apps/contacts/appinfo/update.php b/apps/contacts/appinfo/update.php index 873899f578..21e736bb44 100644 --- a/apps/contacts/appinfo/update.php +++ b/apps/contacts/appinfo/update.php @@ -1,7 +1,7 @@ execute(array()); diff --git a/apps/contacts/appinfo/version b/apps/contacts/appinfo/version index 373f8c6f07..72f9fa8202 100644 --- a/apps/contacts/appinfo/version +++ b/apps/contacts/appinfo/version @@ -1 +1 @@ -0.2.3 \ No newline at end of file +0.2.4 \ No newline at end of file diff --git a/apps/contacts/carddav.php b/apps/contacts/carddav.php index e0579e625d..264eb30836 100644 --- a/apps/contacts/carddav.php +++ b/apps/contacts/carddav.php @@ -1,6 +1,6 @@ array('message' => 'Import file was empty.'))); exit(); } -if(isset($_POST['method']) && $_POST['method'] == 'new'){ - $id = OC_Contacts_Addressbook::add(OCP\USER::getUser(), $_POST['addressbookname']); +if(isset($_POST['method']) && $_POST['method'] == 'new') { + $id = OC_Contacts_Addressbook::add(OCP\USER::getUser(), + $_POST['addressbookname']); if(!$id) { - OCP\JSON::error(array('data' => array('message' => 'Error creating address book.'))); + OCP\JSON::error( + array( + 'data' => array('message' => 'Error creating address book.') + ) + ); exit(); } OC_Contacts_Addressbook::setActive($id, 1); }else{ $id = $_POST['id']; if(!$id) { - OCP\JSON::error(array('data' => array('message' => 'Error getting the ID of the address book.', 'file'=>$_POST['file']))); + OCP\JSON::error( + array( + 'data' => array( + 'message' => 'Error getting the ID of the address book.', + 'file'=>$_POST['file'] + ) + ) + ); exit(); } OC_Contacts_App::getAddressbook($id); // is owner access check @@ -62,7 +74,7 @@ $inelement = false; $parts = array(); $card = array(); foreach($lines as $line){ - if(strtoupper(trim($line)) == 'BEGIN:VCARD'){ + if(strtoupper(trim($line)) == 'BEGIN:VCARD') { $inelement = true; } elseif (strtoupper(trim($line)) == 'END:VCARD') { $card[] = $line; @@ -79,21 +91,40 @@ writeProgress('70'); $imported = 0; $failed = 0; if(!count($parts) > 0) { - OCP\JSON::error(array('data' => array('message' => 'No contacts to import in '.$_POST['file'].'. Please check if the file is corrupted.', 'file'=>$_POST['file']))); + OCP\JSON::error( + array( + 'data' => array( + 'message' => 'No contacts to import in ' + . $_POST['file'].'. Please check if the file is corrupted.', + 'file'=>$_POST['file'] + ) + ) + ); + if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') { + if(!$view->unlink('/imports/' . $_POST['file'])) { + OCP\Util::writeLog('contacts', + 'Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], + OCP\Util::ERROR); + } + } exit(); } foreach($parts as $part){ $card = OC_VObject::parse($part); if (!$card) { $failed += 1; - OCP\Util::writeLog('contacts','Import: skipping card. Error parsing VCard: '.$part, OCP\Util::ERROR); + OCP\Util::writeLog('contacts', + 'Import: skipping card. Error parsing VCard: ' . $part, + OCP\Util::ERROR); continue; // Ditch cards that can't be parsed by Sabre. } try { OC_Contacts_VCard::add($id, $card); $imported += 1; } catch (Exception $e) { - OCP\Util::writeLog('contacts', 'Error importing vcard: '.$e->getMessage().$nl.$card, OCP\Util::ERROR); + OCP\Util::writeLog('contacts', + 'Error importing vcard: ' . $e->getMessage() . $nl . $card, + OCP\Util::ERROR); $failed += 1; } } @@ -103,7 +134,17 @@ sleep(3); OC_Cache::remove($progresskey); if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') { if(!$view->unlink('/imports/' . $_POST['file'])) { - OCP\Util::writeLog('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OCP\Util::ERROR); + OCP\Util::writeLog('contacts', + 'Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], + OCP\Util::ERROR); } } -OCP\JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed, 'file'=>$_POST['file']))); +OCP\JSON::success( + array( + 'data' => array( + 'imported'=>$imported, + 'failed'=>$failed, + 'file'=>$_POST['file'], + ) + ) +); diff --git a/apps/contacts/index.php b/apps/contacts/index.php index 00b1b4f7a9..c35e1b85d4 100644 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -14,13 +14,17 @@ OCP\App::checkAppEnabled('contacts'); // Get active address books. This creates a default one if none exists. $ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser()); -$has_contacts = (count(OC_Contacts_VCard::all($ids, 0, 1)) > 0 ? true : false); // just to check if there are any contacts. +$has_contacts = (count(OC_Contacts_VCard::all($ids, 0, 1)) > 0 + ? true + : false); // just to check if there are any contacts. if($has_contacts === false) { - OCP\Util::writeLog('contacts','index.html: No contacts found.',OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', + 'index.html: No contacts found.', + OCP\Util::DEBUG); } // Load the files we need -OCP\App::setActiveNavigationEntry( 'contacts_index' ); +OCP\App::setActiveNavigationEntry('contacts_index'); // Load a specific user? $id = isset( $_GET['id'] ) ? $_GET['id'] : null; @@ -34,30 +38,31 @@ $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $maxUploadFilesize = min($upload_max_filesize, $post_max_size); $freeSpace=OC_Filesystem::free_space('/'); -$freeSpace=max($freeSpace,0); -$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace); +$freeSpace=max($freeSpace, 0); +$maxUploadFilesize = min($maxUploadFilesize, $freeSpace); -OCP\Util::addscript('','jquery.multiselect'); -OCP\Util::addscript('','oc-vcategories'); -OCP\Util::addscript('contacts','contacts'); -OCP\Util::addscript('contacts','expanding'); -OCP\Util::addscript('contacts','jquery.combobox'); +OCP\Util::addscript('', 'jquery.multiselect'); +OCP\Util::addscript('', 'oc-vcategories'); +OCP\Util::addscript('contacts', 'contacts'); +OCP\Util::addscript('contacts', 'expanding'); +OCP\Util::addscript('contacts', 'jquery.combobox'); OCP\Util::addscript('files', 'jquery.fileupload'); -OCP\Util::addscript('contacts','jquery.inview'); -OCP\Util::addscript('contacts','jquery.Jcrop'); -OCP\Util::addscript('contacts','jquery.multi-autocomplete'); -OCP\Util::addStyle('','jquery.multiselect'); -OCP\Util::addStyle('contacts','jquery.combobox'); -OCP\Util::addStyle('contacts','jquery.Jcrop'); -OCP\Util::addStyle('contacts','contacts'); +OCP\Util::addscript('contacts', 'jquery.inview'); +OCP\Util::addscript('contacts', 'jquery.Jcrop'); +OCP\Util::addscript('contacts', 'jquery.multi-autocomplete'); +OCP\Util::addStyle('', 'jquery.multiselect'); +OCP\Util::addStyle('contacts', 'jquery.combobox'); +OCP\Util::addStyle('contacts', 'jquery.Jcrop'); +OCP\Util::addStyle('contacts', 'contacts'); $tmpl = new OCP\Template( "contacts", "index", "user" ); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize, false); -$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize), false); +$tmpl->assign('uploadMaxHumanFilesize', + OCP\Util::humanFileSize($maxUploadFilesize), false); $tmpl->assign('property_types', $property_types, false); $tmpl->assign('phone_types', $phone_types, false); $tmpl->assign('email_types', $email_types, false); $tmpl->assign('categories', $categories, false); $tmpl->assign('has_contacts', $has_contacts, false); -$tmpl->assign('id',$id, false); +$tmpl->assign('id', $id, false); $tmpl->printPage(); diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index b4e7cdba44..337f51839d 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -12,10 +12,38 @@ String.prototype.strip_tags = function(){ Contacts={ UI:{ + /** + * Arguments: + * message: The text message to show. The only mandatory parameter. + * timeout: The timeout in seconds before the notification disappears. Default 10. + * timeouthandler: A function to run on timeout. + * clickhandler: A function to run on click. If a timeouthandler is given it will be cancelled. + * data: An object that will be passed as argument to the timeouthandler and clickhandler functions. + */ notify:function(params) { - $('#notification').text(params.message); - $('#notification').fadeIn(); - setTimeout(function() {$('#notification').fadeOut();}, 10000); + var notifier = $('#notification'); + notifier.text(params.message); + notifier.fadeIn(); + var timer = setTimeout(function() { + notifier.fadeOut(); + if(params.timeouthandler && $.isFunction(params.timeouthandler)) { + params.timeouthandler(notifier.data(dataid)); + notifier.off('click'); + notifier.data(dataid, null); + } + }, params.timeout && $.isNumeric(params.timeout) ? parseInt(params.timeout)*1000 : 10000); + var dataid = timer.toString(); + if(params.data) { + notifier.data(dataid, params.data); + } + if(params.clickhandler && $.isFunction(params.clickhandler)) { + notifier.on('click', function() { + clearTimeout(timer); + notifier.off('click'); + params.clickhandler(notifier.data(dataid)); + notifier.data(dataid, null); + }); + } }, notImplemented:function() { OC.dialogs.alert(t('contacts', 'Sorry, this functionality has not been implemented yet'), t('contacts', 'Not implemented')); @@ -96,7 +124,7 @@ Contacts={ $('.addresscard,.propertylist li,.propertycontainer').hover( function () { $(this).find('.globe,.mail,.delete,.edit').animate({ opacity: 1.0 }, 200, function() {}); - }, + }, function () { $(this).find('.globe,.mail,.delete,.edit').animate({ opacity: 0.1 }, 200, function() {}); } @@ -107,7 +135,7 @@ Contacts={ obj.tipsy('hide'); Contacts.UI.Card.deleteProperty(obj, 'single'); } - + var goToUrl = function(obj) { var url = Contacts.UI.propertyContainerFor(obj).find('#url').val(); if(url != '') { @@ -115,7 +143,7 @@ Contacts={ newWindow.focus(); } } - + $('#identityprops a.delete').click( function() { deleteItem($(this)) }); $('#identityprops a.delete').keydown( function() { deleteItem($(this)) }); $('#categories_value a.edit').click( function() { $(this).tipsy('hide');OCCategories.edit(); } ); @@ -140,7 +168,7 @@ Contacts={ }); $('#edit_name').click(function(){Contacts.UI.Card.editName()}); $('#edit_name').keydown(function(){Contacts.UI.Card.editName()}); - + $('#phototools li a').click(function() { $(this).tipsy('hide'); }); @@ -167,13 +195,13 @@ Contacts={ OC.dialogs.filepicker(t('contacts', 'Select photo'), Contacts.UI.Card.cloudPhotoSelected, false, 'image', true); }); /* Initialize the photo edit dialog */ - $('#edit_photo_dialog').dialog({ + $('#edit_photo_dialog').dialog({ autoOpen: false, modal: true, height: 'auto', width: 'auto' }); $('#edit_photo_dialog' ).dialog( 'option', 'buttons', [ { text: "Ok", - click: function() { + click: function() { Contacts.UI.Card.savePhoto(this); $(this).dialog('close'); } @@ -183,37 +211,31 @@ Contacts={ click: function() { $(this).dialog('close'); } } ] ); - + // Name has changed. Update it and reorder. $('#fn').change(function(){ var name = $('#fn').val().strip_tags(); - var item = $('.contacts li[data-id="'+Contacts.UI.Card.id+'"]'); + var item = $('.contacts li[data-id="'+Contacts.UI.Card.id+'"]').detach(); $(item).find('a').html(name); Contacts.UI.Card.fn = name; - var added = false; - $('.contacts li[data-bookid="'+Contacts.UI.Card.bookid+'"]').each(function(){ - if ($(this).text().toLowerCase() > name.toLowerCase()) { - $(this).before(item).fadeIn('fast'); - added = true; - return false; - } + Contacts.UI.Contacts.insertContact({ + contactlist:$('#contacts ul[data-id="'+Contacts.UI.Card.bookid+'"]'), + contacts:$('#contacts ul[data-id="'+Contacts.UI.Card.bookid+'"] li'), + contact:item, }); - if(!added) { - $('#contacts ul[data-id="'+Contacts.UI.Card.bookid+'"]').append(item); - } Contacts.UI.Contacts.scrollTo(Contacts.UI.Card.id); }); - $('#contacts_deletecard').click( function() { Contacts.UI.Card.doDelete();return false;} ); - $('#contacts_deletecard').keydown( function(event) { + $('#contacts_deletecard').click( function() { Contacts.UI.Card.delayedDelete();return false;} ); + $('#contacts_deletecard').keydown( function(event) { if(event.which == 13 || event.which == 32) { - Contacts.UI.Card.doDelete(); + Contacts.UI.Card.delayedDelete(); } return false; }); $('#contacts_downloadcard').click( function() { Contacts.UI.Card.doExport();return false;} ); - $('#contacts_downloadcard').keydown( function(event) { + $('#contacts_downloadcard').keydown( function(event) { if(event.which == 13 || event.which == 32) { Contacts.UI.Card.doExport(); } @@ -228,12 +250,12 @@ Contacts={ $('#contacts_details_photo_wrapper').bind('dragover',function(event){ $(event.target).addClass('droppable'); event.stopPropagation(); - event.preventDefault(); + event.preventDefault(); }); $('#contacts_details_photo_wrapper').bind('dragleave',function(event){ $(event.target).removeClass('droppable'); //event.stopPropagation(); - //event.preventDefault(); + //event.preventDefault(); }); $('#contacts_details_photo_wrapper').bind('drop',function(event){ event.stopPropagation(); @@ -285,7 +307,7 @@ Contacts={ data:undefined, update:function(params) { // params {cid:int, aid:int} if(!params) { params = {}; } - $('#contacts li').removeClass('active'); + $('#contacts li,#contacts h3').removeClass('active'); console.log('Card, cid: ' + params.cid + ' aid: ' + params.aid); var newid, bookid, firstitem; if(!parseInt(params.cid) && !parseInt(params.aid)) { @@ -299,7 +321,13 @@ Contacts={ newid = parseInt($('#contacts').find('li[data-bookid="'+bookid+'"]').first().data('id')); } else if(parseInt(params.cid) && !parseInt(params.aid)) { newid = parseInt(params.cid); - bookid = parseInt($('#contacts li[data-id="'+newid+'"]').data('bookid')); + var listitem = $('#contacts li[data-id="'+newid+'"]'); + console.log('Is contact in list? ' + listitem.length); + if(listitem.length) { + bookid = parseInt($('#contacts li[data-id="'+newid+'"]').data('bookid')); + } else { // contact isn't in list yet. + bookid = 'unknown'; + } } else { newid = parseInt(params.cid); bookid = parseInt(params.aid); @@ -311,18 +339,26 @@ Contacts={ console.log('newid: ' + newid + ' bookid: ' +bookid); var localLoadContact = function(newid, bookid) { if($('.contacts li').length > 0) { - $('#contacts li[data-id="'+newid+'"]').addClass('active'); $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){ if(jsondata.status == 'success'){ + if(bookid == 'unknown') { + bookid = jsondata.data.addressbookid; + var contact = Contacts.UI.Contacts.insertContact({ + contactlist:$('#contacts ul[data-id="'+bookid+'"]'), + data:jsondata.data + }); + } + $('#contacts li[data-id="'+newid+'"],#contacts h3[data-id="'+bookid+'"]').addClass('active'); $('#contacts ul[data-id="'+bookid+'"]').slideDown(300); Contacts.UI.Card.loadContact(jsondata.data, bookid); + Contacts.UI.Contacts.scrollTo(newid); } else { OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); } }); } } - + // Make sure proper DOM is loaded. if(!$('#card').length && newid) { console.log('Loading card DOM'); @@ -363,9 +399,6 @@ Contacts={ Contacts.UI.Card.add(';;;;;', '', '', true); return false; }, - createEntry:function(data) { - return $('
  • '+data.displayname+'
  • '); - }, add:function(n, fn, aid, isnew){ // add a new contact console.log('Adding ' + fn); aid = aid?aid:$('#contacts h3.active').first().data('id'); @@ -410,7 +443,7 @@ Contacts={ } }); } - + if(!$('#card').length) { console.log('Loading card DOM'); $.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{'requesttoken': requesttoken},function(jsondata){ @@ -427,47 +460,56 @@ Contacts={ localAddcontact(n, fn, aid, isnew); } }, - doDelete:function() { + delayedDelete:function() { $('#contacts_deletecard').tipsy('hide'); - OC.dialogs.confirm(t('contacts', 'Are you sure you want to delete this contact?'), t('contacts', 'Warning'), function(answer) { - if(answer == true) { - $.post(OC.filePath('contacts', 'ajax', 'deletecard.php'),{'id':Contacts.UI.Card.id},function(jsondata){ - if(jsondata.status == 'success'){ - var newid = '', bookid; - var curlistitem = $('#contacts li[data-id="'+jsondata.data.id+'"]'); - var newlistitem = curlistitem.prev('li'); - if(!newlistitem) { - newlistitem = curlistitem.next('li'); - } - curlistitem.remove(); - if($(newlistitem).is('li')) { - newid = newlistitem.data('id'); - bookid = newlistitem.data('bookid'); - } - $('#rightcontent').data('id',newid); - this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = ''; - this.data = undefined; - - if($('.contacts li').length > 0) { // Load first in list. - Contacts.UI.Card.update({cid:newid, aid:bookid}); - } else { - // load intro page - $.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){ - if(jsondata.status == 'success'){ - id = ''; - $('#rightcontent').data('id',''); - $('#rightcontent').html(jsondata.data.page); - } - else{ - OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); - } - }); - } - } - else{ - OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); - } - }); + var newid = '', bookid; + var curlistitem = $('#contacts li[data-id="'+Contacts.UI.Card.id+'"]'); + curlistitem.removeClass('active'); + var newlistitem = curlistitem.prev('li'); + if(!newlistitem) { + newlistitem = curlistitem.next('li'); + } + curlistitem.detach(); + if($(newlistitem).is('li')) { + newid = newlistitem.data('id'); + bookid = newlistitem.data('bookid'); + } + $('#rightcontent').data('id',newid); + this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = ''; + this.data = undefined; + + if($('.contacts li').length > 0) { // Load first in list. + Contacts.UI.Card.update({cid:newid, aid:bookid}); + } else { + // load intro page + $.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){ + if(jsondata.status == 'success'){ + id = ''; + $('#rightcontent').data('id',''); + $('#rightcontent').html(jsondata.data.page); + } + else{ + OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); + } + }); + } + Contacts.UI.notify({ + data:curlistitem, + message:t('contacts','Click to undo deletion of "') + curlistitem.find('a').text() + '"', + timeouthandler:function(contact) { + Contacts.UI.Card.doDelete(contact.data('id')); + delete contact; + }, + clickhandler:function(contact) { + Contacts.UI.Contacts.insertContact({contact:contact}); + Contacts.UI.notify({message:t('contacts', 'Cancelled deletion of: "') + curlistitem.find('a').text() + '"'}); + } + }); + }, + doDelete:function(id) { + $.post(OC.filePath('contacts', 'ajax', 'deletecard.php'),{'id':id},function(jsondata) { + if(jsondata.status == 'error'){ + OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); } }); return false; @@ -519,7 +561,7 @@ Contacts={ $('#contacts_propertymenu_dropdown a[data-type="'+propname+'"]').parent().hide(); var property = this.data[propname][0]; var value = property['value'], checksum = property['checksum']; - + if(propname == 'BDAY') { var val = $.datepicker.parseDate('yy-mm-dd', value.substring(0, 10)); value = $.datepicker.formatDate('dd-mm-yy', val); @@ -584,7 +626,7 @@ Contacts={ $.each(names, function(key, value) { $('#fn_select') .append($('') - .text(value)); + .text(value)); }); $('#fn_select').combobox('value', this.fn); $('#contact_identity').find('*[data-element="N"]').data('checksum', this.data.N[0]['checksum']); @@ -835,7 +877,7 @@ Contacts={ title: t('contacts', 'Edit name'), height: 'auto', width: 'auto', buttons: { - 'Ok':function() { + 'Ok':function() { Contacts.UI.Card.saveName(this); $(this).dialog('close'); }, @@ -886,9 +928,9 @@ Contacts={ $.each(names, function(key, value) { $('#fn_select') .append($('') - .text(value)); + .text(value)); }); - + if(this.id == '') { var aid = $(dlg).find('#aid').val(); Contacts.UI.Card.add(n.join(';'), $('#short').text(), aid); @@ -952,7 +994,7 @@ Contacts={ container = $('#addressdisplay dl').last(); container.removeClass('template').addClass('propertycontainer'); } else { - params['checksum'] = Contacts.UI.checksumFor(obj); + params['checksum'] = Contacts.UI.checksumFor(obj); } /* Initialize the address edit dialog */ if($('#edit_address_dialog').dialog('isOpen') == true){ @@ -1168,7 +1210,7 @@ Contacts={ $('#phototools li a').tipsy('hide'); var wrapper = $('#contacts_details_photo_wrapper'); wrapper.addClass('loading').addClass('wait'); - + var img = new Image(); $(img).load(function () { $('img.contacts_details_photo').remove() @@ -1177,9 +1219,9 @@ Contacts={ $(this).insertAfter($('#phototools')).fadeIn(); }).error(function () { // notify the user that the image could not be loaded - $(t('contacts','something went wrong.')).insertAfter($('#phototools')); + Contacts.UI.notify({message:t('contacts','Error loading profile picture.')}); }).attr('src', OC.linkTo('contacts', 'photo.php')+'?id='+self.id+refreshstr); - + $.getJSON(OC.filePath('contacts', 'ajax', 'loadphoto.php'),{'id':this.id, 'refresh': refresh},function(jsondata){ if(jsondata.status == 'success'){ $('#contacts_details_photo_wrapper').data('checksum', jsondata.data.checksum); @@ -1334,8 +1376,6 @@ Contacts={ }, }, Addressbooks:{ - droptarget:undefined, - droptext:t('contacts', 'Drop a VCF file
    to import contacts.'), overview:function(){ if($('#chooseaddressbook_dialog').dialog('isOpen') == true){ $('#chooseaddressbook_dialog').dialog('moveToTop'); @@ -1427,7 +1467,7 @@ Contacts={ var displayname = $("#displayname_"+bookid).val().trim(); var active = $("#edit_active_"+bookid+":checked").length; var description = $("#description_"+bookid).val(); - + if(displayname.length == 0) { OC.dialogs.alert(t('contacts', 'Displayname cannot be empty.'), t('contacts', 'Error')); return false; @@ -1456,12 +1496,18 @@ Contacts={ batchnum:50, drop:function(event, ui) { var dragitem = ui.draggable, droptarget = $(this); - //console.log('Drop ' + dragitem.data('id') +' on: ' + droptarget.data('id')); + if(dragitem.is('li')) { + Contacts.UI.Contacts.dropContact(event, dragitem, droptarget); + } else { + Contacts.UI.Contacts.dropAddressbook(event, dragitem, droptarget); + } + }, + dropContact:function(event, dragitem, droptarget) { if(dragitem.data('bookid') == droptarget.data('id')) { return false; } var droplist = (droptarget.is('ul'))?droptarget:droptarget.next(); - $.post(OC.filePath('contacts', 'ajax', 'movetoaddressbook.php'), { ids: dragitem.data('id'), aid: $(this).data('id') }, + $.post(OC.filePath('contacts', 'ajax', 'movetoaddressbook.php'), { ids: dragitem.data('id'), aid: droptarget.data('id') }, function(jsondata){ if(jsondata.status == 'success'){ // Do some inserting/removing/sorting magic @@ -1485,6 +1531,44 @@ Contacts={ } }); }, + dropAddressbook:function(event, dragitem, droptarget) { + alert('Dropping address books not implemented yet'); + }, + /** + * @params params An object with the properties 'contactlist':a jquery object of the ul to insert into, + * 'contacts':a jquery object of all items in the list and either 'data': an object with the properties + * id, addressbookid and displayname or 'contact': a listitem to be inserted directly. + * If 'contactlist' or 'contacts' aren't defined they will be search for based in the properties in 'data'. + */ + insertContact:function(params) { + if(!params.contactlist) { + // FIXME: Check if contact really exists. + var bookid = params.data ? params.data.addressbookid : params.contact.data('bookid'); + params.contactlist = $('#contacts ul[data-id="'+bookid+'"]'); + } + if(!params.contacts) { + var bookid = params.data ? params.data.addressbookid : params.contact.data('bookid'); + params.contacts = $('#contacts ul[data-id="'+bookid+'"] li'); + } + var contact = params.data + ? $('
  • '+params.data.displayname+'
  • ') + : params.contact; + var added = false; + var name = params.data ? params.data.displayname.toLowerCase() : contact.find('a').text().toLowerCase(); + if(params.contacts) { + params.contacts.each(function() { + if ($(this).text().toLowerCase() > name) { + $(this).before(contact); + added = true; + return false; + } + }); + } + if(!added || !params.contacts) { + params.contactlist.append(contact); + } + return contact; + }, // Reload the contacts list. update:function(params){ if(!params) { params = {}; } @@ -1506,7 +1590,7 @@ Contacts={ $.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),opts,function(jsondata){ if(jsondata.status == 'success'){ var books = jsondata.data.entries; - $.each(books, function(b, book) { + $.each(books, function(b, book) { if($('#contacts h3[data-id="'+b+'"]').length == 0) { firstrun = true; if($('#contacts h3').length == 0) { @@ -1525,7 +1609,7 @@ Contacts={ if(!added) { $('#contacts').append(item); } - + } } $('#contacts h3[data-id="'+b+'"]').on('click', function(event) { @@ -1534,7 +1618,7 @@ Contacts={ $('#contacts ul[data-id="'+b+'"]').slideToggle(300); return false; }); - var accept = 'li:not([data-bookid="'+b+'"])'; + var accept = 'li:not([data-bookid="'+b+'"]),h3:not([data-id="'+b+'"])'; $('#contacts h3[data-id="'+b+'"],#contacts ul[data-id="'+b+'"]').droppable({ drop: Contacts.UI.Contacts.drop, activeClass: 'ui-state-hover', @@ -1542,11 +1626,12 @@ Contacts={ }); } var contactlist = $('#contacts ul[data-id="'+b+'"]'); + var contacts = $('#contacts ul[data-id="'+b+'"] li'); for(var c in book.contacts) { if(book.contacts[c].id == undefined) { continue; } - if($('#contacts li[data-id="'+book.contacts[c]['id']+'"][data-id="'+book.contacts[c]['bookid']+'"]').length == 0) { - var contact = Contacts.UI.Card.createEntry(book.contacts[c]); - if(c == self.batchnum-5) { + if(!$('#contacts li[data-id="'+book.contacts[c]['id']+'"]').length) { + var contact = Contacts.UI.Contacts.insertContact({contactlist:contactlist, contacts:contacts, data:book.contacts[c]}); + if(c == self.batchnum-10) { contact.bind('inview', function(event, isInView, visiblePartX, visiblePartY) { $(this).unbind(event); var bookid = $(this).data('bookid'); @@ -1557,15 +1642,15 @@ Contacts={ } }); } - contactlist.append(contact); } } }); if($('#contacts h3').length > 1) { - $('#contacts li').draggable({ + $('#contacts li,#contacts h3').draggable({ + distance: 10, revert: 'invalid', axis: 'y', containment: '#contacts', - scroll: true, scrollSensitivity: 100, + scroll: true, scrollSensitivity: 40, opacity: 0.7, helper: 'clone' }); } else { @@ -1587,9 +1672,10 @@ Contacts={ }, scrollTo:function(id){ var item = $('#contacts li[data-id="'+id+'"]'); + console.log('scrollTo, found item '+id+'? ' + item.length); if(item) { - $('.contacts').animate({ - scrollTop: $('#contacts li[data-id="'+id+'"]').offset().top-20}, 'slow','swing'); + $('#contacts').animate({ + scrollTop: item.offset().top-40}, 'slow','swing'); } } } @@ -1603,13 +1689,13 @@ $(document).ready(function(){ $('#notification').click(function(){ $('#notification').fadeOut(); }); - + $('#chooseaddressbook').click(Contacts.UI.Addressbooks.overview); $('#chooseaddressbook').keydown(Contacts.UI.Addressbooks.overview); $('#contacts_newcontact').click(Contacts.UI.Card.editNew); $('#contacts_newcontact').keydown(Contacts.UI.Card.editNew); - + // Load a contact. $('.contacts').keydown(function(event) { if(event.which == 13 || event.which == 32) { @@ -1625,7 +1711,13 @@ $(document).ready(function(){ item.addClass('active'); var oldid = $('#rightcontent').data('id'); if(oldid != 0){ - $('.contacts li[data-id="'+oldid+'"]').removeClass('active'); + var olditem = $('.contacts li[data-id="'+oldid+'"]'); + var oldbookid = olditem.data('bookid'); + olditem.removeClass('active'); + if(oldbookid != bookid) { + $('#contacts h3[data-id="'+oldbookid+'"]').removeClass('active'); + $('#contacts h3[data-id="'+bookid+'"]').addClass('active'); + } } $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':id},function(jsondata){ if(jsondata.status == 'success'){ @@ -1643,53 +1735,55 @@ $(document).ready(function(){ Contacts.UI.Card.saveProperty(this); }); - // Upload function for dropped contact photos files. Should go in the Contacts class/object. - $.fileUpload = function(files){ - var file = files[0]; - if(file.size > $('#max_upload').val()){ - OC.dialogs.alert(t('contacts','The file you are trying to upload exceed the maximum size for file uploads on this server.'), t('contacts','Upload too large')); - return; - } - if (file.type.indexOf("image") != 0) { - OC.dialogs.alert(t('contacts','Only image files can be used as profile picture.'), t('contacts','Wrong file type')); - return; - } - var xhr = new XMLHttpRequest(); + $(function() { + // Upload function for dropped contact photos files. Should go in the Contacts class/object. + $.fileUpload = function(files){ + var file = files[0]; + if(file.size > $('#max_upload').val()){ + OC.dialogs.alert(t('contacts','The file you are trying to upload exceed the maximum size for file uploads on this server.'), t('contacts','Upload too large')); + return; + } + if (file.type.indexOf("image") != 0) { + OC.dialogs.alert(t('contacts','Only image files can be used as profile picture.'), t('contacts','Wrong file type')); + return; + } + var xhr = new XMLHttpRequest(); - if (!xhr.upload) { - OC.dialogs.alert(t('contacts', 'Your browser doesn\'t support AJAX upload. Please click on the profile picture to select a photo to upload.'), t('contacts', 'Error')) - } - fileUpload = xhr.upload, - xhr.onreadystatechange = function() { - if (xhr.readyState == 4){ - response = $.parseJSON(xhr.responseText); - if(response.status == 'success') { - if(xhr.status == 200) { - Contacts.UI.Card.editPhoto(response.data.id, response.data.tmp); + if (!xhr.upload) { + OC.dialogs.alert(t('contacts', 'Your browser doesn\'t support AJAX upload. Please click on the profile picture to select a photo to upload.'), t('contacts', 'Error')) + } + fileUpload = xhr.upload, + xhr.onreadystatechange = function() { + if (xhr.readyState == 4){ + response = $.parseJSON(xhr.responseText); + if(response.status == 'success') { + if(xhr.status == 200) { + Contacts.UI.Card.editPhoto(response.data.id, response.data.tmp); + } else { + OC.dialogs.alert(xhr.status + ': ' + xhr.responseText, t('contacts', 'Error')); + } } else { - OC.dialogs.alert(xhr.status + ': ' + xhr.responseText, t('contacts', 'Error')); + OC.dialogs.alert(response.data.message, t('contacts', 'Error')); } - } else { - OC.dialogs.alert(response.data.message, t('contacts', 'Error')); } - } - }; - - fileUpload.onprogress = function(e){ - if (e.lengthComputable){ - var _progress = Math.round((e.loaded * 100) / e.total); - //if (_progress != 100){ - //} - } - }; - xhr.open('POST', OC.filePath('contacts', 'ajax', 'uploadphoto.php')+'?id='+Contacts.UI.Card.id+'&requesttoken='+requesttoken+'&imagefile='+encodeURIComponent(file.name), true); - xhr.setRequestHeader('Cache-Control', 'no-cache'); - xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - xhr.setRequestHeader('X_FILE_NAME', encodeURIComponent(file.name)); - xhr.setRequestHeader('X-File-Size', file.size); - xhr.setRequestHeader('Content-Type', file.type); - xhr.send(file); - } + }; + + fileUpload.onprogress = function(e){ + if (e.lengthComputable){ + var _progress = Math.round((e.loaded * 100) / e.total); + //if (_progress != 100){ + //} + } + }; + xhr.open('POST', OC.filePath('contacts', 'ajax', 'uploadphoto.php')+'?id='+Contacts.UI.Card.id+'&requesttoken='+requesttoken+'&imagefile='+encodeURIComponent(file.name), true); + xhr.setRequestHeader('Cache-Control', 'no-cache'); + xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); + xhr.setRequestHeader('X_FILE_NAME', encodeURIComponent(file.name)); + xhr.setRequestHeader('X-File-Size', file.size); + xhr.setRequestHeader('Content-Type', file.type); + xhr.send(file); + } + }); $(document).bind('drop dragover', function (e) { e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone @@ -1703,7 +1797,7 @@ $(document).ready(function(){ $(function() { var uploadingFiles = {}, numfiles = 0, uploadedfiles = 0, retries = 0; var aid; - + $('#import_upload_start').fileupload({ dropZone: $('#contacts'), // restrict dropZone to contacts list. acceptFileTypes: /^text\/(directory|vcard|x-vcard)$/i, @@ -1803,9 +1897,10 @@ $(document).ready(function(){ if(numfiles != uploadedfiles) { Contacts.UI.notify({message:t('contacts', 'Not all files uploaded. Retrying...')}); retries += 1; - if(retries > 0) { + if(retries > 3) { numfiles = uploadedfiles = retries = aid = 0; uploadingFiles = {}; + $('#uploadprogressbar').fadeOut(); OC.dialogs.alert(t('contacts', 'Something went wrong with the upload, please retry.'), t('contacts', 'Error')); return; } @@ -1864,7 +1959,7 @@ $(document).ready(function(){ $(this).dialog('close'); } }, - 'Cancel':function() { + 'Cancel':function() { $(this).dialog('close'); numfiles = uploadedfiles = retries = aid = 0; uploadingFiles = {}; @@ -1879,6 +1974,7 @@ $(document).ready(function(){ }); } } else { + $('#uploadprogressbar').fadeOut(); OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); } }); @@ -1890,11 +1986,11 @@ $(document).ready(function(){ } if(data.dataType != 'iframe ') { $('#upload input.stop').hide(); - } + } } }) }); - + Contacts.UI.loadHandlers(); Contacts.UI.Contacts.update({cid:id}); }); diff --git a/apps/contacts/lib/VCFExportPlugin.php b/apps/contacts/lib/VCFExportPlugin.php index 6554cb258e..9a64c964b0 100644 --- a/apps/contacts/lib/VCFExportPlugin.php +++ b/apps/contacts/lib/VCFExportPlugin.php @@ -31,7 +31,7 @@ class Sabre_CardDAV_VCFExportPlugin extends Sabre_DAV_ServerPlugin { public function initialize(Sabre_DAV_Server $server) { $this->server = $server; - $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'), 90); + $this->server->subscribeEvent('beforeMethod', array($this,'beforeMethod'), 90); } @@ -49,7 +49,7 @@ class Sabre_CardDAV_VCFExportPlugin extends Sabre_DAV_ServerPlugin { if ($this->server->httpRequest->getQueryString()!='export') return; // splitting uri - list($uri) = explode('?',$uri,2); + list($uri) = explode('?', $uri, 2); $node = $this->server->tree->getNodeForPath($uri); @@ -60,12 +60,12 @@ class Sabre_CardDAV_VCFExportPlugin extends Sabre_DAV_ServerPlugin { $aclPlugin->checkPrivileges($uri, '{DAV:}read'); } - $this->server->httpResponse->setHeader('Content-Type','text/directory'); + $this->server->httpResponse->setHeader('Content-Type', 'text/directory'); $this->server->httpResponse->sendStatus(200); $nodes = $this->server->getPropertiesForPath($uri, array( '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}address-data', - ),1); + ), 1); $this->server->httpResponse->sendBody($this->generateVCF($nodes)); diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php index 9d584ff6d6..eb61b6dbce 100644 --- a/apps/contacts/lib/addressbook.php +++ b/apps/contacts/lib/addressbook.php @@ -37,17 +37,17 @@ /** * This class manages our addressbooks. */ -class OC_Contacts_Addressbook{ +class OC_Contacts_Addressbook { /** * @brief Returns the list of addressbooks for a specific user. * @param string $uid * @param boolean $active Only return addressbooks with this $active state, default(=false) is don't care * @return array or false. */ - public static function all($uid, $active=false){ + public static function all($uid, $active=false) { $values = array($uid); $active_where = ''; - if ($active){ + if ($active) { $active_where = ' AND active = ?'; $values[] = 1; } @@ -55,13 +55,13 @@ class OC_Contacts_Addressbook{ $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE userid = ? ' . $active_where . ' ORDER BY displayname' ); $result = $stmt->execute($values); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' uid: '.$uid,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' uid: '.$uid, OCP\Util::DEBUG); return false; } $addressbooks = array(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $addressbooks[] = $row; } if(!$active && !count($addressbooks)) { @@ -76,8 +76,8 @@ class OC_Contacts_Addressbook{ * @param integer $uid User id. If null current user will be used. * @return array */ - public static function activeIds($uid = null){ - if(is_null($uid)){ + public static function activeIds($uid = null) { + if(is_null($uid)) { $uid = OCP\USER::getUser(); } $activeaddressbooks = self::all($uid, true); @@ -93,7 +93,7 @@ class OC_Contacts_Addressbook{ * @param string $uid * @return array */ - public static function active($uid){ + public static function active($uid) { return self::all($uid, true); } @@ -112,13 +112,13 @@ class OC_Contacts_Addressbook{ * @param integer $id * @return associative array or false. */ - public static function find($id){ + public static function find($id) { try { $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ?' ); $result = $stmt->execute(array($id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG); return false; } @@ -129,11 +129,11 @@ class OC_Contacts_Addressbook{ * @brief Adds default address book * @return $id ID of the newly created addressbook or false on error. */ - public static function addDefault($uid = null){ + public static function addDefault($uid = null) { if(is_null($uid)) { $uid = OCP\USER::getUser(); } - $id = self::add($uid,'Contacts','Default Address Book'); + $id = self::add($uid, 'Contacts', 'Default Address Book'); if($id !== false) { self::setActive($id, true); } @@ -147,13 +147,13 @@ class OC_Contacts_Addressbook{ * @param string $description * @return insertid */ - public static function add($uid,$name,$description=''){ + public static function add($uid,$name,$description='') { try { $stmt = OCP\DB::prepare( 'SELECT uri FROM *PREFIX*contacts_addressbooks WHERE userid = ? ' ); $result = $stmt->execute(array($uid)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' uid: '.$uid,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' uid: '.$uid, OCP\Util::DEBUG); return false; } $uris = array(); @@ -166,8 +166,8 @@ class OC_Contacts_Addressbook{ $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)' ); $result = $stmt->execute(array($uid,$name,$uri,$description,1)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uid: '.$uid,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', uid: '.$uid, OCP\Util::DEBUG); return false; } @@ -182,16 +182,16 @@ class OC_Contacts_Addressbook{ * @param string $description * @return insertid or false */ - public static function addFromDAVData($principaluri,$uri,$name,$description){ + public static function addFromDAVData($principaluri,$uri,$name,$description) { $uid = self::extractUserID($principaluri); try { $stmt = OCP\DB::prepare('INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)'); $result = $stmt->execute(array($uid,$name,$uri,$description,1)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uid: '.$uid,OCP\Util::DEBUG); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uri: '.$uri,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', uid: '.$uid, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', uri: '.$uri, OCP\Util::DEBUG); return false; } @@ -205,14 +205,14 @@ class OC_Contacts_Addressbook{ * @param string $description * @return boolean */ - public static function edit($id,$name,$description){ + public static function edit($id,$name,$description) { // Need these ones for checking uri $addressbook = self::find($id); - if(is_null($name)){ + if(is_null($name)) { $name = $addressbook['name']; } - if(is_null($description)){ + if(is_null($description)) { $description = $addressbook['description']; } @@ -220,8 +220,8 @@ class OC_Contacts_Addressbook{ $stmt = OCP\DB::prepare('UPDATE *PREFIX*contacts_addressbooks SET displayname=?,description=?, ctag=ctag+1 WHERE id=?'); $result = $stmt->execute(array($name,$description,$id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG); return false; } @@ -234,15 +234,15 @@ class OC_Contacts_Addressbook{ * @param boolean $active * @return boolean */ - public static function setActive($id,$active){ + public static function setActive($id,$active) { $sql = 'UPDATE *PREFIX*contacts_addressbooks SET active = ? WHERE id = ?'; - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id.', active: '.intval($active),OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id.', active: '.intval($active), OCP\Util::ERROR); try { $stmt = OCP\DB::prepare($sql); $stmt->execute(array(intval($active), $id)); return true; } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(),OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(), OCP\Util::ERROR); return false; } } @@ -252,7 +252,7 @@ class OC_Contacts_Addressbook{ * @param integer $id ID of the address book. * @return boolean */ - public static function isActive($id){ + public static function isActive($id) { $sql = 'SELECT active FROM *PREFIX*contacts_addressbooks WHERE id = ?'; try { $stmt = OCP\DB::prepare( $sql ); @@ -260,7 +260,7 @@ class OC_Contacts_Addressbook{ $row = $result->fetchRow(); return (bool)$row['active']; } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); } } @@ -269,13 +269,13 @@ class OC_Contacts_Addressbook{ * @param integer $id * @return boolean */ - public static function delete($id){ + public static function delete($id) { self::setActive($id, false); try { $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE id = ?' ); $stmt->execute(array($id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(),OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(), OCP\Util::ERROR); return false; } @@ -292,7 +292,7 @@ class OC_Contacts_Addressbook{ * @param integer $id * @return boolean */ - public static function touch($id){ + public static function touch($id) { $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET ctag = ctag + 1 WHERE id = ?' ); $stmt->execute(array($id)); @@ -305,11 +305,11 @@ class OC_Contacts_Addressbook{ * @param array $existing existing addressbook URIs * @return string new name */ - public static function createURI($name,$existing){ + public static function createURI($name,$existing) { $name = str_replace(' ', '_', strtolower($name)); $newname = $name; $i = 1; - while(in_array($newname,$existing)){ + while(in_array($newname, $existing)) { $newname = $name.$i; $i = $i + 1; } @@ -320,8 +320,8 @@ class OC_Contacts_Addressbook{ * @brief gets the userid from a principal path * @return string */ - public static function extractUserID($principaluri){ - list($prefix,$userid) = Sabre_DAV_URLUtil::splitPath($principaluri); + public static function extractUserID($principaluri) { + list($prefix, $userid) = Sabre_DAV_URLUtil::splitPath($principaluri); return $userid; } } diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php index 046ceb0bf0..689149367f 100644 --- a/apps/contacts/lib/app.php +++ b/apps/contacts/lib/app.php @@ -61,11 +61,11 @@ class OC_Contacts_App { if(!is_null($vcard) && !$vcard->__isset('N')) { $version = OCP\App::getAppVersion('contacts'); if($version >= 5) { - OCP\Util::writeLog('contacts','OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OCP\Util::DEBUG); } - OCP\Util::writeLog('contacts','getContactVCard, Missing N field', OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'getContactVCard, Missing N field', OCP\Util::DEBUG); if($vcard->__isset('FN')) { - OCP\Util::writeLog('contacts','getContactVCard, found FN field: '.$vcard->__get('FN'), OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'getContactVCard, found FN field: '.$vcard->__get('FN'), OCP\Util::DEBUG); $n = implode(';', array_reverse(array_slice(explode(' ', $vcard->__get('FN')), 0, 2))).';;;'; $vcard->setString('N', $n); OC_Contacts_VCard::edit( $id, $vcard); @@ -203,9 +203,9 @@ class OC_Contacts_App { foreach($vccontacts as $vccontact) { $cards[] = $vccontact['carddata']; } - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', scanning: '.$batchsize.' starting from '.$start,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', scanning: '.$batchsize.' starting from '.$start, OCP\Util::DEBUG); // only reset on first batch. - self::getVCategories()->rescan($cards, true, ($start==0?true:false)); + self::getVCategories()->rescan($cards, true, ($start == 0 ? true : false)); $start += $batchsize; } } diff --git a/apps/contacts/lib/connector_sabre.php b/apps/contacts/lib/connector_sabre.php index 99b94fc767..9fcfff08fa 100644 --- a/apps/contacts/lib/connector_sabre.php +++ b/apps/contacts/lib/connector_sabre.php @@ -79,7 +79,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract { } } - OC_Contacts_Addressbook::edit($addressbookid,$name,$description); + OC_Contacts_Addressbook::edit($addressbookid, $name, $description); return true; @@ -113,7 +113,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract { } - OC_Contacts_Addressbook::addFromDAVData($principaluri,$url,$name,$description); + OC_Contacts_Addressbook::addFromDAVData($principaluri, $url, $name, $description); } /** @@ -156,7 +156,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract { * @return array */ public function getCard($addressbookid, $carduri) { - return OC_Contacts_VCard::findWhereDAVDataIs($addressbookid,$carduri); + return OC_Contacts_VCard::findWhereDAVDataIs($addressbookid, $carduri); } diff --git a/apps/contacts/lib/hooks.php b/apps/contacts/lib/hooks.php index d91d3c565b..3344e3d693 100644 --- a/apps/contacts/lib/hooks.php +++ b/apps/contacts/lib/hooks.php @@ -34,12 +34,12 @@ */ class OC_Contacts_Hooks{ /** - * @brief Add default Addressbooks of a certain user - * @param paramters parameters from postDeleteUser-Hook + * @brief Add default Addressbook for a certain user + * @param paramters parameters from postCreateUser-Hook * @return array */ static public function createUser($parameters) { - OC_Contacts_Addressbook::addDefault($parameters['uid'],'default','Default Address Book'); + OC_Contacts_Addressbook::addDefault($parameters['uid']); return true; } @@ -61,8 +61,8 @@ class OC_Contacts_Hooks{ static public function getCalenderSources($parameters) { $base_url = OCP\Util::linkTo('calendar', 'ajax/events.php').'?calendar_id='; foreach(OC_Contacts_Addressbook::all(OCP\USER::getUser()) as $addressbook) { - $parameters['sources'][] = - array( + $parameters['sources'][] + = array( 'url' => $base_url.'birthday_'. $addressbook['id'], 'backgroundColor' => '#cccccc', 'borderColor' => '#888', @@ -91,18 +91,24 @@ class OC_Contacts_Hooks{ $date = new DateTime($birthday); $vevent = new OC_VObject('VEVENT'); //$vevent->setDateTime('LAST-MODIFIED', new DateTime($vcard->REV)); - $vevent->setDateTime('DTSTART', $date, Sabre_VObject_Element_DateTime::DATE); + $vevent->setDateTime('DTSTART', $date, + Sabre_VObject_Element_DateTime::DATE); $vevent->setString('DURATION', 'P1D'); - $vevent->setString('UID', substr(md5(rand().time()),0,10)); + $vevent->setString('UID', substr(md5(rand().time()), 0, 10)); // DESCRIPTION? $vevent->setString('RRULE', 'FREQ=YEARLY'); - $title = str_replace('{name}', $vcard->getAsString('FN'), OC_Contacts_App::$l10n->t('{name}\'s Birthday')); + $title = str_replace('{name}', + $vcard->getAsString('FN'), + OC_Contacts_App::$l10n->t('{name}\'s Birthday')); $parameters['events'][] = array( 'id' => 0,//$card['id'], 'vevent' => $vevent, 'repeating' => true, 'summary' => $title, - 'calendardata' => "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Contacts " . OCP\App::getAppVersion('contacts') . "\n" . $vevent->serialize() . "END:VCALENDAR" + 'calendardata' => "BEGIN:VCALENDAR\nVERSION:2.0\n" + . "PRODID:ownCloud Contacts " + . OCP\App::getAppVersion('contacts') . "\n" + . $vevent->serialize() . "END:VCALENDAR" ); } } diff --git a/apps/contacts/lib/search.php b/apps/contacts/lib/search.php index 5d9ca97e76..53aa2b4849 100644 --- a/apps/contacts/lib/search.php +++ b/apps/contacts/lib/search.php @@ -2,7 +2,7 @@ class OC_Search_Provider_Contacts extends OC_Search_Provider{ function search($query){ $addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1); - if(count($addressbooks)==0 || !OCP\App::isEnabled('contacts')){ + if(count($addressbooks)==0 || !OCP\App::isEnabled('contacts')) { return array(); } $results=array(); @@ -10,9 +10,9 @@ class OC_Search_Provider_Contacts extends OC_Search_Provider{ foreach($addressbooks as $addressbook){ $vcards = OC_Contacts_VCard::all($addressbook['id']); foreach($vcards as $vcard){ - if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0){ + if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0) { $link = OCP\Util::linkTo('contacts', 'index.php').'&id='.urlencode($vcard['id']); - $results[]=new OC_Search_Result($vcard['fullname'],'', $link,(string)$l->t('Contact'));//$name,$text,$link,$type + $results[]=new OC_Search_Result($vcard['fullname'], '', $link, (string)$l->t('Contact'));//$name,$text,$link,$type } } } diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index e3b6560562..ca171e792f 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -63,9 +63,9 @@ class OC_Contacts_VCard{ $stmt = OCP\DB::prepare( $prep ); $result = $stmt->execute($id); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '.join(',', $id),OCP\Util::DEBUG); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.'SQL:'.$prep,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', ids: '.join(',', $id), OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.'SQL:'.$prep, OCP\Util::DEBUG); return false; } } elseif(is_int($id) || is_string($id)) { @@ -74,12 +74,12 @@ class OC_Contacts_VCard{ $stmt = OCP\DB::prepare( $sql ); $result = $stmt->execute(array($id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '. $id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', ids: '. $id, OCP\Util::DEBUG); return false; } } else { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.'. Addressbook id(s) argument is empty: '. $id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.'. Addressbook id(s) argument is empty: '. $id, OCP\Util::DEBUG); return false; } $cards = array(); @@ -102,8 +102,8 @@ class OC_Contacts_VCard{ $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE id = ?' ); $result = $stmt->execute(array($id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '. $id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '. $id, OCP\Util::DEBUG); return false; } @@ -121,8 +121,8 @@ class OC_Contacts_VCard{ $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri = ?' ); $result = $stmt->execute(array($aid,$uri)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG); return false; } @@ -177,16 +177,16 @@ class OC_Contacts_VCard{ try { $result = $stmt->execute(array($aid,$uri)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uid'.$uid, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uid'.$uid, OCP\Util::DEBUG); return false; } - if($result->numRows() > 0){ + if($result->numRows() > 0) { while(true) { - $tmpuid = substr(md5(rand().time()),0,10); + $tmpuid = substr(md5(rand().time()), 0, 10); $uri = $tmpuid.'.vcf'; - $result = $stmt->execute(array($aid,$uri)); - if($result->numRows() > 0){ + $result = $stmt->execute(array($aid, $uri)); + if($result->numRows() > 0) { continue; } else { $uid = $tmpuid; @@ -212,7 +212,7 @@ class OC_Contacts_VCard{ // Add version if needed if($version && $version < '3.0') { $upgrade = true; - OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version, OCP\Util::DEBUG); } foreach($vcard->children as &$property){ // Decode string properties and remove obsolete properties. @@ -225,29 +225,29 @@ class OC_Contacts_VCard{ } // Fix format of type parameters. if($upgrade && in_array($property->name, $typeprops)) { - OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. before: '.$property->serialize(),OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. before: '.$property->serialize(), OCP\Util::DEBUG); self::formatPropertyTypes($property); - OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. after: '.$property->serialize(),OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. after: '.$property->serialize(), OCP\Util::DEBUG); } - if($property->name == 'FN'){ + if($property->name == 'FN') { $fn = $property->value; } - if($property->name == 'N'){ + if($property->name == 'N') { $n = $property->value; } - if($property->name == 'UID'){ + if($property->name == 'UID') { $uid = $property->value; } - if($property->name == 'ORG'){ + if($property->name == 'ORG') { $org = $property->value; } - if($property->name == 'EMAIL' && is_null($email)){ // only use the first email as substitute for missing N or FN. + if($property->name == 'EMAIL' && is_null($email)) { // only use the first email as substitute for missing N or FN. $email = $property->value; } } // Check for missing 'N', 'FN' and 'UID' properties if(!$fn) { - if($n && $n != ';;;;'){ + if($n && $n != ';;;;') { $fn = join(' ', array_reverse(array_slice(explode(';', $n), 0, 2))); } elseif($email) { $fn = $email; @@ -257,21 +257,21 @@ class OC_Contacts_VCard{ $fn = 'Unknown Name'; } $vcard->setString('FN', $fn); - OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'FN\' field: '.$fn,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Added missing \'FN\' field: '.$fn, OCP\Util::DEBUG); } - if(!$n || $n == ';;;;'){ // Fix missing 'N' field. Ugly hack ahead ;-) + if(!$n || $n == ';;;;') { // Fix missing 'N' field. Ugly hack ahead ;-) $slice = array_reverse(array_slice(explode(' ', $fn), 0, 2)); // Take 2 first name parts of 'FN' and reverse. if(count($slice) < 2) { // If not enought, add one more... $slice[] = ""; } $n = implode(';', $slice).';;;'; $vcard->setString('N', $n); - OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'N\' field: '.$n,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Added missing \'N\' field: '.$n, OCP\Util::DEBUG); } if(!$uid) { $vcard->setUID(); $uid = $vcard->getAsString('UID'); - OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'UID\' field: '.$uid,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Added missing \'UID\' field: '.$uid, OCP\Util::DEBUG); } if(self::trueUID($aid, $uid)) { $vcard->setString('UID', $uid); @@ -288,8 +288,8 @@ class OC_Contacts_VCard{ * @return insertid on success or false. */ public static function add($aid, OC_VObject $card, $uri=null, $isnew=false){ - if(is_null($card)){ - OCP\Util::writeLog('contacts','OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR); + if(is_null($card)) { + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR); return null; }; @@ -298,7 +298,7 @@ class OC_Contacts_VCard{ self::updateValuesFromAdd($aid, $card); } - $card->setString('VERSION','3.0'); + $card->setString('VERSION', '3.0'); // Add product ID is missing. $prodid = trim($card->getAsString('PRODID')); if(!$prodid) { @@ -323,8 +323,8 @@ class OC_Contacts_VCard{ try { $result = $stmt->execute(array($aid,$fn,$data,$uri,time())); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG); return false; } $newid = OCP\DB::insertid('*PREFIX*contacts_cards'); @@ -355,15 +355,15 @@ class OC_Contacts_VCard{ $now = new DateTime; foreach($objects as $object) { $vcard = OC_VObject::parse($object[1]); - if(!is_null($vcard)){ + if(!is_null($vcard)) { $vcard->setString('REV', $now->format(DateTime::W3C)); $data = $vcard->serialize(); try { $result = $stmt->execute(array($data,time(),$object[0])); //OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0].': '.$object[1],OCP\Util::DEBUG); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$object[0],OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$object[0], OCP\Util::DEBUG); } } } @@ -397,8 +397,8 @@ class OC_Contacts_VCard{ try { $result = $stmt->execute(array($fn,$data,time(),$id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id'.$id, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id'.$id, OCP\Util::DEBUG); return false; } @@ -414,11 +414,11 @@ class OC_Contacts_VCard{ * @param string $data vCard file * @return boolean */ - public static function editFromDAVData($aid,$uri,$data){ - $oldcard = self::findWhereDAVDataIs($aid,$uri); + public static function editFromDAVData($aid, $uri, $data){ + $oldcard = self::findWhereDAVDataIs($aid, $uri); $card = OC_VObject::parse($data); if(!$card) { - OCP\Util::writeLog('contacts','OC_Contacts_VCard::editFromDAVData. Unable to parse VCARD, uri: '.$uri,OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', Unable to parse VCARD, uri: '.$uri, OCP\Util::ERROR); return false; } return self::edit($oldcard['id'], $card); @@ -430,14 +430,13 @@ class OC_Contacts_VCard{ * @return boolean */ public static function delete($id){ - // FIXME: Add error checking. OC_Hook::emit('OC_Contacts_VCard', 'pre_deleteVCard', array('aid' => null, 'id' => $id, 'uri' => null)); $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' ); try { $stmt->execute(array($id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG); return false; } @@ -451,14 +450,13 @@ class OC_Contacts_VCard{ * @return boolean */ public static function deleteFromDAVData($aid,$uri){ - // FIXME: Add error checking. Deleting a card gives an Kontact/Akonadi error. OC_Hook::emit('OC_Contacts_VCard', 'pre_deleteVCard', array('aid' => $aid, 'id' => null, 'uri' => $uri)); $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' ); try { $stmt->execute(array($aid,$uri)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri: '.$uri, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri: '.$uri, OCP\Util::DEBUG); return false; } OC_Contacts_Addressbook::touch($aid); @@ -487,14 +485,14 @@ class OC_Contacts_VCard{ * @return array */ public static function unescapeDelimiters($value, $delimiter=';') { - $array = explode($delimiter,$value); + $array = explode($delimiter, $value); for($i=0;$ichildren as $property){ $temp = self::structureProperty($property); if(!is_null($temp)) { - if(array_key_exists($property->name,$details)){ + if(array_key_exists($property->name, $details)) { $details[$property->name][] = $temp; } else{ @@ -539,10 +537,10 @@ class OC_Contacts_VCard{ * NOTE: $value is not escaped anymore. It shouldn't make any difference * but we should look out for any problems. */ - public static function structureProperty($property){ + public static function structureProperty($property) { $value = $property->value; //$value = htmlspecialchars($value); - if($property->name == 'ADR' || $property->name == 'N'){ + if($property->name == 'ADR' || $property->name == 'N') { $value = self::unescapeDelimiters($value); } elseif($property->name == 'BDAY') { if(strpos($value, '-') === false) { @@ -562,17 +560,17 @@ class OC_Contacts_VCard{ // Faulty entries by kaddressbook // Actually TYPE=PREF is correct according to RFC 2426 // but this way is more handy in the UI. Tanghus. - if($parameter->name == 'TYPE' && $parameter->value == 'PREF'){ + if($parameter->name == 'TYPE' && $parameter->value == 'PREF') { $parameter->name = 'PREF'; $parameter->value = '1'; } // NOTE: Apparently Sabre_VObject_Reader can't always deal with value list parameters // like TYPE=HOME,CELL,VOICE. Tanghus. - if (in_array($property->name, array('TEL', 'EMAIL')) && $parameter->name == 'TYPE'){ - if (isset($temp['parameters'][$parameter->name])){ + if (in_array($property->name, array('TEL', 'EMAIL')) && $parameter->name == 'TYPE') { + if (isset($temp['parameters'][$parameter->name])) { $temp['parameters'][$parameter->name][] = $parameter->value; } - else{ + else { $temp['parameters'][$parameter->name] = array($parameter->value); } } @@ -590,7 +588,7 @@ class OC_Contacts_VCard{ * @return boolean * */ - public static function moveToAddressBook($aid, $id){ + public static function moveToAddressBook($aid, $id) { OC_Contacts_App::getAddressbook($aid); // check for user ownership. if(is_array($id)) { $id_sql = join(',', array_fill(0, count($id), '?')); @@ -601,9 +599,9 @@ class OC_Contacts_VCard{ $vals = array_merge((array)$aid, $id); $result = $stmt->execute($vals); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '.join(',', $vals),OCP\Util::DEBUG); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', SQL:'.$prep,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', ids: '.join(',', $vals), OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', SQL:'.$prep, OCP\Util::DEBUG); return false; } } else { @@ -611,8 +609,8 @@ class OC_Contacts_VCard{ $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id = ?' ); $result = $stmt->execute(array($aid, $id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::DEBUG); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' id: '.$id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' id: '.$id, OCP\Util::DEBUG); return false; } } diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php index 4660d61f61..efdf157cd9 100644 --- a/apps/contacts/photo.php +++ b/apps/contacts/photo.php @@ -13,7 +13,7 @@ OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('contacts'); -function getStandardImage(){ +function getStandardImage() { //OCP\Response::setExpiresHeader('P10D'); OCP\Response::enableCaching(); OCP\Response::redirect(OCP\Util::imagePath('contacts', 'person_large.png')); @@ -27,37 +27,39 @@ if(is_null($id)) { } if(!extension_loaded('gd') || !function_exists('gd_info')) { - OCP\Util::writeLog('contacts','photo.php. GD module not installed',OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', + 'photo.php. GD module not installed', OCP\Util::DEBUG); getStandardImage(); } $contact = OC_Contacts_App::getContactVCard($id); $image = new OC_Image(); -if(!$image) { +if (!$image) { getStandardImage(); } // invalid vcard -if( is_null($contact)) { - OCP\Util::writeLog('contacts','photo.php. The VCard for ID '.$id.' is not RFC compatible',OCP\Util::ERROR); +if (is_null($contact)) { + OCP\Util::writeLog('contacts', + 'photo.php. The VCard for ID ' . $id . ' is not RFC compatible', + OCP\Util::ERROR); } else { OCP\Response::enableCaching($caching); OC_Contacts_App::setLastModifiedHeader($contact); // Photo :-) - if($image->loadFromBase64($contact->getAsString('PHOTO'))) { + if ($image->loadFromBase64($contact->getAsString('PHOTO'))) { // OK OCP\Response::setETagHeader(md5($contact->getAsString('PHOTO'))); } else // Logo :-/ - if($image->loadFromBase64($contact->getAsString('LOGO'))) { + if ($image->loadFromBase64($contact->getAsString('LOGO'))) { // OK OCP\Response::setETagHeader(md5($contact->getAsString('LOGO'))); } if ($image->valid()) { $max_size = 200; - if($image->width() > $max_size || - $image->height() > $max_size) { + if ($image->width() > $max_size || $image->height() > $max_size) { $image->resize($max_size); } } @@ -65,8 +67,7 @@ if( is_null($contact)) { if (!$image->valid()) { // Not found :-( getStandardImage(); - //$image->loadFromFile('img/person_large.png'); } header('Content-Type: '.$image->mimeType()); $image->show(); -//echo OC_Contacts_App::$l10n->t('This card does not contain a photo.'); + diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php index 98cb67a26e..1bc4a19553 100644 --- a/apps/contacts/templates/index.php +++ b/apps/contacts/templates/index.php @@ -25,7 +25,7 @@
    inc('part.contact'); } else{ diff --git a/apps/contacts/templates/part.cropphoto.php b/apps/contacts/templates/part.cropphoto.php index 6d7b1e4477..3f5817622b 100644 --- a/apps/contacts/templates/part.cropphoto.php +++ b/apps/contacts/templates/part.cropphoto.php @@ -2,7 +2,6 @@ $id = $_['id']; $tmpkey = $_['tmpkey']; $requesttoken = $_['requesttoken']; -OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmpkey: '.$tmpkey, OCP\Util::DEBUG); ?>