/**
  * testSaveBackendConfiguration
  */
 public function testSaveBackendConfiguration()
 {
     Tinebase_User::setBackendType(Tinebase_User::LDAP);
     $rawConfigBefore = Tinebase_Config::getInstance()->get(Tinebase_Config::USERBACKEND);
     $key = 'host';
     $testValue = 'phpunit-test-host2';
     Tinebase_User::setBackendConfiguration($testValue, $key);
     Tinebase_User::saveBackendConfiguration();
     $rawConfigAfter = Tinebase_Config::getInstance()->get(Tinebase_Config::USERBACKEND);
     $this->assertNotEquals($rawConfigBefore, $rawConfigAfter);
 }
 /**
  * Update accountsStorage
  *
  * @param array $_data
  * @return void
  */
 protected function _updateAccountsStorage($_data)
 {
     $originalBackend = Tinebase_User::getConfiguredBackend();
     $newBackend = $_data['backend'];
     Tinebase_User::setBackendType($_data['backend']);
     $config = isset($_data[$_data['backend']]) ? $_data[$_data['backend']] : $_data;
     Tinebase_User::setBackendConfiguration($config, null, true);
     Tinebase_User::saveBackendConfiguration();
     if ($originalBackend != $newBackend && $this->isInstalled('Addressbook') && $originalBackend == Tinebase_User::SQL) {
         Setup_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " Switching from {$originalBackend} to {$newBackend} account storage");
         try {
             $db = Setup_Core::getDb();
             $transactionId = Tinebase_TransactionManager::getInstance()->startTransaction($db);
             $this->_migrateFromSqlAccountsStorage();
             Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
         } catch (Exception $e) {
             Tinebase_TransactionManager::getInstance()->rollBack();
             Setup_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' ' . $e->getMessage());
             Setup_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' ' . $e->getTraceAsString());
             Tinebase_User::setBackendType($originalBackend);
             Tinebase_User::saveBackendConfiguration();
             throw $e;
         }
     }
 }
 /**
  * add config table and update to version 0.7 of tinebase
  */
 public function update_6()
 {
     $tableDefinition = '
         <table>
             <name>config</name>
             <version>1</version>
             <declaration>
                 <field>
                     <name>id</name>
                     <type>text</type>
                     <length>40</length>
                     <notnull>true</notnull>
                 </field>
                 <field>
                     <name>application_id</name>
                     <type>integer</type>
                     <unsigned>true</unsigned>
                     <notnull>true</notnull>
                 </field>
                 <field>
                     <name>name</name>
                     <type>text</type>
                     <length>255</length>
                     <notnull>true</notnull>
                 </field>
                 <field>
                     <name>value</name>
                     <type>text</type>
                     <notnull>true</notnull>
                 </field>                
                 <index>
                     <name>id</name>
                     <primary>true</primary>
                     <field>
                         <name>id</name>
                     </field>
                 </index>
                 <index>
                     <name>application_id-name</name>
                     <unique>true</unique>
                     <field>
                         <name>application_id</name>
                     </field>
                     <field>
                         <name>name</name>
                     </field>
                 </index>
                 <index>
                     <name>config::application_id--applications::id</name>
                     <field>
                         <name>application_id</name>
                     </field>
                     <foreign>true</foreign>
                     <reference>
                         <table>applications</table>
                         <field>id</field>
                     </reference>
                 </index>
             </declaration>
         </table>
     ';
     $table = Setup_Backend_Schema_Table_Factory::factory('String', $tableDefinition);
     $this->_backend->createTable($table);
     // add config settings for admin and user groups
     Tinebase_User::setBackendConfiguration(Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY, 'Users');
     Tinebase_User::setBackendConfiguration(Tinebase_User::DEFAULT_ADMIN_GROUP_NAME_KEY, 'Administrators');
     Tinebase_User::saveBackendConfiguration();
     $this->setApplicationVersion('Tinebase', '0.7');
 }
 /**
  * update to 2.3
  * - move accounts storage configuration from config.inc.php to config db table
  * - changed the way the configuration for default user group name and default admin group name is stored
  *  
  */
 public function update_2()
 {
     $config = Setup_Controller::getInstance()->getConfigData();
     if (!empty($config['accounts'])) {
         if (empty($config['accounts']['backend'])) {
             $config['accounts']['backend'] = 'Sql';
         }
         $backendType = ucfirst($config['accounts']['backend']);
         Tinebase_User::setBackendType($backendType);
         //add default settings
         $defaultConfig = Tinebase_User::getBackendConfigurationDefaults($backendType);
         Tinebase_User::setBackendConfiguration($defaultConfig);
         //override default settings with config.inc.php settings
         if (!empty($config['accounts'][$config['accounts']['backend']])) {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Setting config: ' . print_r($config['accounts'][$config['accounts']['backend']], TRUE));
             }
             Tinebase_User::setBackendConfiguration($config['accounts'][$config['accounts']['backend']]);
         }
         //delete old config settings from config.inc.php
         unset($config['accounts']);
     }
     $defaultUserGroupName = Tinebase_Config::getInstance()->get('Default User Group', 'Users');
     $defaultAdminGroupName = Tinebase_Config::getInstance()->get('Default Admin Group', 'Administrators');
     Tinebase_User::setBackendConfiguration($defaultUserGroupName->value, Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY);
     Tinebase_User::setBackendConfiguration($defaultAdminGroupName->value, Tinebase_User::DEFAULT_ADMIN_GROUP_NAME_KEY);
     //write changes to config table
     Tinebase_User::saveBackendConfiguration();
     Tinebase_Config::getInstance()->delete('Default User Group');
     Tinebase_Config::getInstance()->delete('Default Admin Group');
     $this->setApplicationVersion('Tinebase', '2.3');
 }
Пример #5
0
 /**
  * update existing group
  *
  * @param Tinebase_Model_Group $_group
  * @return Tinebase_Model_Group
  */
 public function update(Tinebase_Model_Group $_group)
 {
     $this->checkRight('MANAGE_ACCOUNTS');
     // update default user group if name has changed
     $oldGroup = Tinebase_Group::getInstance()->getGroupById($_group->getId());
     $defaultGroupName = Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY);
     if ($oldGroup->name == $defaultGroupName && $oldGroup->name != $_group->name) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Updated default group name: ' . $oldGroup->name . ' -> ' . $_group->name);
         Tinebase_User::setBackendConfiguration($_group->name, Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY);
         Tinebase_User::saveBackendConfiguration();
     }
     $transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
         $_group->list_id = $oldGroup->list_id;
         $list = $this->createOrUpdateList($_group);
         $_group->list_id = $list->getId();
     }
     $group = Tinebase_Group::getInstance()->updateGroup($_group);
     Tinebase_Group::getInstance()->setGroupMembers($group->getId(), $_group->members);
     Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
     $event = new Admin_Event_UpdateGroup();
     $event->group = $group;
     Tinebase_Event::fireEvent($event);
     return $group;
 }