Ejemplo n.º 1
0
 /**
  * Search for shared or otherwise not listed calendars the user has access
  *
  * @param string Search string
  * @param string Section/source to search
  * @return array List of calendars
  */
 public function search_calendars($query, $source)
 {
     if (!kolab_storage::setup()) {
         return array();
     }
     $this->calendars = array();
     $this->search_more_results = false;
     // find unsubscribed IMAP folders that have "event" type
     if ($source == 'folders') {
         foreach ((array) kolab_storage::search_folders('event', $query, array('other')) as $folder) {
             $calendar = new kolab_calendar($folder->name, $this->cal);
             $this->calendars[$calendar->id] = $calendar;
         }
     } else {
         if ($source == 'users') {
             $limit = $this->rc->config->get('autocomplete_max', 15) * 2;
             // we have slightly more space, so display twice the number
             foreach (kolab_storage::search_users($query, 0, array(), $limit, $count) as $user) {
                 $calendar = new kolab_user_calendar($user, $this->cal);
                 $this->calendars[$calendar->id] = $calendar;
                 // search for calendar folders shared by this user
                 foreach (kolab_storage::list_user_folders($user, 'event', false) as $foldername) {
                     $cal = new kolab_calendar($foldername, $this->cal);
                     $this->calendars[$cal->id] = $cal;
                     $calendar->subscriptions = true;
                 }
             }
             if ($count > $limit) {
                 $this->search_more_results = true;
             }
         }
     }
     // don't list the birthday calendar
     $this->rc->config->set('calendar_contact_birthdays', false);
     $this->rc->config->set('kolab_invitation_calendars', false);
     return $this->list_calendars();
 }
 /**
  * Search for shared or otherwise not listed tasklists the user has access
  *
  * @param string Search string
  * @param string Section/source to search
  * @return array List of tasklists
  */
 public function search_lists($query, $source)
 {
     if (!kolab_storage::setup()) {
         return array();
     }
     $this->search_more_results = false;
     $this->lists = $this->folders = array();
     // find unsubscribed IMAP folders that have "event" type
     if ($source == 'folders') {
         foreach ((array) kolab_storage::search_folders('task', $query, array('other')) as $folder) {
             $this->folders[$folder->id] = $folder;
             $this->lists[$folder->id] = $this->folder_props($folder, array());
         }
     } else {
         if ($source == 'users') {
             $limit = $this->rc->config->get('autocomplete_max', 15) * 2;
             // we have slightly more space, so display twice the number
             foreach (kolab_storage::search_users($query, 0, array(), $limit * 10) as $user) {
                 $folders = array();
                 // search for tasks folders shared by this user
                 foreach (kolab_storage::list_user_folders($user, 'task', false) as $foldername) {
                     $folders[] = new kolab_storage_folder($foldername, 'task');
                 }
                 if (count($folders)) {
                     $userfolder = new kolab_storage_folder_user($user['kolabtargetfolder'], '', $user);
                     $this->folders[$userfolder->id] = $userfolder;
                     $this->lists[$userfolder->id] = $this->folder_props($userfolder, array());
                     foreach ($folders as $folder) {
                         $this->folders[$folder->id] = $folder;
                         $this->lists[$folder->id] = $this->folder_props($folder, array());
                         $count++;
                     }
                 }
                 if ($count >= $limit) {
                     $this->search_more_results = true;
                     break;
                 }
             }
         }
     }
     return $this->get_lists();
 }