当前位置: 首页>>代码示例>>PHP>>正文


PHP Tinebase_Group::syncMemberships方法代码示例

本文整理汇总了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;
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:84,代码来源:User.php


注:本文中的Tinebase_Group::syncMemberships方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。