pages/admin/AdminPeopleHandler.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 // $Id$
00016 
00017 import('pages.admin.AdminHandler');
00018 
00019 class AdminPeopleHandler extends AdminHandler {
00023    function AdminPeopleHandler() {
00024       parent::AdminHandler();
00025    }
00026 
00030    function mergeUsers($args) {
00031       $this->validate();
00032       $this->setupTemplate(true);
00033 
00034       $roleDao =& DAORegistry::getDAO('RoleDAO');
00035       $userDao =& DAORegistry::getDAO('UserDAO');
00036 
00037       $templateMgr =& TemplateManager::getManager();
00038 
00039       $oldUserIds = (array) Request::getUserVar('oldUserIds');
00040       $newUserId = Request::getUserVar('newUserId');
00041 
00042       if (!empty($oldUserIds) && !empty($newUserId)) {
00043          import('user.UserAction');
00044          foreach ($oldUserIds as $oldUserId) {
00045             UserAction::mergeUsers($oldUserId, $newUserId);
00046          }
00047          Request::redirect(null, null, 'admin', 'mergeUsers');
00048       }
00049 
00050       // The administrator must select one or both IDs.
00051       if (Request::getUserVar('roleSymbolic')!=null) $roleSymbolic = Request::getUserVar('roleSymbolic');
00052       else $roleSymbolic = isset($args[0])?$args[0]:'all';
00053 
00054       if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\w+)s$/', $roleSymbolic, $matches)) {
00055          $roleId = $roleDao->getRoleIdFromPath($matches[1]);
00056          if ($roleId == null) {
00057             Request::redirect(null, null, null, null, 'all');
00058          }
00059          $roleName = $roleDao->getRoleName($roleId, true);
00060       } else {
00061          $roleId = 0;
00062          $roleName = 'admin.mergeUsers.allUsers';
00063       }
00064 
00065       $searchType = null;
00066       $searchMatch = null;
00067       $search = Request::getUserVar('search');
00068       $searchInitial = Request::getUserVar('searchInitial');
00069       if (!empty($search)) {
00070          $searchType = Request::getUserVar('searchField');
00071          $searchMatch = Request::getUserVar('searchMatch');
00072 
00073       } elseif (!empty($searchInitial)) {
00074          $searchInitial = String::strtoupper($searchInitial);
00075          $searchType = USER_FIELD_INITIAL;
00076          $search = $searchInitial;
00077       }
00078 
00079       $rangeInfo =& Handler::getRangeInfo('users', array($roleId, (string) $search, (string) $searchMatch, (string) $searchType));
00080 
00081       if ($roleId) {
00082          while (true) {
00083             $users =& $roleDao->getUsersByRoleId($roleId, null, null, $searchType, $search, $searchMatch, $rangeInfo);
00084             if ($users->isInBounds()) break;
00085             unset($rangeInfo);
00086             $rangeInfo =& $users->getLastPageRangeInfo();
00087             unset($users);
00088          }
00089          $templateMgr->assign('roleId', $roleId);
00090       } else {
00091          while (true) {
00092             $users =& $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo);
00093             if ($users->isInBounds()) break;
00094             unset($rangeInfo);
00095             $rangeInfo =& $users->getLastPageRangeInfo();
00096             unset($users);
00097          }
00098       }
00099 
00100       $templateMgr->assign('currentUrl', Request::url(null, null, 'admin', 'mergeUsers'));
00101       $templateMgr->assign('helpTopicId', 'site.administrativeFunctions');
00102       $templateMgr->assign('roleName', $roleName);
00103       $templateMgr->assign_by_ref('users', $users);
00104       $templateMgr->assign_by_ref('thisUser', Request::getUser());
00105       $templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER);
00106 
00107       $templateMgr->assign('searchField', $searchType);
00108       $templateMgr->assign('searchMatch', $searchMatch);
00109       $templateMgr->assign('search', $search);
00110       $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
00111 
00112       if ($roleId == ROLE_ID_REVIEWER) {
00113          $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00114          $templateMgr->assign('rateReviewerOnQuality', $conference->getSetting('rateReviewerOnQuality'));
00115          $templateMgr->assign('qualityRatings', $conference->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($conference->getId()) : null);
00116       }
00117       $templateMgr->assign('fieldOptions', Array(
00118          USER_FIELD_FIRSTNAME => 'user.firstName',
00119          USER_FIELD_LASTNAME => 'user.lastName',
00120          USER_FIELD_USERNAME => 'user.username',
00121          USER_FIELD_EMAIL => 'user.email',
00122          USER_FIELD_INTERESTS => 'user.interests'
00123       ));
00124       $templateMgr->assign('alphaList', explode(' ', __('common.alphaList')));
00125       $templateMgr->assign('oldUserIds', $oldUserIds);
00126       $templateMgr->assign('rolePath', $roleDao->getRolePath($roleId));
00127       $templateMgr->assign('roleSymbolic', $roleSymbolic);
00128       $templateMgr->display('admin/selectMergeUser.tpl');
00129    }
00130 
00131 }
00132 
00133 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7