/**
  * 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;
 }
Пример #2
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');
 }
 /**
  * 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;
 }
Пример #4
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;
 }
Пример #5
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;
 }
 /**
  * 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;
 }
 /**
  * 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);
     }
 }
Пример #8
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();
 }
 /**
  * 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);
 }
 /**
  * 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;
 }
Пример #12
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;
 }
Пример #13
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();
 }
Пример #15
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;
     }
 }
Пример #16
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);
     }
 }
Пример #17
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);
 }
Пример #18
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;
 }
 /**
  * testInstallAdminAccountOptions
  */
 public function testInstallAdminAccountOptions()
 {
     $this->_uninstallAllApplications();
     $this->_uit->installApplications(array('Tinebase'), array('adminLoginName' => 'phpunit-admin', 'adminPassword' => 'phpunit-password'));
     $adminUser = Tinebase_User::getInstance()->getFullUserByLoginName('phpunit-admin');
     $this->assertTrue($adminUser instanceof Tinebase_Model_User);
     $this->assertNull(Tinebase_Auth::getBackendConfiguration('adminLoginName'));
     $this->assertNull(Tinebase_Auth::getBackendConfiguration('adminPassword'));
     $this->assertNull(Tinebase_Auth::getBackendConfiguration('adminConfirmation'));
     // cleanup
     $this->_uninstallAllApplications();
 }
 /**
  * test read grant
  * 
  * @return Tinebase_Model_PersistentFilter
  */
 public function testReadGrant()
 {
     $filter = $this->testSaveSharedFavorite();
     $this->_restoreTestUser = Tinebase_Core::getUser();
     $sclever = Tinebase_User::getInstance()->getFullUserByLoginName('sclever');
     Tinebase_Core::set(Tinebase_Core::USER, $sclever);
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Setting sclever (id: ' . $sclever->getId() . ') as current user');
     }
     $filterAsSeenBySclever = $this->_instance->get($filter->getId());
     $this->assertEquals($filter->name, $filterAsSeenBySclever->name);
     return $filterAsSeenBySclever;
 }
 /**
  * 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();
 }
 /**
  * adds email and samba users, generates username + user password and 
  *   applies multiple options (like accountLoginNamePrefix, accountHomeDirectoryPrefix, ...)
  * 
  * @param array $options
  * @param string $password
  * @return string
  */
 public function applyOptionsAndGeneratePassword($options, $password = NULL)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($options, TRUE));
     }
     if (!isset($this->accountLoginName)) {
         $this->accountLoginName = Tinebase_User::getInstance()->generateUserName($this, isset($options['userNameSchema']) ? $options['userNameSchema'] : 1);
         $this->accountFullName = Tinebase_User::getInstance()->generateAccountFullName($this);
     }
     if (empty($this->accountPrimaryGroup)) {
         if (!empty($options['group_id'])) {
             $groupId = $options['group_id'];
         } else {
             // use default user group
             $defaultUserGroup = Tinebase_Group::getInstance()->getDefaultGroup();
             $groupId = $defaultUserGroup->getId();
         }
         $this->accountPrimaryGroup = $groupId;
     }
     // add prefix to login name if given
     if (!empty($options['accountLoginNamePrefix'])) {
         $this->accountLoginName = $options['accountLoginNamePrefix'] . $this->accountLoginName;
     }
     // short username if needed
     $this->accountLoginName = $this->shortenUsername();
     // add home dir if empty and prefix is given (append login name)
     if (empty($this->accountHomeDirectory) && !empty($options['accountHomeDirectoryPrefix'])) {
         $this->accountHomeDirectory = $options['accountHomeDirectoryPrefix'] . $this->accountLoginName;
     }
     // create email address if accountEmailDomain if given
     if (empty($this->accountEmailAddress) && !empty($options['accountEmailDomain'])) {
         $this->accountEmailAddress = $this->accountLoginName . '@' . $options['accountEmailDomain'];
     }
     if (!empty($options['samba'])) {
         $this->_addSambaSettings($options['samba']);
     }
     if (empty($this->accountLoginShell) && !empty($options['accountLoginShell'])) {
         $this->accountLoginShell = $options['accountLoginShell'];
     }
     // generate passwd (use accountLoginName or password from options or password from csv in this order)
     $userPassword = $this->accountLoginName;
     if (!empty($password)) {
         $userPassword = $password;
     } else {
         if (!empty($options['password'])) {
             $userPassword = $options['password'];
         }
     }
     $this->_addEmailUser($userPassword);
     return $userPassword;
 }
Пример #23
0
 /**
  * Append contacts by foreign key (record embedding)
  * 
  * @param Tinebase_Record_Abstract $record
  * @return void
  */
 protected function appendDependentRecords($record)
 {
     Tinebase_User::getInstance()->resolveUsers($record, 'created_by_user');
     Tinebase_User::getInstance()->resolveUsers($record, 'processed_by_user');
     if ($record->__get('job_id')) {
         $this->appendForeignRecordToRecord($record, 'job_id', 'job_id', 'id', new Billing_Backend_BatchJob());
     }
     if ($record->__get('contact_id')) {
         $this->appendForeignRecordToRecord($record, 'contact_id', 'contact_id', 'id', Addressbook_Backend_Factory::factory(Addressbook_Backend_Factory::SQL));
     }
     if ($record->__get('debitor_id')) {
         $this->appendForeignRecordToRecord($record, 'debitor_id', 'debitor_id', 'id', new Billing_Backend_Debitor());
     }
 }
 /**
  * test employee import
  * 
  * @group longrunning
  */
 public function testImportEmployee()
 {
     $cc = $this->_getSalesCostCenter(7);
     $this->_doImport(true);
     $susan = $this->_getSusan();
     $this->assertEquals('Street 48', $susan->street, print_r($susan->toArray(), TRUE));
     $this->assertEquals('techniker', $susan->health_insurance, print_r($susan->toArray(), TRUE));
     $sclever = Tinebase_User::getInstance()->getFullUserByLoginName('sclever');
     $this->assertEquals($sclever->getId(), $susan->account_id, print_r($susan->toArray(), TRUE));
     $this->assertEquals('1973-12-12 00:00:00', $susan->bday->__toString(), print_r($susan->toArray(), TRUE));
     $susan->contracts = HumanResources_Controller_Contract::getInstance()->getContractsByEmployeeId($susan->getId());
     $this->assertEquals(1, $susan->contracts->count(), 'no contracts found');
     return $susan;
 }
 /**
  * @return void
  */
 public function testEmailsToAttendee()
 {
     $event = $this->_getEvent();
     $persistentEvent = Calendar_Controller_Event::getInstance()->create($event);
     $sclever = Tinebase_User::getInstance()->getUserByLoginName('sclever', 'Tinebase_Model_FullUser');
     $newEmail = Tinebase_Record_Abstract::generateUID() . '@unittest.com';
     // delete newly created contact in tearDown()
     $this->_testEmailContacts[] = $newEmail;
     $newAttendees = array(array('userType' => Calendar_Model_Attender::USERTYPE_USER, 'firstName' => $this->_originalTestUser->accountFirstName, 'lastName' => $this->_originalTestUser->accountLastName, 'partStat' => Calendar_Model_Attender::STATUS_ACCEPTED, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => $this->_originalTestUser->accountEmailAddress), array('userType' => Calendar_Model_Attender::USERTYPE_USER, 'displayName' => $sclever->accountDisplayName, 'partStat' => Calendar_Model_Attender::STATUS_DECLINED, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => $sclever->accountEmailAddress), array('userType' => Calendar_Model_Attender::USERTYPE_USER, 'firstName' => 'Lars', 'lastName' => 'Kneschke', 'partStat' => Calendar_Model_Attender::STATUS_TENTATIVE, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => $newEmail));
     Calendar_Model_Attender::emailsToAttendee($persistentEvent, $newAttendees, TRUE);
     $this->assertEquals(3, count($persistentEvent->attendee));
     $this->assertEquals(1, count($persistentEvent->attendee->filter('status', Calendar_Model_Attender::STATUS_ACCEPTED)));
     $this->assertEquals(1, count($persistentEvent->attendee->filter('status', Calendar_Model_Attender::STATUS_DECLINED)));
     $this->assertEquals(1, count($persistentEvent->attendee->filter('status', Calendar_Model_Attender::STATUS_TENTATIVE)));
 }
Пример #26
0
 /**
  * returns array with record related properties
  * resolves the creator display name and calls Tinebase_Record_Abstract::toArray() 
  *
  * @param boolean $_recursive
  * @param boolean $_resolveCreator
  * @return array
  */
 public function toArray($_recursive = TRUE, $_resolveCreator = TRUE)
 {
     $result = parent::toArray($_recursive);
     // get creator
     if ($this->created_by && $_resolveCreator) {
         //resolve creator; return default NonExistentUser-Object if creator cannot be resolved =>
         //@todo perhaps we should add a "getNonExistentUserIfNotExists" parameter to Tinebase_User::getUserById
         try {
             $creator = Tinebase_User::getInstance()->getUserById($this->created_by);
         } catch (Tinebase_Exception_NotFound $e) {
             $creator = Tinebase_User::getInstance()->getNonExistentUser();
         }
         $result['created_by'] = $creator->accountDisplayName;
     }
     return $result;
 }
Пример #27
0
 public function _testTasks()
 {
     $allUsers = Tinebase_User::getInstance()->getFullUsers('');
     $numSearches = 0;
     foreach ($allUsers as $user) {
         if ($numSearches > 120) {
             break;
         }
         echo ".";
         $filterData = array(array('field' => 'container_id', 'operator' => 'in', 'value' => '/'));
         $filter = new Tasks_Model_TaskFilter($filterData);
         Tasks_Controller_Task::getInstance()->search($filter, NULL, FALSE);
         //$json = new Tasks_Frontend_Json();
         //$json->searchTasks($filterData, array());
         $numSearches += 1;
     }
 }
 public function testCreateDemoCalendars()
 {
     ob_start();
     Calendar_Setup_DemoData::getInstance()->createDemoData(array('locale' => 'en'));
     ob_end_clean();
     $pwulf = Tinebase_User::getInstance()->getFullUserByLoginName('pwulf');
     $businessCalendar = Tinebase_Container::getInstance()->getContainerByName('Calendar', 'Business', Tinebase_Model_Container::TYPE_PERSONAL, $pwulf->getId());
     $sharedCalendar = Tinebase_Container::getInstance()->getContainerByName('Calendar', 'Shared Calendar', Tinebase_Model_Container::TYPE_SHARED);
     $cce = Calendar_Controller_Event::getInstance();
     $filter = new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $businessCalendar->getId())), 'AND');
     $businessEvents = $cce->search($filter);
     $cce->deleteByFilter($filter);
     $filter = new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $sharedCalendar->getId())), 'AND');
     $sharedEvents = $cce->search($filter);
     $cce->deleteByFilter($filter);
     $this->assertEquals($businessEvents->count(), 1);
     $this->assertEquals($sharedEvents->count(), 10);
 }
 /**
  * Creates a new calendar for a principal.
  *
  * If the creation was a success, an id must be returned that can be used to reference
  * this calendar in other methods, such as updateCalendar.
  *
  * This function must return a server-wide unique id that can be used 
  * later to reference the calendar.
  *
  * @param string $principalUri
  * @param string $calendarUri
  * @param array $properties
  * @return string|int 
  */
 function createCalendar($principalUri, $calendarUri, array $properties)
 {
     throw new Sabre\DAV\Exception\MethodNotAllowed('createCalendar');
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' $principalUri: ' . $principalUri . ' $calendarUri: ' . $calendarUri . ' $properties' . print_r($properties, TRUE));
     }
     // NOTE: at the moment we only support a predefined set of colors
     //        if ((isset($properties['{http://apple.com/ns/ical/}calendar-color']) || array_key_exists('{http://apple.com/ns/ical/}calendar-color', $properties))) {
     //            $color = substr($properties['{http://apple.com/ns/ical/}calendar-color'], 0, 7);
     //            $container->color = $color;
     //        }
     $principalParts = explode('/', $principalUri);
     if (count($principalParts) == 2) {
         $container = new Tinebase_Model_Container(array('name' => $properties['{DAV:}displayname'], 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $principalParts[1]), 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'backend' => 'Sql', 'model' => 'Calendar_Model_Event'));
         $container = Tinebase_Container::getInstance()->addContainer($container);
     } else {
         throw new Sabre\DAV\Exception\PreconditionFailed('unsupported pricipalUri');
     }
     return $container->getId();
 }
Пример #30
0
 /**
  * create a attendee filter of users affected by this filter
  * 
  * @return Calendar_Model_AttenderFilter
  */
 public function getRelatedAttendeeFilter()
 {
     // allways set currentaccount
     $userIds = array(Tinebase_Core::getUser()->getId());
     // rip users from pathes
     foreach ((array) $this->getValue() as $value) {
         if (preg_match("/^\\/personal\\/([0-9a-z_\\-]+)/i", $value, $matches)) {
             // transform current user
             $userIds[] = $matches[1] == Tinebase_Model_User::CURRENTACCOUNT ? Tinebase_Core::getUser()->getId() : $matches[1];
         }
     }
     // get contact ids
     $users = Tinebase_User::getInstance()->getMultiple(array_unique($userIds));
     $attendeeFilterData = array();
     foreach ($users as $user) {
         $attendeeFilterData[] = array('user_type' => Calendar_Model_Attender::USERTYPE_USER, 'user_id' => $user->contact_id);
     }
     $attenderFilter = new Calendar_Model_AttenderFilter('attender', 'in', $attendeeFilterData);
     return $attenderFilter;
 }