本文整理汇总了PHP中Tinebase_User::syncUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_User::syncUsers方法的具体用法?PHP Tinebase_User::syncUsers怎么用?PHP Tinebase_User::syncUsers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_User
的用法示例。
在下文中一共展示了Tinebase_User::syncUsers方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initialize
/**
* Override method: Setup needs additional initialisation
*
* @see tine20/Setup/Setup_Initialize#_initialize($_application)
*/
protected function _initialize(Tinebase_Model_Application $_application, $_options = null)
{
parent::_initialize($_application, $_options);
$initialAdminUserOptions = $this->_parseInitialAdminUserOptions($_options);
if (Tinebase_User::getInstance() instanceof Tinebase_User_Interface_SyncAble) {
Tinebase_User::syncUsers(true);
} else {
Tinebase_User::createInitialAccounts($initialAdminUserOptions);
}
// set current user
$initialUser = Tinebase_User::getInstance()->getUserByProperty('accountLoginName', $initialAdminUserOptions['adminLoginName']);
Tinebase_Core::set(Tinebase_Core::USER, $initialUser);
parent::_initialize($_application, $_options);
}
示例2: _initialize
/**
* Override method: Setup needs additional initialisation
*
* @see tine20/Setup/Setup_Initialize#_initialize($_application)
*/
protected function _initialize(Tinebase_Model_Application $_application, $_options = null)
{
$initialAdminUserOptions = $this->_parseInitialAdminUserOptions($_options);
if (Tinebase_User::getInstance() instanceof Tinebase_User_Interface_SyncAble) {
Tinebase_User::syncUsers(array('syncContactData' => TRUE));
}
try {
$initialUser = Tinebase_User::getInstance()->getUserByProperty('accountLoginName', $initialAdminUserOptions['adminLoginName']);
} catch (Tinebase_Exception_NotFound $tenf) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . ' Could not find initial admin account in user backend. Creating new one ...');
}
Tinebase_User::createInitialAccounts($initialAdminUserOptions);
$initialUser = Tinebase_User::getInstance()->getUserByProperty('accountLoginName', $initialAdminUserOptions['adminLoginName']);
}
Tinebase_Core::set(Tinebase_Core::USER, $initialUser);
parent::_initialize($_application, $_options);
}
示例3: testSyncGroups
/**
* @see 0009852: improve cache cleaning after LDAP sync
*/
public function testSyncGroups()
{
$defaultUserGroup = Tinebase_Group::getInstance()->getDefaultGroup();
$group = $this->testAddGroup();
$user = $this->_addUserToGroup($group);
// add user to group (only in LDAP)
$this->_groupLDAP->addGroupMemberInSyncBackend($defaultUserGroup->getId(), $user);
// trigger caching
$memberships = $this->_groupLDAP->getGroupMembers($defaultUserGroup);
$this->assertFalse(in_array($user->getId(), $memberships));
// sync users
Tinebase_User::syncUsers(array('syncContactData' => TRUE));
// check group memberships
$memberships = $this->_groupLDAP->getGroupMembers($defaultUserGroup);
$this->assertTrue(in_array($user->getId(), $memberships), 'group memberships not updated: ' . print_r($memberships, true));
}
示例4: testSyncDeleted
/**
* @see 0011192: LDAP sync should delete contacts
*/
public function testSyncDeleted()
{
$user = $this->testAddUser();
// add user contact
$contact = Admin_Controller_User::getInstance()->createOrUpdateContact($user);
$user->contact_id = $contact->getId();
Tinebase_User::getInstance()->updateUser($user);
// delete user in ldap
Tinebase_User::getInstance()->deleteUserInSyncBackend($user->getId());
// check if still in tine20 db
$sqlUser = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $user->getId());
$this->assertEquals($user->getId(), $sqlUser->getId());
// set sync config/option + start user sync
$syncOptions = array('deleteUsers' => true);
Tinebase_User::syncUsers($syncOptions);
$now = Tinebase_DateTime::now();
$user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $user->getId(), 'Tinebase_Model_FullUser');
$this->assertTrue($now->isLaterOrEquals($user->accountExpires), 'user should be expired');
sleep(1);
Tinebase_User::syncUsers($syncOptions);
$user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $user->getId(), 'Tinebase_Model_FullUser');
$this->assertTrue($now->toString() == $user->accountExpires->toString() || $now->subSecond(1)->toString() == $user->accountExpires->toString(), 'expiry date should still be the same');
// set expired to -1 year -> user should be deleted
$user->accountExpires = $now->subYear(1);
Tinebase_User::getInstance()->updateUserInSqlBackend($user);
// sync again
sleep(1);
Tinebase_User::syncUsers($syncOptions);
// check if user is deleted in tine, too
try {
Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $user->getId());
$this->fail('user should be deleted from tine20 db');
} catch (Tinebase_Exception_NotFound $tenf) {
$this->assertContains('User with accountId = ' . $sqlUser->getId(), $tenf->getMessage());
}
// check if user contact is deleted, too
try {
Addressbook_Controller_Contact::getInstance()->get($sqlUser->contact_id);
$this->fail('user contact should be deleted from tine20 db');
} catch (Tinebase_Exception_NotFound $tenf) {
$this->assertContains('Addressbook_Model_Contact record with id = ' . $sqlUser->contact_id, $tenf->getMessage());
}
}
示例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: _importAccounts
/**
* import accounts from ldap
*
* @param Zend_Console_Getopt $_opts
*/
protected function _importAccounts(Zend_Console_Getopt $_opts)
{
// disable timelimit during import of user accounts
Setup_Core::setExecutionLifeTime(0);
// import groups
if (!$_opts->onlyusers) {
Tinebase_Group::syncGroups();
}
// import users
$options = array('syncContactData' => TRUE);
if ($_opts->dbmailldap) {
$options['ldapplugins'] = array(new Tinebase_EmailUser_Imap_LdapDbmailSchema(), new Tinebase_EmailUser_Smtp_LdapDbmailSchema());
}
if ($_opts->syncdeletedusers) {
$options['deleteUsers'] = true;
}
Tinebase_User::syncUsers($options);
}
示例7: _importAccounts
/**
* import accounts from ldap
*
* @param Zend_Console_Getopt $_opts
*/
protected function _importAccounts(Zend_Console_Getopt $_opts)
{
// disable timelimit during import of user accounts
Setup_Core::setExecutionLifeTime(0);
// import groups
Tinebase_Group::syncGroups();
// import users
Tinebase_User::syncUsers(true);
}
示例8: testSyncDeleted
/**
* @see 0011192: LDAP sync should delete contacts
*/
public function testSyncDeleted()
{
$user = $this->testAddUser();
// delete user in ldap
Tinebase_User::getInstance()->deleteUserInSyncBackend($user->getId());
// check if still in tine20 db
$sqlUser = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $user->getId());
$this->assertEquals($user->getId(), $sqlUser->getId());
// set sync config/option + start user sync
$syncOptions = array('deleteUsers' => true);
Tinebase_User::syncUsers($syncOptions);
// check if user is deleted in tine, too
try {
Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $user->getId());
$this->fail('user should be deleted from tine20 db');
} catch (Tinebase_Exception_NotFound $tenf) {
$this->assertContains('User with accountId = ' . $sqlUser->getId(), $tenf->getMessage());
}
}