Horde_Core_ActiveSync_Connector::horde_listApis PHP Method

horde_listApis() public method

Return all active api interfaces.
public horde_listApis ( ) : array
return array An array of interface names.
    public function horde_listApis()
    {
        $apis = $this->_registry->horde->listAPIs();
        // Note support not added until 5.1. Need to check the feature.
        // @TODO: H6, add this check to all apps. BC break to check it now,
        // since we didn't have this feature earlier.
        if ($key = array_search('notes', $apis)) {
            if (!$this->hasFeature('activesync', 'notes')) {
                unset($apis[$key]);
            }
        }
        $inactive = $this->_registry->listApps(array('inactive'));
        $active_apis = array();
        foreach ($apis as $api) {
            if (!$this->_registry->isInactive($this->_registry->hasInterface($api))) {
                $active_apis[] = $api;
            }
        }
        return $active_apis;
    }

Usage Example

Example #1
0
 /**
  * Return an array of the server's folder objects.
  *
  * @return array  An array of Horde_ActiveSync_Message_Folder objects.
  */
 public function getFolders()
 {
     $multiplex = $this->_device->multiplex;
     if (empty($this->_folders)) {
         ob_start();
         try {
             $supported = $this->_connector->horde_listApis();
         } catch (Exception $e) {
             $this->_logger->err($e->getMessage());
             $this->_endBuffer();
             return array();
         }
         $folders = array();
         if (array_search('calendar', $supported) !== false) {
             $temp = $this->_connector->getFolders(Horde_ActiveSync::CLASS_CALENDAR, $multiplex);
             if (is_array($temp)) {
                 foreach ($temp as $id => $folder) {
                     try {
                         $folders[] = $this->_getFolder(Horde_ActiveSync::CLASS_CALENDAR . ':' . $id, array('class' => Horde_ActiveSync::CLASS_CALENDAR, 'primary' => $folder['primary'], 'display' => $folder['display']));
                     } catch (Horde_ActiveSync_Exception $e) {
                     }
                 }
             } else {
                 try {
                     $folders[] = $this->_getFolder($temp);
                 } catch (Horde_ActiveSync_Exception $e) {
                 }
             }
         }
         if (array_search('contacts', $supported) !== false) {
             $temp = $this->_connector->getFolders(Horde_ActiveSync::CLASS_CONTACTS, $multiplex);
             if (is_array($temp)) {
                 foreach ($temp as $id => $folder) {
                     try {
                         $folders[] = $this->_getFolder(Horde_ActiveSync::CLASS_CONTACTS . ':' . $id, array('class' => Horde_ActiveSync::CLASS_CONTACTS, 'primary' => $folder['primary'], 'display' => $folder['display']));
                     } catch (Horde_ActiveSync_Exception $e) {
                     }
                 }
             } else {
                 try {
                     $folders[] = $this->_getFolder($temp);
                 } catch (Horde_ActiveSync_Exception $e) {
                 }
             }
         }
         if (array_search('tasks', $supported) !== false) {
             $temp = $this->_connector->getFolders(Horde_ActiveSync::CLASS_TASKS, $multiplex);
             if (is_array($temp)) {
                 foreach ($temp as $id => $folder) {
                     try {
                         $folders[] = $this->_getFolder(Horde_ActiveSync::CLASS_TASKS . ':' . $id, array('class' => Horde_ActiveSync::CLASS_TASKS, 'primary' => $folder['primary'], 'display' => $folder['display']));
                     } catch (Horde_ActiveSync_Exception $e) {
                     }
                 }
             } else {
                 try {
                     $folders[] = $this->_getFolder($temp);
                 } catch (Horde_ActiveSync_Exception $e) {
                 }
             }
         }
         if (array_search('notes', $supported) !== false) {
             $temp = $this->_connector->getFolders(Horde_ActiveSync::CLASS_NOTES, $multiplex);
             if (is_array($temp)) {
                 foreach ($temp as $id => $folder) {
                     try {
                         $folders[] = $this->_getFolder(Horde_ActiveSync::CLASS_NOTES . ':' . $id, array('class' => Horde_ActiveSync::CLASS_NOTES, 'primary' => $folder['primary'], 'display' => $folder['display']));
                     } catch (Horde_ActiveSync_Exception $e) {
                     }
                 }
             } else {
                 try {
                     $folders[] = $this->_getFolder($temp);
                 } catch (Horde_ActiveSync_Exception $e) {
                 }
             }
         }
         if ($this->_version > Horde_ActiveSync::VERSION_TWELVEONE) {
             $folders[] = $this->_getFolder('RI', array('class' => 'RI'));
         }
         // Always return at least the "dummy" IMAP folders since some
         // clients refuse to consider a FOLDERSYNC successful without
         // at least an INBOX, even with email sync turned off.
         try {
             $folders = array_merge($folders, $this->_getMailFolders());
         } catch (Horde_ActiveSync_Exception $e) {
             $this->_logger->err($e->getMessage());
             $this->_endBuffer();
             return array();
         }
         $this->_endBuffer();
         $this->_folders = $folders;
     }
     return $this->_folders;
 }