本文整理汇总了PHP中Tinebase_Group::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Group::factory方法的具体用法?PHP Tinebase_Group::factory怎么用?PHP Tinebase_Group::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Group
的用法示例。
在下文中一共展示了Tinebase_Group::factory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$this->_groupLDAP = Tinebase_Group::factory(Tinebase_Group::LDAP);
$this->_userLDAP = Tinebase_User::factory(Tinebase_User::LDAP);
$this->_groupSQL = Tinebase_Group::factory(Tinebase_Group::SQL);
$this->objects['initialGroup'] = new Tinebase_Model_Group(array('name' => 'tine20phpunit', 'description' => 'initial group'));
$this->objects['updatedGroup'] = new Tinebase_Model_Group(array('name' => 'tine20phpunit updated', 'description' => 'updated group'));
$this->objects['initialAccount'] = new Tinebase_Model_FullUser(array('accountLoginName' => 'tine20phpunit', 'accountStatus' => 'enabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => 'must be set to valid groupid', 'accountLastName' => 'Tine 2.0', 'accountFirstName' => 'PHPUnit', 'accountEmailAddress' => 'phpunit@metaways.de'));
}
示例2: 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::LDAP) {
$this->markTestSkipped('LDAP backend not enabled');
}
$this->_groupLDAP = Tinebase_Group::factory(Tinebase_Group::LDAP);
$this->_userLDAP = Tinebase_User::factory(Tinebase_User::LDAP);
$this->_groupSQL = Tinebase_Group::factory(Tinebase_Group::SQL);
$this->objects['initialGroup'] = new Tinebase_Model_Group(array('name' => 'tine20phpunit', 'description' => 'initial group'));
$this->objects['updatedGroup'] = new Tinebase_Model_Group(array('name' => 'tine20phpunit updated', 'description' => 'updated group'));
$this->objects['initialAccount'] = new Tinebase_Model_FullUser(array('accountLoginName' => 'tine20phpunit', 'accountStatus' => 'enabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => 'must be set to valid groupid', 'accountLastName' => 'Tine 2.0', 'accountFirstName' => 'PHPUnit', 'accountEmailAddress' => 'phpunit@metaways.de'));
$this->objects['groups'] = new Tinebase_Record_RecordSet('Tinebase_Model_Group');
$this->objects['users'] = new Tinebase_Record_RecordSet('Tinebase_Model_FullUser');
}
示例3: getSharedContractsContainer
/**
* get (create if it does not exist) container for shared contracts
*
* @return Tinebase_Model_Container|NULL
*/
public static function getSharedContractsContainer()
{
$sharedContracts = NULL;
$appId = Tinebase_Application::getInstance()->getApplicationByName('Sales')->getId();
try {
$sharedContractsId = Tinebase_Config::getInstance()->getConfig(Sales_Model_Config::SHAREDCONTRACTSID, $appId, '')->value;
$sharedContracts = Tinebase_Container::getInstance()->get($sharedContractsId);
} catch (Tinebase_Exception_NotFound $tenf) {
$newContainer = new Tinebase_Model_Container(array('name' => 'Shared Contracts', 'type' => Tinebase_Model_Container::TYPE_SHARED, 'backend' => 'Sql', 'application_id' => $appId));
$sharedContracts = Tinebase_Container::getInstance()->addContainer($newContainer, NULL, TRUE);
Tinebase_Config::getInstance()->setConfigForApplication(Sales_Model_Config::SHAREDCONTRACTSID, $sharedContracts->getId(), 'Sales');
// add grants for groups
$groupsBackend = Tinebase_Group::factory(Tinebase_Group::SQL);
$adminGroup = $groupsBackend->getDefaultAdminGroup();
$userGroup = $groupsBackend->getDefaultGroup();
Tinebase_Container::getInstance()->addGrants($sharedContracts, Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP, $userGroup, array(Tinebase_Model_Grants::GRANT_READ, Tinebase_Model_Grants::GRANT_EDIT), TRUE);
Tinebase_Container::getInstance()->addGrants($sharedContracts, Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP, $adminGroup, array(Tinebase_Model_Grants::GRANT_ADD, Tinebase_Model_Grants::GRANT_READ, Tinebase_Model_Grants::GRANT_EDIT, Tinebase_Model_Grants::GRANT_DELETE, Tinebase_Model_Grants::GRANT_ADMIN), TRUE);
}
return $sharedContracts;
}
示例4: testUpdateUser
/**
* try to update an user
*
*/
public function testUpdateUser()
{
$groupsBackend = Tinebase_Group::factory(Tinebase_Group::LDAP);
$user = $this->testAddUser();
$groupsBackend->addGroupMemberInSyncBackend($user->accountPrimaryGroup, $user);
$groupsBeforeUpdate = $groupsBackend->getGroupMembershipsFromSyncBackend($user);
$user->accountLoginName = 'tine20phpunituser-updated';
$this->_usernamesToDelete[] = $user->accountLoginName;
$testUser = $this->_backend->updateUser($user);
$groupsAfterUpdate = $groupsBackend->getGroupMembershipsFromSyncBackend($testUser);
sort($groupsBeforeUpdate);
sort($groupsAfterUpdate);
$this->assertEquals($user->accountLoginName, $testUser->accountLoginName);
$this->assertEquals($groupsBeforeUpdate, $groupsAfterUpdate);
}
示例5: _migrateFromSqlAccountsStorage
/**
* migrate from SQL account storage to another one (for example LDAP)
* - deletes all users, groups and roles because they will be
* imported from new accounts storage backend
*/
protected function _migrateFromSqlAccountsStorage()
{
Setup_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Deleting all user accounts, groups, roles and rights');
Tinebase_User::factory(Tinebase_User::SQL)->deleteAllUsers();
$contactSQLBackend = new Addressbook_Backend_Sql();
$allUserContactIds = $contactSQLBackend->search(new Addressbook_Model_ContactFilter(array('type' => 'user')), null, true);
if (count($allUserContactIds) > 0) {
$contactSQLBackend->delete($allUserContactIds);
}
Tinebase_Group::factory(Tinebase_Group::SQL)->deleteAllGroups();
$listsSQLBackend = new Addressbook_Backend_List();
$allGroupListIds = $listsSQLBackend->search(new Addressbook_Model_ListFilter(array('type' => 'group')), null, true);
if (count($allGroupListIds) > 0) {
$listsSQLBackend->delete($allGroupListIds);
}
$roles = Tinebase_Acl_Roles::getInstance();
$roles->deleteAllRoles();
// import users (from new backend) / create initial users (SQL)
Tinebase_User::syncUsers(array('syncContactData' => TRUE));
$roles->createInitialRoles();
$applications = Tinebase_Application::getInstance()->getApplications(NULL, 'id');
foreach ($applications as $application) {
Setup_Initialize::initializeApplicationRights($application);
}
}
示例6: updateUserInSyncBackend
/**
* updates an existing user
*
* @todo check required objectclasses?
*
* @param Tinebase_Model_FullUser $_account
* @return Tinebase_Model_FullUser
*/
public function updateUserInSyncBackend(Tinebase_Model_FullUser $_account)
{
if ($this->_isReadOnlyBackend) {
return $_account;
}
$ldapEntry = $this->_getLdapEntry('accountId', $_account);
$ldapData = $this->_user2ldap($_account, $ldapEntry);
foreach ($this->_ldapPlugins as $plugin) {
$plugin->inspectUpdateUser($_account, $ldapData, $ldapEntry);
}
// no need to update this attribute, it's not allowed to change and even might not be update-able
unset($ldapData[$this->_userUUIDAttribute]);
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' DN: ' . $ldapEntry['dn']);
}
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' LDAP data: ' . print_r($ldapData, true));
}
$this->_ldap->update($ldapEntry['dn'], $ldapData);
$dn = Zend_Ldap_Dn::factory($ldapEntry['dn'], null);
$rdn = $dn->getRdn();
// do we need to rename the entry?
if (isset($ldapData[key($rdn)]) && $rdn[key($rdn)] != $ldapData[key($rdn)]) {
$groupsBackend = Tinebase_Group::factory(Tinebase_Group::LDAP);
// get the current group memberships
$memberships = $groupsBackend->getGroupMembershipsFromSyncBackend($_account);
// remove the user from current groups, because the dn/uid has changed
foreach ($memberships as $groupId) {
$groupsBackend->removeGroupMemberInSyncBackend($groupId, $_account);
}
$newDN = $this->_generateDn($_account);
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' rename ldap entry to: ' . $newDN);
}
$this->_ldap->rename($dn, $newDN);
// add the user to current groups again
foreach ($memberships as $groupId) {
$groupsBackend->addGroupMemberInSyncBackend($groupId, $_account);
}
}
// refetch user from ldap backend
$user = $this->getUserByPropertyFromSyncBackend('accountId', $_account, 'Tinebase_Model_FullUser');
return $user;
}
示例7: _createInitialRights
/**
* Override method because this app requires special rights
* @see tine20/Setup/Setup_Initialize#_createInitialRights($_application)
*
*/
protected function _createInitialRights(Tinebase_Model_Application $_application)
{
parent::_createInitialRights($_application);
$groupsBackend = Tinebase_Group::factory(Tinebase_Group::SQL);
$adminGroup = $groupsBackend->getDefaultAdminGroup();
// give anyone read rights to the internal addressbook
// give Adminstrators group read/edit/admin rights to the internal addressbook
Tinebase_Container::getInstance()->addGrants($this->_getInternalAddressbook(), Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE, '0', array(Tinebase_Model_Grants::GRANT_READ), TRUE);
Tinebase_Container::getInstance()->addGrants($this->_getInternalAddressbook(), Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP, $adminGroup, array(Tinebase_Model_Grants::GRANT_READ, Tinebase_Model_Grants::GRANT_EDIT, Tinebase_Model_Grants::GRANT_ADMIN), TRUE);
}