/**
  * convert objects with user data to ldap data array
  * 
  * @param Tinebase_Model_FullUser  $_user
  * @param array                    $_ldapData  the data to be written to ldap
  */
 protected function _group2ldap(Tinebase_Model_Group $_group, array &$_ldapData)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ENCRYPT ' . print_r($_ldapData, true));
     }
     if (isset($_ldapData['objectclass'])) {
         $_ldapData['objectclass'] = array_unique(array_merge($_ldapData['objectclass'], $this->_requiredObjectClass));
     }
     if (isset($_ldapData['gidnumber'])) {
         $gidNumber = $_ldapData['gidnumber'];
     } else {
         $gidNumber = $this->_getGidNumber($_group->getId());
     }
     // when we try to add a group, $_group has no id which leads to Tinebase_Exception_InvalidArgument in $this->_getGroupMetaData
     try {
         $metaData = $this->_getGroupMetaData($_group);
     } catch (Tinebase_Exception_InvalidArgument $teia) {
         $metaData = array();
     }
     if (!isset($metaData['sambasid'])) {
         $_ldapData['sambasid'] = $this->_options[Tinebase_Group_Ldap::PLUGIN_SAMBA]['sid'] . '-' . (2 * $gidNumber + 1001);
         $_ldapData['sambagrouptype'] = 2;
     }
     $_ldapData['displayname'] = $_group->name;
 }
 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);
 }
 /**
  * calls Timetracker_Controller_Timesheet::findTimesheetsByTimeaccountAndPeriod arguments suitable for async job
  * returns true if cache could be saved.
  * 
  * @param array $args
  * @return boolean
  */
 public function findTimesheetsForReport(array $args)
 {
     $cache = Tinebase_Core::getCache();
     $results = Timetracker_Controller_Timesheet::getInstance()->findTimesheetsByTimeaccountAndPeriod($args['timeaccountId'], $args['startDate'], $args['endDate'], $args['destination'], $args['taCostCenter']);
     $m = str_replace('-', '', $args['month']);
     return $cache->save(array('results' => $results), $args['cacheId'], array($args['cacheId'] . '_' . $m));
 }
Example #4
0
 /**
  * the constructor
  *
  * don't use the constructor. use the singleton 
  */
 private function __construct()
 {
     $this->_applicationName = 'Sales';
     $this->_backend = new Sales_Backend_Contract();
     $this->_modelName = 'Sales_Model_Contract';
     $this->_currentAccount = Tinebase_Core::getUser();
 }
 /**
  * Sets up the fixture.
  * 
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     // we need that because the voip db tables can have a different prefix
     Tinebase_Core::set('voipdbTablePrefix', SQL_TABLE_PREFIX);
     $phoneId = Tinebase_Record_Abstract::generateUID();
     $this->_objects['location'] = new Voipmanager_Model_Snom_Location(array('id' => Tinebase_Record_Abstract::generateUID(), 'name' => 'phpunit test location', 'registrar' => 'registrar'));
     $this->_objects['software'] = new Voipmanager_Model_Snom_Software(array('id' => Tinebase_Record_Abstract::generateUID()));
     $this->_objects['setting'] = new Voipmanager_Model_Snom_Setting(array('id' => Tinebase_Record_Abstract::generateUID(), 'name' => Tinebase_Record_Abstract::generateUID(), 'description' => Tinebase_Record_Abstract::generateUID(), 'language_w' => true));
     $this->_objects['phonesettings'] = new Voipmanager_Model_Snom_PhoneSettings(array('phone_id' => $phoneId, 'language' => 'Deutsch'));
     $this->_objects['template'] = new Voipmanager_Model_Snom_Template(array('id' => Tinebase_Record_Abstract::generateUID(), 'name' => 'phpunit test location', 'software_id' => $this->_objects['software']->getId(), 'setting_id' => $this->_objects['setting']->getId()));
     $this->_objects['phone'] = new Voipmanager_Model_Snom_Phone(array('id' => $phoneId, 'macaddress' => "1234567890cd", 'location_id' => $this->_objects['location']->getId(), 'template_id' => $this->_objects['template']->getId(), 'current_model' => 'snom320', 'redirect_event' => 'none'));
     $this->_objects['phoneOwner'] = array('account_id' => Zend_Registry::get('currentAccount')->getId(), 'account_type' => 'user');
     $rights = new Tinebase_Record_RecordSet('Voipmanager_Model_Snom_PhoneRight', array($this->_objects['phoneOwner']));
     $this->_objects['phone']->rights = $rights;
     // create phone, location, template
     $snomLocationBackend = new Voipmanager_Backend_Snom_Location();
     $snomTemplateBackend = new Voipmanager_Backend_Snom_Template();
     $snomSoftwareBackend = new Voipmanager_Backend_Snom_Software();
     $snomPhoneBackend = new Voipmanager_Backend_Snom_Phone();
     $snomSettingBackend = new Voipmanager_Backend_Snom_Setting();
     $snomPhoneSettingsBackend = new Voipmanager_Backend_Snom_PhoneSettings();
     $snomSoftwareBackend->create($this->_objects['software']);
     $snomLocationBackend->create($this->_objects['location']);
     $snomTemplateBackend->create($this->_objects['template']);
     $snomSettingBackend->create($this->_objects['setting']);
     $snomPhoneBackend->create($this->_objects['phone']);
     $snomPhoneSettingsBackend->create($this->_objects['phonesettings']);
 }
 protected function _onAfterExportRecords($result)
 {
     $user = Tinebase_Core::getUser();
     $this->_docTemplate->setValue('date', Tinebase_DateTime::now()->format('Y-m-d'));
     $this->_docTemplate->setValue('account_n_given', $user->accountFirstName);
     $this->_docTemplate->setValue('account_n_family', $user->accountLastName);
 }
 /**
  * resolves all virtual fields for the address
  *
  * @param array $address
  * @return array with property => value
  */
 public function resolveVirtualFields($address)
 {
     if (!isset($address['type'])) {
         if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Invalid address for resolving: ' . print_r($address, true));
         }
         return $address;
     }
     $ft = '';
     $i18n = Tinebase_Translation::getTranslation($this->_applicationName)->getAdapter();
     $type = $address['type'];
     $ft .= !empty($address['prefix1']) ? $address['prefix1'] : '';
     $ft .= !empty($address['prefix1']) && !empty($address['prefix2']) ? ' ' : '';
     $ft .= !empty($address['prefix2']) ? $address['prefix2'] : '';
     $ft .= !empty($address['prefix1']) || !empty($address['prefix2']) ? ', ' : '';
     $ft .= !empty($address['postbox']) ? $address['postbox'] : (!empty($address['street']) ? $address['street'] : '');
     $ft .= !empty($address['postbox']) || !empty($address['street']) ? ', ' : '';
     $ft .= !empty($address['postalcode']) ? $address['postalcode'] . ' ' : '';
     $ft .= !empty($address['locality']) ? $address['locality'] : '';
     $ft .= ' (';
     $ft .= $i18n->_($type);
     if ($type == 'billing') {
         $ft .= ' - ' . $address['custom1'];
     }
     $ft .= ')';
     $address['fulltext'] = $ft;
     return $address;
 }
 public static function getThemeConfig()
 {
     $extJS = 'ext-all.css';
     $themePath = 'tine20';
     $favicon = 'images/favicon.ico';
     $title = 'Tine 2.0';
     $themeConfig = Tinebase_Core::getConfig()->theme;
     if ($themeConfig instanceof Tinebase_Config_Struct && $themeConfig->active) {
         if ($themeConfig->path) {
             $themePath = $themeConfig->path;
             //is useBlueAsBase set?
             if ($themeConfig->useBlueAsBase) {
                 $extJS = 'ext-all-notheme.css';
             }
             //is there a customized favicon?
             if (file_exists('themes/' . $themePath . '/resources/images/favicon.ico')) {
                 $favicon = 'themes/' . $themePath . '/resources/images/favicon.ico';
             }
         }
     }
     //Do we have a branding favicon?
     $favicon = Tinebase_Config::getInstance()->get(Tinebase_Config::BRANDING_FAVICON) ? Tinebase_Config::getInstance()->get(Tinebase_Config::BRANDING_FAVICON) : $favicon;
     //Do we have a branding title?
     $title = Tinebase_Config::getInstance()->get(Tinebase_Config::BRANDING_TITLE) ? Tinebase_Config::getInstance()->get(Tinebase_Config::BRANDING_TITLE) : $title;
     $result = array('favicon' => $favicon, 'extJs' => '<link rel="stylesheet" type="text/css" href="library/ExtJS/resources/css/' . $extJS . '" />', 'themePath' => '<link rel="stylesheet" type="text/css" href="themes/' . $themePath . '/resources/css/' . $themePath . '.css" />', 'title' => $title);
     return $result;
 }
 /**
  * test testGetProperties method
  */
 public function testGetProperties()
 {
     $body = '<?xml version="1.0" encoding="utf-8"?>
              <propfind xmlns="DAV:">
                 <prop>
                     <getlastmodified xmlns="DAV:"/>
                     <getcontentlength xmlns="DAV:"/>
                     <resourcetype xmlns="DAV:"/>
                     <getetag xmlns="DAV:"/>
                     <id xmlns="http://owncloud.org/ns"/>
                 </prop>
              </propfind>';
     $request = new Sabre\HTTP\Request(array('REQUEST_METHOD' => 'PROPFIND', 'REQUEST_URI' => '/remote.php/webdav/' . Tinebase_Core::getUser()->accountDisplayName, 'HTTP_DEPTH' => '0'));
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
     //var_dump($this->response->body);
     $this->assertEquals('HTTP/1.1 207 Multi-Status', $this->response->status);
     $responseDoc = new DOMDocument();
     $responseDoc->loadXML($this->response->body);
     //$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('owncloud', 'http://owncloud.org/ns');
     $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/owncloud:id');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
 }
 /**
  * test general functionality of Tinebase_Server_Plugin_WebDAV
  */
 public function testServerGetParameter()
 {
     $request = \Zend\Http\PhpEnvironment\Request::fromString("POST /index.php?frontend=webdav HTTP/1.1\r\n" . "Host: localhost\r\n" . "Depth: 0\r\n" . "User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120824 Thunderbird/15.0 Lightning/1.7");
     $request->setQuery(new Zend\Stdlib\Parameters(array('frontend' => 'webdav')));
     $server = Tinebase_Core::getDispatchServer($request);
     $this->assertInstanceOf('Tinebase_Server_WebDAV', $server);
 }
Example #11
0
 /**
  * update to 5.1
  *  - move task status to key field config
  */
 public function update_0()
 {
     $tasksAppId = Tinebase_Application::getInstance()->getApplicationByName('Tasks')->getId();
     // remove status_id keys
     $this->_backend->dropForeignKey('tasks', 'tasks::status_id--tasks_status::id');
     $this->_backend->dropIndex('tasks', 'status_id');
     // need to replace all NULL values first
     $this->_db->update(SQL_TABLE_PREFIX . 'tasks', array('status_id' => 1), "`status_id` IS NULL");
     // alter status_id -> status
     $declaration = new Setup_Backend_Schema_Field_Xml('
         <field>
             <name>status</name>
             <type>text</type>
             <length>40</length>
             <default>NEEDS-ACTION</default>
             <notnull>true</notnull>
         </field>');
     $this->_backend->alterCol('tasks', $declaration, 'status_id');
     // get all current status datas and drop old status table
     $stmt = $this->_db->query("SELECT * FROM `" . SQL_TABLE_PREFIX . "tasks_status`");
     $statusDatas = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
     $this->_backend->dropTable('tasks_status', $tasksAppId);
     // update task table
     $statusMap = array();
     // oldId => newId
     foreach ($statusDatas as $statusData) {
         $statusMap[$statusData['id']] = $statusData['status_name'];
         $this->_db->update(SQL_TABLE_PREFIX . 'tasks', array('status' => $statusData['status_name']), "`status` = '{$statusData['id']}'");
     }
     // create status config
     $cb = new Tinebase_Backend_Sql(array('modelName' => 'Tinebase_Model_Config', 'tableName' => 'config'));
     $tasksStatusConfig = array('name' => Tasks_Config::TASK_STATUS, 'records' => array(array('id' => 'NEEDS-ACTION', 'value' => 'No response', 'is_open' => 1, 'icon' => 'images/oxygen/16x16/actions/mail-mark-unread-new.png', 'system' => true), array('id' => 'COMPLETED', 'value' => 'Completed', 'is_open' => 0, 'icon' => 'images/oxygen/16x16/actions/ok.png', 'system' => true), array('id' => 'CANCELLED', 'value' => 'Cancelled', 'is_open' => 0, 'icon' => 'images/oxygen/16x16/actions/dialog-cancel.png', 'system' => true), array('id' => 'IN-PROCESS', 'value' => 'In process', 'is_open' => 1, 'icon' => 'images/oxygen/16x16/actions/view-refresh.png', 'system' => true)));
     // add non system custom status
     foreach ($statusDatas as $statusData) {
         if (!in_array($statusData['status_name'], array('NEEDS-ACTION', 'COMPLETED', 'CANCELLED', 'IN-PROCESS'))) {
             $tasksStatusConfig['records'][] = array('id' => $statusData['status_name'], 'value' => $statusData['status_name'], 'is_open' => $statusData['status_is_open'], 'icon' => $statusData['status_icon']);
         }
     }
     $cb->create(new Tinebase_Model_Config(array('application_id' => $tasksAppId, 'name' => Tasks_Config::TASK_STATUS, 'value' => json_encode($tasksStatusConfig))));
     // update persistent filters
     $stmt = $this->_db->query("SELECT * FROM `" . SQL_TABLE_PREFIX . "filter` WHERE " . "`application_id` = '" . $tasksAppId . "' AND " . "`model` = 'Tasks_Model_TaskFilter'");
     $pfiltersDatas = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
     foreach ($pfiltersDatas as $pfilterData) {
         $filtersData = Zend_Json::decode($pfilterData['filters']);
         foreach ($filtersData as &$filterData) {
             if (array_key_exists('field', $filterData) && $filterData['field'] == 'status_id') {
                 $filterData['field'] = 'status';
                 $newStatusIds = array();
                 foreach ((array) $filterData['value'] as $oldStatusId) {
                     $newStatusIds[] = $statusMap[$oldStatusId];
                 }
                 $filterData['value'] = is_array($filterData['value']) ? $newStatusIds : $newStatusIds[0];
                 Tinebase_Core::getLogger()->ERR(print_r($filterData, TRUE));
             }
         }
         $this->_db->update(SQL_TABLE_PREFIX . 'filter', array('filters' => Zend_Json::encode($filtersData)), "`id` LIKE '{$pfilterData['id']}'");
     }
     $this->setTableVersion('tasks', '4');
     $this->setApplicationVersion('Tasks', '5.1');
 }
 /**
  * test testGetProperties method
  */
 public function testGetProperties()
 {
     $body = '<?xml version="1.0" encoding="utf-8"?>
              <propfind xmlns="DAV:">
                 <prop>
                     <default-alarm-vevent-date xmlns="urn:ietf:params:xml:ns:caldav"/>
                     <default-alarm-vevent-datetime xmlns="urn:ietf:params:xml:ns:caldav"/>
                     <default-alarm-vtodo-date xmlns="urn:ietf:params:xml:ns:caldav"/>
                     <default-alarm-vtodo-datetime xmlns="urn:ietf:params:xml:ns:caldav"/>
                 </prop>
              </propfind>';
     $request = new Sabre\HTTP\Request(array('REQUEST_METHOD' => 'PROPFIND', 'REQUEST_URI' => '/calendars/' . Tinebase_Core::getUser()->contact_id, 'HTTP_DEPTH' => '0'));
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
     //var_dump($this->response->body);
     $this->assertEquals('HTTP/1.1 207 Multi-Status', $this->response->status);
     $responseDoc = new DOMDocument();
     $responseDoc->loadXML($this->response->body);
     //$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('cal', 'urn:ietf:params:xml:ns:caldav');
     $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/cal:default-alarm-vevent-datetime');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/cal:default-alarm-vevent-date');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/cal:default-alarm-vtodo-datetime');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/cal:default-alarm-vtodo-date');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
 }
 /**
  * inspect set password
  * 
  * @param string   $_userId
  * @param string   $_password
  * @param boolean  $_encrypt
  * @param boolean  $_mustChange
  * @param array    $_ldapData    the data to be written to ldap
  */
 public function inspectSetPassword($_userId, $_password, $_encrypt, $_mustChange, array &$_ldapData)
 {
     if ($_encrypt !== true) {
         Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . ' can not transform crypted password into nt/lm samba password. Make sure to reset password for user ' . $_userId);
     } else {
         $_ldapData['sambantpassword'] = Tinebase_User_Abstract::encryptPassword($_password, Tinebase_User_Abstract::ENCRYPT_NTPASSWORD);
         $_ldapData['sambalmpassword'] = array();
         if ($_mustChange === true) {
             $_ldapData['sambapwdmustchange'] = '1';
             $_ldapData['sambapwdcanchange'] = '1';
             $_ldapData['sambapwdlastset'] = array();
         } else {
             if ($_mustChange === false) {
                 $_ldapData['sambapwdmustchange'] = '2147483647';
                 $_ldapData['sambapwdcanchange'] = '1';
                 $_ldapData['sambapwdlastset'] = Tinebase_DateTime::now()->getTimestamp();
             } else {
                 if ($_mustChange === null && $_userId instanceof Tinebase_Model_FullUser && isset($_userId->sambaSAM) && isset($_userId->sambaSAM->pwdMustChange) && isset($_userId->sambaSAM->pwdCanChange)) {
                     $_ldapData['sambapwdmustchange'] = $_userId->sambaSAM->pwdMustChange->getTimestamp();
                     $_ldapData['sambapwdcanchange'] = $_userId->sambaSAM->pwdCanChange->getTimestamp();
                     $_ldapData['sambapwdlastset'] = array();
                 }
             }
         }
     }
 }
 /**
  * init the test frameworks
  *
  */
 public function initFramework()
 {
     Setup_Core::initFramework();
     //$this->getConfig();
     Tinebase_Core::startCoreSession();
     Tinebase_Core::set('frameworkInitialized', true);
 }
 /**
  * converts Addressbook_Model_Contact to vcard
  * 
  * @param  Addressbook_Model_Contact  $_record
  * @return string
  */
 public function fromTine20Model(Tinebase_Record_Abstract $_record)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' contact ' . print_r($_record->toArray(), true));
     }
     // initialize vcard object
     $card = $this->_fromTine20ModelRequiredFields($_record);
     $card->add('TEL', $_record->tel_work, array('TYPE' => 'WORK'));
     $card->add('TEL', $_record->tel_home, array('TYPE' => 'HOME'));
     $card->add('TEL', $_record->tel_cell, array('TYPE' => 'CELL'));
     $card->add('TEL', $_record->tel_fax, array('TYPE' => 'FAX'));
     $card->add('TEL', $_record->tel_pager, array('TYPE' => 'PAGER'));
     $card->add('ADR', array(null, $_record->adr_one_street2, $_record->adr_one_street, $_record->adr_one_locality, $_record->adr_one_region, $_record->adr_one_postalcode, $_record->adr_one_countryname), array('TYPE' => 'WORK'));
     $card->add('ADR', array(null, $_record->adr_two_street2, $_record->adr_two_street, $_record->adr_two_locality, $_record->adr_two_region, $_record->adr_two_postalcode, $_record->adr_two_countryname), array('TYPE' => 'HOME'));
     $card->add('EMAIL', $_record->email, array('TYPE' => 'WORK'));
     $card->add('EMAIL', $_record->email_home, array('TYPE' => 'HOME'));
     $card->add('URL', $_record->url, array('TYPE' => 'WORK'));
     $card->add('URL', $_record->url_home, array('TYPE' => 'HOME'));
     $card->add('NOTE', $_record->note);
     $this->_fromTine20ModelAddBirthday($_record, $card);
     $this->_fromTine20ModelAddPhoto($_record, $card);
     $this->_fromTine20ModelAddGeoData($_record, $card);
     $this->_fromTine20ModelAddCategories($_record, $card);
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' card ' . $card->serialize());
     }
     return $card;
 }
 /**
  * send notifications to a list a recipients
  *
  * @param Tinebase_Model_FullUser   $_updater
  * @param array                     $_recipients array of int|Addressbook_Model_Contact
  * @param string                    $_subject
  * @param string                    $_messagePlain
  * @param string                    $_messageHtml
  * @param string|array              $_attachments
  * @throws Tinebase_Exception
  * 
  * @todo improve exception handling: collect all messages / exceptions / failed email addresses / ...
  */
 public function send($_updater, $_recipients, $_subject, $_messagePlain, $_messageHtml = NULL, $_attachments = NULL)
 {
     $contactsBackend = Addressbook_Backend_Factory::factory(Addressbook_Backend_Factory::SQL);
     $exception = NULL;
     $sentContactIds = array();
     foreach ($_recipients as $recipient) {
         try {
             if (!$recipient instanceof Addressbook_Model_Contact) {
                 $recipient = $contactsBackend->get($recipient);
             }
             if (!in_array($recipient->getId(), $sentContactIds)) {
                 $this->_smtpBackend->send($_updater, $recipient, $_subject, $_messagePlain, $_messageHtml, $_attachments);
                 $sentContactIds[] = $recipient->getId();
             }
         } catch (Exception $e) {
             $exception = $e;
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                 Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Failed to send notification message (recipient: ' . ($recipient instanceof Addressbook_Model_Contact ? $recipient->email : $recipient) . '. Exception: ' . $e);
             }
         }
     }
     if ($exception !== NULL) {
         // throw exception in the end when all recipients have been processed
         throw $exception;
     }
 }
Example #17
0
 /**
  * handler for JSON api requests
  * 
  * @return JSON
  */
 public function handle()
 {
     try {
         // init server and request first
         $server = new Zend_Json_Server();
         $server->setClass('Setup_Frontend_Json', 'Setup');
         $server->setClass('Tinebase_Frontend_Json', 'Tinebase');
         $server->setAutoHandleExceptions(false);
         $server->setAutoEmitResponse(false);
         $request = new Zend_Json_Server_Request_Http();
         Setup_Core::initFramework();
         $method = $request->getMethod();
         $jsonKey = isset($_SERVER['HTTP_X_TINE20_JSONKEY']) ? $_SERVER['HTTP_X_TINE20_JSONKEY'] : '';
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' is JSON request. method: ' . $method);
         $anonymnousMethods = array('Setup.getAllRegistryData', 'Setup.login', 'Tinebase.getAvailableTranslations', 'Tinebase.getTranslations', 'Tinebase.setLocale');
         if (!Setup_Core::configFileExists()) {
             $anonymnousMethods = array_merge($anonymnousMethods, array('Setup.envCheck'));
         }
         // check json key for all methods but some exceptoins
         if (!in_array($method, $anonymnousMethods) && Setup_Core::configFileExists() && (empty($jsonKey) || $jsonKey != Setup_Core::get('jsonKey') || !Setup_Core::isRegistered(Setup_Core::USER))) {
             if (!Setup_Core::isRegistered(Setup_Core::USER)) {
                 Setup_Core::getLogger()->INFO(__METHOD__ . '::' . __LINE__ . ' Attempt to request a privileged Json-API method without authorisation from "' . $_SERVER['REMOTE_ADDR'] . '". (session timeout?)');
                 throw new Tinebase_Exception_AccessDenied('Not Authorised', 401);
             } else {
                 Setup_Core::getLogger()->WARN(__METHOD__ . '::' . __LINE__ . ' Fatal: got wrong json key! (' . $jsonKey . ') Possible CSRF attempt!' . ' affected account: ' . print_r(Setup_Core::getUser(), true) . ' request: ' . print_r($_REQUEST, true));
                 throw new Tinebase_Exception_AccessDenied('Not Authorised', 401);
             }
         }
         $response = $server->handle($request);
     } catch (Exception $exception) {
         $response = $this->_handleException($server, $request, $exception);
     }
     echo $response;
 }
 public function testCachedResults()
 {
     $this->_uit->setCache(Tinebase_Core::get('cache'));
     $this->testGetListOfTimezonesForOffsets();
     $this->testGetListOfTimezonesForPackedStrings();
     $this->_uit->setCache(null);
 }
 /**
  * update to 9.1
  *
  * @return void
  */
 public function update_0()
 {
     // we need at least addressbook version 9,7
     if (version_compare($this->getApplicationVersion('Addressbook'), '9.8') < 0) {
         return;
     }
     $setupUser = $this->_getSetupFromConfigOrCreateOnTheFly();
     if ($setupUser) {
         Tinebase_Core::set(Tinebase_Core::USER, $setupUser);
         $filter = new Phone_Model_CallFilter(array(array('field' => 'start', 'operator' => 'after', 'value' => date('Y-m-d H:i:s', time() - 3600 * 24 * 30 * 3))), 'AND', array('ignoreAcl' => true));
         $addressbookController = Addressbook_Controller_Contact::getInstance();
         $phoneController = Phone_Controller_Call::getInstance();
         $calls = $phoneController->search($filter);
         foreach ($calls as $_record) {
             // resolve telephone number to contacts if possible
             $telNumber = Addressbook_Model_Contact::normalizeTelephoneNoCountry($phoneController->resolveInternalNumber($_record->destination));
             if (null === $telNumber) {
                 continue;
             }
             $filter = new Addressbook_Model_ContactFilter(array(array('field' => 'telephone_normalized', 'operator' => 'equals', 'value' => $telNumber)));
             $contacts = $addressbookController->search($filter);
             $relations = array();
             foreach ($contacts as $contact) {
                 $relations[] = array('related_model' => 'Addressbook_Model_Contact', 'related_id' => $contact->getId(), 'related_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'related_backend' => Tinebase_Model_Relation::DEFAULT_RECORD_BACKEND, 'type' => 'CALLER');
             }
             if (count($relations) > 0) {
                 $_record->relations = $relations;
                 $phoneController->update($_record);
             }
         }
     }
     $this->setApplicationVersion('Phone', '9.1');
 }
Example #20
0
 /**
  * handler for command line scripts
  * 
  * @return boolean
  */
 public function handle()
 {
     Tinebase_Core::initFramework();
     #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .' is Asterisk curl request: ' . print_r($_REQUEST, true));
     if (Tinebase_Controller::getInstance()->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $_SERVER['REMOTE_ADDR'], 'TineAsterisk') === true) {
         $server = new Tinebase_Http_Server();
         $server->setClass('Voipmanager_Frontend_Asterisk_SipPeers', 'Voipmanager_SipPeers');
         $server->setClass('Voipmanager_Frontend_Asterisk_SipRegs', 'Voipmanager_SipRegs');
         $server->setClass('Voipmanager_Frontend_Asterisk_CallForward', 'Voipmanager_CallForward');
         $server->setClass('Voipmanager_Frontend_Asterisk_MeetMe', 'Voipmanager_MeetMe');
         list($class, $method) = explode('.', $_REQUEST['method']);
         // ugly hack to parse requests from res_config_curl
         if ($method == 'handleResConfig') {
             // set method to a usefull value
             $pos = strpos($_REQUEST['action'], '?');
             if ($pos !== false) {
                 $action = substr($_REQUEST['action'], 0, $pos);
                 list($key, $value) = explode('=', substr($_REQUEST['action'], $pos + 1));
                 $_REQUEST[$key] = $value;
             } else {
                 $action = $_REQUEST['action'];
             }
             #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .' action: ' . $action);
             $method = ucfirst(substr($action, 1));
             $_REQUEST['method'] = $class . '.handle' . $method;
         }
         #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .' action: ' . print_r($_REQUEST, true));
         $server->handle($_REQUEST);
         Tinebase_Controller::getInstance()->logout($_SERVER['REMOTE_ADDR']);
     } else {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' auth failed ');
         }
     }
 }
 public function testGetDispatchServerWebDAV()
 {
     $request = \Zend\Http\PhpEnvironment\Request::fromString("GET /index.php?frontend=webdav HTTP/1.1\r\n" . "User-Agent: SAMSUNG-GT-I9300/101.403");
     $request->setQuery(new \Zend\Stdlib\Parameters(array('frontend' => 'webdav')));
     $server = Tinebase_Core::getDispatchServer($request);
     $this->assertInstanceOf('Tinebase_Server_WebDAV', $server);
 }
 /**
  * test with post parameter requestType set to JSON
  */
 public function testServerPostParameter()
 {
     $request = \Zend\Http\PhpEnvironment\Request::fromString("POST /index.php?requestType=JSON HTTP/1.1\r\n" . "Host: localhost\r\n" . "User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120824 Thunderbird/15.0 Lightning/1.7");
     $request->setPost(new Zend\Stdlib\Parameters(array('requestType' => 'JSON')));
     $server = Tinebase_Core::getDispatchServer($request);
     $this->assertInstanceOf('Tinebase_Server_Json', $server);
 }
 /**
  * converts an array of tags names to a recordSet of Tinebase_Model_Tag
  * 
  * @param  iteratable           $tagNames
  * @param  bool                 $implicitAddMissingTags
  * @return Tinebase_Record_RecordSet
  */
 public static function resolveTagNameToTag($tagNames, $applicationName, $implicitAddMissingTags = true)
 {
     if (empty($tagNames)) {
         return new Tinebase_Record_RecordSet('Tinebase_Model_Tag');
     }
     $resolvedTags = array();
     foreach ((array) $tagNames as $tagName) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Trying to allocate tag ' . $tagName);
         }
         $tagName = trim($tagName);
         if (empty($tagName)) {
             continue;
         }
         $existingTags = Tinebase_Tags::getInstance()->searchTags(new Tinebase_Model_TagFilter(array('name' => $tagName, 'application' => $applicationName)), new Tinebase_Model_Pagination(array('sort' => 'type', 'dir' => 'DESC', 'limit' => 1)));
         if (count($existingTags) === 1) {
             //var_dump($existingTags->toArray());
             $resolvedTags[] = $existingTags->getFirstRecord();
         } elseif ($implicitAddMissingTags === true) {
             // No tag found, lets create a personal tag
             $resolvedTag = Tinebase_Tags::GetInstance()->createTag(new Tinebase_Model_Tag(array('type' => Tinebase_Model_Tag::TYPE_PERSONAL, 'name' => $tagName)));
             $resolvedTags[] = $resolvedTag;
         }
     }
     return new Tinebase_Record_RecordSet('Tinebase_Model_Tag', $resolvedTags);
 }
Example #24
0
 public function testSearchEvents()
 {
     $from = '2009-04-03 00:00:00';
     $until = '2009-04-10 23:59:59';
     $events = new Tinebase_Record_RecordSet('Calendar_Model_Event', array(array('dtstart' => '2009-04-02 22:00:00', 'dtend' => '2009-04-02 23:59:59', 'summary' => 'non recur event ending before search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-02 23:30:00', 'dtend' => '2009-04-03 00:30:00', 'summary' => 'non recur event ending within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-06 12:00:00', 'dtend' => '2009-04-07 12:00:00', 'summary' => 'non recur event completly within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-10 23:30:00', 'dtend' => '2009-04-11 00:30:00', 'summary' => 'non recur event starting within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-11 00:00:00', 'dtend' => '2009-04-11 02:00:00', 'summary' => 'non recur event starting after search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-03-27 22:00:00', 'dtend' => '2009-03-27 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-02 23:59:59', 'summary' => 'recur event ending before search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-02 23:59:59', Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-03-27 22:00:00', 'dtend' => '2009-03-27 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-05 23:59:59', 'summary' => 'recur event ending within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-05 23:59:59', Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-03 22:00:00', 'dtend' => '2009-04-03 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-06 23:59:59', 'summary' => 'recur event completly within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-06 23:59:59', Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-03 22:00:00', 'dtend' => '2009-04-03 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-12 23:59:59', 'summary' => 'recur event starting within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-12 23:59:59', Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-11 00:00:00', 'dtend' => '2009-04-11 02:00:00', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-15 02:00:00', 'summary' => 'recur event starting after search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_testCalendar->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-15 02:00:00', Tinebase_Model_Grants::GRANT_READ => true)));
     foreach ($events as $event) {
         $persistentEvent = $this->_backend->create($event);
         $event->attendee->cal_event_id = $persistentEvent->getId();
         foreach ($event->attendee as $attender) {
             $this->_backend->createAttendee($attender);
         }
     }
     $filter = new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_testCalendar->getId()), array('field' => 'period', 'operator' => 'within', 'value' => array('from' => $from, 'until' => $until))));
     $eventsFound = $this->_backend->search($filter, new Tinebase_Model_Pagination());
     $eventsFoundIds = $eventsFound->getArrayOfIds();
     foreach ($events as $event) {
         $eventId = $event->getId();
         if (strpos($event->summary, '_not_') === false) {
             $this->assertTrue(in_array($eventId, $eventsFoundIds), 'The following event is missing in the search result :' . print_r($event->toArray(), true));
         } else {
             $this->assertFalse(in_array($eventId, $eventsFoundIds), 'The following event is in the search result, but should not be :' . print_r($event->toArray(), true));
         }
     }
     $expectedAttendee = $this->_getAttendee();
     foreach ($eventsFound as $fetchedEvent) {
         $this->_assertAttendee($expectedAttendee, $fetchedEvent->attendee);
     }
 }
Example #25
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');
 }
 public function validate($username, $password)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Options: ' . print_r($this->_options, true));
     }
     $url = isset($this->_options['url']) ? $this->_options['url'] : 'https://localhost/validate/check';
     $adapter = new Zend_Http_Client_Adapter_Socket();
     $adapter->setStreamContext($this->_options = array('ssl' => array('verify_peer' => isset($this->_options['ignorePeerName']) ? false : true, 'allow_self_signed' => isset($this->_options['allowSelfSigned']) ? true : false)));
     $client = new Zend_Http_Client($url, array('maxredirects' => 0, 'timeout' => 30));
     $client->setAdapter($adapter);
     $params = array('user' => $username, 'pass' => $password);
     $client->setParameterPost($params);
     try {
         $response = $client->request(Zend_Http_Client::POST);
     } catch (Zend_Http_Client_Adapter_Exception $zhcae) {
         Tinebase_Exception::log($zhcae);
         return Tinebase_Auth::FAILURE;
     }
     $body = $response->getBody();
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Request: ' . $client->getLastRequest());
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Response: ' . $body);
     }
     if ($response->getStatus() !== 200) {
         return Tinebase_Auth::FAILURE;
     }
     $result = Tinebase_Helper::jsonDecode($body);
     if (isset($result['result']) && $result['result']['status'] === true && $result['result']['value'] === true) {
         return Tinebase_Auth::SUCCESS;
     } else {
         return Tinebase_Auth::FAILURE;
     }
 }
Example #27
0
 /**
  * factory function to return a selected account/imap backend class
  *
  * @param   string|Felamimail_Model_Account $_accountId
  * @return  Felamimail_Backend_ImapProxy
  * @throws  Felamimail_Exception_IMAPInvalidCredentials
  */
 public static function factory($_accountId)
 {
     $accountId = $_accountId instanceof Felamimail_Model_Account ? $_accountId->getId() : $_accountId;
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Getting IMAP backend for account id ' . $accountId);
     }
     if (!isset(self::$_backends[$accountId])) {
         // get imap config from account
         $account = $_accountId instanceof Felamimail_Model_Account ? $_accountId : Felamimail_Controller_Account::getInstance()->get($_accountId);
         $imapConfig = $account->getImapConfig();
         // we need to instantiate a new imap backend
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Connecting to server ' . $imapConfig['host'] . ':' . $imapConfig['port'] . ' (' . (array_key_exists('ssl', $imapConfig) ? $imapConfig['ssl'] : 'none') . ')' . ' with username ' . $imapConfig['user']);
         }
         try {
             self::$_backends[$accountId] = new Felamimail_Backend_ImapProxy($imapConfig);
             Felamimail_Controller_Account::getInstance()->updateCapabilities($account, self::$_backends[$accountId]);
         } catch (Felamimail_Exception_IMAPInvalidCredentials $feiic) {
             // add account and username to Felamimail_Exception_IMAPInvalidCredentials
             $feiic->setAccount($account)->setUsername($imapConfig['user']);
             throw $feiic;
         }
     }
     return self::$_backends[$accountId];
 }
 /**
  * resetCache() - resets the cache
  */
 public function resetCache()
 {
     setcookie(self::COOKIE_KEY, '', time() - 3600);
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Reset credential cache cookie.');
     }
 }
 /**
  * Constructor
  *
  * @param array  $options An array of arrays of IMAP options
  * @param string $username
  * @param string $password
  */
 public function __construct(array $options = array(), $username = null, $password = null)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($options, true));
     }
     parent::__construct($options, $username, $password);
 }
Example #30
0
 /**
  * parse iseragent and return backend and version
  * 
  * @return array
  */
 public static function parseUserAgent($_userAgent)
 {
     Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' user agent: ' . $_userAgent);
     // MacOS X
     if (preg_match(Addressbook_Convert_Contact_VCard_MacOSX::HEADER_MATCH, $_userAgent, $matches)) {
         $backend = Addressbook_Convert_Contact_VCard_Factory::CLIENT_MACOSX;
         $version = $matches['version'];
         // Thunderbird with Sogo Connector
     } elseif (preg_match(Addressbook_Convert_Contact_VCard_Sogo::HEADER_MATCH, $_userAgent, $matches)) {
         $backend = Addressbook_Convert_Contact_VCard_Factory::CLIENT_SOGO;
         $version = $matches['version'];
         // iOS addressbook
     } elseif (preg_match(Addressbook_Convert_Contact_VCard_IOS::HEADER_MATCH, $_userAgent, $matches)) {
         $backend = Addressbook_Convert_Contact_VCard_Factory::CLIENT_IOS;
         $version = $matches['version'];
         // KDE addressbook
     } elseif (preg_match(Addressbook_Convert_Contact_VCard_KDE::HEADER_MATCH, $_userAgent, $matches)) {
         $backend = Addressbook_Convert_Contact_VCard_Factory::CLIENT_KDE;
         $version = $matches['version'];
         // generic client
     } else {
         $backend = Addressbook_Convert_Contact_VCard_Factory::CLIENT_GENERIC;
         $version = null;
     }
     return array($backend, $version);
 }