/**
  * @param Zend_Console_Getopt $_opts
  * @return boolean success
  */
 public function rebuildPaths($opts)
 {
     if (!$this->_checkAdminRight()) {
         return -1;
     }
     $applications = Tinebase_Application::getInstance()->getApplications();
     foreach ($applications as $application) {
         try {
             $app = Tinebase_Core::getApplicationInstance($application, '', true);
         } catch (Tinebase_Exception_NotFound $tenf) {
             continue;
         }
         if (!$app instanceof Tinebase_Controller_Abstract) {
             continue;
         }
         $pathModels = $app->getModelsUsingPaths();
         if (!is_array($pathModels)) {
             $pathModels = array();
         }
         foreach ($pathModels as $pathModel) {
             $controller = Tinebase_Core::getApplicationInstance($pathModel, '', true);
             $_filter = $pathModel . 'Filter';
             $_filter = new $_filter();
             $iterator = new Tinebase_Record_Iterator(array('iteratable' => $this, 'controller' => $controller, 'filter' => $_filter, 'options' => array('getRelations' => true), 'function' => 'rebuildPathsIteration'));
             $result = $iterator->iterate($controller);
             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                 if (false === $result) {
                     $result['totalcount'] = 0;
                 }
                 Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Build paths for ' . $result['totalcount'] . ' records of ' . $pathModel);
             }
         }
     }
 }
 /**
  * create system groups for addressbook lists that dont have a system group
  *
  * @param $_opts
  */
 public function createSystemGroupsForAddressbookLists($_opts)
 {
     $_filter = new Addressbook_Model_ListFilter();
     $iterator = new Tinebase_Record_Iterator(array('iteratable' => $this, 'controller' => Addressbook_Controller_List::getInstance(), 'filter' => $_filter, 'options' => array('getRelations' => false), 'function' => 'iterateAddressbookLists'));
     $result = $iterator->iterate();
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         if (false === $result) {
             $result['totalcount'] = 0;
         }
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Worked on ' . $result['totalcount'] . ' lists');
     }
 }
 /**
  * move messages to folder
  *
  * @param  mixed  $_messages
  * @param  mixed  $_targetFolder can be one of: folder_id, Expressomail_Model_Folder or Expressomail_Model_Folder::FOLDER_TRASH (constant)
  * @return Tinebase_Record_RecordSet of Expressomail_Model_Folder
  */
 public function moveMessages($_messages, $_targetFolder)
 {
     if ($_targetFolder !== Expressomail_Model_Folder::FOLDER_TRASH) {
         $targetFolder = $_targetFolder instanceof Expressomail_Model_Folder ? $_targetFolder : Expressomail_Controller_Folder::getInstance()->get($_targetFolder);
     } else {
         $targetFolder = $_targetFolder;
     }
     if ($_messages instanceof Tinebase_Model_Filter_FilterGroup) {
         $iterator = new Tinebase_Record_Iterator(array('iteratable' => $this, 'controller' => $this, 'filter' => $_messages, 'function' => 'processMoveIteration'));
         $iterateResult = $iterator->iterate($targetFolder);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Moved ' . $iterateResult['totalcount'] . ' message(s).');
         }
         // @todo return all results?
         $result = !empty($iterateResult['results']) ? array_pop($iterateResult['results']) : new Tinebase_Record_RecordSet('Expressomail_Model_Folder');
     } else {
         $messages = $this->_convertToRecordSet($_messages, TRUE);
         $result = $this->processMoveIteration($messages, $targetFolder);
     }
     return $result;
 }
 /**
  * creates the auto invoices, gets called by cli
  * 
  * @param Tinebase_DateTime $currentDate
  * @param Sales_Model_Contract $contract
  * @param boolean $merge
  */
 public function createAutoInvoices(Tinebase_DateTime $currentDate, Sales_Model_Contract $contract = NULL, $merge = false)
 {
     $this->_autoInvoiceIterationResults = array();
     $this->_autoInvoiceIterationDetailResults = array();
     $this->_autoInvoiceIterationFailures = array();
     $contractBackend = new Sales_Backend_Contract();
     $ids = $contract ? array($contract->getId()) : $contractBackend->getBillableContractIds($currentDate);
     $filter = new Sales_Model_ContractFilter(array());
     $filter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'id', 'operator' => 'in', 'value' => $ids)));
     $iterator = new Tinebase_Record_Iterator(array('iteratable' => $this, 'controller' => Sales_Controller_Contract::getInstance(), 'filter' => $filter, 'options' => array('getRelations' => TRUE, 'limit' => $this->_autoInvoiceIterationLimit), 'function' => 'processAutoInvoiceIteration'));
     $iterator->iterate($currentDate, $merge);
     unset($this->_autoInvoiceIterationDetailResults);
     $result = array('failures' => $this->_autoInvoiceIterationFailures, 'failures_count' => count($this->_autoInvoiceIterationFailures), 'created' => $this->_autoInvoiceIterationResults, 'created_count' => count($this->_autoInvoiceIterationResults));
     return $result;
 }
 /**
  * updates last autobill of product aggregates
  *
  * @param boolen $update
  */
 public function updateLastAutobillOfProductAggregates()
 {
     $filter = new Sales_Model_ContractFilter(array());
     $iterator = new Tinebase_Record_Iterator(array('iteratable' => $this, 'controller' => Sales_Controller_Contract::getInstance(), 'filter' => $filter, 'options' => array('getRelations' => TRUE, 'limit' => 20), 'function' => 'processUpdateLastAutobillOfProductAggregates'));
     $iterator->iterate();
 }
 /**
  * update multiple records
  *
  * @param   Tinebase_Model_Filter_FilterGroup $_filter
  * @param   array $_data
  * @return  integer number of updated records
  * 
  * @todo add param $_returnFullResults (if false, do not return updated records in 'results')
  */
 public function updateMultiple($_filter, $_data)
 {
     $this->_checkRight('update');
     $this->checkFilterACL($_filter, 'update');
     $getRelations = false;
     $this->_newRelations = NULL;
     $this->_removeRelations = NULL;
     foreach ($_data as $key => $value) {
         if (stristr($key, '#')) {
             $_data['customfields'][substr($key, 1)] = $value;
             unset($_data[$key]);
         }
         if (stristr($key, '%')) {
             $getRelations = true;
             $this->_handleRelationsOnUpdateMultiple($key, $value);
             unset($_data[$key]);
         }
     }
     $this->_updateMultipleResult = array('results' => new Tinebase_Record_RecordSet($this->_modelName), 'exceptions' => new Tinebase_Record_RecordSet('Tinebase_Model_UpdateMultipleException'), 'totalcount' => 0, 'failcount' => 0);
     $iterator = new Tinebase_Record_Iterator(array('iteratable' => $this, 'controller' => $this, 'filter' => $_filter, 'options' => array('getRelations' => $getRelations), 'function' => 'processUpdateMultipleIteration'));
     $result = $iterator->iterate($_data);
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Updated ' . $this->_updateMultipleResult['totalcount'] . ' records.');
     }
     if ($this->_clearCustomFieldsCache) {
         Tinebase_Core::getCache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('customfields'));
     }
     return $this->_updateMultipleResult;
 }
예제 #7
0
 /**
  * update multiple records
  *
  * @param   Tinebase_Model_Filter_FilterGroup $_filter
  * @param   array $_data
  * @return  integer number of updated records
  * 
  * @todo add param $_returnFullResults (if false, do not return updated records in 'results')
  */
 public function updateMultiple($_filter, $_data)
 {
     $this->_checkRight('update');
     $this->checkFilterACL($_filter, 'update');
     foreach ($_data as $key => $value) {
         if (stristr($key, '#')) {
             $_data['customfields'][substr($key, 1)] = $value;
             unset($_data[$key]);
         }
     }
     $this->_updateMultipleResult = array('results' => new Tinebase_Record_RecordSet($this->_modelName), 'exceptions' => new Tinebase_Record_RecordSet('Tinebase_Model_UpdateMultipleException'), 'totalcount' => 0, 'failcount' => 0);
     $iterator = new Tinebase_Record_Iterator(array('iteratable' => $this, 'controller' => $this, 'filter' => $_filter, 'function' => 'processUpdateMultipleIteration'));
     $result = $iterator->iterate($_data);
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Updated ' . $this->_updateMultipleResult['totalcount'] . ' records.');
     }
     return $this->_updateMultipleResult;
 }
예제 #8
0
 /**
  * export records
  */
 protected function _exportRecords()
 {
     $iterator = new Tinebase_Record_Iterator(array('iteratable' => $this, 'controller' => $this->_controller, 'filter' => $this->_filter, 'options' => array('searchAction' => 'export', 'sortInfo' => $this->_sortInfo, 'getRelations' => $this->_getRelations)));
     $result = $iterator->iterate();
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Exported ' . $result['totalcount'] . ' records.');
     }
 }
 /**
  * export records
  */
 protected function _exportRecords()
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Starting export of ' . $this->_modelName . ' with filter: ' . print_r($this->_filter->toArray(), true) . ' and sort info: ' . print_r($this->_sortInfo, true));
     }
     $iterator = new Tinebase_Record_Iterator(array('iteratable' => $this, 'controller' => $this->_controller, 'filter' => $this->_filter, 'options' => array('searchAction' => 'export', 'sortInfo' => $this->_sortInfo, 'getRelations' => $this->_getRelations)));
     $result = $iterator->iterate();
     $this->_onAfterExportRecords($result);
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Exported ' . $result['totalcount'] . ' records.');
     }
 }