Example #1
0
 public static function getCalenderSources($parameters)
 {
     $base_url = \OCP\Util::linkTo('calendar', 'ajax/events.php') . '?calendar_id=';
     foreach (Addressbook::all(\OCP\USER::getUser()) as $addressbook) {
         $parameters['sources'][] = array('url' => $base_url . 'birthday_' . $addressbook['id'], 'backgroundColor' => '#cccccc', 'borderColor' => '#888', 'textColor' => 'black', 'cache' => true, 'editable' => false);
     }
 }
Example #2
0
 /**
  * scan vcards for categories.
  * @param $vccontacts VCards to scan. null to check all vcards for the current user.
  */
 public static function scanCategories($vccontacts = null)
 {
     if (is_null($vccontacts)) {
         $vcaddressbooks = Addressbook::all(\OCP\USER::getUser());
         if (count($vcaddressbooks) > 0) {
             $vcaddressbookids = array();
             foreach ($vcaddressbooks as $vcaddressbook) {
                 if ($vcaddressbook['userid'] === \OCP\User::getUser()) {
                     $vcaddressbookids[] = $vcaddressbook['id'];
                 }
             }
             $start = 0;
             $batchsize = 10;
             $categories = new \OC_VCategories('contact');
             while ($vccontacts = VCard::all($vcaddressbookids, $start, $batchsize)) {
                 $cards = array();
                 foreach ($vccontacts as $vccontact) {
                     $cards[] = array($vccontact['id'], $vccontact['carddata']);
                 }
                 \OCP\Util::writeLog('contacts', __CLASS__ . '::' . __METHOD__ . ', scanning: ' . $batchsize . ' starting from ' . $start, \OCP\Util::DEBUG);
                 // only reset on first batch.
                 $categories->rescan($cards, true, $start == 0 ? true : false);
                 $start += $batchsize;
             }
         }
     }
 }
Example #3
0
 /**
  * @brief Get the last modification time.
  * @param OC_VObject|Sabre\VObject\Component|integer|null $contact
  * @returns DateTime | null
  */
 public static function lastModified($contact = null)
 {
     if (is_null($contact)) {
         $addressBooks = Addressbook::all(\OCP\User::getUser());
         $lastModified = 0;
         foreach ($addressBooks as $addressBook) {
             if (isset($addressBook['ctag']) and (int) $addressBook['ctag'] > $lastModified) {
                 $lastModified = $addressBook['ctag'];
             }
         }
         return new \DateTime('@' . $lastModified);
     } else {
         if (is_numeric($contact)) {
             $card = VCard::find($contact, array('lastmodified'));
             return $card ? new \DateTime('@' . $card['lastmodified']) : null;
         } elseif ($contact instanceof \OC_VObject || $contact instanceof VObject\Component) {
             return isset($contact->REV) ? \DateTime::createFromFormat(\DateTime::W3C, $contact->REV) : null;
         }
     }
 }