Пример #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;
             }
         }
     }
 }
 /**
  * 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);
 }
Пример #3
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);
 }
 /**
  * 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()
 {
     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());
 }
Пример #7
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();
 }
 /**
  * Tears down the fixture
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     if (Tinebase_User::getConfiguredBackend() !== Tinebase_User::LDAP) {
         return;
     }
     $this->_groupLDAP->deleteGroups($this->objects['groups']);
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Deleting users: ' . print_r($this->objects['users']->toArray(), true));
     }
     $this->_userLDAP->deleteUsers($this->objects['users']->getArrayOfIds());
 }
 /**
  * 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();
 }
 /**
  * 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));
     }
 }
 /**
  * the singleton pattern
  *
  * @return Tinebase_Group_Abstract
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         $backendType = Tinebase_User::getConfiguredBackend();
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' groups backend: ' . $backendType);
         }
         self::$_instance = self::factory($backendType);
     }
     return self::$_instance;
 }
 /**
  * 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();
 }
 /**
  * testMaintenanceModeLoginFail
  */
 public function testMaintenanceModeLoginFail()
 {
     if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP || Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
         $this->markTestSkipped('FIXME: Does not work with LDAP/AD backend (full test suite run)');
     }
     Tinebase_Config::getInstance()->maintenanceMode = 1;
     try {
         $this->_instance->login('sclever', Tinebase_Helper::array_value('password', TestServer::getInstance()->getTestCredentials()), new \Zend\Http\PhpEnvironment\Request());
         $this->fail('expecting exception: Tinebase_Exception_MaintenanceMode');
     } catch (Tinebase_Exception_MaintenanceMode $temm) {
         $this->assertEquals('Installation is in maintenance mode. Please try again later', $temm->getMessage());
     }
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  */
 public function setUp()
 {
     if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
         // account email addresses are empty with AD backend
         $this->markTestSkipped('skipped for ad backend');
     }
     parent::setUp();
     $this->objects['initialContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId())));
     $this->objects['sharedContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_SHARED, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId())));
     $prefs = new Calendar_Preference();
     $prefs->setValue(Calendar_Preference::DEFAULTCALENDAR, $this->objects['initialContainer']->getId());
     $_SERVER['REQUEST_URI'] = 'lars';
 }
 /**
  * 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');
     }
     if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
         // error: Zend_Ldap_Exception: 0x44 (Already exists; 00002071: samldb: Account name (sAMAccountName)
         // 'tine20phpunituser' already in use!): adding: cn=PHPUnit User Tine 2.0,cn=Users,dc=example,dc=org
         $this->markTestSkipped('skipped for ad backends as it does not allow duplicate CNs');
     }
     $this->objects['users'] = array();
     $this->_mailDomain = TestServer::getPrimaryMailDomain();
 }
 /**
  * set config options (accounts/authentication/email/...)
  *
  * @param array $_options
  */
 protected function _setupConfigOptions($_options)
 {
     // ignore empty options
     foreach ($_options as $key => $value) {
         if (empty($_options[$key])) {
             unset($_options[$key]);
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Saving config options (accounts/authentication/email/...)');
     }
     // this is a dangerous TRACE as there might be passwords in here!
     //if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_options, TRUE));
     $defaults = empty($_options['authenticationData']) ? Setup_Controller::getInstance()->loadAuthenticationData() : $_options['authenticationData'];
     $defaultGroupNames = $this->_parseDefaultGroupNameOptions($_options);
     $defaults['accounts'][Tinebase_User::getConfiguredBackend()] = array_merge($defaults['accounts'][Tinebase_User::getConfiguredBackend()], $defaultGroupNames);
     $emailConfigKeys = Setup_Controller::getInstance()->getEmailConfigKeys();
     $configsToSet = array_merge($emailConfigKeys, array('authentication', 'accounts', 'redirectSettings', 'acceptedTermsVersion'));
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($configsToSet, TRUE));
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($defaults, TRUE));
     }
     $optionsToSave = array();
     foreach ($configsToSet as $group) {
         if (isset($_options[$group])) {
             $parsedOptions = is_string($_options[$group]) ? Setup_Frontend_Cli::parseConfigValue($_options[$group]) : $_options[$group];
             switch ($group) {
                 case 'authentication':
                 case 'accounts':
                     $backend = isset($parsedOptions['backend']) ? ucfirst($parsedOptions['backend']) : Tinebase_User::SQL;
                     $optionsToSave[$group][$backend] = isset($parsedOptions[$backend]) ? $parsedOptions[$backend] : $parsedOptions;
                     $optionsToSave[$group]['backend'] = $backend;
                     break;
                 default:
                     $optionsToSave[$group] = $parsedOptions;
             }
         } else {
             if (isset($defaults[$group])) {
                 $optionsToSave[$group] = $defaults[$group];
             }
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($optionsToSave, TRUE));
     }
     Setup_Controller::getInstance()->saveEmailConfig($optionsToSave);
     Setup_Controller::getInstance()->saveAuthentication($optionsToSave);
 }
 /**
  * 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);
     // remove user left over by broken tests
     try {
         $user = $this->_backend->getUserByLoginName('tine20phpunituser', 'Tinebase_Model_FullUser');
         $this->_backend->deleteUser($user);
     } catch (Tinebase_Exception_NotFound $tenf) {
         // do nothing
     }
     $this->objects['users'] = array();
 }
 /**
  * test generation of login names
  */
 public function testGenerateUserName()
 {
     if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
         // error: Zend_Ldap_Exception: 0x44 (Already exists;
         // Entry CN=Leonie Weiss,CN=Users,DC=example,DC=org already exists):
         // adding: cn=Leonie Weiss,cn=Users,dc=example,dc=org
         $this->markTestSkipped('skipped for ad backends as it does not allow duplicate CNs');
     }
     $user = new Tinebase_Model_FullUser(array('accountFirstName' => 'Leonie', 'accountLastName' => 'Weiss', 'accountPrimaryGroup' => Tinebase_Core::getUser()->accountPrimaryGroup), true);
     $createdUserIds = array();
     for ($i = 0; $i < 10; $i++) {
         $user->accountLoginName = $this->_uit->generateUserName($user);
         $createdUserIds[] = $this->_uit->addUser($user)->getId();
         $user->setId(NULL);
     }
     $this->_uit->deleteUsers($createdUserIds);
 }
 /**
  * the constructor
  *
  * don't use the constructor. use the singleton 
  */
 private function __construct()
 {
     if (!Tinebase_Core::getConfig()->samba) {
         throw new Admin_Exception('No samba settings defined in config.');
     }
     if (Tinebase_User::getConfiguredBackend() != Tinebase_User::LDAP) {
         throw new Admin_Exception('Works only with LDAP user backend.');
     }
     $ldapOptions = Tinebase_User::getBackendConfiguration();
     $sambaOptions = Tinebase_Core::getConfig()->samba->toArray();
     $options = array_merge($ldapOptions, $sambaOptions);
     $options['machineGroup'] = isset($options['machineGroup']) ? $options['machineGroup'] : 'Domain Computers';
     $this->_options = $options;
     $this->_applicationName = 'Admin';
     // we might want to add a factory here when we support multiple backends
     $this->_backend = new Admin_Backend_SambaMachine($this->_options);
 }
 /**
  * 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(true);
     Calendar_Config::getInstance()->set(Calendar_Config::DISABLE_EXTERNAL_IMIP, false);
     $this->_iMIPFrontend = new Calendar_Frontend_iMIP();
     $this->_iMIPFrontendMock = new Calendar_Frontend_iMIPMock();
     try {
         $this->_emailTestClass = new Felamimail_Controller_MessageTest();
         $this->_emailTestClass->setup();
     } catch (Exception $e) {
         // do nothing
     }
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->_config = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP, new Tinebase_Config_Struct())->toArray();
     if (!isset($this->_config['backend']) || !('Imap_' . ucfirst($this->_config['backend']) == Tinebase_EmailUser::IMAP_DOVECOT) || $this->_config['active'] != true) {
         $this->markTestSkipped('Dovecot MySQL backend not configured or not enabled');
     }
     if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
         // error: Zend_Ldap_Exception: 0x44 (Already exists; 00002071: samldb: Account name (sAMAccountName)
         // 'tine20phpunituser' already in use!): adding: cn=PHPUnit User Tine 2.0,cn=Users,dc=example,dc=org
         $this->markTestSkipped('skipped for ad backends as it does not allow duplicate CNs');
     }
     $this->_backend = Tinebase_EmailUser::getInstance(Tinebase_Config::IMAP);
     $personas = Zend_Registry::get('personas');
     $this->_objects['user'] = clone $personas['jsmith'];
     //$this->_objects['user']->setId(Tinebase_Record_Abstract::generateUID());
     $this->_objects['addedUsers'] = array();
     $this->_objects['fullUsers'] = array();
 }
 /**
  * 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) {
         $this->markTestSkipped('only working in non-AD setups');
     }
     parent::setUp();
     $mockBackend = new Sabre\DAV\Auth\Backend\Mock();
     $mockBackend->defaultUser = Tinebase_Core::getUser()->contact_id;
     $plugin = new Sabre\DAV\Auth\Plugin($mockBackend, 'realm');
     $this->server->addPlugin($plugin);
     $aclPlugin = new \Sabre\DAVACL\Plugin();
     $aclPlugin->defaultUsernamePath = Tinebase_WebDav_PrincipalBackend::PREFIX_USERS;
     $aclPlugin->principalCollectionSet = array(Tinebase_WebDav_PrincipalBackend::PREFIX_USERS, Tinebase_WebDav_PrincipalBackend::PREFIX_GROUPS);
     $this->server->addPlugin($aclPlugin);
     $this->server->addPlugin(new \Sabre\CalDAV\Plugin());
     $this->server->addPlugin(new \Sabre\CalDAV\SharingPlugin());
     $this->plugin = new Tinebase_WebDav_Plugin_PrincipalSearch();
     $this->server->addPlugin($this->plugin);
 }
Пример #23
0
 /**
  * Returns registry data of tinebase.
  * @see Tinebase_Application_Json_Abstract
  *
  * @return mixed array 'variable name' => 'data'
  */
 public function getRegistryData()
 {
     $locale = Tinebase_Core::get('locale');
     $tbFrontendHttp = new Tinebase_Frontend_Http();
     // default credentials
     if (isset(Tinebase_Core::getConfig()->login)) {
         $loginConfig = Tinebase_Core::getConfig()->login;
         $defaultUsername = isset($loginConfig->username) ? $loginConfig->username : '';
         $defaultPassword = isset($loginConfig->password) ? $loginConfig->password : '';
     } else {
         $defaultUsername = '';
         $defaultPassword = '';
     }
     $registryData = array('serviceMap' => $tbFrontendHttp->getServiceMap(), 'timeZone' => Tinebase_Core::get(Tinebase_Core::USERTIMEZONE), 'locale' => array('locale' => $locale->toString(), 'language' => Zend_Locale::getTranslation($locale->getLanguage(), 'language', $locale), 'region' => Zend_Locale::getTranslation($locale->getRegion(), 'country', $locale)), 'version' => array('buildType' => TINE20_BUILDTYPE, 'codeName' => TINE20_CODENAME, 'packageString' => TINE20_PACKAGESTRING, 'releaseTime' => TINE20_RELEASETIME, 'filesHash' => TINE20_BUILDTYPE != 'DEVELOPMENT' ? $tbFrontendHttp->getJsCssHash() : null), 'defaultUsername' => $defaultUsername, 'defaultPassword' => $defaultPassword, 'denySurveys' => Tinebase_Core::getConfig()->denySurveys, 'titlePostfix' => Tinebase_Config::getInstance()->getConfig(Tinebase_Model_Config::PAGETITLEPOSTFIX, NULL, '')->value, 'redirectUrl' => Tinebase_Config::getInstance()->getConfig(Tinebase_Model_Config::REDIRECTURL, NULL, '')->value, 'maxFileUploadSize' => convertToBytes(ini_get('upload_max_filesize')), 'maxPostSize' => convertToBytes(ini_get('post_max_size')));
     if (Tinebase_Core::isRegistered(Tinebase_Core::USER)) {
         $user = Tinebase_Core::getUser();
         $userContactArray = array();
         if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
             try {
                 $userContactArray = Addressbook_Controller_Contact::getInstance()->getContactByUserId($user->getId(), TRUE)->toArray();
             } catch (Addressbook_Exception_NotFound $aenf) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                     Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' User not found in Addressbook: ' . $user->accountDisplayName);
                 }
             }
         }
         $registryData += array('currentAccount' => $user->toArray(), 'userContact' => $userContactArray, 'accountBackend' => Tinebase_User::getConfiguredBackend(), 'jsonKey' => Tinebase_Core::get('jsonKey'), 'userApplications' => $user->getApplications()->toArray(), 'NoteTypes' => $this->getNoteTypes(), 'stateInfo' => Tinebase_State::getInstance()->loadStateInfo(), 'changepw' => Tinebase_User::getBackendConfiguration('changepw', true), 'mustchangepw' => $user->mustChangePassword(), 'mapPanel' => Tinebase_Config::getInstance()->getConfig(Tinebase_Config::MAPPANEL, NULL, TRUE)->value, 'confirmLogout' => Tinebase_Core::getPreference()->getValue(Tinebase_Preference::CONFIRM_LOGOUT, 1), 'persistentFilters' => Tinebase_Frontend_Json_PersistentFilter::getAllPersistentFilters(), 'messenger' => $this->getMessengerConfig());
     }
     return $registryData;
 }
 /**
  * get user registry
  * 
  * @return array
  */
 protected function _getUserRegistryData()
 {
     $user = Tinebase_Core::getUser();
     $userContactArray = array();
     if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
         try {
             $userContactArray = Addressbook_Controller_Contact::getInstance()->getContactByUserId($user->getId(), TRUE)->toArray();
         } catch (Addressbook_Exception_NotFound $aenf) {
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                 /** @noinspection PhpUndefinedMethodInspection */
                 Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' User not found in Addressbook: ' . $user->accountDisplayName);
             }
         }
     }
     try {
         $persistentFilters = Tinebase_Frontend_Json_PersistentFilter::getAllPersistentFilters();
     } catch (Tinebase_Exception_NotFound $tenf) {
         if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
             Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . " Failed to fetch persistent filters. Exception: \n" . $tenf);
         }
         $persistentFilters = array();
     } catch (Exception $e) {
         if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
             Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . " Failed to fetch persistent filters. Exception: \n" . $e);
         }
         $persistentFilters = array();
     }
     $userRegistryData = array('timeZone' => Tinebase_Core::getUserTimezone(), 'currentAccount' => $user->toArray(), 'userContact' => $userContactArray, 'accountBackend' => Tinebase_User::getConfiguredBackend(), 'jsonKey' => Tinebase_Core::get('jsonKey'), 'userApplications' => $user->getApplications()->toArray(), 'NoteTypes' => $this->getNoteTypes(), 'stateInfo' => Tinebase_State::getInstance()->loadStateInfo(), 'mustchangepw' => $user->mustChangePassword(), 'confirmLogout' => Tinebase_Core::getPreference()->getValue(Tinebase_Preference::CONFIRM_LOGOUT, 1), 'advancedSearch' => Tinebase_Core::getPreference()->getValue(Tinebase_Preference::ADVANCED_SEARCH, 0), 'persistentFilters' => $persistentFilters, 'userAccountChanged' => Tinebase_Controller::getInstance()->userAccountChanged());
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' User registry: ' . print_r($userRegistryData, TRUE));
     }
     return $userRegistryData;
 }
 /**
  * tear down tests
  */
 protected function tearDown()
 {
     if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP) {
         $this->_deleteUsers();
         $this->_deleteGroups();
     }
     if ($this->_transactionId) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Rolling back test transaction');
         }
         Tinebase_TransactionManager::getInstance()->rollBack();
     }
     Addressbook_Controller_Contact::getInstance()->setGeoDataForContacts(true);
     if ($this->_originalTestUser instanceof Tinebase_Model_User) {
         Tinebase_Core::set(Tinebase_Core::USER, $this->_originalTestUser);
     }
     if ($this->_invalidateRolesCache) {
         Tinebase_Acl_Roles::getInstance()->resetClassCache();
     }
     Tinebase_Cache_PerRequest::getInstance()->reset();
     $this->_releaseDBLocks();
 }
 /**
  * maps tine 2.0 user/group Id to egw account Id
  * 
  * @param  int      $_tineAccountId
  * @param  string   $_accountType
  * @return string 
  */
 public function mapAccountIdTine2Egw($_tineAccountId, $_accountType = 'User')
 {
     $egwAccountId = NULL;
     $keys = array_keys($this->_accountIdMapCache, $_tineAccountId);
     foreach ((array) $keys as $candidate) {
         if ($_accountType == 'User' && (int) $candidate > 0) {
             $egwAccountId = $candidate;
         } else {
             if ($_accountType == 'Group' && (int) $candidate < 0) {
                 $egwAccountId = $candidate;
             }
         }
     }
     // not in cache
     if (!$egwAccountId) {
         if ($this->_config->accountIdMap) {
             throw new Exception("account with id {$_tineAccountId} not found in static map");
         } else {
             if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP) {
                 if ($_accountType == 'User') {
                     $this->_accountIdMapCache[$egwAccountId] = Tinebase_User::getInstance()->resolveUUIdToUIdNumber($_tineAccountId);
                 } else {
                     $this->_accountIdMapCache[$egwAccountId] = Tinebase_Group::getInstance()->resolveUUIdToGIdNumber($_tineAccountId);
                 }
             } else {
                 $egwAccountId = ($_accountType == 'User' ? '' : '-') . $_tineAccountId;
             }
         }
         $this->_accountIdMapCache[$egwAccountId] = $_tineAccountId;
     }
     return $egwAccountId;
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->_originalBackendConfiguration = Tinebase_User::getBackendConfiguration();
     $this->_originalBackendType = Tinebase_User::getConfiguredBackend();
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
 }
 /**
  * Test students loginname with schema 3 with SpecialChars
  */
 public function testStudentNameSchemaSpecialChars()
 {
     if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
         // fails in AD setup (only with all tests):
         // Zend_Ldap_Exception: 0x15 (Invalid syntax; 0000200B: objectclass_attrs:
         // attribute 'primarygroupid' on entry 'cn=mycourse44 Lehrer,cn=Users,dc=example,dc=org'
         // contains at least one invalid value!): updating: cn=mycourse44 Lehrer,cn=Users,dc=example,dc=org
         $this->markTestSkipped('skipped for ad backend');
     }
     $this->_schemaConfigChanged = true;
     Courses_Config::getInstance()->set(Courses_Config::STUDENTS_USERNAME_SCHEMA, 3);
     $course = $this->_getCourseData();
     $courseData = $this->_json->saveCourse($course);
     $this->_groupsToDelete->addRecord(Tinebase_Group::getInstance()->getGroupById($courseData['group_id']));
     $result = $this->_json->addNewMember(array('accountFirstName' => 'Ütmür', 'accountLastName' => 'Höt'), $courseData);
     $this->assertEquals(2, count($result['results']), 'should add 2 new members');
     $id = NULL;
     foreach ($result['results'] as $result) {
         if ($result['name'] === 'Höt, Ütmür') {
             $id = $result['id'];
         }
     }
     $this->assertTrue($id !== NULL);
     $newUser = Tinebase_User::getInstance()->getFullUserById($id);
     $this->assertEquals('u.hoet', $newUser->accountLoginName);
 }
 /**
  * get Accounts storage data
  *
  * @return array
  */
 protected function _getAccountsStorageData()
 {
     $result = Tinebase_User::getBackendConfigurationWithDefaults(Setup_Core::get(Setup_Core::CHECKDB));
     $result['backend'] = Setup_Core::get(Setup_Core::CHECKDB) ? Tinebase_User::getConfiguredBackend() : Tinebase_User::SQL;
     return $result;
 }
Пример #30
0
 /**
  * reset password for given account
  *
  * @param array|string $account Tinebase_Model_FullUser data or account id
  * @param string $password the new password
  * @param bool $mustChange
  * @return array
  */
 public function resetPassword($account, $password, $mustChange)
 {
     if (is_array($account)) {
         $account = new Tinebase_Model_FullUser($account);
     } else {
         $account = Tinebase_User::factory(Tinebase_User::getConfiguredBackend())->getFullUserById($account);
     }
     $controller = Admin_Controller_User::getInstance();
     $controller->setAccountPassword($account, $password, $password, (bool) $mustChange);
     $result = array('success' => TRUE);
     return $result;
 }