Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like CalDavBackend often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use CalDavBackend, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 57 | class CalDavBackend extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport { |
||
| 58 | |||
| 59 | /** |
||
| 60 | * We need to specify a max date, because we need to stop *somewhere* |
||
| 61 | * |
||
| 62 | * On 32 bit system the maximum for a signed integer is 2147483647, so |
||
| 63 | * MAX_DATE cannot be higher than date('Y-m-d', 2147483647) which results |
||
| 64 | * in 2038-01-19 to avoid problems when the date is converted |
||
| 65 | * to a unix timestamp. |
||
| 66 | */ |
||
| 67 | const MAX_DATE = '2038-01-01'; |
||
| 68 | |||
| 69 | const CLASSIFICATION_PUBLIC = 0; |
||
| 70 | const CLASSIFICATION_PRIVATE = 1; |
||
| 71 | const CLASSIFICATION_CONFIDENTIAL = 2; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * List of CalDAV properties, and how they map to database field names |
||
| 75 | * Add your own properties by simply adding on to this array. |
||
| 76 | * |
||
| 77 | * Note that only string-based properties are supported here. |
||
| 78 | * |
||
| 79 | * @var array |
||
| 80 | */ |
||
| 81 | public $propertyMap = [ |
||
| 82 | '{DAV:}displayname' => 'displayname', |
||
| 83 | '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'description', |
||
| 84 | '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => 'timezone', |
||
| 85 | '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', |
||
| 86 | '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', |
||
| 87 | ]; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * List of subscription properties, and how they map to database field names. |
||
| 91 | * |
||
| 92 | * @var array |
||
| 93 | */ |
||
| 94 | public $subscriptionPropertyMap = [ |
||
| 95 | '{DAV:}displayname' => 'displayname', |
||
| 96 | '{http://apple.com/ns/ical/}refreshrate' => 'refreshrate', |
||
| 97 | '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', |
||
| 98 | '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', |
||
| 99 | '{http://calendarserver.org/ns/}subscribed-strip-todos' => 'striptodos', |
||
| 100 | '{http://calendarserver.org/ns/}subscribed-strip-alarms' => 'stripalarms', |
||
| 101 | '{http://calendarserver.org/ns/}subscribed-strip-attachments' => 'stripattachments', |
||
| 102 | ]; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @var string[] Map of uid => display name |
||
| 106 | */ |
||
| 107 | protected $userDisplayNames; |
||
| 108 | |||
| 109 | /** @var IDBConnection */ |
||
| 110 | private $db; |
||
| 111 | |||
| 112 | /** @var Backend */ |
||
| 113 | private $sharingBackend; |
||
| 114 | |||
| 115 | /** @var Principal */ |
||
| 116 | private $principalBackend; |
||
| 117 | |||
| 118 | /** @var IUserManager */ |
||
| 119 | private $userManager; |
||
| 120 | |||
| 121 | /** |
||
| 122 | * CalDavBackend constructor. |
||
| 123 | * |
||
| 124 | * @param IDBConnection $db |
||
| 125 | * @param Principal $principalBackend |
||
| 126 | * @param IUserManager $userManager |
||
| 127 | */ |
||
| 128 | View Code Duplication | public function __construct(IDBConnection $db, Principal $principalBackend, IUserManager $userManager) { |
|
| 134 | |||
| 135 | /** |
||
| 136 | * Returns a list of calendars for a principal. |
||
| 137 | * |
||
| 138 | * Every project is an array with the following keys: |
||
| 139 | * * id, a unique id that will be used by other functions to modify the |
||
| 140 | * calendar. This can be the same as the uri or a database key. |
||
| 141 | * * uri, which the basename of the uri with which the calendar is |
||
| 142 | * accessed. |
||
| 143 | * * principaluri. The owner of the calendar. Almost always the same as |
||
| 144 | * principalUri passed to this method. |
||
| 145 | * |
||
| 146 | * Furthermore it can contain webdav properties in clark notation. A very |
||
| 147 | * common one is '{DAV:}displayname'. |
||
| 148 | * |
||
| 149 | * Many clients also require: |
||
| 150 | * {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set |
||
| 151 | * For this property, you can just return an instance of |
||
| 152 | * Sabre\CalDAV\Property\SupportedCalendarComponentSet. |
||
| 153 | * |
||
| 154 | * If you return {http://sabredav.org/ns}read-only and set the value to 1, |
||
| 155 | * ACL will automatically be put in read-only mode. |
||
| 156 | * |
||
| 157 | * @param string $principalUri |
||
| 158 | * @return array |
||
| 159 | */ |
||
| 160 | function getCalendarsForUser($principalUri) { |
||
| 261 | |||
| 262 | View Code Duplication | private function getUserDisplayName($uid) { |
|
| 275 | |||
| 276 | /** |
||
| 277 | * @param string $principal |
||
| 278 | * @param string $uri |
||
| 279 | * @return array|null |
||
| 280 | */ |
||
| 281 | public function getCalendarByUri($principal, $uri) { |
||
| 325 | |||
| 326 | public function getCalendarById($calendarId) { |
||
| 369 | |||
| 370 | /** |
||
| 371 | * Creates a new calendar for a principal. |
||
| 372 | * |
||
| 373 | * If the creation was a success, an id must be returned that can be used to reference |
||
| 374 | * this calendar in other methods, such as updateCalendar. |
||
| 375 | * |
||
| 376 | * @param string $principalUri |
||
| 377 | * @param string $calendarUri |
||
| 378 | * @param array $properties |
||
| 379 | * @return int |
||
| 380 | */ |
||
| 381 | function createCalendar($principalUri, $calendarUri, array $properties) { |
||
| 418 | |||
| 419 | /** |
||
| 420 | * Updates properties for a calendar. |
||
| 421 | * |
||
| 422 | * The list of mutations is stored in a Sabre\DAV\PropPatch object. |
||
| 423 | * To do the actual updates, you must tell this object which properties |
||
| 424 | * you're going to process with the handle() method. |
||
| 425 | * |
||
| 426 | * Calling the handle method is like telling the PropPatch object "I |
||
| 427 | * promise I can handle updating this property". |
||
| 428 | * |
||
| 429 | * Read the PropPatch documentation for more info and examples. |
||
| 430 | * |
||
| 431 | * @param PropPatch $propPatch |
||
| 432 | * @return void |
||
| 433 | */ |
||
| 434 | function updateCalendar($calendarId, PropPatch $propPatch) { |
||
| 467 | |||
| 468 | /** |
||
| 469 | * Delete a calendar and all it's objects |
||
| 470 | * |
||
| 471 | * @param mixed $calendarId |
||
| 472 | * @return void |
||
| 473 | */ |
||
| 474 | function deleteCalendar($calendarId) { |
||
| 486 | |||
| 487 | /** |
||
| 488 | * Returns all calendar objects within a calendar. |
||
| 489 | * |
||
| 490 | * Every item contains an array with the following keys: |
||
| 491 | * * calendardata - The iCalendar-compatible calendar data |
||
| 492 | * * uri - a unique key which will be used to construct the uri. This can |
||
| 493 | * be any arbitrary string, but making sure it ends with '.ics' is a |
||
| 494 | * good idea. This is only the basename, or filename, not the full |
||
| 495 | * path. |
||
| 496 | * * lastmodified - a timestamp of the last modification time |
||
| 497 | * * etag - An arbitrary string, surrounded by double-quotes. (e.g.: |
||
| 498 | * '"abcdef"') |
||
| 499 | * * size - The size of the calendar objects, in bytes. |
||
| 500 | * * component - optional, a string containing the type of object, such |
||
| 501 | * as 'vevent' or 'vtodo'. If specified, this will be used to populate |
||
| 502 | * the Content-Type header. |
||
| 503 | * |
||
| 504 | * Note that the etag is optional, but it's highly encouraged to return for |
||
| 505 | * speed reasons. |
||
| 506 | * |
||
| 507 | * The calendardata is also optional. If it's not returned |
||
| 508 | * 'getCalendarObject' will be called later, which *is* expected to return |
||
| 509 | * calendardata. |
||
| 510 | * |
||
| 511 | * If neither etag or size are specified, the calendardata will be |
||
| 512 | * used/fetched to determine these numbers. If both are specified the |
||
| 513 | * amount of times this is needed is reduced by a great degree. |
||
| 514 | * |
||
| 515 | * @param mixed $calendarId |
||
| 516 | * @return array |
||
| 517 | */ |
||
| 518 | function getCalendarObjects($calendarId) { |
||
| 541 | |||
| 542 | /** |
||
| 543 | * Returns information from a single calendar object, based on it's object |
||
| 544 | * uri. |
||
| 545 | * |
||
| 546 | * The object uri is only the basename, or filename and not a full path. |
||
| 547 | * |
||
| 548 | * The returned array must have the same keys as getCalendarObjects. The |
||
| 549 | * 'calendardata' object is required here though, while it's not required |
||
| 550 | * for getCalendarObjects. |
||
| 551 | * |
||
| 552 | * This method must return null if the object did not exist. |
||
| 553 | * |
||
| 554 | * @param mixed $calendarId |
||
| 555 | * @param string $objectUri |
||
| 556 | * @return array|null |
||
| 557 | */ |
||
| 558 | function getCalendarObject($calendarId, $objectUri) { |
||
| 582 | |||
| 583 | /** |
||
| 584 | * Returns a list of calendar objects. |
||
| 585 | * |
||
| 586 | * This method should work identical to getCalendarObject, but instead |
||
| 587 | * return all the calendar objects in the list as an array. |
||
| 588 | * |
||
| 589 | * If the backend supports this, it may allow for some speed-ups. |
||
| 590 | * |
||
| 591 | * @param mixed $calendarId |
||
| 592 | * @param string[] $uris |
||
| 593 | * @return array |
||
| 594 | */ |
||
| 595 | function getMultipleCalendarObjects($calendarId, array $uris) { |
||
| 623 | |||
| 624 | /** |
||
| 625 | * Creates a new calendar object. |
||
| 626 | * |
||
| 627 | * The object uri is only the basename, or filename and not a full path. |
||
| 628 | * |
||
| 629 | * It is possible return an etag from this function, which will be used in |
||
| 630 | * the response to this PUT request. Note that the ETag must be surrounded |
||
| 631 | * by double-quotes. |
||
| 632 | * |
||
| 633 | * However, you should only really return this ETag if you don't mangle the |
||
| 634 | * calendar-data. If the result of a subsequent GET to this object is not |
||
| 635 | * the exact same as this request body, you should omit the ETag. |
||
| 636 | * |
||
| 637 | * @param mixed $calendarId |
||
| 638 | * @param string $objectUri |
||
| 639 | * @param string $calendarData |
||
| 640 | * @return string |
||
| 641 | */ |
||
| 642 | function createCalendarObject($calendarId, $objectUri, $calendarData) { |
||
| 666 | |||
| 667 | /** |
||
| 668 | * Updates an existing calendarobject, based on it's uri. |
||
| 669 | * |
||
| 670 | * The object uri is only the basename, or filename and not a full path. |
||
| 671 | * |
||
| 672 | * It is possible return an etag from this function, which will be used in |
||
| 673 | * the response to this PUT request. Note that the ETag must be surrounded |
||
| 674 | * by double-quotes. |
||
| 675 | * |
||
| 676 | * However, you should only really return this ETag if you don't mangle the |
||
| 677 | * calendar-data. If the result of a subsequent GET to this object is not |
||
| 678 | * the exact same as this request body, you should omit the ETag. |
||
| 679 | * |
||
| 680 | * @param mixed $calendarId |
||
| 681 | * @param string $objectUri |
||
| 682 | * @param string $calendarData |
||
| 683 | * @return string |
||
| 684 | */ |
||
| 685 | function updateCalendarObject($calendarId, $objectUri, $calendarData) { |
||
| 707 | |||
| 708 | /** |
||
| 709 | * @param int $calendarObjectId |
||
| 710 | * @param int $classification |
||
| 711 | */ |
||
| 712 | public function setClassification($calendarObjectId, $classification) { |
||
| 724 | |||
| 725 | /** |
||
| 726 | * Deletes an existing calendar object. |
||
| 727 | * |
||
| 728 | * The object uri is only the basename, or filename and not a full path. |
||
| 729 | * |
||
| 730 | * @param mixed $calendarId |
||
| 731 | * @param string $objectUri |
||
| 732 | * @return void |
||
| 733 | */ |
||
| 734 | function deleteCalendarObject($calendarId, $objectUri) { |
||
| 740 | |||
| 741 | /** |
||
| 742 | * Performs a calendar-query on the contents of this calendar. |
||
| 743 | * |
||
| 744 | * The calendar-query is defined in RFC4791 : CalDAV. Using the |
||
| 745 | * calendar-query it is possible for a client to request a specific set of |
||
| 746 | * object, based on contents of iCalendar properties, date-ranges and |
||
| 747 | * iCalendar component types (VTODO, VEVENT). |
||
| 748 | * |
||
| 749 | * This method should just return a list of (relative) urls that match this |
||
| 750 | * query. |
||
| 751 | * |
||
| 752 | * The list of filters are specified as an array. The exact array is |
||
| 753 | * documented by Sabre\CalDAV\CalendarQueryParser. |
||
| 754 | * |
||
| 755 | * Note that it is extremely likely that getCalendarObject for every path |
||
| 756 | * returned from this method will be called almost immediately after. You |
||
| 757 | * may want to anticipate this to speed up these requests. |
||
| 758 | * |
||
| 759 | * This method provides a default implementation, which parses *all* the |
||
| 760 | * iCalendar objects in the specified calendar. |
||
| 761 | * |
||
| 762 | * This default may well be good enough for personal use, and calendars |
||
| 763 | * that aren't very large. But if you anticipate high usage, big calendars |
||
| 764 | * or high loads, you are strongly advised to optimize certain paths. |
||
| 765 | * |
||
| 766 | * The best way to do so is override this method and to optimize |
||
| 767 | * specifically for 'common filters'. |
||
| 768 | * |
||
| 769 | * Requests that are extremely common are: |
||
| 770 | * * requests for just VEVENTS |
||
| 771 | * * requests for just VTODO |
||
| 772 | * * requests with a time-range-filter on either VEVENT or VTODO. |
||
| 773 | * |
||
| 774 | * ..and combinations of these requests. It may not be worth it to try to |
||
| 775 | * handle every possible situation and just rely on the (relatively |
||
| 776 | * easy to use) CalendarQueryValidator to handle the rest. |
||
| 777 | * |
||
| 778 | * Note that especially time-range-filters may be difficult to parse. A |
||
| 779 | * time-range filter specified on a VEVENT must for instance also handle |
||
| 780 | * recurrence rules correctly. |
||
| 781 | * A good example of how to interprete all these filters can also simply |
||
| 782 | * be found in Sabre\CalDAV\CalendarQueryFilter. This class is as correct |
||
| 783 | * as possible, so it gives you a good idea on what type of stuff you need |
||
| 784 | * to think of. |
||
| 785 | * |
||
| 786 | * @param mixed $calendarId |
||
| 787 | * @param array $filters |
||
| 788 | * @return array |
||
| 789 | */ |
||
| 790 | function calendarQuery($calendarId, array $filters) { |
||
| 854 | |||
| 855 | /** |
||
| 856 | * Searches through all of a users calendars and calendar objects to find |
||
| 857 | * an object with a specific UID. |
||
| 858 | * |
||
| 859 | * This method should return the path to this object, relative to the |
||
| 860 | * calendar home, so this path usually only contains two parts: |
||
| 861 | * |
||
| 862 | * calendarpath/objectpath.ics |
||
| 863 | * |
||
| 864 | * If the uid is not found, return null. |
||
| 865 | * |
||
| 866 | * This method should only consider * objects that the principal owns, so |
||
| 867 | * any calendars owned by other principals that also appear in this |
||
| 868 | * collection should be ignored. |
||
| 869 | * |
||
| 870 | * @param string $principalUri |
||
| 871 | * @param string $uid |
||
| 872 | * @return string|null |
||
| 873 | */ |
||
| 874 | function getCalendarObjectByUID($principalUri, $uid) { |
||
| 891 | |||
| 892 | /** |
||
| 893 | * The getChanges method returns all the changes that have happened, since |
||
| 894 | * the specified syncToken in the specified calendar. |
||
| 895 | * |
||
| 896 | * This function should return an array, such as the following: |
||
| 897 | * |
||
| 898 | * [ |
||
| 899 | * 'syncToken' => 'The current synctoken', |
||
| 900 | * 'added' => [ |
||
| 901 | * 'new.txt', |
||
| 902 | * ], |
||
| 903 | * 'modified' => [ |
||
| 904 | * 'modified.txt', |
||
| 905 | * ], |
||
| 906 | * 'deleted' => [ |
||
| 907 | * 'foo.php.bak', |
||
| 908 | * 'old.txt' |
||
| 909 | * ] |
||
| 910 | * ); |
||
| 911 | * |
||
| 912 | * The returned syncToken property should reflect the *current* syncToken |
||
| 913 | * of the calendar, as reported in the {http://sabredav.org/ns}sync-token |
||
| 914 | * property This is * needed here too, to ensure the operation is atomic. |
||
| 915 | * |
||
| 916 | * If the $syncToken argument is specified as null, this is an initial |
||
| 917 | * sync, and all members should be reported. |
||
| 918 | * |
||
| 919 | * The modified property is an array of nodenames that have changed since |
||
| 920 | * the last token. |
||
| 921 | * |
||
| 922 | * The deleted property is an array with nodenames, that have been deleted |
||
| 923 | * from collection. |
||
| 924 | * |
||
| 925 | * The $syncLevel argument is basically the 'depth' of the report. If it's |
||
| 926 | * 1, you only have to report changes that happened only directly in |
||
| 927 | * immediate descendants. If it's 2, it should also include changes from |
||
| 928 | * the nodes below the child collections. (grandchildren) |
||
| 929 | * |
||
| 930 | * The $limit argument allows a client to specify how many results should |
||
| 931 | * be returned at most. If the limit is not specified, it should be treated |
||
| 932 | * as infinite. |
||
| 933 | * |
||
| 934 | * If the limit (infinite or not) is higher than you're willing to return, |
||
| 935 | * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception. |
||
| 936 | * |
||
| 937 | * If the syncToken is expired (due to data cleanup) or unknown, you must |
||
| 938 | * return null. |
||
| 939 | * |
||
| 940 | * The limit is 'suggestive'. You are free to ignore it. |
||
| 941 | * |
||
| 942 | * @param string $calendarId |
||
| 943 | * @param string $syncToken |
||
| 944 | * @param int $syncLevel |
||
| 945 | * @param int $limit |
||
| 946 | * @return array |
||
| 947 | */ |
||
| 948 | View Code Duplication | function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) { |
|
| 1012 | |||
| 1013 | /** |
||
| 1014 | * Returns a list of subscriptions for a principal. |
||
| 1015 | * |
||
| 1016 | * Every subscription is an array with the following keys: |
||
| 1017 | * * id, a unique id that will be used by other functions to modify the |
||
| 1018 | * subscription. This can be the same as the uri or a database key. |
||
| 1019 | * * uri. This is just the 'base uri' or 'filename' of the subscription. |
||
| 1020 | * * principaluri. The owner of the subscription. Almost always the same as |
||
| 1021 | * principalUri passed to this method. |
||
| 1022 | * |
||
| 1023 | * Furthermore, all the subscription info must be returned too: |
||
| 1024 | * |
||
| 1025 | * 1. {DAV:}displayname |
||
| 1026 | * 2. {http://apple.com/ns/ical/}refreshrate |
||
| 1027 | * 3. {http://calendarserver.org/ns/}subscribed-strip-todos (omit if todos |
||
| 1028 | * should not be stripped). |
||
| 1029 | * 4. {http://calendarserver.org/ns/}subscribed-strip-alarms (omit if alarms |
||
| 1030 | * should not be stripped). |
||
| 1031 | * 5. {http://calendarserver.org/ns/}subscribed-strip-attachments (omit if |
||
| 1032 | * attachments should not be stripped). |
||
| 1033 | * 6. {http://calendarserver.org/ns/}source (Must be a |
||
| 1034 | * Sabre\DAV\Property\Href). |
||
| 1035 | * 7. {http://apple.com/ns/ical/}calendar-color |
||
| 1036 | * 8. {http://apple.com/ns/ical/}calendar-order |
||
| 1037 | * 9. {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set |
||
| 1038 | * (should just be an instance of |
||
| 1039 | * Sabre\CalDAV\Property\SupportedCalendarComponentSet, with a bunch of |
||
| 1040 | * default components). |
||
| 1041 | * |
||
| 1042 | * @param string $principalUri |
||
| 1043 | * @return array |
||
| 1044 | */ |
||
| 1045 | function getSubscriptionsForUser($principalUri) { |
||
| 1085 | |||
| 1086 | /** |
||
| 1087 | * Creates a new subscription for a principal. |
||
| 1088 | * |
||
| 1089 | * If the creation was a success, an id must be returned that can be used to reference |
||
| 1090 | * this subscription in other methods, such as updateSubscription. |
||
| 1091 | * |
||
| 1092 | * @param string $principalUri |
||
| 1093 | * @param string $uri |
||
| 1094 | * @param array $properties |
||
| 1095 | * @return mixed |
||
| 1096 | */ |
||
| 1097 | function createSubscription($principalUri, $uri, array $properties) { |
||
| 1135 | |||
| 1136 | /** |
||
| 1137 | * Updates a subscription |
||
| 1138 | * |
||
| 1139 | * The list of mutations is stored in a Sabre\DAV\PropPatch object. |
||
| 1140 | * To do the actual updates, you must tell this object which properties |
||
| 1141 | * you're going to process with the handle() method. |
||
| 1142 | * |
||
| 1143 | * Calling the handle method is like telling the PropPatch object "I |
||
| 1144 | * promise I can handle updating this property". |
||
| 1145 | * |
||
| 1146 | * Read the PropPatch documentation for more info and examples. |
||
| 1147 | * |
||
| 1148 | * @param mixed $subscriptionId |
||
| 1149 | * @param PropPatch $propPatch |
||
| 1150 | * @return void |
||
| 1151 | */ |
||
| 1152 | function updateSubscription($subscriptionId, PropPatch $propPatch) { |
||
| 1182 | |||
| 1183 | /** |
||
| 1184 | * Deletes a subscription. |
||
| 1185 | * |
||
| 1186 | * @param mixed $subscriptionId |
||
| 1187 | * @return void |
||
| 1188 | */ |
||
| 1189 | function deleteSubscription($subscriptionId) { |
||
| 1195 | |||
| 1196 | /** |
||
| 1197 | * Returns a single scheduling object for the inbox collection. |
||
| 1198 | * |
||
| 1199 | * The returned array should contain the following elements: |
||
| 1200 | * * uri - A unique basename for the object. This will be used to |
||
| 1201 | * construct a full uri. |
||
| 1202 | * * calendardata - The iCalendar object |
||
| 1203 | * * lastmodified - The last modification date. Can be an int for a unix |
||
| 1204 | * timestamp, or a PHP DateTime object. |
||
| 1205 | * * etag - A unique token that must change if the object changed. |
||
| 1206 | * * size - The size of the object, in bytes. |
||
| 1207 | * |
||
| 1208 | * @param string $principalUri |
||
| 1209 | * @param string $objectUri |
||
| 1210 | * @return array |
||
| 1211 | */ |
||
| 1212 | function getSchedulingObject($principalUri, $objectUri) { |
||
| 1234 | |||
| 1235 | /** |
||
| 1236 | * Returns all scheduling objects for the inbox collection. |
||
| 1237 | * |
||
| 1238 | * These objects should be returned as an array. Every item in the array |
||
| 1239 | * should follow the same structure as returned from getSchedulingObject. |
||
| 1240 | * |
||
| 1241 | * The main difference is that 'calendardata' is optional. |
||
| 1242 | * |
||
| 1243 | * @param string $principalUri |
||
| 1244 | * @return array |
||
| 1245 | */ |
||
| 1246 | function getSchedulingObjects($principalUri) { |
||
| 1266 | |||
| 1267 | /** |
||
| 1268 | * Deletes a scheduling object from the inbox collection. |
||
| 1269 | * |
||
| 1270 | * @param string $principalUri |
||
| 1271 | * @param string $objectUri |
||
| 1272 | * @return void |
||
| 1273 | */ |
||
| 1274 | function deleteSchedulingObject($principalUri, $objectUri) { |
||
| 1281 | |||
| 1282 | /** |
||
| 1283 | * Creates a new scheduling object. This should land in a users' inbox. |
||
| 1284 | * |
||
| 1285 | * @param string $principalUri |
||
| 1286 | * @param string $objectUri |
||
| 1287 | * @param string $objectData |
||
| 1288 | * @return void |
||
| 1289 | */ |
||
| 1290 | function createSchedulingObject($principalUri, $objectUri, $objectData) { |
||
| 1303 | |||
| 1304 | /** |
||
| 1305 | * Adds a change record to the calendarchanges table. |
||
| 1306 | * |
||
| 1307 | * @param mixed $calendarId |
||
| 1308 | * @param string $objectUri |
||
| 1309 | * @param int $operation 1 = add, 2 = modify, 3 = delete. |
||
| 1310 | * @return void |
||
| 1311 | */ |
||
| 1312 | View Code Duplication | protected function addChange($calendarId, $objectUri, $operation) { |
|
| 1327 | |||
| 1328 | /** |
||
| 1329 | * Parses some information from calendar objects, used for optimized |
||
| 1330 | * calendar-queries. |
||
| 1331 | * |
||
| 1332 | * Returns an array with the following keys: |
||
| 1333 | * * etag - An md5 checksum of the object without the quotes. |
||
| 1334 | * * size - Size of the object in bytes |
||
| 1335 | * * componentType - VEVENT, VTODO or VJOURNAL |
||
| 1336 | * * firstOccurence |
||
| 1337 | * * lastOccurence |
||
| 1338 | * * uid - value of the UID property |
||
| 1339 | * |
||
| 1340 | * @param string $calendarData |
||
| 1341 | * @return array |
||
| 1342 | */ |
||
| 1343 | public function getDenormalizedData($calendarData) { |
||
| 1419 | |||
| 1420 | private function readBlob($cardData) { |
||
| 1427 | |||
| 1428 | /** |
||
| 1429 | * @param IShareable $shareable |
||
| 1430 | * @param array $add |
||
| 1431 | * @param array $remove |
||
| 1432 | */ |
||
| 1433 | public function updateShares($shareable, $add, $remove) { |
||
| 1436 | |||
| 1437 | /** |
||
| 1438 | * @param int $resourceId |
||
| 1439 | * @return array |
||
| 1440 | */ |
||
| 1441 | public function getShares($resourceId) { |
||
| 1444 | |||
| 1445 | /** |
||
| 1446 | * @param int $resourceId |
||
| 1447 | * @param array $acl |
||
| 1448 | * @return array |
||
| 1449 | */ |
||
| 1450 | public function applyShareAcl($resourceId, $acl) { |
||
| 1453 | |||
| 1454 | View Code Duplication | private function convertPrincipal($principalUri, $toV2) { |
|
| 1464 | } |
||
| 1465 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.