本文整理汇总了PHP中Tinebase_Group::syncMemberships方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Group::syncMemberships方法的具体用法?PHP Tinebase_Group::syncMemberships怎么用?PHP Tinebase_Group::syncMemberships使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Group
的用法示例。
在下文中一共展示了Tinebase_Group::syncMemberships方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: syncUser
/**
* syncronize user from syncbackend to local sql backend
*
* @param mixed $username the login id of the user to synchronize
* @param array $options
* @return Tinebase_Model_FullUser
* @throws Tinebase_Exception
*
* @todo make use of dbmail plugin configurable (should be false by default)
* @todo switch to new primary group if it could not be found
* @todo write a test and refactor this ... :(
*/
public static function syncUser($username, $options = array())
{
if ($username instanceof Tinebase_Model_FullUser) {
$username = $username->accountLoginName;
}
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " sync user data for: " . $username);
}
$userBackend = Tinebase_User::getInstance();
if (isset($options['ldapplugins']) && is_array($options['ldapplugins'])) {
foreach ($options['ldapplugins'] as $plugin) {
$userBackend->registerLdapPlugin($plugin);
}
}
$user = $userBackend->getUserByPropertyFromSyncBackend('accountLoginName', $username, 'Tinebase_Model_FullUser');
$user->accountPrimaryGroup = Tinebase_Group::getInstance()->resolveGIdNumberToUUId($user->accountPrimaryGroup);
$userProperties = method_exists($userBackend, 'getLastUserProperties') ? $userBackend->getLastUserProperties() : array();
$hookResult = self::_syncUserHook($user, $userProperties);
if (!$hookResult) {
return null;
}
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($user->toArray(), TRUE));
}
self::getPrimaryGroupForUser($user);
try {
$currentUser = $userBackend->getUserByProperty('accountId', $user, 'Tinebase_Model_FullUser');
$currentUser->accountLoginName = $user->accountLoginName;
$currentUser->accountLastPasswordChange = $user->accountLastPasswordChange;
$currentUser->accountExpires = $user->accountExpires;
$currentUser->accountPrimaryGroup = $user->accountPrimaryGroup;
$currentUser->accountDisplayName = $user->accountDisplayName;
$currentUser->accountLastName = $user->accountLastName;
$currentUser->accountFirstName = $user->accountFirstName;
$currentUser->accountFullName = $user->accountFullName;
$currentUser->accountEmailAddress = $user->accountEmailAddress;
$currentUser->accountHomeDirectory = $user->accountHomeDirectory;
$currentUser->accountLoginShell = $user->accountLoginShell;
if (!empty($user->visibility) && $currentUser->visibility !== $user->visibility) {
$currentUser->visibility = $user->visibility;
if (empty($currentUser->contact_id) && $currentUser->visibility == Tinebase_Model_FullUser::VISIBILITY_DISPLAYED) {
self::createContactForSyncedUser($currentUser);
}
}
Tinebase_Timemachine_ModificationLog::setRecordMetaData($currentUser, 'update');
$syncedUser = $userBackend->updateUserInSqlBackend($currentUser);
if (!empty($user->container_id)) {
$syncedUser->container_id = $user->container_id;
}
$userBackend->updatePluginUser($syncedUser, $user);
} catch (Tinebase_Exception_NotFound $ten) {
try {
$invalidUser = $userBackend->getUserByPropertyFromSqlBackend('accountLoginName', $username, 'Tinebase_Model_FullUser');
if (Tinebase_Core::isLogLevel(Zend_Log::CRIT)) {
Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . " Remove invalid user: " . $username);
}
$userBackend->deleteUserInSqlBackend($invalidUser);
} catch (Tinebase_Exception_NotFound $ten) {
// do nothing
}
if ($user->visibility !== Tinebase_Model_FullUser::VISIBILITY_HIDDEN) {
self::createContactForSyncedUser($user);
}
Tinebase_Timemachine_ModificationLog::setRecordMetaData($user, 'create');
$syncedUser = $userBackend->addUserInSqlBackend($user);
$userBackend->addPluginUser($syncedUser, $user);
}
self::syncContactData($syncedUser, $options);
// sync group memberships
Tinebase_Group::syncMemberships($syncedUser);
return $syncedUser;
}