Beispiel #1
0
 /**
  * returns all observers of a given observable and event
  * 
  * @param Tinebase_Record_Interface $_observable 
  * @param string _event 
  * @return Tinebase_Record_RecordSet
  */
 protected function getObserversByEvent($_observable, $_event)
 {
     if (!$_observer->getApplication() || !$_observer->getId()) {
         throw new Tinebase_Exception_Record_DefinitionFailure();
     }
     $where = array($this->_db->quoteIdentifier('observable_application') . ' =' . $_observable->getApplication(), $this->_db->quoteIdentifier('observable_identifier') . '  =' . $_observable->getId(), $this->_db->quoteIdentifier('observed_event') . '         =' . $this->_db->getAdapter()->quote($_event));
     return new Tinebase_Record_RecordSet('Tinebase_Model_PersistentObserver', $this->_db->fetchAll($where), true);
 }
 /**
  * get option setting string
  * 
  * @deprecated
  * @param Tinebase_Record_Interface $_record
  * @param string $_id
  * @param string $_label
  * @return string
  */
 public static function getOptionString($_record, $_label)
 {
     $controller = Tinebase_Core::getApplicationInstance($_record->getApplication());
     $settings = $controller->getConfigSettings();
     $idField = $_label . '_id';
     $option = $settings->getOptionById($_record->{$idField}, $_label . 's');
     $result = isset($option[$_label]) ? $option[$_label] : '';
     return $result;
 }
 /**
  * get custom fields and add them to $_record->customfields arraay
  *
  * @param Tinebase_Record_Interface $_record
  * @param Tinebase_Record_RecordSet $_customFields
  * @param Tinebase_Record_RecordSet $_configs
  */
 public function resolveRecordCustomFields(Tinebase_Record_Interface $_record, $_customFields = NULL, $_configs = NULL)
 {
     $customFields = $_customFields === NULL ? $this->_getCustomFields($_record->getId()) : $_customFields;
     if (count($customFields) == 0) {
         return;
     }
     if ($_configs === NULL) {
         $_configs = $this->getCustomFieldsForApplication(Tinebase_Application::getInstance()->getApplicationByName($_record->getApplication()));
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Adding ' . count($customFields) . ' customfields to record  ' . $_record->getId());
     }
     $result = array();
     foreach ($customFields as $customField) {
         $this->_setCfValueInRecord($_record, $customField, $_configs);
     }
 }
Beispiel #4
0
 /**
  * get custom fields and add them to $_record->customfields arraay
  *
  * @param Tinebase_Record_Interface $_record
  * @param Tinebase_Record_RecordSet $_customFields
  * @param Tinebase_Record_RecordSet $_configs
  */
 public function resolveRecordCustomFields(Tinebase_Record_Interface $_record, $_customFields = NULL, $_configs = NULL)
 {
     $customFields = $_customFields === NULL ? $this->_getCustomFields($_record->getId()) : $_customFields;
     if (count($customFields) == 0) {
         return;
     }
     if ($_configs === NULL) {
         $_configs = $this->getCustomFieldsForApplication(Tinebase_Application::getInstance()->getApplicationByName($_record->getApplication()));
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Adding ' . count($customFields) . ' custom fields to record  ' . $_record->getId());
     }
     $result = array();
     foreach ($customFields as $customField) {
         $idx = $_configs->getIndexById($customField->customfield_id);
         if ($idx !== FALSE) {
             $config = $_configs[$idx];
             if (strtolower($config->definition['type']) == 'record') {
                 try {
                     $modelParts = explode('.', $config->definition['recordConfig']['value']['records']);
                     // get model parts from saved record class e.g. Tine.Admin.Model.Group
                     $controllerName = $modelParts[1] . '_Controller_' . $modelParts[3];
                     $controller = call_user_func(array($controllerName, 'getInstance'));
                     $result[$config->name] = $controller->get($customField->value)->toArray();
                 } catch (Exception $e) {
                     if (Tinebase_Core::isLogLevel(Zend_Log::ERR)) {
                         Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' Error resolving custom field record: ' . $e->getMessage());
                     }
                     $result[$config->name] = $customField->value;
                 }
             } else {
                 $result[$config->name] = $customField->value;
             }
         }
     }
     $_record->customfields = $result;
 }
 /**
  * Gets tags of a given record where user has the required right to
  * The tags are stored in the records $_tagsProperty.
  *
  * @param Tinebase_Record_Interface $_record        the record object
  * @param string                    $_tagsProperty  the property in the record where the tags are in (defaults: 'tags')
  * @param string                    $_right         the required right current user must have on the tags
  * @return Tinebase_Record_RecordSet tags of record
  */
 public function getTagsOfRecord($_record, $_tagsProperty = 'tags', $_right = Tinebase_Model_TagRight::VIEW_RIGHT)
 {
     $recordId = $_record->getId();
     $tags = new Tinebase_Record_RecordSet('Tinebase_Model_Tag');
     if (!empty($recordId)) {
         $select = $this->_getSelect($recordId, Tinebase_Application::getInstance()->getApplicationByName($_record->getApplication())->getId());
         Tinebase_Model_TagRight::applyAclSql($select, $_right, $this->_db->quoteIdentifier('tagging.tag_id'));
         Tinebase_Backend_Sql_Abstract::traitGroup($select);
         foreach ($this->_db->fetchAssoc($select) as $tagArray) {
             $tags->addRecord(new Tinebase_Model_Tag($tagArray, true));
         }
     }
     $_record[$_tagsProperty] = $tags;
     return $tags;
 }