本文整理匯總了PHP中UserAction::mergeUsers方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserAction::mergeUsers方法的具體用法?PHP UserAction::mergeUsers怎麽用?PHP UserAction::mergeUsers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserAction
的用法示例。
在下文中一共展示了UserAction::mergeUsers方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
/**
* Execute the merge users command.
*/
function execute()
{
$userDao =& DAORegistry::getDAO('UserDAO');
$oldUser =& $userDao->getUserbyUsername($this->username2);
$newUser =& $userDao->getUserbyUsername($this->username1);
$oldUserId = isset($oldUser) ? $oldUser->getId() : null;
$newUserId = isset($newUser) ? $newUser->getId() : null;
if (empty($oldUserId)) {
printf("Error: '%s' is not a valid username.\n", $this->username2);
exit;
}
if (empty($newUserId)) {
printf("Error: '%s' is not a valid username.\n", $this->username1);
exit;
}
// Both user IDs are valid. Merge the accounts.
import('classes.user.UserAction');
UserAction::mergeUsers($oldUserId, $newUserId);
printf("Merge completed: '%s' merged into '%s'.\n", $this->username2, $this->username1);
}
示例2: mergeUsers
/**
* Allow the Conference Manager to merge user accounts, including attributed papers etc.
*/
function mergeUsers($args)
{
$this->validate();
$this->setupTemplate(true);
$roleDao =& DAORegistry::getDAO('RoleDAO');
$userDao =& DAORegistry::getDAO('UserDAO');
$conference =& Request::getConference();
$schedConf =& Request::getSchedConf();
$schedConfId = isset($schedConf) ? $schedConf->getId() : null;
$templateMgr =& TemplateManager::getManager();
$oldUserIds = (array) Request::getUserVar('oldUserIds');
$newUserId = Request::getUserVar('newUserId');
// Ensure that we have administrative priveleges over the specified user(s).
$canAdministerAll = true;
foreach ($oldUserIds as $oldUserId) {
if (!Validation::canAdminister($conference->getId(), $oldUserId)) {
$canAdministerAll = false;
}
}
if (!empty($oldUserIds) && !$canAdministerAll || !empty($newUserId) && !Validation::canAdminister($conference->getId(), $newUserId)) {
$templateMgr->assign('pageTitle', 'manager.people');
$templateMgr->assign('errorMsg', 'manager.people.noAdministrativeRights');
$templateMgr->assign('backLink', Request::url(null, null, null, 'people', 'all'));
$templateMgr->assign('backLinkLabel', 'manager.people.allUsers');
return $templateMgr->display('common/error.tpl');
}
if (!empty($oldUserIds) && !empty($newUserId)) {
import('classes.user.UserAction');
foreach ($oldUserIds as $oldUserId) {
UserAction::mergeUsers($oldUserId, $newUserId);
}
Request::redirect(null, null, 'manager');
}
// The manager must select one or both IDs.
if (Request::getUserVar('roleSymbolic') != null) {
$roleSymbolic = Request::getUserVar('roleSymbolic');
} else {
$roleSymbolic = isset($args[0]) ? $args[0] : 'all';
}
if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\\w+)s$/', $roleSymbolic, $matches)) {
$roleId = $roleDao->getRoleIdFromPath($matches[1]);
if ($roleId == null) {
Request::redirect(null, null, null, null, 'all');
}
$roleName = $roleDao->getRoleName($roleId, true);
} else {
$roleId = 0;
$roleName = 'manager.people.allUsers';
}
$sort = Request::getUserVar('sort');
$sort = isset($sort) ? $sort : 'name';
$sortDirection = Request::getUserVar('sortDirection');
$searchType = null;
$searchMatch = null;
$search = Request::getUserVar('search');
$searchInitial = Request::getUserVar('searchInitial');
if (!empty($search)) {
$searchType = Request::getUserVar('searchField');
$searchMatch = Request::getUserVar('searchMatch');
} elseif (!empty($searchInitial)) {
$searchInitial = String::strtoupper($searchInitial);
$searchType = USER_FIELD_INITIAL;
$search = $searchInitial;
}
$rangeInfo =& Handler::getRangeInfo('users', array($roleId, (string) $search, (string) $searchMatch, (string) $searchType));
if ($roleId) {
while (true) {
$users =& $roleDao->getUsersByRoleId($roleId, $conference->getId(), $schedConfId, $searchType, $search, $searchMatch, $rangeInfo, $sort);
if ($users->isInBounds()) {
break;
}
unset($rangeInfo);
$rangeInfo =& $users->getLastPageRangeInfo();
unset($users);
}
$templateMgr->assign('roleId', $roleId);
} else {
while (true) {
$users =& $roleDao->getUsersByConferenceId($conference->getId(), $searchType, $search, $searchMatch, $rangeInfo, $sort);
if ($users->isInBounds()) {
break;
}
unset($rangeInfo);
$rangeInfo =& $users->getLastPageRangeInfo();
unset($users);
}
}
$templateMgr->assign('currentUrl', Request::url(null, null, null, 'people', 'all'));
$templateMgr->assign('helpTopicId', 'conference.users.mergeUsers');
$templateMgr->assign('roleName', $roleName);
$templateMgr->assign_by_ref('users', $users);
$templateMgr->assign_by_ref('thisUser', Request::getUser());
$templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER);
$templateMgr->assign('searchField', $searchType);
$templateMgr->assign('searchMatch', $searchMatch);
$templateMgr->assign('search', $search);
$templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
//.........這裏部分代碼省略.........
示例3: mergeUsers
/**
* Allow the Site Administrator to merge user accounts.
*/
function mergeUsers($args)
{
$this->validate();
$this->setupTemplate(true);
$roleDao =& DAORegistry::getDAO('RoleDAO');
$userDao =& DAORegistry::getDAO('UserDAO');
$templateMgr =& TemplateManager::getManager();
$oldUserIds = (array) Request::getUserVar('oldUserIds');
$newUserId = Request::getUserVar('newUserId');
if (!empty($oldUserIds) && !empty($newUserId)) {
import('user.UserAction');
foreach ($oldUserIds as $oldUserId) {
UserAction::mergeUsers($oldUserId, $newUserId);
}
Request::redirect(null, null, 'admin', 'mergeUsers');
}
// The administrator must select one or both IDs.
if (Request::getUserVar('roleSymbolic') != null) {
$roleSymbolic = Request::getUserVar('roleSymbolic');
} else {
$roleSymbolic = isset($args[0]) ? $args[0] : 'all';
}
if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\\w+)s$/', $roleSymbolic, $matches)) {
$roleId = $roleDao->getRoleIdFromPath($matches[1]);
if ($roleId == null) {
Request::redirect(null, null, null, null, 'all');
}
$roleName = $roleDao->getRoleName($roleId, true);
} else {
$roleId = 0;
$roleName = 'admin.mergeUsers.allUsers';
}
$searchType = null;
$searchMatch = null;
$search = Request::getUserVar('search');
$searchInitial = Request::getUserVar('searchInitial');
if (!empty($search)) {
$searchType = Request::getUserVar('searchField');
$searchMatch = Request::getUserVar('searchMatch');
} elseif (!empty($searchInitial)) {
$searchInitial = String::strtoupper($searchInitial);
$searchType = USER_FIELD_INITIAL;
$search = $searchInitial;
}
$rangeInfo =& Handler::getRangeInfo('users', array($roleId, (string) $search, (string) $searchMatch, (string) $searchType));
if ($roleId) {
while (true) {
$users =& $roleDao->getUsersByRoleId($roleId, null, null, $searchType, $search, $searchMatch, $rangeInfo);
if ($users->isInBounds()) {
break;
}
unset($rangeInfo);
$rangeInfo =& $users->getLastPageRangeInfo();
unset($users);
}
$templateMgr->assign('roleId', $roleId);
} else {
while (true) {
$users =& $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo);
if ($users->isInBounds()) {
break;
}
unset($rangeInfo);
$rangeInfo =& $users->getLastPageRangeInfo();
unset($users);
}
}
$templateMgr->assign('currentUrl', Request::url(null, null, 'admin', 'mergeUsers'));
$templateMgr->assign('helpTopicId', 'site.administrativeFunctions');
$templateMgr->assign('roleName', $roleName);
$templateMgr->assign_by_ref('users', $users);
$templateMgr->assign_by_ref('thisUser', Request::getUser());
$templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER);
$templateMgr->assign('searchField', $searchType);
$templateMgr->assign('searchMatch', $searchMatch);
$templateMgr->assign('search', $search);
$templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
if ($roleId == ROLE_ID_REVIEWER) {
$reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
$templateMgr->assign('rateReviewerOnQuality', $conference->getSetting('rateReviewerOnQuality'));
$templateMgr->assign('qualityRatings', $conference->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($conference->getId()) : null);
}
$templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email', USER_FIELD_INTERESTS => 'user.interests'));
$templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList')));
$templateMgr->assign('oldUserIds', $oldUserIds);
$templateMgr->assign('rolePath', $roleDao->getRolePath($roleId));
$templateMgr->assign('roleSymbolic', $roleSymbolic);
$templateMgr->display('admin/selectMergeUser.tpl');
}
示例4: mergeUsers
/**
* Allow the Press Manager to merge user accounts, including attributed monographs etc.
* @param $args array
* @param $request PKPRequest
*/
function mergeUsers($args, &$request)
{
$this->setupTemplate(true);
$userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
$userDao =& DAORegistry::getDAO('UserDAO');
$press =& $request->getPress();
$pressId = $press->getId();
$templateMgr =& TemplateManager::getManager();
$oldUserIds = (array) $request->getUserVar('oldUserIds');
$newUserId = $request->getUserVar('newUserId');
// Ensure that we have administrative priveleges over the specified user(s).
$canAdministerAll = true;
foreach ($oldUserIds as $oldUserId) {
if (!Validation::canAdminister($pressId, $oldUserId)) {
$canAdministerAll = false;
}
}
if (!empty($oldUserIds) && !$canAdministerAll || !empty($newUserId) && !Validation::canAdminister($pressId, $newUserId)) {
$templateMgr->assign('pageTitle', 'manager.people');
$templateMgr->assign('errorMsg', 'manager.people.noAdministrativeRights');
$templateMgr->assign('backLink', $request->url(null, null, 'people', 'all'));
$templateMgr->assign('backLinkLabel', 'manager.people.allUsers');
return $templateMgr->display('common/error.tpl');
}
if (!empty($oldUserIds) && !empty($newUserId)) {
import('classes.user.UserAction');
foreach ($oldUserIds as $oldUserId) {
UserAction::mergeUsers($oldUserId, $newUserId);
}
$request->redirect(null, 'manager');
}
// The manager must select one or both IDs.
if ($request->getUserVar('userGroupId') != null) {
$userGroupId = $request->getUserVar('userGroupId');
} else {
$userGroupId = isset($args[0]) ? $args[0] : 'all';
}
if ($userGroupId != 'all' && is_numeric($userGroupId)) {
$userGroup =& $userGroupDao->getById($userGroupId);
if ($userGroupId == null) {
$request->redirect(null, null, null, 'all');
}
} else {
$userGroup = null;
}
$sort = $request->getUserVar('sort');
$sort = isset($sort) ? $sort : 'name';
$sortDirection = $request->getUserVar('sortDirection');
$searchType = null;
$searchMatch = null;
$search = $request->getUserVar('search');
$searchInitial = $request->getUserVar('searchInitial');
if (!empty($search)) {
$searchType = $request->getUserVar('searchField');
$searchMatch = $request->getUserVar('searchMatch');
} else {
if (!empty($searchInitial)) {
$searchInitial = String::strtoupper($searchInitial);
$searchType = USER_FIELD_INITIAL;
$search = $searchInitial;
}
}
$rangeInfo = $this->getRangeInfo('users');
if ($userGroup) {
$users =& $userGroupDao->getUsersById($userGroupId, $pressId, $searchType, $search, $searchMatch, $rangeInfo, $sort);
$templateMgr->assign_by_ref('userGroup', $userGroup);
$isReviewer = $userGroup->getRoleId() == ROLE_ID_REVIEWER;
} else {
$users =& $userGroupDao->getUsersByContextId($pressId, $searchType, $search, $searchMatch, $rangeInfo, $sort);
$isReviewer = false;
}
//$templateMgr->assign_by_ref('roleSettings', $this->retrieveRoleAssignmentPreferences($press->getId()));
$templateMgr->assign('currentUrl', $request->url(null, null, 'people', 'all'));
$templateMgr->assign('helpTopicId', 'press.managementPages.mergeUsers');
$templateMgr->assign_by_ref('users', $users);
$templateMgr->assign_by_ref('thisUser', $request->getUser());
$templateMgr->assign('isReviewer', $isReviewer);
$templateMgr->assign('searchField', $searchType);
$templateMgr->assign('searchMatch', $searchMatch);
$templateMgr->assign('search', $search);
$templateMgr->assign('searchInitial', $request->getUserVar('searchInitial'));
if ($isReviewer) {
$reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
$templateMgr->assign('rateReviewerOnQuality', $press->getSetting('rateReviewerOnQuality'));
$templateMgr->assign('qualityRatings', $press->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($pressId) : null);
}
$templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email', USER_FIELD_INTERESTS => 'user.interests'));
$templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList')));
$templateMgr->assign('oldUserIds', $oldUserIds);
$templateMgr->assign('userGroupId', $userGroupId);
$templateMgr->assign('sort', $sort);
$templateMgr->assign('sortDirection', $sortDirection);
$templateMgr->display('manager/people/selectMergeUser.tpl');
}
示例5: mergeUsers
/**
* Allow the Site Administrator to merge user accounts, including attributed submissions etc.
* @param $args array
* @param $request PKPRequest
*/
function mergeUsers($args, $request)
{
// if there is a $newUserId, this is the second time through, so merge the users.
$newUserId = (int) $request->getUserVar('newUserId');
$oldUserId = (int) $request->getUserVar('oldUserId');
if ($newUserId > 0 && $oldUserId > 0) {
import('classes.user.UserAction');
$userAction = new UserAction();
$userAction->mergeUsers($oldUserId, $newUserId);
return DAO::getDataChangedEvent();
} else {
// this shouldn't happen since the first time this action is
// selected on the grid there is no call to the handler.
$json = new JSONMessage(false, __('grid.user.cannotAdminister'));
return $json->getString();
}
}
示例6: mergeUsers
/**
* Allow user account merging, including attributed submissions etc.
* @param $args array
* @param $request PKPRequest
* @return JSONMessage JSON object
*/
function mergeUsers($args, $request)
{
// if there is a $newUserId, this is the second time through, so merge the users.
$newUserId = (int) $request->getUserVar('newUserId');
$oldUserId = (int) $request->getUserVar('oldUserId');
$user = $request->getUser();
if ($newUserId > 0 && $oldUserId > 0 && Validation::canAdminister($oldUserId, $user->getId())) {
import('classes.user.UserAction');
$userAction = new UserAction();
$userAction->mergeUsers($oldUserId, $newUserId);
return DAO::getDataChangedEvent();
} else {
// The grid shouldn't have presented an action in this
// case.
return new JSONMessage(false, __('grid.user.cannotAdminister'));
}
}