当前位置: 首页>>代码示例>>PHP>>正文


PHP Tinebase_Core::getApplicationInstance方法代码示例

本文整理汇总了PHP中Tinebase_Core::getApplicationInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Core::getApplicationInstance方法的具体用法?PHP Tinebase_Core::getApplicationInstance怎么用?PHP Tinebase_Core::getApplicationInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tinebase_Core的用法示例。


在下文中一共展示了Tinebase_Core::getApplicationInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _doImport

 /**
  * import helper
  *
  * @param array $_options
  * @param string|Tinebase_Model_ImportExportDefinition $_definition
  * @param Tinebase_Model_Filter_FilterGroup $_exportFilter
  * @throws Tinebase_Exception_NotFound
  * @return array
  */
 protected function _doImport(array $_options, $_definition, Tinebase_Model_Filter_FilterGroup $_exportFilter = NULL)
 {
     if (!$this->_importerClassName || !$this->_modelName) {
         throw new Tinebase_Exception_NotFound('No import class or model name given');
     }
     $definition = $_definition instanceof Tinebase_Model_ImportExportDefinition ? $_definition : Tinebase_ImportExportDefinition::getInstance()->getByName($_definition);
     $this->_instance = call_user_func_array($this->_importerClassName . '::createFromDefinition', array($definition, $_options));
     // export first
     if ($_exportFilter !== NULL && $this->_exporterClassName) {
         $exporter = new $this->_exporterClassName($_exportFilter, Tinebase_Core::getApplicationInstance($this->_modelName));
         $this->_filename = $exporter->generate();
     }
     // then import
     $result = $this->_instance->importFile($this->_filename);
     return $result;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:25,代码来源:ImportTestCase.php

示例2: _appendRelationFilter

 /**
  * append relation filter
  * 
  * @param Crm_Model_LeadFilter $filter
  */
 protected function _appendRelationFilter($filter)
 {
     if (!Tinebase_Core::getPreference()->getValue(Tinebase_Preference::ADVANCED_SEARCH, false)) {
         return;
     }
     $relationsToSearchIn = array('Addressbook_Model_Contact', 'Sales_Model_Product', 'Tasks_Model_Task');
     $leadIds = array();
     foreach ($relationsToSearchIn as $relatedModel) {
         $filterModel = $relatedModel . 'Filter';
         $relatedFilter = new $filterModel(array(array('field' => 'query', 'operator' => 'contains', 'value' => $this->_value)));
         $relatedIds = Tinebase_Core::getApplicationInstance($relatedModel)->search($relatedFilter, NULL, FALSE, TRUE);
         $relationFilter = new Tinebase_Model_RelationFilter(array(array('field' => 'own_model', 'operator' => 'equals', 'value' => 'Crm_Model_Lead'), array('field' => 'related_model', 'operator' => 'equals', 'value' => $relatedModel), array('field' => 'related_id', 'operator' => 'in', 'value' => $relatedIds)));
         $leadIds = array_merge($leadIds, Tinebase_Relations::getInstance()->search($relationFilter, NULL)->own_id);
     }
     $filter->addFilter(new Tinebase_Model_Filter_Id('id', 'in', $leadIds));
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:21,代码来源:LeadQueryFilter.php

示例3: __construct

 /**
  * the constructor
  * 
  * @param string $_path
  * @throws Sabre\DAV\Exception\NotFound
  */
 public function __construct($path)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Record path: ' . $path);
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r(Sabre\DAV\URLUtil::splitPath($path), true));
     }
     try {
         list($appModel, $id) = Sabre\DAV\URLUtil::splitPath($path);
         list($appName, $records, $model) = explode('/', $appModel);
         $this->_record = Tinebase_Core::getApplicationInstance($appName, $model)->get($id);
     } catch (Tinebase_Exception_NotFound $tenf) {
         throw new Sabre\DAV\Exception\NotFound('Record ' . $path . ' not found');
     }
     $this->_appName = $appName;
     $this->_path = $path;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:24,代码来源:Record.php

示例4: fireEvent

 /**
  * calls the handleEvent function in the controller of all enabled applications 
  *
  * @param  Tinebase_Event_Object  $_eventObject  the event object
  */
 public static function fireEvent(Tinebase_Event_Abstract $_eventObject)
 {
     self::$events[get_class($_eventObject)][$_eventObject->getId()] = $_eventObject;
     if (self::isDuplicateEvent($_eventObject)) {
         // do nothing
         return;
     }
     foreach (Tinebase_Application::getInstance()->getApplicationsByState(Tinebase_Application::ENABLED) as $application) {
         try {
             $controller = Tinebase_Core::getApplicationInstance($application, NULL, TRUE);
         } catch (Tinebase_Exception_NotFound $e) {
             // application has no controller or is not useable at all
             continue;
         }
         if ($controller instanceof Tinebase_Event_Interface) {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . ' (' . __LINE__ . ') calling eventhandler for event ' . get_class($_eventObject) . ' of application ' . (string) $application);
             }
             try {
                 $controller->handleEvent($_eventObject);
             } catch (Exception $e) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                     Tinebase_Core::getLogger()->notice(__METHOD__ . ' (' . __LINE__ . ') ' . (string) $application . ' threw an exception: ' . $e->getMessage());
                 }
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                     Tinebase_Core::getLogger()->debug(__METHOD__ . ' (' . __LINE__ . ') ' . $e->getTraceAsString());
                 }
             }
         }
     }
     // try custom user defined listeners
     try {
         if (@class_exists('CustomEventHooks')) {
             $methods = get_class_methods('CustomEventHooks');
             if (in_array('handleEvent', (array) $methods)) {
                 Tinebase_Core::getLogger()->info(__METHOD__ . ' (' . __LINE__ . ') ' . ' about to process user defined event hook for ' . get_class($_eventObject));
                 CustomEventHooks::handleEvent($_eventObject);
             }
         }
     } catch (Exception $e) {
         Tinebase_Core::getLogger()->info(__METHOD__ . ' (' . __LINE__ . ') ' . ' failed to process user defined event hook with message: ' . $e);
     }
     unset(self::$events[get_class($_eventObject)][$_eventObject->getId()]);
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:49,代码来源:Event.php

示例5: sendPendingAlarms

 /**
  * send pending alarms
  *
  * @param mixed $_eventName
  * @return void
  * 
  * @todo sort alarms (by model/...)?
  * @todo what to do about Tinebase_Model_Alarm::STATUS_FAILURE alarms?
  */
 public function sendPendingAlarms($_eventName)
 {
     $eventName = is_array($_eventName) ? $_eventName['eventName'] : $_eventName;
     $job = Tinebase_AsyncJob::getInstance()->startJob($eventName);
     if (!$job) {
         return;
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' No ' . $eventName . ' is running. Starting new one.');
     }
     try {
         // get all pending alarms
         $filter = new Tinebase_Model_AlarmFilter(array(array('field' => 'alarm_time', 'operator' => 'before', 'value' => Tinebase_DateTime::now()->subMinute(1)->get(Tinebase_Record_Abstract::ISO8601LONG)), array('field' => 'sent_status', 'operator' => 'equals', 'value' => Tinebase_Model_Alarm::STATUS_PENDING)));
         $limit = Tinebase_Config::getInstance()->get(Tinebase_Config::ALARMS_EACH_JOB, 100);
         $pagination = $limit > 0 ? new Tinebase_Model_Pagination(array('limit' => $limit)) : null;
         $alarms = $this->_backend->search($filter, $pagination);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Sending ' . count($alarms) . ' alarms (limit: ' . $limit . ').');
         }
         // loop alarms and call sendAlarm in controllers
         foreach ($alarms as $alarm) {
             list($appName, $i, $itemName) = explode('_', $alarm->model);
             $appController = Tinebase_Core::getApplicationInstance($appName, $itemName);
             if ($appController instanceof Tinebase_Controller_Alarm_Interface) {
                 $alarm->sent_time = Tinebase_DateTime::now();
                 try {
                     // NOTE: we set the status here, so controller can adopt the status itself
                     $alarm->sent_status = Tinebase_Model_Alarm::STATUS_SUCCESS;
                     $appController->sendAlarm($alarm);
                 } catch (Exception $e) {
                     Tinebase_Exception::log($e);
                     $alarm->sent_message = $e->getMessage();
                     $alarm->sent_status = Tinebase_Model_Alarm::STATUS_FAILURE;
                 }
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                     Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Updating alarm status: ' . $alarm->sent_status);
                 }
                 $this->update($alarm);
             }
         }
         $job = Tinebase_AsyncJob::getInstance()->finishJob($job);
     } catch (Exception $e) {
         // save new status 'failure'
         $job = Tinebase_AsyncJob::getInstance()->finishJob($job, Tinebase_Model_AsyncJob::STATUS_FAILURE, $e->getMessage());
         if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Job failed: ' . $e->getMessage());
         }
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $e->getTraceAsString());
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Job ' . $eventName . ' finished.');
     }
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:64,代码来源:Alarm.php

示例6: _getModelConfigMethods

 /**
  * get default modelconfig methods
  *
  * @return array of Zend_Server_Method_Definition
  */
 protected static function _getModelConfigMethods()
 {
     // get all apps user has RUN right for
     $userApplications = Tinebase_Core::getUser()->getApplications();
     $definitions = array();
     foreach ($userApplications as $application) {
         try {
             $controller = Tinebase_Core::getApplicationInstance($application->name);
             $models = $controller->getModels();
             if (!$models) {
                 continue;
             }
         } catch (Exception $e) {
             Tinebase_Exception::log($e);
             continue;
         }
         foreach ($models as $model) {
             $config = $model::getConfiguration();
             if ($config && $config->exposeJsonApi) {
                 // TODO replace this with generic method
                 $simpleModelName = str_replace($application->name . '_Model_', '', $model);
                 $commonJsonApiMethods = array('get' => array('params' => array(new Zend_Server_Method_Parameter(array('type' => 'string', 'name' => 'id'))), 'help' => 'get one ' . $simpleModelName . ' identified by $id', 'plural' => false), 'search' => array('params' => array(new Zend_Server_Method_Parameter(array('type' => 'array', 'name' => 'filter')), new Zend_Server_Method_Parameter(array('type' => 'array', 'name' => 'paging'))), 'help' => 'Search for ' . $simpleModelName . 's matching given arguments', 'plural' => true), 'save' => array('params' => array(new Zend_Server_Method_Parameter(array('type' => 'array', 'name' => 'recordData'))), 'help' => 'Save ' . $simpleModelName . '', 'plural' => false), 'delete' => array('params' => array(new Zend_Server_Method_Parameter(array('type' => 'array', 'name' => 'ids'))), 'help' => 'Delete multiple ' . $simpleModelName . 's', 'plural' => true));
                 foreach ($commonJsonApiMethods as $name => $method) {
                     $key = $application->name . '.' . $name . $simpleModelName . ($method['plural'] ? 's' : '');
                     $appJsonFrontendClass = $application->name . '_Frontend_Json';
                     if (class_exists($appJsonFrontendClass)) {
                         $class = $appJsonFrontendClass;
                         $object = null;
                     } else {
                         $class = 'Tinebase_Frontend_Json_Generic';
                         $object = new Tinebase_Frontend_Json_Generic($application->name);
                     }
                     $definitions[$key] = new Zend_Server_Method_Definition(array('name' => $key, 'prototypes' => array(array('returnType' => 'array', 'parameters' => $method['params'])), 'methodHelp' => $method['help'], 'invokeArguments' => array(), 'object' => $object, 'callback' => array('type' => 'instance', 'class' => $class, 'method' => $name . $simpleModelName . ($method['plural'] ? 's' : ''))));
                 }
             }
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Got MC definitions: ' . print_r(array_keys($definitions), true));
     }
     return $definitions;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:47,代码来源:Json.php

示例7: moveRecordsToContainer

 /**
  * move records to container
  * 
  * @param string $targetContainerId
  * @param array  $filterData
  * @param string $applicationName
  * @param string $model
  * @return array
  */
 public function moveRecordsToContainer($targetContainerId, $filterData, $applicationName, $model)
 {
     $filterModel = $applicationName . '_Model_' . $model . 'Filter';
     $filter = new $filterModel(array());
     $filter->setFromArrayInUsersTimezone($filterData);
     $this->_longRunningRequest();
     $recordController = Tinebase_Core::getApplicationInstance($applicationName, $model);
     $result = $recordController->move($filter, $targetContainerId);
     return array('status' => 'success', 'results' => $result);
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:19,代码来源:Container.php

示例8: _resolveForeignIdFields

 /**
  * resolve foreign fields for records like user ids to users, etc.
  * 
  * @param Tinebase_Record_RecordSet $records
  * @param string $foreignRecordClassName
  * @param array $fields
  */
 protected static function _resolveForeignIdFields($records, $foreignRecordClassName, $fields)
 {
     $options = isset($fields['options']) || array_key_exists('options', $fields) ? $fields['options'] : array();
     $fields = isset($fields['fields']) || array_key_exists('fields', $fields) ? $fields['fields'] : $fields;
     $foreignIds = array();
     foreach ($fields as $field) {
         $foreignIds = array_unique(array_merge($foreignIds, $records->{$field}));
     }
     try {
         $controller = Tinebase_Core::getApplicationInstance($foreignRecordClassName);
     } catch (Tinebase_Exception_AccessDenied $tead) {
         if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
             Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' No right to access application of record ' . $foreignRecordClassName);
         }
         return;
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Fetching ' . $foreignRecordClassName . ' by id: ' . print_r($foreignIds, TRUE));
     }
     if ((isset($options['ignoreAcl']) || array_key_exists('ignoreAcl', $options)) && $options['ignoreAcl']) {
         // @todo make sure that second param of getMultiple() is $ignoreAcl
         $foreignRecords = $controller->getMultiple($foreignIds, TRUE);
     } else {
         $foreignRecords = $controller->getMultiple($foreignIds);
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Foreign records found: ' . print_r($foreignRecords->toArray(), TRUE));
     }
     if (count($foreignRecords) === 0) {
         return;
     }
     foreach ($records as $record) {
         foreach ($fields as $field) {
             if (is_scalar($record->{$field})) {
                 $idx = $foreignRecords->getIndexById($record->{$field});
                 if (isset($idx) && $idx !== FALSE) {
                     $record->{$field} = $foreignRecords[$idx];
                 } else {
                     switch ($foreignRecordClassName) {
                         case 'Tinebase_Model_User':
                         case 'Tinebase_Model_FullUser':
                             $record->{$field} = Tinebase_User::getInstance()->getNonExistentUser();
                             break;
                         default:
                             // skip
                     }
                 }
             }
         }
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:58,代码来源:Json.php

示例9: getOptionString

 /**
  * 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;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:18,代码来源:Config.php

示例10: _getProductAccountables

 /**
  * @param Sales_Model_ProductAggregate $productAggregate
  * @return null|Tinebase_Record_RecordSet
  * @throws Tinebase_Exception_AccessDenied
  * @throws Tinebase_Exception_NotFound
  */
 protected function _getProductAccountables(Sales_Model_ProductAggregate $productAggregate)
 {
     $json_attributes = $productAggregate->json_attributes;
     if (!is_array($json_attributes) || !isset($json_attributes['assignedAccountables'])) {
         return null;
     }
     $product = Sales_Controller_Product::getInstance()->get($productAggregate->product_id);
     if ($product->accountable == '') {
         return null;
     }
     $app = Tinebase_Core::getApplicationInstance($product->accountable, '');
     return $app->getMultiple($json_attributes['assignedAccountables']);
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:19,代码来源:ProductAggregate.php

示例11: getImage

 /**
  * gets image info and data
  * 
  * @param   string $_application application which manages the image
  * @param   string $_identifier identifier of image/record
  * @param   string $_location optional additional identifier
  * @return  Tinebase_Model_Image
  * @throws  Tinebase_Exception_NotFound
  * @throws  Tinebase_Exception_UnexpectedValue
  */
 public function getImage($_application, $_identifier, $_location = '')
 {
     $appController = Tinebase_Core::getApplicationInstance($_application);
     if (!method_exists($appController, 'getImage')) {
         throw new Tinebase_Exception_NotFound("{$_application} has no getImage function.");
     }
     $image = $appController->getImage($_identifier, $_location);
     if (!$image instanceof Tinebase_Model_Image) {
         throw new Tinebase_Exception_UnexpectedValue("{$_application} returned invalid image.");
     }
     return $image;
 }
开发者ID:hernot,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:22,代码来源:Controller.php

示例12: _createContainer

 /**
  * creates a new container
  * 
  * @todo allow to create personal folders only when in currents users own path
  * 
  * @param  array  $properties  properties for new container
  * @throws \Sabre\DAV\Exception\Forbidden
  * @return Tinebase_Model_Container
  */
 protected function _createContainer(array $properties)
 {
     if (count($this->_getPathParts()) !== 2) {
         throw new \Sabre\DAV\Exception\Forbidden('Permission denied to create directory ' . $properties['name']);
     }
     $containerType = Tinebase_Helper::array_value(1, $this->_getPathParts()) == Tinebase_Model_Container::TYPE_SHARED ? Tinebase_Model_Container::TYPE_SHARED : Tinebase_Model_Container::TYPE_PERSONAL;
     $newContainer = new Tinebase_Model_Container(array_merge($properties, array('type' => $containerType, 'backend' => 'Sql', 'application_id' => $this->_getApplication()->getId(), 'model' => Tinebase_Core::getApplicationInstance($this->_applicationName)->getDefaultModel())));
     try {
         $container = Tinebase_Container::getInstance()->addContainer($newContainer);
     } catch (Tinebase_Exception_AccessDenied $tead) {
         throw new \Sabre\DAV\Exception\Forbidden('Permission denied to create directory ' . $properties['name']);
     }
     return $container;
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:23,代码来源:AbstractContainerTree.php

示例13: generatePathForRecord

 /**
  * generates path for the record
  *
  * @param Tinebase_Record_Abstract $record
  * @param boolean $rebuildRecursively
  * @return Tinebase_Record_RecordSet
  *
  * TODO what about acl? the account who creates the path probably does not see all relations ...
  */
 public function generatePathForRecord(Tinebase_Record_Abstract $record, $rebuildRecursively = false)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Generate path for ' . get_class($record) . ' record with id ' . $record->getId());
     }
     $recordController = Tinebase_Core::getApplicationInstance(get_class($record));
     // if we rebuild recursively, dont do any tree operation, just rebuild the paths for the record and be done with it
     if (false === $rebuildRecursively) {
         // fetch full record + check acl
         $record = $recordController->get($record->getId());
         $currentPaths = Tinebase_Record_Path::getInstance()->getPathsForRecords($record);
     }
     $newPaths = new Tinebase_Record_RecordSet('Tinebase_Model_Path');
     // fetch all parent -> child relations and add to path
     $newPaths->merge($this->_getPathsOfRecord($record, $rebuildRecursively));
     if (method_exists($recordController, 'generatePathForRecord')) {
         $newPaths->merge($recordController->generatePathForRecord($record));
     }
     // if we rebuild recursively, dont do any tree operation, just rebuild the paths for the record and be done with it
     if (false === $rebuildRecursively) {
         //compare currentPaths with newPaths to find out if we need to make subtree updates
         //we should do this before the new paths of the current record have been persisted to DB!
         $currentShadowPathOffset = array();
         foreach ($currentPaths as $offset => $path) {
             $currentShadowPathOffset[$path->shadow_path] = $offset;
         }
         $newShadowPathOffset = array();
         foreach ($newPaths as $offset => $path) {
             $newShadowPathOffset[$path->shadow_path] = $offset;
         }
         $toDelete = array();
         $anyOldOffset = null;
         foreach ($currentShadowPathOffset as $shadowPath => $offset) {
             $anyOldOffset = $offset;
             // parent path has been deleted!
             if (false === isset($newShadowPathOffset[$shadowPath])) {
                 $toDelete[] = $shadowPath;
                 continue;
             }
             $currentPath = $currentPaths[$offset];
             $newPath = $newPaths[$newShadowPathOffset[$shadowPath]];
             // path changed (a title was updated or similar)
             if ($currentPath->path !== $newPath->path) {
                 // update ... set path = REPLACE(path, $currentPath->path, $newPath->path) where shadow_path LIKE '$shadowPath/%'
                 $this->_backend->replacePathForShadowPathTree($shadowPath, $currentPath->path, $newPath->path);
             }
             unset($newShadowPathOffset[$shadowPath]);
         }
         // new parents
         if (count($newShadowPathOffset) > 0 && null !== $anyOldOffset) {
             $anyPath = $currentPaths[$anyOldOffset];
             $newParents = array_values($newShadowPathOffset);
             foreach ($newParents as $newParentOffset) {
                 $newParent = $newPaths[$newParentOffset];
                 // insert into ... select
                 // REPLACE(path, $anyPath->path, $newParent->path) as path,
                 // REPLACE(shadow_path, $anyPath->shadow_path, $newParent->shadow_path) as shadow_path
                 // from ... where shadow_path LIKE '$anyPath->shadow_path/%'
                 $this->_backend->copyTreeByShadowPath($anyPath->shadow_path, $newParent->path, $anyPath->path, $newParent->shadow_path, $anyPath->shadow_path);
             }
         }
         //execute deletes only now, important to make 100% sure "new parents" just above still has data to work on!
         foreach ($toDelete as $delete) {
             // delete where shadow_path LIKE '$delete/%'
             $this->_backend->deleteForShadowPathTree($delete);
         }
     }
     // delete current paths of this record
     $this->deletePathsForRecord($record);
     // recreate new paths of this record
     foreach ($newPaths as $path) {
         $this->_backend->create($path);
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Created ' . count($newPaths) . ' paths.');
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($newPaths->toArray(), true));
     }
     return $newPaths;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:90,代码来源:Path.php

示例14: createSystemContainer

 /**
  * create a new system container
  * - by default user group gets READ grant
  * - by default admin group gets all grants
  *
  * NOTE: this should never be called in user land and only in admin/setup contexts
  * 
  * @param Tinebase_Model_Application|string $application app record, app id or app name
  * @param string $name
  * @param string $idConfig save id in config if given
  * @param Tinebase_Record_RecordSet $grants use this to overwrite default grants
  * @param string $model the model the container contains
  * @return Tinebase_Model_Container
  */
 public function createSystemContainer($application, $name, $configId = NULL, Tinebase_Record_RecordSet $grants = NULL, $model = NULL)
 {
     $application = $application instanceof Tinebase_Model_Application ? $application : Tinebase_Application::getInstance()->getApplicationById($application);
     if ($model === null) {
         $controller = Tinebase_Core::getApplicationInstance($application->name, '', true);
         $model = $controller->getDefaultModel();
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Creating system container for model ' . $model);
     }
     $newContainer = new Tinebase_Model_Container(array('name' => $name, 'type' => Tinebase_Model_Container::TYPE_SHARED, 'backend' => 'Sql', 'application_id' => $application->getId(), 'model' => $model));
     $groupsBackend = Tinebase_Group::getInstance();
     $grants = $grants ? $grants : new Tinebase_Record_RecordSet('Tinebase_Model_Grants', array(array('account_id' => $groupsBackend->getDefaultGroup()->getId(), 'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP, Tinebase_Model_Grants::GRANT_READ => true, Tinebase_Model_Grants::GRANT_EXPORT => true, Tinebase_Model_Grants::GRANT_SYNC => true), array('account_id' => $groupsBackend->getDefaultAdminGroup()->getId(), 'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP, Tinebase_Model_Grants::GRANT_READ => true, Tinebase_Model_Grants::GRANT_ADD => true, Tinebase_Model_Grants::GRANT_EDIT => true, Tinebase_Model_Grants::GRANT_DELETE => true, Tinebase_Model_Grants::GRANT_ADMIN => true, Tinebase_Model_Grants::GRANT_EXPORT => true, Tinebase_Model_Grants::GRANT_SYNC => true)), TRUE);
     $newContainer = Tinebase_Container::getInstance()->addContainer($newContainer, $grants, TRUE);
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Created new system container ' . $name . ' for application ' . $application->name);
     }
     if ($configId !== NULL) {
         $configClass = $application->name . '_Config';
         if (@class_exists($configClass)) {
             $config = call_user_func(array($configClass, 'getInstance'));
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Setting system container config "' . $configId . '" = ' . $newContainer->getId());
             }
             $config->set($configId, $newContainer->getId());
         } else {
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                 Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Could not find preferences class ' . $configClass);
             }
         }
     }
     $this->resetClassCache();
     return $newContainer;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:48,代码来源:Container.php

示例15: _deleteLinkedObjects

 /**
  * delete linked objects (notes, relations, ...) of record
  *
  * @param Tinebase_Record_Interface $_record
  */
 protected function _deleteLinkedObjects(Tinebase_Record_Interface $_record)
 {
     // delete notes & relations
     if ($_record->has('notes')) {
         Tinebase_Notes::getInstance()->deleteNotesOfRecord($this->_modelName, $this->_backend->getType(), $_record->getId());
     }
     if ($_record->has('relations')) {
         $relations = Tinebase_Relations::getInstance()->getRelations($this->_modelName, $this->_backend->getType(), $_record->getId());
         if (!empty($relations)) {
             // remove relations
             Tinebase_Relations::getInstance()->setRelations($this->_modelName, $this->_backend->getType(), $_record->getId(), array());
             // remove related objects
             if (!empty($this->_relatedObjectsToDelete)) {
                 foreach ($relations as $relation) {
                     if (in_array($relation->related_model, $this->_relatedObjectsToDelete)) {
                         list($appName, $i, $itemName) = explode('_', $relation->related_model);
                         $appController = Tinebase_Core::getApplicationInstance($appName, $itemName);
                         $appController->delete($relation->related_id);
                     }
                 }
             }
         }
     }
 }
开发者ID:,项目名称:,代码行数:29,代码来源:


注:本文中的Tinebase_Core::getApplicationInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。