Пример #1
0
 /**
  * fill record from json data
  *
  * @param  array &$data
  * @return void
  */
 protected function _setFromJson(array &$data)
 {
     /************* add new relations *******************/
     if (isset($data['relations'])) {
         foreach ((array) $data['relations'] as $key => $relation) {
             if (!isset($relation['id'])) {
                 $relationData = array('own_model' => 'Sales_Model_Contract', 'own_backend' => 'Sql', 'own_id' => isset($data['id']) ? $data['id'] : 0, 'own_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'type' => $relation['type'], 'related_record' => isset($relation['related_record']) ? $relation['related_record'] : array(), 'related_id' => isset($relation['related_id']) ? $relation['related_id'] : NULL);
                 switch ($relation['type']) {
                     case self::RELATION_TYPE_ACCOUNT:
                         $relationData['related_model'] = 'Tinebase_Model_User';
                         $relationData['related_backend'] = Tinebase_User::getConfiguredBackend();
                         break;
                     case self::RELATION_TYPE_CUSTOMER:
                         $relationData['related_model'] = 'Addressbook_Model_Contact';
                         $relationData['related_backend'] = Addressbook_Backend_Factory::SQL;
                         break;
                     default:
                         throw new Sales_Exception_UnexpectedValue('Relation type not supported.');
                 }
                 // sanitize container id
                 if (isset($relation['related_record']['container_id']) && is_array($relation['related_record']['container_id'])) {
                     $data['related_record']['container_id'] = $relation['related_record']['container_id']['id'];
                 }
                 $data['relations'][$key] = $relationData;
             }
         }
     }
 }
Пример #2
0
 /**
  * return all groups an account is member of
  * - this function caches its result (with cache tag 'ldap')
  *
  * @param mixed $_accountId the account as integer or Tinebase_Model_User
  * @return array
  */
 public function getGroupMemberships($_accountId)
 {
     $cache = Tinebase_Core::get(Tinebase_Core::CACHE);
     $cacheId = convertCacheId('getLdapGroupMemberships' . ($_accountId instanceof Tinebase_Model_FullUser ? $_accountId->getId() : $_accountId));
     $result = $cache->load($cacheId);
     if (!$result) {
         if ($_accountId instanceof Tinebase_Model_FullUser) {
             $memberuid = $_accountId->accountLoginName;
         } else {
             $account = Tinebase_User::getInstance()->getFullUserById($_accountId);
             $memberuid = $account->accountLoginName;
         }
         $filter = "(&(objectclass=user)(sAMAccountName={$memberuid}))";
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' search filter: ' . $filter);
         }
         $groupMemberships = $this->_ldap->fetchAll($this->_options['userDn'], $filter, array('memberOf'));
         $memberships = array();
         foreach ($groupMemberships as $groupMembership) {
             $group = $this->_ldap->fetch($groupMembership['memberOf'][0], 'objectClass=group', array('objectGUID'));
             $memberships[] = $group['objectGUID'][0];
         }
         $result = $memberships;
         $cache->save($result, $cacheId, array('ldap'), 240);
     }
     return $result;
 }
Пример #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');
 }
 /**
  * returns array with the filter settings of this filter
  *
  * @param  bool $_valueToJson resolve value for json api?
  * @return array
  */
 public function toArray($_valueToJson = false)
 {
     $result = parent::toArray($_valueToJson);
     if ($this->_userOperator && $this->_userOperator == 'inGroup') {
         $result['operator'] = $this->_userOperator;
         $result['value'] = $this->_userValue;
     }
     if ($_valueToJson == true) {
         if ($this->_userOperator && $this->_userOperator == 'inGroup' && $this->_userValue) {
             $result['value'] = Tinebase_Group::getInstance()->getGroupById($this->_userValue)->toArray();
         } else {
             switch ($this->_operator) {
                 case 'equals':
                     $result['value'] = $result['value'] ? Tinebase_User::getInstance()->getUserById($this->_value)->toArray() : $result['value'];
                     break;
                 case 'in':
                     $result['value'] = array();
                     foreach ($this->_value as $userId) {
                         $result['value'][] = Tinebase_User::getInstance()->getUserById($userId)->toArray();
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     return $result;
 }
 /**
  * reset sync for user
  *
  * @param mixed $user
  * @param array|string $classesToReset
  * @return boolean
  */
 public function resetSyncForUser($user, $classesToReset)
 {
     if (is_string($classesToReset)) {
         $classesToReset = array($classesToReset);
     }
     if (!$user instanceof Tinebase_Model_User) {
         try {
             $user = Tinebase_User::getInstance()->getFullUserById($user);
         } catch (Tinebase_Exception_NotFound $tenf) {
             $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $user);
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Resetting sync for user ' . $user->accountDisplayName . ' collections: ' . print_r($classesToReset, true));
     }
     self::initSyncrotonRegistry();
     $devices = $this->_getDevicesForUser($user->getId());
     foreach ($devices as $device) {
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Resetting device' . $device->friendlyname . ' / id: ' . $device->getId());
         }
         foreach ($classesToReset as $class) {
             $folderToReset = $this->_getFoldersForDeviceAndClass($device, $class);
             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                 Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Resetting ' . count($folderToReset) . ' folder(s) for class ' . $class);
             }
             foreach ($folderToReset as $folderState) {
                 Syncroton_Registry::getSyncStateBackend()->resetState($device->getId(), $folderState->id);
             }
         }
     }
     return true;
 }
Пример #6
0
 /**
  * the constructor
  *
  */
 public function __construct(array $_options = array())
 {
     if (Tinebase_User::getConfiguredBackend() != Tinebase_User::LDAP) {
         throw new Tinebase_Exception('No LDAP config found.');
     }
     $this->_options = array_merge($this->_options, $_options);
 }
 /**
  * @return void
  */
 public function testEmailsToAttendeeWithGroups()
 {
     if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP || Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
         $this->markTestSkipped('FIXME: Does not work with LDAP/AD backend');
     }
     $event = $this->_getEvent();
     $persistentEvent = Calendar_Controller_Event::getInstance()->create($event);
     $primaryGroup = Tinebase_Group::getInstance()->getGroupById(Tinebase_Core::getUser()->accountPrimaryGroup);
     $newAttendees = array(array('userType' => Calendar_Model_Attender::USERTYPE_USER, 'firstName' => $this->_originalTestUser->accountFirstName, 'lastName' => $this->_originalTestUser->accountLastName, 'partStat' => Calendar_Model_Attender::STATUS_TENTATIVE, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => $this->_originalTestUser->accountEmailAddress), array('userType' => Calendar_Model_Attender::USERTYPE_GROUP, 'displayName' => $primaryGroup->name, 'partStat' => Calendar_Model_Attender::STATUS_NEEDSACTION, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => '*****@*****.**'));
     Calendar_Model_Attender::emailsToAttendee($persistentEvent, $newAttendees, TRUE);
     $persistentEvent = Calendar_Controller_Event::getInstance()->update($persistentEvent);
     $attendees = clone $persistentEvent->attendee;
     Calendar_Model_Attender::resolveAttendee($attendees);
     $newAttendees = array();
     foreach ($attendees as $attendee) {
         $newAttendees[] = array('userType' => $attendee->user_type == 'group' ? Calendar_Model_Attender::USERTYPE_GROUP : Calendar_Model_Attender::USERTYPE_USER, 'partStat' => Calendar_Model_Attender::STATUS_TENTATIVE, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => $attendee->user_type == 'group' ? $attendee->user_id->getId() : $attendee->user_id->email, 'displayName' => $attendee->user_type == 'group' ? $attendee->user_id->name : $attendee->user_id->n_fileas);
     }
     Calendar_Model_Attender::emailsToAttendee($persistentEvent, $newAttendees, TRUE);
     $persistentEvent = Calendar_Controller_Event::getInstance()->update($persistentEvent);
     //         print_r($persistentEvent->attendee->toArray());
     // there must be more than 2 attendees the user, the group + the groupmembers
     $this->assertGreaterThan(2, count($persistentEvent->attendee));
     // current account must not be a groupmember
     $this->assertFalse(!!Calendar_Model_Attender::getAttendee($persistentEvent->attendee, new Calendar_Model_Attender(array('user_type' => Calendar_Model_Attender::USERTYPE_GROUPMEMBER, 'user_id' => $this->_originalTestUser->contact_id))), 'found user as groupmember');
     $this->assertEquals(Calendar_Model_Attender::STATUS_TENTATIVE, Calendar_Model_Attender::getOwnAttender($persistentEvent->attendee)->status);
 }
 /**
  * update to 6.1
  * - changepw config option has moved
  */
 public function update_0()
 {
     $changepwSetting = Tinebase_User::getBackendConfiguration('changepw', TRUE);
     if (!$changepwSetting) {
         Tinebase_Config::getInstance()->set(Tinebase_Config::PASSWORD_CHANGE, FALSE);
     }
     $this->setApplicationVersion('Tinebase', '6.1');
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     if (Tinebase_User::getConfiguredBackend() !== Tinebase_User::SQL) {
         $this->markTestSkipped('SQL backend not enabled');
     }
     $this->_backend = Tinebase_User::factory(Tinebase_User::SQL);
     parent::setUp();
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->_groupLDAP = Tinebase_Group::factory(Tinebase_Group::LDAP);
     $this->_userLDAP = Tinebase_User::factory(Tinebase_User::LDAP);
     $this->_groupSQL = Tinebase_Group::factory(Tinebase_Group::SQL);
     $this->objects['initialGroup'] = new Tinebase_Model_Group(array('name' => 'tine20phpunit', 'description' => 'initial group'));
     $this->objects['updatedGroup'] = new Tinebase_Model_Group(array('name' => 'tine20phpunit updated', 'description' => 'updated group'));
     $this->objects['initialAccount'] = new Tinebase_Model_FullUser(array('accountLoginName' => 'tine20phpunit', 'accountStatus' => 'enabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => 'must be set to valid groupid', 'accountLastName' => 'Tine 2.0', 'accountFirstName' => 'PHPUnit', 'accountEmailAddress' => '*****@*****.**'));
 }
Пример #11
0
 /**
  * creates the initial folder for new accounts
  *
  * @param mixed[int|Tinebase_Model_User] $_account   the accountd object
  * @return Tinebase_Record_RecordSet                            of subtype Tinebase_Model_Container
  */
 public function createPersonalFolder($_accountId)
 {
     $translation = Tinebase_Translation::getTranslation('ExampleApplication');
     $account = Tinebase_User::getInstance()->getUserById($_accountId);
     $newContainer = new Tinebase_Model_Container(array('name' => sprintf($translation->_("%s's personal example records"), $account->accountFullName), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => $_accountId, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('ExampleApplication')->getId()));
     $personalContainer = Tinebase_Container::getInstance()->addContainer($newContainer);
     $container = new Tinebase_Record_RecordSet('Tinebase_Model_Container', array($personalContainer));
     return $container;
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
         // account email addresses are empty with AD backend
         $this->markTestSkipped('skipped for ad backend');
     }
     Calendar_Controller_Event::getInstance()->sendNotifications(false);
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
 }
 /**
  * init/create user contacts
  */
 protected function _initializeUserContacts()
 {
     foreach (Tinebase_User::getInstance()->getFullUsers() as $fullUser) {
         $fullUser->container_id = $this->_getInternalAddressbook()->getId();
         $contact = Admin_Controller_User::getInstance()->createOrUpdateContact($fullUser);
         $fullUser->contact_id = $contact->getId();
         Tinebase_User::getInstance()->updateUser($fullUser);
     }
 }
Пример #14
0
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->_backend = Tinebase_User::getInstance();
     if (!array_key_exists('Tinebase_EmailUser_Imap_Cyrus', $this->_backend->getPlugins())) {
         $this->markTestSkipped('Cyrus IMAP plugin not enabled');
     }
     $this->_config = Tinebase_Config::getInstance()->getConfigAsArray(Tinebase_Config::IMAP);
     $this->objects['users'] = array();
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->_backend = Tinebase_User::getInstance();
     if (!array_key_exists('Tinebase_EmailUser_Imap_Dbmail', $this->_backend->getPlugins())) {
         $this->markTestSkipped('Dbmail MySQL plugin not enabled');
     }
     $this->_config = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP, new Tinebase_Config_Struct())->toArray();
     $this->objects['users'] = array();
 }
 /**
  * creates the initial folder for new accounts
  *
  * @param mixed[int|Tinebase_Model_User] $_account   the accountd object
  * @return Tinebase_Record_RecordSet                            of subtype Tinebase_Model_Container
  */
 public function createPersonalFolder($_account)
 {
     $translation = Tinebase_Translation::getTranslation($this->_applicationName);
     $account = Tinebase_User::getInstance()->getUserById($_account);
     $newContainer = new Tinebase_Model_Container(array('name' => sprintf($translation->_("%s's personal Projects"), $account->accountFullName), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => $account->getId(), 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName($this->_applicationName)->getId(), 'model' => static::$_defaultModel));
     $personalContainer = Tinebase_Container::getInstance()->addContainer($newContainer);
     $container = new Tinebase_Record_RecordSet('Tinebase_Model_Container', array($personalContainer));
     return $container;
 }
Пример #17
0
 /**
  * the constructor
  *
  */
 public function __construct(array $_options = array())
 {
     parent::__construct($_options);
     $ldapOptions = Tinebase_User::getBackendConfiguration();
     $config = Tinebase_EmailUser::getConfig($this->_backendType);
     $this->_options = array_merge($this->_options, $config);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($this->_options, true));
     }
 }
 /**
  * validate if user is allowed to use the software in maintenance mode
  *
  * @return bool
  */
 public function validate()
 {
     if (Tinebase_Core::inMaintenanceMode()) {
         $currentAccount = Tinebase_User::getInstance()->getFullUserById($this->getValidData());
         if (!$currentAccount->hasRight('Tinebase', Tinebase_Acl_Rights::MAINTENANCE)) {
             return false;
         }
     }
     return true;
 }
 /**
  * set new password & credentials
  * 
  * @param string $_username
  * @param string $_password
  */
 protected function _setCredentials($_username, $_password)
 {
     Tinebase_User::getInstance()->setPassword(Tinebase_Core::getUser(), $_password, true, false);
     $oldCredentialCache = Tinebase_Core::get(Tinebase_Core::USERCREDENTIALCACHE);
     // update credential cache
     $credentialCache = Tinebase_Auth_CredentialCache::getInstance()->cacheCredentials($_username, $_password);
     Tinebase_Core::set(Tinebase_Core::USERCREDENTIALCACHE, $credentialCache);
     $event = new Tinebase_Event_User_ChangeCredentialCache($oldCredentialCache);
     Tinebase_Event::fireEvent($event);
 }
Пример #20
0
 /**
  * creates the initial folder for new accounts
  *
  * @param mixed[int|Tinebase_Model_User] $_account   the accountd object
  * @return Tinebase_Record_RecordSet                            of subtype Tinebase_Model_Container
  */
 public function createPersonalFolder($_accountId)
 {
     $translation = Tinebase_Translation::getTranslation('Projects');
     $accountId = Tinebase_Model_User::convertUserIdToInt($_accountId);
     $account = Tinebase_User::getInstance()->getUserById($accountId);
     $newContainer = new Tinebase_Model_Container(array('name' => sprintf($translation->_("%s's personal Projects"), $account->accountFullName), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Projects')->getId()));
     $personalContainer = Tinebase_Container::getInstance()->addContainer($newContainer, NULL, FALSE, $accountId);
     $container = new Tinebase_Record_RecordSet('Tinebase_Model_Container', array($personalContainer));
     return $container;
 }
Пример #21
0
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     if (Tinebase_User::getConfiguredBackend() !== Tinebase_User::LDAP) {
         $this->markTestSkipped('LDAP backend not enabled');
     }
     $this->_backend = Tinebase_User::factory(Tinebase_User::LDAP);
     if (!array_key_exists('Tinebase_User_Plugin_Samba', $this->_backend->getPlugins())) {
         $this->markTestSkipped('Samba LDAP plugin not enabled');
     }
     $this->objects['users'] = array();
 }
 /**
  * the constructor
  *
  */
 public function __construct(array $_options = array())
 {
     if (Tinebase_User::getConfiguredBackend() != Tinebase_User::LDAP) {
         throw new Tinebase_Exception('No LDAP config found.');
     }
     $this->_options = array_merge($this->_options, Tinebase_EmailUser::getConfig($this instanceof Tinebase_EmailUser_Imap_Interface ? Tinebase_Config::IMAP : Tinebase_Config::SMTP));
     $this->_options = array_merge($this->_options, $_options);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($this->_options, true));
     }
 }
Пример #23
0
 /**
  * import single record (create password if in data)
  *
  * @param Tinebase_Record_Abstract $_record
  * @param string $_resolveStrategy
  * @param array $_recordData
  * @return Tinebase_Record_Interface
  * @throws Tinebase_Exception_Record_Validation
  */
 protected function _importRecord($_record, $_resolveStrategy = NULL, $_recordData = array())
 {
     if ($_record instanceof Tinebase_Model_FullUser && $this->_controller instanceof Admin_Controller_User) {
         $record = $_record;
         // create valid login name
         if (!isset($record->accountLoginName)) {
             $record->accountLoginName = Tinebase_User::getInstance()->generateUserName($record, $this->_options['userNameSchema']);
         }
         // add prefix to login name if given
         if (!empty($this->_options['accountLoginNamePrefix'])) {
             $record->accountLoginName = $this->_options['accountLoginNamePrefix'] . $record->accountLoginName;
         }
         // add home dir if empty and prefix is given (append login name)
         if (empty($record->accountHomeDirectory) && !empty($this->_options['accountHomeDirectoryPrefix'])) {
             $record->accountHomeDirectory = $this->_options['accountHomeDirectoryPrefix'] . $record->accountLoginName;
         }
         // create email address if accountEmailDomain if given
         if (empty($record->accountEmailAddress) && !empty($this->_options['accountEmailDomain'])) {
             $record->accountEmailAddress = $record->accountLoginName . '@' . $this->_options['accountEmailDomain'];
         }
         if (!empty($this->_options['samba'])) {
             $this->_addSambaSettings($record);
         }
         Tinebase_Event::fireEvent(new Admin_Event_BeforeImportUser($record, $this->_options));
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($record->toArray(), true));
         }
         // generate passwd (use accountLoginName or password from options or password from csv in this order)
         $password = $record->accountLoginName;
         if (!empty($this->_options['password'])) {
             $password = $this->_options['password'];
         }
         if (isset($_recordData['password']) && !empty($_recordData['password'])) {
             $password = $_recordData['password'];
         }
         $this->_addEmailUser($record, $password);
         //if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Adding record: ' . print_r($record->toArray(), TRUE));
         // try to create record with password
         if ($record->isValid()) {
             if (!$this->_options['dryrun']) {
                 $record = $this->_controller->create($record, $password, $password);
             } else {
                 $this->_importResult['results']->addRecord($record);
             }
             $this->_importResult['totalcount']++;
         } else {
             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Record invalid: ' . print_r($record->getValidationErrors(), TRUE));
             throw new Tinebase_Exception_Record_Validation('Imported record is invalid.');
         }
     } else {
         $record = parent::_importRecord($_record, $_resolveStrategy, $_recordData);
     }
     return $record;
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     if (Tinebase_User::getConfiguredBackend() !== Tinebase_User::LDAP) {
         $this->markTestSkipped('LDAP backend not enabled');
     }
     $this->_backend = Tinebase_User::getInstance();
     if (!array_key_exists('Tinebase_EmailUser_Smtp_LdapMailSchema', $this->_backend->getPlugins())) {
         $this->markTestSkipped('Mail LDAP plugin not enabled');
     }
     $this->objects['users'] = array();
 }
Пример #25
0
 /**
  * resolve containers, tags and users
  *
  * @param Tinebase_Record_RecordSet $_records
  * @param array $_resolveUserFields
  */
 public static function resolveContainerTagsUsers(Tinebase_Record_RecordSet $_records, $_resolveUserFields = array())
 {
     if ($_records->getFirstRecord()->has('container_id')) {
         Tinebase_Container::getInstance()->getGrantsOfRecords($_records, Tinebase_Core::getUser());
     }
     if ($_records->getFirstRecord()->has('tags')) {
         Tinebase_Tags::getInstance()->getMultipleTagsOfRecords($_records);
     }
     if (array_key_exists($_records->getRecordClassName(), $_resolveUserFields)) {
         Tinebase_User::getInstance()->resolveMultipleUsers($_records, $_resolveUserFields[$_records->getRecordClassName()], TRUE);
     }
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     if (Tinebase_User::getConfiguredBackend() !== Tinebase_User::LDAP) {
         $this->markTestSkipped('LDAP backend not enabled');
     }
     $this->_backend = Tinebase_User::factory(Tinebase_User::LDAP);
     if (!array_key_exists('Tinebase_EmailUser_Imap_LdapDbmailSchema', $this->_backend->getPlugins())) {
         $this->markTestSkipped('Dbmail LDAP plugin not enabled');
     }
     $this->_config = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP, new Tinebase_Config_Struct())->toArray();
     $this->objects['users'] = array();
 }
Пример #27
0
 protected function appendDependentRecords($record)
 {
     Tinebase_User::getInstance()->resolveUsers($record, 'created_by');
     Tinebase_User::getInstance()->resolveUsers($record, 'last_modified_by');
     //Tinebase_User::getInstance()->resolveMultipleUsers($_records, 'account_id', true);
     if ($record->__get('order_id')) {
         $this->appendForeignRecordToRecord($record, 'order_id', 'order_id', 'id', new Billing_Backend_Order());
         $order = $record->__get('order_id');
         try {
             if ($order instanceof Billing_Model_Order) {
                 $debitorId = $order->__get('debitor_id');
             } else {
                 $debitorId = $order->debitor_id;
             }
             $debitor = Billing_Controller_Debitor::getInstance()->get($debitorId);
             if ($order instanceof Billing_Model_Order) {
                 $order->__set('debitor_id', $debitor->toArray());
             } else {
                 $order->debitor_id = $debitor->toArray();
             }
         } catch (Exception $e) {
         }
         $record->__set('order_id', $order);
     }
     if ($record->__get('booking_id')) {
         $this->appendForeignRecordToRecord($record, 'booking_id', 'booking_id', 'id', new Billing_Backend_Booking());
     }
     if ($record->__get('payment_method_id')) {
         $this->appendForeignRecordToRecord($record, 'payment_method_id', 'payment_method_id', 'id', new Billing_Backend_PaymentMethod());
     }
     if ($record->__get('fee_group_id')) {
         $this->appendForeignRecordToRecord($record, 'fee_group_id', 'fee_group_id', 'id', new Membership_Backend_FeeGroup());
     }
     //        $rBackend = new Billing_Backend_ReceiptPosition();
     //        $receiptPositions = $rBackend->getByReceiptId($record->getId());
     //        $sumNetto = 0;
     //        $sumBrutto = 0;
     //        $count = 0;
     //        $totalWeight = 0;
     //        foreach($receiptPositions as $pos){
     //        	$netto = $pos->__get('total_netto');
     //        	$brutto = $pos->__get('total_brutto');
     //        	$weight = $pos->__get('total_weight');
     //        	$sumNetto += $netto;
     //        	$sumBrutto += $brutto;
     //        	$totalWeight += $weight;
     //        	$count++;
     //        }
     //        $record->__set('total_netto', $sumNetto);
     //        $record->__set('total_brutto', $sumBrutto);
     //        $record->__set('pos_count', $count);
     //        $record->__set('total_weight', $totalWeight);
 }
Пример #28
0
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->_backend = Tinebase_User::getInstance();
     if (!array_key_exists('Tinebase_EmailUser_Smtp_Postfix', $this->_backend->getPlugins())) {
         $this->markTestSkipped('Postfix SQL plugin not enabled');
     }
     $this->objects['users'] = array();
     $config = TestServer::getInstance()->getConfig();
     if ($config->maildomain) {
         $this->_mailDomain = $config->maildomain;
     }
 }
Пример #29
0
 /**
  * (non-PHPdoc)
  * @see Sabre_DAVACL_IPrincipalBackend::getGroupMembership()
  */
 public function getGroupMembership($principal)
 {
     $result = array();
     list(, $contactId) = Sabre_DAV_URLUtil::splitPath($principal);
     $user = Tinebase_User::getInstance()->getUserByProperty('contactId', $contactId);
     $groupIds = Tinebase_Group::getInstance()->getGroupMemberships($user);
     $groups = Tinebase_Group::getInstance()->getMultiple($groupIds);
     foreach ($groups as $group) {
         $result[] = 'principals/groups/' . $group->list_id;
     }
     return $result;
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     parent::setUp();
     $this->objects['application'] = Tinebase_Application::getInstance()->getApplicationByName('Addressbook');
     $this->objects['user'] = new Tinebase_Model_FullUser(array('accountLoginName' => 'tine20phpunit', 'accountDisplayName' => 'tine20phpunit', 'accountStatus' => 'enabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => Tinebase_Group::getInstance()->getDefaultGroup()->getId(), 'accountLastName' => 'Tine 2.0', 'accountFirstName' => 'PHPUnit', 'accountEmailAddress' => '*****@*****.**'));
     $this->objects['role'] = new Tinebase_Model_Role(array('id' => 10, 'name' => 'phpunitrole', 'description' => 'test role for phpunit'));
     $this->objects['role_2'] = new Tinebase_Model_Role(array('id' => 11, 'name' => 'phpunitrole 2', 'description' => 'test role 2 for phpunit'));
     // add account for group / role member tests
     $this->_usernamesToDelete[] = $this->objects['user']->accountLoginName;
     $this->objects['user'] = Tinebase_User::getInstance()->addUser($this->objects['user']);
     Tinebase_Group::getInstance()->addGroupMember($this->objects['user']->accountPrimaryGroup, $this->objects['user']);
     Tinebase_Acl_Roles::getInstance()->resetClassCache();
 }