Esempio n. 1
0
 /**
  * Returns registry data of admin.
  * @see Tinebase_Application_Json_Abstract
  * 
  * @return mixed array 'variable name' => 'data'
  */
 public function getRegistryData()
 {
     $appConfigDefaults = Admin_Controller::getInstance()->getConfigSettings();
     $smtpConfig = Tinebase_Config::getInstance()->getConfigAsArray(Tinebase_Config::SMTP);
     $registryData = array('manageSAM' => $this->_manageSAM, 'manageImapEmailUser' => $this->_manageImapEmailUser, 'manageSmtpEmailUser' => $this->_manageSmtpEmailUser, 'primarydomain' => array_key_exists('primarydomain', $smtpConfig) ? $smtpConfig['primarydomain'] : '', 'secondarydomains' => array_key_exists('secondarydomains', $smtpConfig) ? $smtpConfig['secondarydomains'] : '', 'defaultPrimaryGroup' => Tinebase_Group::getInstance()->getDefaultGroup()->toArray(), 'defaultInternalAddressbook' => $appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK] !== NULL ? Tinebase_Container::getInstance()->get($appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK])->toArray() : NULL);
     return $registryData;
 }
Esempio n. 2
0
 /**
  * View の処理を実行する
  * @access public
  * @see Admin_ViewClass::preforward()
  */
 function preforward($param = false)
 {
     if ($param !== false) {
         $logger = Admin_Controller::getInstance()->getLogger();
         $logger->log(LOG_ERR, $param);
     }
     header("HTTP/1.1 304 Not Modified");
     exit;
 }
Esempio n. 3
0
function performance()
{
    global $time, $mem;
    // Logにパフォーマンス情報を書き込む
    $action = Admin_Controller::getInstance()->getCurrentActionName();
    $logger = Admin_Controller::getInstance()->getBackend()->getLogger();
    $logger->begin();
    $logger->log(LOG_INFO, $action . ': peak memory: ' . memory_get_peak_usage() / 1024 / 1024 . 'Mb' . ': diff memory: ' . (memory_get_peak_usage() - $mem) / 1024 / 1024 . 'Mb' . ': ececute time: ' . (microtime(true) - $time) . 's' . ': timestamp: ' . time());
    $logger->end();
}
Esempio n. 4
0
 /**
  * update to 3.1
  * - add DEFAULTINTERNALADDRESSBOOK
  * @return void
  */
 public function update_0()
 {
     $settings = Admin_Controller::getInstance()->getConfigSettings();
     if (!array_key_exists(Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK, $settings)) {
         try {
             $internalAddressbook = Tinebase_Container::getInstance()->getContainerByName('Addressbook', 'Internal Contacts', Tinebase_Model_Container::TYPE_SHARED);
             Admin_Controller::getInstance()->saveConfigSettings(array(Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK => $internalAddressbook->getId()));
         } catch (Tinebase_Exception_NotFound $tenf) {
             // do nothing
         }
     }
     $this->setApplicationVersion('Admin', '3.1');
 }
 /**
  * get default internal adb id
  * 
  * @return string
  */
 protected function _getDefaultInternalAddressbook()
 {
     $appConfigDefaults = Admin_Controller::getInstance()->getConfigSettings();
     $result = isset($appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK]) ? $appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK] : NULL;
     if (empty($result)) {
         if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
             Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Default internal addressbook not found. Creating new config setting.');
         }
         $result = Addressbook_Setup_Initialize::setDefaultInternalAddressbook()->getId();
     }
     return $result;
 }
 /**
  * testSyncLists
  * 
  * @see 0005768: create addressbook lists when migrating users
  * 
  * @todo make this work for LDAP accounts backend: currently the user is not present in sync backend but in sql
  */
 public function testSyncLists()
 {
     if (Tinebase_Group::getInstance() instanceof Tinebase_Group_Ldap) {
         $this->markTestSkipped('@todo make this work for LDAP accounts backend');
     }
     $testGroup = $this->testAddGroup();
     // don't use any existing persona here => will break other tests
     $testUser = new Tinebase_Model_FullUser(array('accountLoginName' => Tinebase_Record_Abstract::generateUID(), 'accountPrimaryGroup' => $testGroup->getId(), 'accountDisplayName' => Tinebase_Record_Abstract::generateUID(), 'accountLastName' => Tinebase_Record_Abstract::generateUID(), 'accountFullName' => Tinebase_Record_Abstract::generateUID(), 'visibility' => Tinebase_Model_User::VISIBILITY_DISPLAYED));
     $contact = Admin_Controller_User::getInstance()->createOrUpdateContact($testUser);
     $testUser->contact_id = $contact->getId();
     $testUser = Tinebase_User::getInstance()->addUserInSqlBackend($testUser);
     Tinebase_User::createContactForSyncedUser($testUser);
     Tinebase_User::getInstance()->updateUserInSqlBackend($testUser);
     $this->testSetGroupMembers($testGroup, array($testUser->accountId));
     Tinebase_Group::syncListsOfUserContact(array($testGroup->getId()), $testUser->contact_id);
     $group = Tinebase_Group::getInstance()->getGroupById($testGroup);
     $this->assertTrue(!empty($group->list_id), 'list id empty: ' . print_r($group->toArray(), TRUE));
     $list = Addressbook_Controller_List::getInstance()->get($group->list_id);
     $this->assertEquals($group->getId(), $list->group_id);
     $this->assertEquals($group->name, $list->name);
     $this->assertTrue(!empty($list->members), 'list members empty: ' . print_r($list->toArray(), TRUE) . ' should contain: ' . print_r($testUser->toArray(), TRUE));
     $this->assertContains($testUser->contact_id, $list->members);
     $appConfigDefaults = Admin_Controller::getInstance()->getConfigSettings();
     $this->assertTrue(!empty($appConfigDefaults), 'app config defaults empty');
     $internal = $appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK];
     $this->assertEquals($internal, $list->container_id, 'did not get correct internal container');
     // sync again -> should not change anything
     Tinebase_Group::syncListsOfUserContact(array($group->getId()), $testUser->contact_id);
     $listAgain = Addressbook_Controller_List::getInstance()->get($group->list_id);
     $this->assertEquals($list->toArray(), $listAgain->toArray());
     // change list id -> should get list by (group) name
     $group->list_id = NULL;
     $group = Tinebase_Group::getInstance()->updateGroup($group);
     Tinebase_Group::syncListsOfUserContact(array($group->getId()), $testUser->contact_id);
     $this->assertEquals($list->getId(), Tinebase_Group::getInstance()->getGroupById($group)->list_id);
 }
 /**
  * wrapper for get container functions
  *
  * @param  string $_function
  * @param  string $_ownerId    => needed for $_node == 'personal'
  * @return array of container ids
  * @throws Tinebase_Exception_UnexpectedValue
  */
 protected function _resolveContainerNode($_node, $_ownerId = NULL)
 {
     $currentAccount = Tinebase_Core::getUser();
     $appName = $this->_options['applicationName'];
     switch ($_node) {
         case 'all':
             return Tinebase_Container::getInstance()->getContainerByACL($currentAccount, $appName, $this->_requiredGrants, TRUE, $this->_options['ignoreAcl']);
         case 'personal':
             return Tinebase_Container::getInstance()->getPersonalContainer($currentAccount, $appName, $_ownerId, $this->_requiredGrants, $this->_options['ignoreAcl'])->getId();
         case 'shared':
             return $this->_getSharedContainer($currentAccount, $appName);
         case Tinebase_Model_Container::TYPE_OTHERUSERS:
             return Tinebase_Container::getInstance()->getOtherUsersContainer($currentAccount, $appName, $this->_requiredGrants, $this->_options['ignoreAcl'])->getId();
         case 'internal':
             // @todo remove legacy code
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                 Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Trying to fetch obsolete "/internal" node. Please make sure this filter is no longer used because this is deprecated.');
             }
             $adminConfigDefaults = Admin_Controller::getInstance()->getConfigSettings();
             return array($adminConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK]);
         default:
             throw new Tinebase_Exception_UnexpectedValue('specialNode ' . $_node . ' not supported.');
     }
     return $ids;
 }
 /**
  * try to save a hidden account
  */
 public function testSaveHiddenAccount()
 {
     $accountData = $this->objects['user']->toArray();
     $accountData['visibility'] = Tinebase_Model_User::VISIBILITY_HIDDEN;
     $accountData['container_id'] = 0;
     $account = $this->_createUser($accountData);
     $this->assertTrue(is_array($account));
     $this->assertTrue(!empty($account['contact_id']));
     $appConfigDefaults = Admin_Controller::getInstance()->getConfigSettings();
     $this->assertEquals($appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK], $account['container_id']['id']);
 }
 /**
  * returns default internal addressbook container
  * 
  * @return string|int ID
  */
 public function getDefaultInternalAddressbook()
 {
     $appConfigDefaults = Admin_Controller::getInstance()->getConfigSettings();
     if (empty($appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK])) {
         $internalAdb = Addressbook_Setup_Initialize::setDefaultInternalAddressbook();
         $internalAdbId = $internalAdb->getId();
     } else {
         $internalAdbId = $appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK];
     }
     return $internalAdbId;
 }
 /**
  * testGetSaveApplicationConfig
  */
 public function testGetSaveApplicationConfig()
 {
     $config = $this->_instance->getConfig('Admin');
     $this->assertGreaterThan(0, count($config));
     $data = array('id' => 'Admin', 'settings' => Admin_Controller::getInstance()->getConfigSettings());
     $newConfig = $this->_instance->saveConfig($data);
     $this->assertEquals($config, $newConfig);
 }
 /**
  * testInternalAddressbookConfig
  * 
  * @see http://forge.tine20.org/mantisbt/view.php?id=5846
  */
 public function testInternalAddressbookConfig()
 {
     $list = $this->objects['initialList'];
     $list->container_id = NULL;
     $listBackend = new Addressbook_Backend_List();
     $listBackend->update($list);
     Admin_Config::getInstance()->delete(Tinebase_Config::APPDEFAULTS);
     $list = Addressbook_Controller_List::getInstance()->addListMember($list, $this->objects['contact1']);
     $appConfigDefaults = Admin_Controller::getInstance()->getConfigSettings();
     $this->assertTrue(!empty($appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK]), print_r($appConfigDefaults, TRUE));
 }
 /**
  * checks if container to delete is a "system" container 
  * 
  * @param array|integer|Tinebase_Model_Container $containerIds
  * @throws Tinebase_Exception_Record_SystemContainer
  * 
  * @TODO: generalize when there are more "system" containers
  * @todo move Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK to adb config
  */
 public function checkSystemContainer($containerIds)
 {
     if (!is_array($containerIds)) {
         $containerIds = array($containerIds);
     }
     $appConfigDefaults = Admin_Controller::getInstance()->getConfigSettings();
     // at the moment, just the internal addressbook is checked
     try {
         $defaultAddressbook = $this->get($appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK])->toArray();
     } catch (Tinebase_Exception_NotFound $e) {
         $defaultAddressbook = null;
     }
     if ($defaultAddressbook && in_array($defaultAddressbook['id'], $containerIds)) {
         // _('You are not allowed to delete this Container. Please define another container as the default addressbook for internal contacts!')
         throw new Tinebase_Exception_Record_SystemContainer('You are not allowed to delete this Container. Please define another container as the default addressbook for internal contacts!');
     }
 }
Esempio n. 13
0
 /**
  * create or update contact in addressbook backend
  * 
  * @param  Tinebase_Model_FullUser $_user
  * @return Addressbook_Model_Contact
  */
 public function createOrUpdateContact(Tinebase_Model_FullUser $_user)
 {
     $contactsBackend = Addressbook_Backend_Factory::factory(Addressbook_Backend_Factory::SQL);
     $contactsBackend->setGetDisabledContacts(true);
     if (empty($_user->container_id)) {
         $appConfigDefaults = Admin_Controller::getInstance()->getConfigSettings();
         $_user->container_id = $appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK];
     }
     try {
         if (empty($_user->contact_id)) {
             // jump to catch block
             throw new Tinebase_Exception_NotFound('contact_id is empty');
         }
         $contact = $contactsBackend->get($_user->contact_id);
         // update exisiting contact
         $contact->n_family = $_user->accountLastName;
         $contact->n_given = $_user->accountFirstName;
         $contact->n_fn = $_user->accountFullName;
         $contact->n_fileas = $_user->accountDisplayName;
         $contact->email = $_user->accountEmailAddress;
         $contact->type = Addressbook_Model_Contact::CONTACTTYPE_USER;
         $contact->container_id = $_user->container_id;
         // add modlog info
         Tinebase_Timemachine_ModificationLog::setRecordMetaData($contact, 'update');
         $contact = $contactsBackend->update($contact);
     } catch (Tinebase_Exception_NotFound $tenf) {
         // add new contact
         $contact = new Addressbook_Model_Contact(array('n_family' => $_user->accountLastName, 'n_given' => $_user->accountFirstName, 'n_fn' => $_user->accountFullName, 'n_fileas' => $_user->accountDisplayName, 'email' => $_user->accountEmailAddress, 'type' => Addressbook_Model_Contact::CONTACTTYPE_USER, 'container_id' => $_user->container_id));
         // add modlog info
         Tinebase_Timemachine_ModificationLog::setRecordMetaData($contact, 'create');
         $contact = $contactsBackend->create($contact);
     }
     return $contact;
 }
Esempio n. 14
0
 /**
  * testSyncLists
  * 
  * @see http://forge.tine20.org/mantisbt/view.php?id=5768
  */
 public function testSyncLists()
 {
     $group = $this->objects['initialGroup'];
     Tinebase_User::syncContact($this->objects['account1']);
     Tinebase_User::getInstance()->updateUserInSqlBackend($this->objects['account1']);
     $this->testSetGroupMembers();
     Tinebase_Group::syncListsOfUserContact(array($group->getId()), $this->objects['account1']->contact_id);
     $group = Tinebase_Group::getInstance()->getGroupById($this->objects['initialGroup']);
     $this->assertTrue(!empty($group->list_id), 'list id empty: ' . print_r($group->toArray(), TRUE));
     $list = Addressbook_Controller_List::getInstance()->get($group->list_id);
     $this->assertEquals($group->getId(), $list->group_id);
     $this->assertEquals($group->name, $list->name);
     $this->assertTrue(!empty($list->members), 'list members empty: ' . print_r($list->toArray(), TRUE));
     $this->assertEquals($this->objects['account1']->contact_id, $list->members[0]);
     $appConfigDefaults = Admin_Controller::getInstance()->getConfigSettings();
     $internal = $appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK];
     $this->assertEquals($internal, $list->container_id);
     // sync again -> should not change anything
     Tinebase_Group::syncListsOfUserContact(array($group->getId()), $this->objects['account1']->contact_id);
     $listAgain = Addressbook_Controller_List::getInstance()->get($group->list_id);
     $this->assertEquals($list->toArray(), $listAgain->toArray());
 }