コード例 #1
0
 /**
  * returns model configurations for application starter
  *
  * @return array
  */
 public function getModelsConfiguration()
 {
     $ret = NULL;
     if ($this->_configuredModels) {
         return Tinebase_ModelConfiguration::getFrontendConfigForModels($this->_configuredModels, $this->_applicationName);
     }
     return $ret;
 }
コード例 #2
0
 /**
  * Returns registry data of all applications current user has access to
  * @see Tinebase_Application_Json_Abstract
  *
  * @return mixed array 'variable name' => 'data'
  */
 public function getAllRegistryData()
 {
     $registryData = array();
     if (Tinebase_Core::getUser()) {
         $userApplications = Tinebase_Core::getUser()->getApplications(TRUE);
         $clientConfig = Tinebase_Config::getInstance()->getClientRegistryConfig();
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
             /** @noinspection PhpUndefinedFieldInspection */
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' User applications to fetch registry for: ' . print_r($userApplications->name, TRUE));
         }
         /** @noinspection PhpUndefinedFieldInspection */
         if (!in_array('Tinebase', $userApplications->name)) {
             Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' User has no permissions to run Tinebase.');
             $this->logout();
             throw new Tinebase_Exception_AccessDenied('User has no permissions to run Tinebase');
         }
         foreach ($userApplications as $application) {
             $appRegistry = array();
             $appRegistry['rights'] = Tinebase_Core::getUser()->getRights($application->name);
             $appRegistry['config'] = isset($clientConfig[$application->name]) ? $clientConfig[$application->name]->toArray() : array();
             // @todo do we need this for all apps?
             $exportDefinitions = Tinebase_ImportExportDefinition::getInstance()->getExportDefinitionsForApplication($application);
             $appRegistry['exportDefinitions'] = array('results' => $exportDefinitions->toArray(), 'totalcount' => count($exportDefinitions));
             $customfields = Tinebase_CustomField::getInstance()->getCustomFieldsForApplication($application);
             Tinebase_CustomField::getInstance()->resolveConfigGrants($customfields);
             $appRegistry['customfields'] = $customfields->toArray();
             // add preferences for app
             try {
                 $prefRegistry = $this->_getAppPreferencesForRegistry($application);
                 $appRegistry = array_merge_recursive($appRegistry, $prefRegistry);
             } catch (Tinebase_Exception_AccessDenied $tead) {
                 // do not add prefs if user has no run right
             }
             $customAppRegistry = $this->_getCustomAppRegistry($application);
             if (empty($customAppRegistry)) {
                 // TODO always get this from app controller (and remove from _getCustomAppRegistry)
                 $appController = Tinebase_Core::getApplicationInstance($application->name);
                 $models = $appController->getModels();
                 $appRegistry['models'] = Tinebase_ModelConfiguration::getFrontendConfigForModels($models);
                 $appRegistry['defaultModel'] = $appController->getDefaultModel();
             } else {
                 $appRegistry = array_merge_recursive($appRegistry, $customAppRegistry);
             }
             $registryData[$application->name] = $appRegistry;
         }
     } else {
         $registryData['Tinebase'] = $this->getRegistryData();
     }
     return $registryData;
 }
 /**
  * tests if the Timeaccount Filter is there
  */
 public function testTimeaccountfilterWithoutAdmin()
 {
     $this->_removeRoleRight('Timetracker', Tinebase_Acl_Rights::ADMIN);
     $this->assertFalse(Tinebase_Core::getUser()->hasRight('Timetracker', Tinebase_Acl_Rights::ADMIN));
     $config = Tinebase_ModelConfiguration::getFrontendConfigForModels(array('Timetracker_Model_Timesheet'));
     $this->assertTrue(isset($config['Timesheet']['filterModel']['timeaccount_id']));
 }
コード例 #4
0
 /**
  * resolves virtual fields, if a function has been defined in the field definition
  *
  * @param array $resultSet
  * @param Tinebase_ModelConfiguration $modelConfiguration
  * @param boolean $multiple
  * @return array
  */
 protected function _resolveVirtualFields($resultSet, $modelConfiguration = NULL, $multiple = false)
 {
     if (!$modelConfiguration || !($virtualFields = $modelConfiguration->virtualFields)) {
         return $resultSet;
     }
     if ($modelConfiguration->resolveVFGlobally === TRUE) {
         /** @var Tinebase_Controller_Record_Interface $controller */
         $controller = $modelConfiguration->getControllerInstance();
         if ($multiple) {
             return $controller->resolveMultipleVirtualFields($resultSet);
         }
         return $controller->resolveVirtualFields($resultSet);
     }
     foreach ($virtualFields as $field) {
         // resolve virtual relation record from relations property
         if (!$multiple && isset($field['type']) && $field['type'] == 'relation') {
             $fc = $field['config'];
             if (isset($resultSet['relations']) && is_array($resultSet['relations'])) {
                 foreach ($resultSet['relations'] as $relation) {
                     if ($relation['type'] == $fc['type'] && $relation['related_model'] == $fc['appName'] . '_Model_' . $fc['modelName']) {
                         $resultSet[$field['key']] = $relation['related_record'];
                     }
                 }
             }
             // resolve virtual field by function
         } else {
             if (isset($field['function']) || array_key_exists('function', $field)) {
                 if (is_array($field['function'])) {
                     if (count($field['function']) > 1) {
                         // static method call
                         $class = $field['function'][0];
                         $method = $field['function'][1];
                         $resultSet = $class::$method($resultSet);
                     } else {
                         // use key as classname and value as method name
                         $ks = array_keys($field['function']);
                         $class = array_pop($ks);
                         $vs = array_values($field['function']);
                         $method = array_pop($vs);
                         $class = $class::getInstance();
                         $resultSet = $class->{$method}($resultSet);
                     }
                     // if no array has been given, this should be a function name
                 } else {
                     $resolveFunction = $field['function'];
                     $resultSet = $resolveFunction($resultSet);
                 }
             }
         }
     }
     return $resultSet;
 }