コード例 #1
0
 /**
  * freebusy right/pref -> freebusy grant
  */
 public function update_1()
 {
     /**
      * old const from pref class
      * give all useraccounts grants to view free/busy of the account this preference is yes
      */
     $FREEBUSY = 'freeBusy';
     try {
         // get all users with freebusy pref
         $freebusyUserIds = Tinebase_Core::getPreference('Calendar')->getUsersWithPref($FREEBUSY, 1);
         // get all affected calendars
         $containerIds = array();
         foreach ($freebusyUserIds as $userId) {
             $containerIds = array_merge($containerIds, Tinebase_Container::getInstance()->getPersonalContainer($userId, 'Calendar', $userId, NULL, TRUE)->getId());
         }
         // grant freebusy to anyone for this calendars
         foreach ($containerIds as $containerId) {
             $containerGrants = Tinebase_Container::getInstance()->getGrantsOfContainer($containerId, TRUE);
             $anyoneGrant = $containerGrants->filter('account_type', Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE)->getFirstRecord();
             if (!$anyoneGrant) {
                 $anyoneGrant = new Tinebase_Model_Grants(array('account_id' => 0, 'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE));
                 $containerGrants->addRecord($anyoneGrant);
             }
             $anyoneGrant->{Tinebase_Model_Grants::GRANT_FREEBUSY} = TRUE;
             Tinebase_Container::getInstance()->setGrants($containerId, $containerGrants, TRUE, TRUE);
         }
         // drop freeBusy prefs from pref table
         $this->_db->delete(SQL_TABLE_PREFIX . 'preferences', "name LIKE 'freeBusy'");
     } catch (Tinebase_Exception_NotFound $nfe) {
         // pref was not found in system -> no user ever set freebusy -> nothing to do
     }
     $this->setApplicationVersion('Calendar', '3.2');
 }
コード例 #2
0
 public function printDocs()
 {
     // print payments which are debit returns and have flag print inquiry
     $resultData = array();
     $filters = array(array('field' => 'is_return_debit', 'operator' => 'equals', 'value' => '1'), array('field' => 'print_inquiry', 'operator' => 'equals', 'value' => '1'), array('field' => 'inquiry_print_date', 'operator' => 'isnull', 'value' => ''));
     $objFilter = new Billing_Model_PaymentFilter($filters, 'AND');
     $paymentIds = Billing_Controller_Payment::getInstance()->search($objFilter, null, null, true);
     foreach ($paymentIds as $paymentId) {
         $payment = Billing_Controller_Payment::getInstance()->get($paymentId);
         // get base payment
         $basePayment = $payment->getForeignRecordBreakNull('return_debit_base_payment_id', Billing_Controller_Payment::getInstance());
         if ($basePayment) {
             $batchJobDta = $basePayment->getForeignRecordBreakNull('batch_job_dta_id', Billing_Controller_BatchJobDta::getInstance());
             if ($batchJobDta) {
                 $bankAccount = Billing_Api_BankAccount::getFromBatchJobDta($batchJobDta);
                 $debitor = $payment->getForeignRecord('debitor_id', Billing_Controller_Debitor::getInstance());
                 $contact = $debitor->getForeignRecord('contact_id', Addressbook_Controller_Contact::getInstance());
                 $data = array();
                 $dummyTextBlocks = null;
                 $data = array_merge($data, Addressbook_Custom_Template::getContactData(array('contact' => $contact, 'user' => Tinebase_Core::get(Tinebase_Core::USER), 'userContact' => Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::get(Tinebase_Core::USER)->getId())), $dummyTextBlocks));
                 $data = array_merge($data, array('bank_name' => $bankAccount->getBank(), 'account_name' => $bankAccount->getName(), 'account_nr' => $bankAccount->getNumber(), 'bank_code' => $bankAccount->getBankCode()));
                 $resultData[$contact->__get('n_fileas')] = $data;
                 $payment->__set('inquiry_print_date', new Zend_Date());
                 Billing_Controller_Payment::getInstance()->update($payment);
             }
         }
     }
     $outputFileName = 'Ruecklastschrift-Nachforschung-' . strftime('%d-%m-%Y %H-%M-%S') . '.pdf';
     $templateId = Tinebase_Core::getPreference('Billing')->getValue(Billing_Preference::TEMPLATE_DEBIT_RETURN_INQUIRY);
     ksort($resultData);
     Billing_Controller_PrintJobRecordData::getInstance()->export($resultData, $templateId, $outputFileName);
 }
コード例 #3
0
 /**
  * update function (-> 3.2)
  * - check all users with 'userEmailAccount' and update their accounts / preferences
  */
 public function update_1()
 {
     // update account types for users with userEmailAccount preference
     $imapConfig = Tinebase_Config::getInstance()->getConfigAsArray(Tinebase_Config::IMAP);
     if (array_key_exists('host', $imapConfig)) {
         $accounts = Felamimail_Controller_Account::getInstance()->getAll();
         $accountBackend = new Felamimail_Backend_Account();
         foreach ($accounts as $account) {
             try {
                 if (Tinebase_Core::getPreference('Felamimail')->getValueForUser('userEmailAccount', $account->user_id)) {
                     $user = Tinebase_User::getInstance()->getFullUserById($account->user_id);
                     // account email == user->emailAddress && account->host == system account host -> type = system
                     if ($account->email == $user->accountEmailAddress && $account->host == $imapConfig['host']) {
                         $account->type = Felamimail_Model_Account::TYPE_SYSTEM;
                         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Switching to system account: ' . $account->name);
                         $accountBackend->update($account);
                     }
                 }
             } catch (Exception $e) {
                 // do nothing
             }
         }
     }
     // rename preference
     $this->_db->query('UPDATE ' . SQL_TABLE_PREFIX . "preferences SET name = 'useSystemAccount' WHERE name = 'userEmailAccount'");
     $this->setApplicationVersion('Felamimail', '3.2');
 }
コード例 #4
0
 /**
  * process the XML file and add, change, delete or fetches data 
  *
  * @return resource
  */
 public function handle()
 {
     $defaultAccountId = Tinebase_Core::getPreference('Felamimail')->{Felamimail_Preference::DEFAULTACCOUNT};
     try {
         $this->_account = Felamimail_Controller_Account::getInstance()->get($defaultAccountId);
     } catch (Tinebase_Exception_NotFound $ten) {
         if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . " no email account configured");
         }
         throw new ActiveSync_Exception('no email account configured');
     }
     if (empty(Tinebase_Core::getUser()->accountEmailAddress)) {
         throw new ActiveSync_Exception('no email address set for current user');
     }
     $this->_saveInSent = isset($_GET['SaveInSent']) && (bool) $_GET['SaveInSent'] == 'T';
     if (!is_resource($this->_inputStream)) {
         $this->_inputStream = fopen("php://input", 'r');
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         $debugStream = fopen("php://temp", 'r+');
         stream_copy_to_stream($this->_inputStream, $debugStream);
         rewind($debugStream);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " email to send:" . stream_get_contents($debugStream));
         }
         // replace original stream wirh debug stream, as php://input can't be rewinded
         $this->_inputStream = $debugStream;
         rewind($this->_inputStream);
     }
     $this->_incomingMessage = new Zend_Mail_Message(array('file' => $this->_inputStream));
 }
 /**
  * testGetTranslatedValue
  * 
  * @see 0008600: Fix fatal error in Calendar/Model/Event.php
  */
 public function testGetTranslatedValue()
 {
     $event = new Calendar_Model_Event(array('dtstart' => new Tinebase_DateTime('2011-11-23 14:25:00'), 'dtend' => new Tinebase_DateTime('2011-11-23 15:25:00'), 'summary' => 'test event', 'organizer' => Tinebase_Core::getUser()->contact_id));
     $translation = Tinebase_Translation::getTranslation('Calendar');
     $timezone = Tinebase_Core::getPreference()->getValueForUser(Tinebase_Preference::TIMEZONE, Tinebase_Core::getUser()->getId());
     $fileas = Calendar_Model_Event::getTranslatedValue('organizer', $event->organizer, $translation, $timezone);
     $userContact = Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::getUser()->getId());
     $this->assertEquals($userContact->n_fileas, $fileas);
 }
コード例 #6
0
ファイル: Export.php プロジェクト: carriercomm/Billing-5
 public function exportArticleSellList($data, $exportType)
 {
     $export = Billing_Custom_ArticleExportData::create($data);
     if ($export->hasNoGrouping() || $exportType == 'CSV') {
         $export->setRecordSet(Billing_Controller_ArticleSold::getInstance()->search($export->getFilter(), $export->getPagination()));
     } elseif ($export->hasGroupingCustomer()) {
         // get all customers
         // -> maybe a huge set
         // check restrictions of filter regarding customer (customer_group)
         /*	$debitorFilter = new Billing_Model_DebitorFilter(array(),'AND');
         			$debFilter = null;
         			$articleFilter = $export->getFilter();
         			
         			if($articleFilter->isFilterSet('debitor_id')){
         				$debFilter = $articleFilter->getFilter('debitor_id');
         				
         				if($debFilter->isFilterSet('id')){
         					$debitorFilter->addFilter($debFilter->get('id'));
         				}
         				
         				if($debFilter->isFilterSet('debitor_group_id')){
         					$debitorFilter->addFilter($debFilter->get('debitor_group_id'));
         				}
         			}*/
         $debitorIds = Billing_Controller_ArticleSold::getInstance()->getDebitorIds($export->getFilter());
         foreach ($debitorIds as $debitorId) {
             $debitor = Billing_Controller_Debitor::getInstance()->get($debitorId);
             $export->addCustomerRecordSet(Billing_Controller_ArticleSold::getInstance()->search($export->getCustomerFilter($debitor), $export->getPagination()), $debitorId);
         }
     }
     switch ($exportType) {
         case 'PDF':
             $outputFileName = 'Artikel-Verkaufsliste-' . strftime('%d-%m-%Y %H-%M-%S') . '.pdf';
             $templateId = Tinebase_Core::getPreference('Billing')->getValue(Billing_Preference::TEMPLATE_ARTICLE_SOLD);
             if ($export->hasGroupingCustomer()) {
                 $data = array();
                 $aResult = $export->customerRecordsToArray(true);
                 foreach ($aResult as $debitorId => $result) {
                     $debitor = Billing_Controller_Debitor::getInstance()->get($debitorId);
                     $contact = $debitor->getForeignRecord('contact_id', Addressbook_Controller_Contact::getInstance());
                     $data[$contact->__get('n_fileas')] = array('POS_TABLE' => $result['data'], 'customer_nr' => $debitor->__get('debitor_nr'), 'customer_name' => $contact->__get('n_fileas'), 'begin_date' => \org\sopen\app\util\format\Date::format(new Zend_Date($export->getStartDate())), 'end_date' => $export->getEndDate() ? \org\sopen\app\util\format\Date::format(new Zend_Date($export->getEndDate())) : 'heute', 'sum_total_netto' => number_format($result['total_netto'], 2, ',', '.'), 'sum_total_brutto' => number_format($result['total_brutto'], 2, ',', '.'));
                 }
                 ksort($data);
             } else {
                 $data = array(array('POS_TABLE' => $export->toArray(true), 'begin_date' => \org\sopen\app\util\format\Date::format(new Zend_Date($export->getStartDate())), 'end_date' => $export->getEndDate() ? \org\sopen\app\util\format\Date::format(new Zend_Date($export->getEndDate())) : 'heute', 'sum_total_netto' => number_format($export->getSumTotalNetto(), 2, ',', '.'), 'sum_total_brutto' => number_format($export->getSumTotalBrutto(), 2, ',', '.')));
             }
             Billing_Controller_PrintJobRecordData::getInstance()->export($data, $templateId, $outputFileName);
             break;
         case 'CSV':
             $this->exportAsCsv($export, 'Artikel-Verkaufsliste-' . strftime('%d-%m-%Y %H-%M-%S') . '.csv');
             break;
     }
 }
コード例 #7
0
 /**
  * set up tests
  *
  */
 public function setUp()
 {
     $this->_transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     $this->_backend = new Calendar_Backend_Sql();
     $this->_personas = Zend_Registry::get('personas');
     foreach ($this->_personas as $loginName => $user) {
         $defaultCalendarId = Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $user->getId());
         $this->_personasContacts[$loginName] = Addressbook_Controller_Contact::getInstance()->getContactByUserId($user->getId());
         $this->_personasDefaultCals[$loginName] = Tinebase_Container::getInstance()->getContainerById($defaultCalendarId);
     }
     $this->_testUser = Tinebase_Core::getUser();
     $this->_testUserContact = Addressbook_Controller_Contact::getInstance()->getContactByUserId($this->_testUser->getId());
     $this->_testCalendar = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => 'PHPUnit test calendar', 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => Tinebase_Core::getUser(), 'backend' => $this->_backend->getType(), 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId()), true));
     $this->_testCalendars = new Tinebase_Record_RecordSet('Tinebase_Model_Container');
     $this->_testCalendars->addRecord($this->_testCalendar);
 }
 /**
  * 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));
 }
コード例 #9
0
 /**
  * process the XML file and add, change, delete or fetches data 
  *
  * @return resource
  */
 public function handle()
 {
     $defaultAccountId = Tinebase_Core::getPreference('Felamimail')->{Felamimail_Preference::DEFAULTACCOUNT};
     try {
         $this->_account = Felamimail_Controller_Account::getInstance()->get($defaultAccountId);
     } catch (Tinebase_Exception_NotFound $ten) {
         if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . " no email account configured");
         }
         throw new ActiveSync_Exception('no email account configured');
     }
     list($this->_messageId, $this->_partId) = explode('-', $_GET['AttachmentName'], 2);
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " messageId: " . $this->_messageId . ' partId: ' . $this->_partId);
     }
 }
コード例 #10
0
 public function getMonitionStage()
 {
     $monitionStage1Days = (int) Tinebase_Core::getPreference('Billing')->getValue(Billing_Preference::MONITION_STAGE1);
     $monitionStage2Days = (int) Tinebase_Core::getPreference('Billing')->getValue(Billing_Preference::MONITION_STAGE2);
     $monitionStage3Days = (int) Tinebase_Core::getPreference('Billing')->getValue(Billing_Preference::MONITION_STAGE3);
     $dueDays = $this->__get('due_days');
     if ($monitionStage3Days < $dueDays) {
         return 3;
     }
     if ($monitionStage2Days < $dueDays) {
         return 2;
     }
     if ($monitionStage1Days < $dueDays) {
         return 1;
     }
     return 0;
 }
コード例 #11
0
 /**
  * testCreateEvent
  */
 public function testCreateEvent()
 {
     $scleverDisplayContainerId = Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $this->_personas['sclever']->getId());
     $contentSeqBefore = Tinebase_Container::getInstance()->getContentSequence($scleverDisplayContainerId);
     $eventData = $this->_getEvent()->toArray();
     $tag = Tinebase_Tags::getInstance()->createTag(new Tinebase_Model_Tag(array('name' => 'phpunit-' . substr(Tinebase_Record_Abstract::generateUID(), 0, 10), 'type' => Tinebase_Model_Tag::TYPE_PERSONAL)));
     $eventData['tags'] = array($tag->toArray());
     $note = new Tinebase_Model_Note(array('note' => 'very important note!', 'note_type_id' => Tinebase_Notes::getInstance()->getNoteTypes()->getFirstRecord()->getId()));
     $eventData['notes'] = array($note->toArray());
     $persistentEventData = $this->_uit->saveEvent($eventData);
     $loadedEventData = $this->_uit->getEvent($persistentEventData['id']);
     $this->_assertJsonEvent($eventData, $loadedEventData, 'failed to create/load event');
     $contentSeqAfter = Tinebase_Container::getInstance()->getContentSequence($scleverDisplayContainerId);
     $this->assertEquals($contentSeqBefore + 1, $contentSeqAfter, 'content sequence of display container should be increased by 1:' . $contentSeqAfter);
     $this->assertEquals($contentSeqAfter, Tinebase_Container::getInstance()->get($scleverDisplayContainerId)->content_seq);
     return $loadedEventData;
 }
コード例 #12
0
 /**
  * (non-PHPdoc)
  * @see Sabre_DAVACL_IPrincipalBackend::getPrincipalByPath()
  */
 public function getPrincipalByPath($path)
 {
     $principal = array('uri' => 'principals/users/' . Tinebase_Core::getUser()->contact_id, '{DAV:}displayname' => Tinebase_Core::getUser()->accountDisplayName);
     if (!empty(Tinebase_Core::getUser()->accountEmailAddress)) {
         $principal['{http://sabredav.org/ns}email-address'] = Tinebase_Core::getUser()->accountEmailAddress;
     }
     if (Tinebase_Core::getUser()->hasRight('Calendar', Tinebase_Acl_Rights::RUN)) {
         try {
             $defaultCalendar = Tinebase_Core::getPreference('Calendar')->getValue(Calendar_Preference::DEFAULTCALENDAR);
             $principal['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}schedule-inbox-URL'] = $defaultCalendar;
             $principal['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}schedule-outbox-URL'] = $defaultCalendar;
         } catch (Tinebase_Exception_NotFound $tenf) {
             if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
                 Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' no default calendar found');
             }
         }
     }
     return $principal;
 }
コード例 #13
0
 /**
  * update to 1.2
  * - add window style
  */
 public function update_1()
 {
     // add window type preference
     $windowStylePref = new Tinebase_Model_Preference(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Tinebase')->getId(), 'name' => Tinebase_Preference::WINDOW_TYPE, 'value' => 'Browser', 'account_id' => 0, 'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE, 'type' => Tinebase_Model_Preference::TYPE_DEFAULT, 'options' => '<?xml version="1.0" encoding="UTF-8"?>
             <options>
                 <option>
                     <label>ExtJs style</label>
                     <value>Ext</value>
                 </option>
                 <option>
                     <label>Browser style</label>
                     <value>Browser</value>
                 </option>
             </options>'));
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . print_r($windowStylePref->toArray(), TRUE));
     }
     Tinebase_Core::getPreference()->create($windowStylePref);
     $this->setApplicationVersion('Tinebase', '1.2');
 }
コード例 #14
0
 /**
  * event handler function
  * 
  * all events get routed through this function
  *
  * @param Tinebase_Event_Abstract $_eventObject the eventObject
  */
 protected function _handleEvent(Tinebase_Event_Abstract $_eventObject)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . ' (' . __LINE__ . ') handle event of type ' . get_class($_eventObject));
     }
     switch (get_class($_eventObject)) {
         case 'Admin_Event_AddAccount':
             //$this->createPersonalFolder($_eventObject->account);
             Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $_eventObject->account->getId());
             break;
         case 'Tinebase_Event_User_DeleteAccount':
             /**
              * @var Tinebase_Event_User_DeleteAccount $_eventObject
              */
             $this->_handleDeleteUserEvent($_eventObject);
             // let event bubble
             parent::_handleEvent($_eventObject);
             break;
         case 'Admin_Event_UpdateGroup':
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . ' (' . __LINE__ . ') updated group ' . $_eventObject->group->name);
             }
             Tinebase_ActionQueue::getInstance()->queueAction('Calendar.onUpdateGroup', $_eventObject->group->getId());
             break;
         case 'Admin_Event_AddGroupMember':
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . ' (' . __LINE__ . ') add groupmember ' . (string) $_eventObject->userId . ' to group ' . (string) $_eventObject->groupId);
             }
             Tinebase_ActionQueue::getInstance()->queueAction('Calendar.onUpdateGroup', $_eventObject->groupId);
             break;
         case 'Admin_Event_RemoveGroupMember':
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . ' (' . __LINE__ . ') removed groupmember ' . (string) $_eventObject->userId . ' from group ' . (string) $_eventObject->groupId);
             }
             Tinebase_ActionQueue::getInstance()->queueAction('Calendar.onUpdateGroup', $_eventObject->groupId);
             break;
         case 'Tinebase_Event_Container_BeforeCreate':
             $this->_handleContainerBeforeCreateEvent($_eventObject);
             break;
     }
 }
コード例 #15
0
 /**
  * parse FolderUpdate request
  *
  */
 public function handle()
 {
     $xml = simplexml_import_dom($this->_inputDom);
     $this->_syncKey = (int) $xml->SyncKey;
     $this->_parentId = (string) $xml->ParentId;
     $this->_displayName = (string) $xml->DisplayName;
     $this->_serverId = (string) $xml->ServerId;
     if ($this->_logger instanceof Zend_Log) {
         $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " synckey is {$this->_syncKey} parentId {$this->_parentId} name {$this->_displayName}");
     }
     $defaultAccountId = Tinebase_Core::getPreference('Felamimail')->{Felamimail_Preference::DEFAULTACCOUNT};
     $this->_syncState = $this->_syncStateBackend->validate($this->_device, 'FolderSync', $this->_syncKey);
     try {
         $this->_folder = $this->_folderBackend->getFolder($this->_device, $this->_serverId);
         $dataController = Syncope_Data_Factory::factory($this->_folder->class, $this->_device, $this->_syncTimeStamp);
         $felamimail_model_folder = Felamimail_Controller_Folder::getInstance()->get($this->_folder->folderid);
         $dataController->updateFolder($defaultAccountId, trim($this->_displayName), $felamimail_model_folder['globalname']);
         $this->_folderBackend->update($this->_folder);
     } catch (Syncope_Exception_NotFound $senf) {
         if ($this->_logger instanceof Zend_Log) {
             $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " " . $senf->getMessage());
         }
     }
 }
 public function testUpdateEntriesIPhone()
 {
     $syncrotonFolder = $this->testCreateFolder();
     $syncrotonFolder2 = $this->testCreateFolder();
     //make $syncrotonFolder2 the default
     Tinebase_Core::getPreference('Calendar')->setValue(Calendar_Preference::DEFAULTCALENDAR, $syncrotonFolder2->serverId);
     $controller = Syncroton_Data_Factory::factory($this->_class, $this->_getDevice(Syncroton_Model_Device::TYPE_IPHONE), Tinebase_DateTime::now());
     list($serverId, $syncrotonEvent) = $this->testCreateEntry($syncrotonFolder);
     $event = Calendar_Controller_Event::getInstance()->get($serverId);
     unset($syncrotonEvent->recurrence);
     unset($syncrotonEvent->exceptions);
     unset($syncrotonEvent->attendees);
     // need to create new controller to set new sync timestamp for concurrency handling
     $syncTimestamp = Calendar_Controller_Event::getInstance()->get($serverId)->last_modified_time;
     $controller = Syncroton_Data_Factory::factory($this->_class, $this->_getDevice(Syncroton_Model_Device::TYPE_IPHONE), $syncTimestamp);
     $serverId = $controller->updateEntry($syncrotonFolder->serverId, $serverId, $syncrotonEvent);
     $syncrotonEvent = $controller->getEntry(new Syncroton_Model_SyncCollection(array('collectionId' => $syncrotonFolder->serverId)), $serverId);
     $updatedEvent = Calendar_Controller_Event::getInstance()->get($serverId);
     $this->assertEmpty($syncrotonEvent->attendees, 'Events attendees found in folder which is not the default calendar');
     $this->assertNotEmpty($updatedEvent->attendee, 'attendee must be preserved');
     $this->assertEquals($event->attendee[0]->getId(), $updatedEvent->attendee[0]->getId(), 'attendee must be perserved');
     return;
     list($serverId, $syncrotonEvent) = $this->testCreateEntry($syncrotonFolder2);
     unset($syncrotonEvent->recurrence);
     unset($syncrotonEvent->exceptions);
     $syncrotonEvent->attendees[0]->name = Tinebase_Record_Abstract::generateUID();
     // need to create new controller to set new sync timestamp for concurrency handling
     $syncTimestamp = Calendar_Controller_Event::getInstance()->get($serverId)->last_modified_time;
     $controller = Syncroton_Data_Factory::factory($this->_class, $this->_getDevice(Syncroton_Model_Device::TYPE_IPHONE), $syncTimestamp);
     $serverId = $controller->updateEntry($syncrotonFolder2->serverId, $serverId, $syncrotonEvent);
     $syncrotonEvent = $controller->getEntry(new Syncroton_Model_SyncCollection(array('collectionId' => $syncrotonFolder2->serverId)), $serverId);
     $this->assertNotEmpty($syncrotonEvent->attendees, 'Events attendees not found in default calendar');
 }
コード例 #17
0
 /**
  * @see Tinebase_Setup_DemoData_Abstract
  */
 protected function _onCreate()
 {
     $currentUser = Tinebase_Core::getUser();
     $this->_getDays();
     $this->_sharedTaskContainer = $this->_createSharedContainer('Tasks aus Leads', array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Tasks')->getId()), false);
     $fe = new Tinebase_Frontend_Json();
     $fe->savePreferences(array("Tasks" => array("defaultTaskList" => array('value' => $this->_sharedTaskContainer->getId()), "defaultpersistentfilter" => array('value' => '_default_'))), true);
     foreach ($this->_personas as $loginName => $persona) {
         $this->_containers[$loginName] = Tinebase_Container::getInstance()->getContainerById(Tinebase_Core::getPreference('Crm')->getValueForUser(Crm_Preference::DEFAULTLEADLIST, $persona->getId()));
         Tinebase_Container::getInstance()->addGrants($this->_containers[$loginName]->getId(), 'user', $this->_personas['sclever']->getId(), $this->_secretaryGrants, true);
         Tinebase_Container::getInstance()->addGrants($this->_containers[$loginName]->getId(), 'user', $this->_personas['rwright']->getId(), $this->_controllerGrants, true);
     }
 }
コード例 #18
0
 /**
  * @see Tinebase_Setup_DemoData_Abstract
  */
 protected function _onCreate()
 {
     $this->_getDays();
     foreach ($this->_personas as $loginName => $persona) {
         $this->_calendars[$loginName] = Tinebase_Container::getInstance()->getContainerById(Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $persona->getId()));
         Tinebase_Container::getInstance()->addGrants($this->_calendars[$loginName]->getId(), 'user', $this->_personas['sclever']->getId(), $this->_secretaryGrants, true);
         Tinebase_Container::getInstance()->addGrants($this->_calendars[$loginName]->getId(), 'user', $this->_personas['rwright']->getId(), $this->_controllerGrants, true);
     }
 }
コード例 #19
0
 /**
  * gets the personal container of given user
  * 
  * @param  string $userId
  * @return Tinebase_Model_Container
  */
 public function getPersonalContainer($userId)
 {
     if (!(isset($this->_personalContainerCache[$userId]) || array_key_exists($userId, $this->_personalContainerCache))) {
         // get container by preference to ensure its the default personal
         $defaultContainerId = Tinebase_Core::getPreference($this->getApplication()->name)->getValueForUser($this->_defaultContainerConfigProperty, $userId, Tinebase_Acl_Rights::ACCOUNT_TYPE_USER);
         $container = Tinebase_Container::getInstance()->getContainerById($defaultContainerId);
         // detect if container just got created
         $isNewContainer = false;
         if ($container->creation_time instanceof DateTime) {
             $isNewContainer = $this->_migrationStartTime->isEarlier($container->creation_time);
         }
         if ($isNewContainer && $this->_config->setPersonalContainerGrants || $this->_config->forcePersonalContainerGrants) {
             // resolve grants based on user/groupmemberships
             $grants = $this->getGrantsByOwner($this->getApplication()->name, $userId);
             Tinebase_Container::getInstance()->setGrants($container->getId(), $grants, TRUE);
         }
         $this->_personalContainerCache[$userId] = $container;
     }
     return $this->_personalContainerCache[$userId];
 }
コード例 #20
0
 /**
  * Returns registry data of the calendar.
  *
  * @return mixed array 'variable name' => 'data'
  * 
  * @todo move exception handling (no default calender found) to another place?
  */
 public function getRegistryData()
 {
     $defaultCalendarId = Tinebase_Core::getPreference('Calendar')->getValue(Calendar_Preference::DEFAULTCALENDAR);
     try {
         $defaultCalendarArray = Tinebase_Container::getInstance()->getContainerById($defaultCalendarId)->toArray();
         $defaultCalendarArray['account_grants'] = Tinebase_Container::getInstance()->getGrantsOfAccount(Tinebase_Core::getUser(), $defaultCalendarId)->toArray();
         $defaultCalendarArray['ownerContact'] = Addressbook_Controller_Contact::getInstance()->getContactByUserId($defaultCalendarArray['owner_id'])->toArray();
     } catch (Exception $e) {
         // remove default cal pref
         Tinebase_Core::getPreference('Calendar')->deleteUserPref(Calendar_Preference::DEFAULTCALENDAR);
         $defaultCalendarArray = array();
     }
     $importDefinitions = $this->_getImportDefinitions();
     $registryData = array('defaultContainer' => $defaultCalendarArray, 'defaultImportDefinition' => $importDefinitions['default'], 'importDefinitions' => $importDefinitions);
     return $registryData;
 }
コード例 #21
0
 /**
  * Toogles advanced search preference
  *
  * @param $state
  * @return true
  */
 public function toogleAdvancedSearch($state)
 {
     Tinebase_Core::getPreference()->setValue(Tinebase_Preference::ADVANCED_SEARCH, (int) $state);
     return $state == Tinebase_Core::getPreference()->getValue(Tinebase_Preference::ADVANCED_SEARCH, 0);
 }
コード例 #22
0
 /**
  * returns multiple records prepared for json transport
  *
  * @param Tinebase_Record_RecordSet $_records Tinebase_Record_Abstract
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @return array data
  */
 protected function _multipleRecordsToJson(Tinebase_Record_RecordSet $_records, $_filter = NULL)
 {
     if (count($_records) == 0) {
         return array();
     }
     switch ($_records->getRecordClassName()) {
         case 'Tinebase_Model_Preference':
             $accountFilterArray = $_filter->getFilter('account')->toArray();
             $adminMode = $accountFilterArray['value']['accountId'] == 0 && $accountFilterArray['value']['accountType'] == Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE;
             foreach ($_records as $record) {
                 if (!isset($app) || $record->application_id != $app->getId()) {
                     $app = Tinebase_Application::getInstance()->getApplicationById($record->application_id);
                 }
                 $preference = Tinebase_Core::getPreference($app->name, TRUE);
                 $preference->resolveOptions($record);
                 if ($record->type == Tinebase_Model_Preference::TYPE_DEFAULT || !$adminMode && $record->type == Tinebase_Model_Preference::TYPE_ADMIN) {
                     $record->value = Tinebase_Model_Preference::DEFAULT_VALUE;
                 }
             }
             break;
     }
     $result = parent::_multipleRecordsToJson($_records, $_filter);
     return $result;
 }
コード例 #23
0
 /**
  * try to export Timesheets (as ods)
  */
 public function testExportTimesheetsOds()
 {
     Tinebase_Core::getPreference('Timetracker')->setValue(Timetracker_Preference::TSODSEXPORTCONFIG, 'ts_default_ods');
     $this->_exportTsOds();
 }
コード例 #24
0
 /**
  * testTeacherDefaultFavorite
  * 
  * @see 0006876: create "my course" default favorite for new teachers
  */
 public function testTeacherDefaultFavorite()
 {
     $course = $this->_getCourseData();
     $courseData = $this->_json->saveCourse($course);
     $this->_groupsToDelete->addRecord(Tinebase_Group::getInstance()->getGroupById($courseData['group_id']));
     $teacher = Tinebase_User::getInstance()->getFullUserById($courseData['members'][0]['id']);
     $filter = Tinebase_PersistentFilter::getInstance()->getFilterById(Tinebase_Core::getPreference('Courses')->getValueForUser(Courses_Preference::DEFAULTPERSISTENTFILTER, $teacher->getId()));
     $this->assertEquals(array(array('field' => 'name', 'operator' => 'equals', 'value' => $course['name'])), $filter->toArray());
 }
コード例 #25
0
 /**
  * testAdvancedSearch in related products
  * 
  * @see 0010814: quicksearch should search in related records
  */
 public function testAdvancedSearchInProduct()
 {
     Tinebase_Core::getPreference()->setValue(Tinebase_Preference::ADVANCED_SEARCH, true);
     $this->_saveLead();
     $filter = array(array('field' => 'query', 'operator' => 'contains', 'value' => 'PHPUnit test product'));
     $searchLeads = $this->_instance->searchLeads($filter, '');
     $this->assertEquals(1, $searchLeads['totalcount']);
 }
コード例 #26
0
ファイル: Account.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * add system account with tine user credentials (from config.inc.php or config db) 
  *
  * @param Tinebase_Record_RecordSet $_accounts of Felamimail_Model_Account
  */
 protected function _addSystemAccount(Tinebase_Record_RecordSet $_accounts)
 {
     $userId = $this->_currentAccount->getId();
     $fullUser = Tinebase_User::getInstance()->getFullUserById($userId);
     $email = $this->_getAccountEmail($fullUser);
     // only create account if email address is set
     if ($email) {
         $systemAccount = new Felamimail_Model_Account(NULL, TRUE);
         $this->_addSystemAccountConfigValues($systemAccount);
         $systemAccount->type = Felamimail_Model_Account::TYPE_SYSTEM;
         $systemAccount->user_id = $userId;
         $this->_addUserValues($systemAccount, $fullUser, $email);
         $this->_addFolderDefaults($systemAccount, TRUE);
         // create new account and update capabilities
         Tinebase_Timemachine_ModificationLog::setRecordMetaData($systemAccount, 'create');
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($systemAccount->toArray(), TRUE));
         }
         $systemAccount = $this->_backend->create($systemAccount);
         $_accounts->addRecord($systemAccount);
         $this->_addedDefaultAccount = TRUE;
         // set as default account preference
         Tinebase_Core::getPreference($this->_applicationName)->{Felamimail_Preference::DEFAULTACCOUNT} = $systemAccount->getId();
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Created new system account "' . $systemAccount->name . '".');
     } else {
         Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Could not create system account for user ' . $fullUser->accountLoginName . '. No email address given.');
     }
 }
コード例 #27
0
 /**
  * initialize user (session, locale, tz)
  * 
  * @param Tinebase_Model_FullUser $_user
  * @param boolean $fixCookieHeader
  */
 public function initUser(Tinebase_Model_FullUser $_user, $fixCookieHeader = true)
 {
     Tinebase_Core::set(Tinebase_Core::USER, $_user);
     if (Tinebase_Session_Abstract::getSessionEnabled()) {
         $this->_initUserSession($fixCookieHeader);
     }
     // need to set locale again and because locale might not be set correctly during loginFromPost
     // use 'auto' setting because it is fetched from cookie or preference then
     Tinebase_Core::setupUserLocale('auto');
     // need to set userTimeZone again
     $userTimezone = Tinebase_Core::getPreference()->getValue(Tinebase_Preference::TIMEZONE);
     Tinebase_Core::setupUserTimezone($userTimezone);
 }
 /**
  * (non-PHPdoc)
  * @see ActiveSync_Frontend_Abstract::_addContainerFilter()
  */
 protected function _addContainerFilter(Tinebase_Model_Filter_FilterGroup $_filter, $_containerId)
 {
     // custom filter gets added when created
     $_filter->createFilter('account_id', 'equals', Tinebase_Core::getPreference('Expressomail')->{Expressomail_Preference::DEFAULTACCOUNT});
     $_filter->addFilter($_filter->createFilter('folder_id', 'equals', $_containerId));
 }
コード例 #29
0
 /**
  * extract values from folder filter
  *
  * @param Felamimail_Model_FolderFilter $_filter
  * @return array (assoc) with filter values
  * 
  * @todo add AND/OR conditions for multiple filters of the same field?
  */
 protected function _extractFilter(Felamimail_Model_FolderFilter $_filter)
 {
     $result = array('account_id' => Tinebase_Core::getPreference('Felamimail')->{Felamimail_Preference::DEFAULTACCOUNT}, 'globalname' => '');
     $filters = $_filter->getFilterObjects();
     foreach ($filters as $filter) {
         switch ($filter->getField()) {
             case 'account_id':
                 $result['account_id'] = $filter->getValue();
                 break;
             case 'globalname':
                 $result['globalname'] = $filter->getValue();
                 break;
         }
     }
     return $result;
 }
コード例 #30
0
 /**
  * NOTE: calendarFilter is based on contentFilter for ActiveSync
  *
  * @param $folderId
  */
 protected function _assertContentControllerParams($folderId)
 {
     try {
         $container = Tinebase_Container::getInstance()->getContainerById($folderId);
     } catch (Exception $e) {
         $containerId = Tinebase_Core::getPreference('ActiveSync')->{$this->_defaultFolder};
         $container = Tinebase_Container::getInstance()->getContainerById($containerId);
     }
     Calendar_Controller_MSEventFacade::getInstance()->assertEventFacadeParams($container, false);
 }