pages/manager/PeopleHandler.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 import('pages.manager.ManagerHandler');
00018 
00019 class PeopleHandler extends ManagerHandler {
00023    function PeopleHandler() {
00024       parent::ManagerHandler();
00025    }
00026 
00031    function people($args) {
00032       $this->validate();
00033       $this->setupTemplate(true);
00034 
00035       $roleDao =& DAORegistry::getDAO('RoleDAO');
00036 
00037       if (Request::getUserVar('roleSymbolic')!=null) $roleSymbolic = Request::getUserVar('roleSymbolic');
00038       else $roleSymbolic = isset($args[0])?$args[0]:'all';
00039 
00040       if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\w+)s$/', $roleSymbolic, $matches)) {
00041          $roleId = $roleDao->getRoleIdFromPath($matches[1]);
00042          if ($roleId == null) {
00043             Request::redirect(null, null, null, 'all');
00044          }
00045          $roleName = $roleDao->getRoleName($roleId, true);
00046 
00047       } else {
00048          $roleId = 0;
00049          $roleName = 'manager.people.allUsers';
00050       }
00051 
00052       $sort = Request::getUserVar('sort');
00053       $sort = isset($sort) ? $sort : 'name';
00054       $sortDirection = Request::getUserVar('sortDirection');
00055 
00056       $conference =& Request::getConference();
00057       $schedConf =& Request::getSchedConf();
00058 
00059       $templateMgr =& TemplateManager::getManager();
00060 
00061       $searchType = null;
00062       $searchMatch = null;
00063       $search = Request::getUserVar('search');
00064       $searchInitial = Request::getUserVar('searchInitial');
00065       if (!empty($search)) {
00066          $searchType = Request::getUserVar('searchField');
00067          $searchMatch = Request::getUserVar('searchMatch');
00068 
00069       } elseif (!empty($searchInitial)) {
00070          $searchInitial = String::strtoupper($searchInitial);
00071          $searchType = USER_FIELD_INITIAL;
00072          $search = $searchInitial;
00073       }
00074 
00075       $rangeInfo =& Handler::getRangeInfo('users', array((string) $search, (string) $searchMatch, (string) $searchType, $roleId));
00076 
00077       if ($roleId) {
00078          while (true) {
00079             $users =& $roleDao->getUsersByRoleId($roleId, $conference->getId(),
00080                ($schedConf? $schedConf->getId() : null), $searchType, $search, $searchMatch, $rangeInfo, $sort, $sortDirection);
00081             if ($users->isInBounds()) break;
00082             unset($rangeInfo);
00083             $rangeInfo =& $users->getLastPageRangeInfo();
00084             unset($users);
00085          }
00086          $templateMgr->assign('roleId', $roleId);
00087          switch($roleId) {
00088             case ROLE_ID_CONFERENCE_MANAGER:
00089                $helpTopicId = 'conference.roles.conferenceManager';
00090                break;
00091             case ROLE_ID_DIRECTOR:
00092                $helpTopicId = 'conference.roles.directors';
00093                break;
00094             case ROLE_ID_TRACK_DIRECTOR:
00095                $helpTopicId = 'conference.roles.trackDirectors';
00096                break;
00097             case ROLE_ID_REVIEWER:
00098                $helpTopicId = 'conference.roles.reviewers';
00099                break;
00100             case ROLE_ID_AUTHOR:
00101                $helpTopicId = 'conference.roles.authors';
00102                break;
00103             case ROLE_ID_READER:
00104                $helpTopicId = 'conference.roles.readers';
00105                break;
00106             default:
00107                $helpTopicId = 'conference.roles.indexs';
00108                break;
00109          }
00110       } else {
00111          $users =& $roleDao->getUsersByConferenceId($conference->getId(), $searchType, $search, $searchMatch, $rangeInfo, $sort, $sortDirection);
00112          $helpTopicId = 'conference.users.allUsers';
00113       }
00114 
00115       $templateMgr->assign('currentUrl', Request::url(null, null, null, 'people', 'all'));
00116       $templateMgr->assign('roleName', $roleName);
00117       $templateMgr->assign_by_ref('users', $users);
00118       $templateMgr->assign_by_ref('thisUser', Request::getUser());
00119       $templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER);
00120 
00121       $templateMgr->assign('searchField', $searchType);
00122       $templateMgr->assign('searchMatch', $searchMatch);
00123       $templateMgr->assign('search', $search);
00124       $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
00125 
00126       if ($roleId == ROLE_ID_REVIEWER) {
00127          $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00128          $templateMgr->assign('rateReviewerOnQuality', $conference->getSetting('rateReviewerOnQuality'));
00129          $templateMgr->assign('qualityRatings', $conference->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($conference->getId()) : null);
00130       }
00131       $templateMgr->assign('helpTopicId', $helpTopicId);
00132       $templateMgr->assign('fieldOptions', Array(
00133          USER_FIELD_FIRSTNAME => 'user.firstName',
00134          USER_FIELD_LASTNAME => 'user.lastName',
00135          USER_FIELD_USERNAME => 'user.username',
00136          USER_FIELD_EMAIL => 'user.email',
00137          USER_FIELD_INTERESTS => 'user.interests'
00138       ));
00139       $templateMgr->assign('rolePath', $roleDao->getRolePath($roleId));
00140       $templateMgr->assign('alphaList', explode(' ', __('common.alphaList')));
00141       $templateMgr->assign('roleSymbolic', $roleSymbolic);
00142       $templateMgr->assign('isSchedConfManagement', $schedConf ? true : false);
00143       $templateMgr->assign('isConferenceManagement', $schedConf ? false : true);
00144       $templateMgr->assign('sort', $sort);
00145       $templateMgr->assign('sortDirection', $sortDirection);
00146       $templateMgr->display('manager/people/enrollment.tpl');
00147    }
00148 
00153    function enrollSearch($args) {
00154       $this->validate();
00155       $this->setupTemplate(true);
00156 
00157       $roleDao =& DAORegistry::getDAO('RoleDAO');
00158       $userDao =& DAORegistry::getDAO('UserDAO');
00159 
00160       $roleId = (int)(isset($args[0])?$args[0]:Request::getUserVar('roleId'));
00161       $conference =& Request::getConference();
00162       $schedConf =& Request::getSchedConf();
00163 
00164       $templateMgr =& TemplateManager::getManager();
00165 
00166       $searchType = null;
00167       $searchMatch = null;
00168       $search = Request::getUserVar('search');
00169       $searchInitial = Request::getUserVar('searchInitial');
00170       if (!empty($search)) {
00171          $searchType = Request::getUserVar('searchField');
00172          $searchMatch = Request::getUserVar('searchMatch');
00173 
00174       } elseif (!empty($searchInitial)) {
00175          $searchInitial = String::strtoupper($searchInitial);
00176          $searchType = USER_FIELD_INITIAL;
00177          $search = $searchInitial;
00178       }
00179 
00180       $sort = Request::getUserVar('sort');
00181       $sort = isset($sort) ? $sort : 'name';
00182       $sortDirection = Request::getUserVar('sortDirection');
00183 
00184       $rangeInfo =& Handler::getRangeInfo('users', array((string) $search, (string) $searchMatch, (string) $searchType));
00185 
00186       while (true) {
00187          $users =& $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo, $sort, $sortDirection);
00188          if ($users->isInBounds()) break;
00189          unset($rangeInfo);
00190          $rangeInfo =& $users->getLastPageRangeInfo();
00191          unset($users);
00192       }
00193 
00194       $templateMgr->assign('isSchedConfManagement', $schedConf ? true : false);
00195       $templateMgr->assign('isConferenceManagement', $schedConf ? false : true);
00196 
00197       $templateMgr->assign('searchField', $searchType);
00198       $templateMgr->assign('searchMatch', $searchMatch);
00199       $templateMgr->assign('search', $search);
00200       $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
00201 
00202       $templateMgr->assign('roleId', $roleId);
00203       $templateMgr->assign('fieldOptions', Array(
00204          USER_FIELD_FIRSTNAME => 'user.firstName',
00205          USER_FIELD_LASTNAME => 'user.lastName',
00206          USER_FIELD_USERNAME => 'user.username',
00207          USER_FIELD_INTERESTS => 'user.interests',
00208          USER_FIELD_EMAIL => 'user.email'
00209       ));
00210       $templateMgr->assign_by_ref('users', $users);
00211       $templateMgr->assign_by_ref('thisUser', Request::getUser());
00212       $templateMgr->assign('alphaList', explode(' ', __('common.alphaList')));
00213       $templateMgr->assign('helpTopicId', 'conference.users.index');
00214       $templateMgr->assign('sort', $sort);
00215       $templateMgr->assign('sortDirection', $sortDirection);
00216       $templateMgr->display('manager/people/searchUsers.tpl');
00217    }
00218 
00222    function enroll($args) {
00223       $this->validate();
00224 
00225       $roleId = (int)(isset($args[0])?$args[0]:Request::getUserVar('roleId'));
00226 
00227       // Get a list of users to enroll -- either from the
00228       // submitted array 'users', or the single user ID in
00229       // 'userId'
00230       $users = Request::getUserVar('users');
00231       if (!isset($users) && Request::getUserVar('userId') != null) {
00232          $users = array(Request::getUserVar('userId'));
00233       }
00234 
00235       $conference =& Request::getConference();
00236       $schedConf =& Request::getSchedConf();
00237 
00238       $roleDao =& DAORegistry::getDAO('RoleDAO');
00239       $rolePath = $roleDao->getRolePath($roleId);
00240 
00241       $isConferenceManager = Validation::isConferenceManager($conference->getId()) || Validation::isSiteAdmin();
00242 
00243       // Don't allow scheduled conference directors (who can end up here) to enroll
00244       // conference managers or scheduled conference directors.
00245       if ($users != null &&
00246             is_array($users) &&
00247             $rolePath != '' &&
00248             $rolePath != ROLE_PATH_SITE_ADMIN &&
00249             $isConferenceManager) {
00250 
00251          $schedConfId = ($schedConf? $schedConf->getId() : 0);
00252 
00253          for ($i=0; $i<count($users); $i++) {
00254             if (!$roleDao->roleExists($conference->getId(), $schedConfId, $users[$i], $roleId)) {
00255                if ($schedConfId == 0) {
00256                   // In case they're enrolled in individual scheduled conferences and we want to enrol
00257                   // them in the whole conference, ensure they don't have multiple roles
00258                   $roleDao->deleteRoleByUserId($users[$i], $conference->getId(), $roleId);
00259                } else if ($roleDao->roleExists($conference->getId(), 0, $users[$i], $roleId)) {
00260                   // If they're enrolled in the whole conference, this individual
00261                   // enrollment isn't valuable.
00262                   return;
00263                }
00264 
00265                $role = new Role();
00266                $role->setConferenceId($conference->getId());
00267                if ($schedConf && $rolePath != ROLE_PATH_CONFERENCE_MANAGER) {
00268                   $role->setSchedConfId($schedConfId);
00269                } else {
00270                   $role->setSchedConfId(0);
00271                }
00272                $role->setUserId($users[$i]);
00273                $role->setRoleId($roleId);
00274                $roleDao->insertRole($role);
00275             }
00276          }
00277       }
00278 
00279       Request::redirect(null, null, null, 'people', (empty($rolePath) ? null : $rolePath . 's'));
00280    }
00281 
00285    function unEnroll($args) {
00286       $roleId = isset($args[0])?$args[0]:0;
00287       $this->validate();
00288 
00289       $conference =& Request::getConference();
00290       $isConferenceManager = Validation::isConferenceManager($conference->getId()) || Validation::isSiteAdmin();
00291       $roleDao =& DAORegistry::getDAO('RoleDAO');
00292 
00293       // Don't allow scheduled conference managers to unenroll scheduled conference managers or
00294       // conference managers. FIXME is this still relevant?
00295       if ($roleId != ROLE_ID_SITE_ADMIN && $isConferenceManager) {
00296          $roleDao->deleteRoleByUserId(Request::getUserVar('userId'), $conference->getId(), $roleId);
00297       }
00298 
00299       Request::redirect(null, null, null, 'people', $roleDao->getRolePath($roleId) . 's');
00300    }
00301 
00305    function enrollSyncSelect($args) {
00306       $this->validate();
00307       $this->setupTemplate(true);
00308 
00309       $rolePath = isset($args[0]) ? $args[0] : '';
00310       $roleDao =& DAORegistry::getDAO('RoleDAO');
00311       $roleId = $roleDao->getRoleIdFromPath($rolePath);
00312       if ($roleId) {
00313          $roleName = $roleDao->getRoleName($roleId, true);
00314       } else {
00315          $rolePath = '';
00316          $roleName = '';
00317       }
00318 
00319       $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00320       $conferenceTitles =& $conferenceDao->getConferenceTitles();
00321 
00322       $conference =& Request::getConference();
00323       $schedConf =& Request::getSchedConf();
00324       if (!$schedConf) Request::redirect(null, null, 'manager');
00325 
00326       unset($conferenceTitles[$conference->getId()]);
00327 
00328       $templateMgr =& TemplateManager::getManager();
00329       $templateMgr->assign('rolePath', $rolePath);
00330       $templateMgr->assign('roleName', $roleName);
00331       $templateMgr->assign('conferenceOptions', $conferenceTitles);
00332       $templateMgr->display('manager/people/enrollSync.tpl');
00333    }
00334 
00338    function enrollSync($args) {
00339       $this->validate();
00340 
00341       $conference =& Request::getConference();
00342       $schedConf =& Request::getSchedConf();
00343       $rolePath = Request::getUserVar('rolePath');
00344       $syncConference = Request::getUserVar('syncConference');
00345 
00346       if (!$schedConf) Request::redirect(null, null, 'manager');
00347 
00348       $roleDao =& DAORegistry::getDAO('RoleDAO');
00349       $roleId = $roleDao->getRoleIdFromPath($rolePath);
00350 
00351       if ((!empty($roleId) || $rolePath == 'all') && !empty($syncConference)) {
00352          $roles =& $roleDao->getRolesByConferenceId($syncConference == 'all' ? null : $syncConference, $roleId);
00353          while (!$roles->eof()) {
00354             $role =& $roles->next();
00355             $role->setConferenceId($conference->getId());
00356             $role->setSchedConfId($schedConf->getId());
00357             if ($role->getRolePath() != ROLE_PATH_SITE_ADMIN && !$roleDao->roleExists($role->getConferenceId(), $schedConf->getId(), $role->getUserId(), $role->getRoleId())) {
00358                $roleDao->insertRole($role);
00359             }
00360          }
00361       }
00362 
00363       Request::redirect(null, null, null, 'people', $roleDao->getRolePath($roleId));
00364    }
00365 
00370    function suggestUsername() {
00371       $this->validate();
00372       $suggestion = Validation::suggestUsername(
00373          Request::getUserVar('firstName'),
00374          Request::getUserVar('lastName')
00375       );
00376       echo $suggestion;
00377    }
00378 
00382    function createUser() {
00383       PeopleHandler::editUser();
00384    }
00385 
00390    function editUser($args = array()) {
00391       $this->validate();
00392       $this->setupTemplate(true);
00393 
00394       $conference =& Request::getConference();
00395 
00396       $userId = isset($args[0])?$args[0]:null;
00397 
00398       $templateMgr =& TemplateManager::getManager();
00399 
00400       if ($userId !== null && !Validation::canAdminister($conference->getId(), $userId)) {
00401          // We don't have administrative rights
00402          // over this user. Display an error.
00403          $templateMgr->assign('pageTitle', 'manager.people');
00404          $templateMgr->assign('errorMsg', 'manager.people.noAdministrativeRights');
00405          $templateMgr->assign('backLink', Request::url(null, null, null, 'people', 'all'));
00406          $templateMgr->assign('backLinkLabel', 'manager.people.allUsers');
00407 
00408          return $templateMgr->display('common/error.tpl');
00409       }
00410 
00411       import('manager.form.UserManagementForm');
00412 
00413       $templateMgr->assign('currentUrl', Request::url(null, null, null, 'people', 'all'));
00414 
00415       if (checkPhpVersion('5.0.0')) { // WARNING: This form needs $this in constructor
00416          $userForm = new UserManagementForm($userId);
00417       } else {
00418          $userForm =& new UserManagementForm($userId);
00419       }
00420       if ($userForm->isLocaleResubmit()) {
00421          $userForm->readInputData();
00422       } else {
00423          $userForm->initData();
00424       }
00425       $userForm->display();
00426    }
00427 
00431    function mergeUsers($args) {
00432       $this->validate();
00433       $this->setupTemplate(true);
00434 
00435       $roleDao =& DAORegistry::getDAO('RoleDAO');
00436       $userDao =& DAORegistry::getDAO('UserDAO');
00437 
00438       $conference =& Request::getConference();
00439       $schedConf =& Request::getSchedConf();
00440       $schedConfId = isset($schedConf)? $schedConf->getId() : null;
00441       $templateMgr =& TemplateManager::getManager();
00442 
00443       $oldUserIds = (array) Request::getUserVar('oldUserIds');
00444       $newUserId = Request::getUserVar('newUserId');
00445 
00446       // Ensure that we have administrative priveleges over the specified user(s).
00447       $canAdministerAll = true;
00448       foreach ($oldUserIds as $oldUserId) {
00449          if (!Validation::canAdminister($conference->getId(), $oldUserId)) $canAdministerAll = false;
00450       }
00451       if (
00452          (!empty($oldUserIds) && !$canAdministerAll) ||
00453          (!empty($newUserId) && !Validation::canAdminister($conference->getId(), $newUserId))
00454       ) {
00455          $templateMgr->assign('pageTitle', 'manager.people');
00456          $templateMgr->assign('errorMsg', 'manager.people.noAdministrativeRights');
00457          $templateMgr->assign('backLink', Request::url(null, null, null, 'people', 'all'));
00458          $templateMgr->assign('backLinkLabel', 'manager.people.allUsers');
00459          return $templateMgr->display('common/error.tpl');
00460       }
00461 
00462       if (!empty($oldUserIds) && !empty($newUserId)) {
00463          import('user.UserAction');
00464          foreach ($oldUserIds as $oldUserId) {
00465             UserAction::mergeUsers($oldUserId, $newUserId);
00466          }
00467          Request::redirect(null, null, 'manager');
00468       }
00469 
00470       // The manager must select one or both IDs.
00471       if (Request::getUserVar('roleSymbolic')!=null) $roleSymbolic = Request::getUserVar('roleSymbolic');
00472       else $roleSymbolic = isset($args[0])?$args[0]:'all';
00473 
00474       if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\w+)s$/', $roleSymbolic, $matches)) {
00475          $roleId = $roleDao->getRoleIdFromPath($matches[1]);
00476          if ($roleId == null) {
00477             Request::redirect(null, null, null, null, 'all');
00478          }
00479          $roleName = $roleDao->getRoleName($roleId, true);
00480       } else {
00481          $roleId = 0;
00482          $roleName = 'manager.people.allUsers';
00483       }
00484 
00485       $sort = Request::getUserVar('sort');
00486       $sort = isset($sort) ? $sort : 'name';
00487       $sortDirection = Request::getUserVar('sortDirection');
00488 
00489       $searchType = null;
00490       $searchMatch = null;
00491       $search = Request::getUserVar('search');
00492       $searchInitial = Request::getUserVar('searchInitial');
00493       if (!empty($search)) {
00494          $searchType = Request::getUserVar('searchField');
00495          $searchMatch = Request::getUserVar('searchMatch');
00496 
00497       } elseif (!empty($searchInitial)) {
00498          $searchInitial = String::strtoupper($searchInitial);
00499          $searchType = USER_FIELD_INITIAL;
00500          $search = $searchInitial;
00501       }
00502 
00503       $rangeInfo =& Handler::getRangeInfo('users', array($roleId, (string) $search, (string) $searchMatch, (string) $searchType));
00504 
00505       if ($roleId) {
00506          while (true) {
00507             $users =& $roleDao->getUsersByRoleId($roleId, $conference->getId(), $schedConfId, $searchType, $search, $searchMatch, $rangeInfo, $sort);
00508             if ($users->isInBounds()) break;
00509             unset($rangeInfo);
00510             $rangeInfo =& $users->getLastPageRangeInfo();
00511             unset($users);
00512          }
00513          $templateMgr->assign('roleId', $roleId);
00514       } else {
00515          while (true) {
00516             $users =& $roleDao->getUsersByConferenceId($conference->getId(), $searchType, $search, $searchMatch, $rangeInfo, $sort);
00517             if ($users->isInBounds()) break;
00518             unset($rangeInfo);
00519             $rangeInfo =& $users->getLastPageRangeInfo();
00520             unset($users);
00521          }
00522       }
00523 
00524       $templateMgr->assign('currentUrl', Request::url(null, null, null, 'people', 'all'));
00525       $templateMgr->assign('helpTopicId', 'conference.users.mergeUsers');
00526       $templateMgr->assign('roleName', $roleName);
00527       $templateMgr->assign_by_ref('users', $users);
00528       $templateMgr->assign_by_ref('thisUser', Request::getUser());
00529       $templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER);
00530 
00531       $templateMgr->assign('searchField', $searchType);
00532       $templateMgr->assign('searchMatch', $searchMatch);
00533       $templateMgr->assign('search', $search);
00534       $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
00535 
00536       if ($roleId == ROLE_ID_REVIEWER) {
00537          $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00538          $templateMgr->assign('rateReviewerOnQuality', $conference->getSetting('rateReviewerOnQuality'));
00539          $templateMgr->assign('qualityRatings', $conference->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($conference->getId()) : null);
00540       }
00541       $templateMgr->assign('fieldOptions', Array(
00542          USER_FIELD_FIRSTNAME => 'user.firstName',
00543          USER_FIELD_LASTNAME => 'user.lastName',
00544          USER_FIELD_USERNAME => 'user.username',
00545          USER_FIELD_EMAIL => 'user.email',
00546          USER_FIELD_INTERESTS => 'user.interests'
00547       ));
00548       $templateMgr->assign('alphaList', explode(' ', __('common.alphaList')));
00549       $templateMgr->assign('oldUserIds', $oldUserIds);
00550       $templateMgr->assign('rolePath', $roleDao->getRolePath($roleId));
00551       $templateMgr->assign('roleSymbolic', $roleSymbolic);
00552       $templateMgr->assign('sort', $sort);
00553       $templateMgr->assign('sortDirection', $sortDirection);
00554       $templateMgr->display('manager/people/selectMergeUser.tpl');
00555    }
00556 
00561    function disableUser($args) {
00562       $this->validate();
00563       $this->setupTemplate(true);
00564 
00565       $userId = isset($args[0])?$args[0]:Request::getUserVar('userId');
00566       $user =& Request::getUser();
00567       $conference =& Request::getConference();
00568 
00569       if ($userId != null && $userId != $user->getId()) {
00570          if (!Validation::canAdminister($conference->getId(), $userId)) {
00571             // We don't have administrative rights
00572             // over this user. Display an error.
00573             $templateMgr =& TemplateManager::getManager();
00574             $templateMgr->assign('pageTitle', 'manager.people');
00575             $templateMgr->assign('errorMsg', 'manager.people.noAdministrativeRights');
00576             $templateMgr->assign('backLink', Request::url(null, null, null, 'people', 'all'));
00577             $templateMgr->assign('backLinkLabel', 'manager.people.allUsers');
00578             return $templateMgr->display('common/error.tpl');
00579          }
00580          $userDao =& DAORegistry::getDAO('UserDAO');
00581          $user =& $userDao->getUser($userId);
00582          if ($user) {
00583             $user->setDisabled(1);
00584             $user->setDisabledReason(Request::getUserVar('reason'));
00585          }
00586          $userDao->updateObject($user);
00587       }
00588 
00589       Request::redirect(null, null, null, 'people', 'all');
00590    }
00591 
00596    function enableUser($args) {
00597       $this->validate();
00598       $this->setupTemplate(true);
00599 
00600       $userId = isset($args[0])?$args[0]:null;
00601       $user =& Request::getUser();
00602 
00603       if ($userId != null && $userId != $user->getId()) {
00604          $userDao =& DAORegistry::getDAO('UserDAO');
00605          $user =& $userDao->getUser($userId, true);
00606          if ($user) {
00607             $user->setDisabled(0);
00608          }
00609          $userDao->updateObject($user);
00610       }
00611 
00612       Request::redirect(null, null, null, 'people', 'all');
00613    }
00614 
00619    function removeUser($args) {
00620       $this->validate();
00621       $this->setupTemplate(true);
00622 
00623       $userId = isset($args[0])?$args[0]:null;
00624       $user =& Request::getUser();
00625       $conference =& Request::getConference();
00626 
00627       if ($userId != null && $userId != $user->getId()) {
00628          $roleDao =& DAORegistry::getDAO('RoleDAO');
00629          $roleDao->deleteRoleByUserId($userId, $conference->getId());
00630       }
00631 
00632       Request::redirect(null, null, null, 'people', 'all');
00633    }
00634 
00638    function updateUser() {
00639       $this->validate();
00640       $this->setupTemplate(true);
00641 
00642       $conference =& Request::getConference();
00643       $userId = Request::getUserVar('userId');
00644 
00645       if (!empty($userId) && !Validation::canAdminister($conference->getId(), $userId)) {
00646          // We don't have administrative rights
00647          // over this user. Display an error.
00648          $templateMgr =& TemplateManager::getManager();
00649          $templateMgr->assign('pageTitle', 'manager.people');
00650          $templateMgr->assign('errorMsg', 'manager.people.noAdministrativeRights');
00651          $templateMgr->assign('backLink', Request::url(null, null, null, 'people', 'all'));
00652          $templateMgr->assign('backLinkLabel', 'manager.people.allUsers');
00653          return $templateMgr->display('common/error.tpl');
00654       }
00655 
00656       import('manager.form.UserManagementForm');
00657 
00658       if (checkPhpVersion('5.0.0')) { // WARNING: This form needs $this in constructor
00659          $userForm = new UserManagementForm($userId);
00660       } else {
00661          $userForm =& new UserManagementForm($userId);
00662       }
00663       $userForm->readInputData();
00664 
00665       if ($userForm->validate()) {
00666          $userForm->execute();
00667 
00668          if (Request::getUserVar('createAnother')) {
00669             $templateMgr =& TemplateManager::getManager();
00670             $templateMgr->assign('currentUrl', Request::url(null, null, null, 'people', 'all'));
00671             $templateMgr->assign('userCreated', true);
00672             unset($userForm);
00673             if (checkPhpVersion('5.0.0')) { // WARNING: This form needs $this in constructor
00674                $userForm = new UserManagementForm();
00675             } else {
00676                $userForm =& new UserManagementForm();
00677             }
00678             $userForm->initData();
00679             $userForm->display();
00680 
00681          } else {
00682             if ($source = Request::getUserVar('source')) Request::redirectUrl($source);
00683             else Request::redirect(null, null, null, 'people', 'all');
00684          }
00685       } else {
00686          $userForm->display();
00687       }
00688    }
00689 
00694    function userProfile($args) {
00695       $this->validate();
00696       $this->setupTemplate(true);
00697 
00698       $templateMgr =& TemplateManager::getManager();
00699       $templateMgr->assign('currentUrl', Request::url(null, null, null, 'people', 'all'));
00700       $templateMgr->assign('helpTopicId', 'conference.users.index');
00701 
00702       $userDao =& DAORegistry::getDAO('UserDAO');
00703       $userId = isset($args[0]) ? $args[0] : 0;
00704       if (is_numeric($userId)) {
00705          $userId = (int) $userId;
00706          $user = $userDao->getUser($userId);
00707       } else {
00708          $user = $userDao->getUserByUsername($userId);
00709       }
00710 
00711 
00712       if ($user == null) {
00713          // Non-existent user requested
00714          $templateMgr->assign('pageTitle', 'manager.people');
00715          $templateMgr->assign('errorMsg', 'manager.people.invalidUser');
00716          $templateMgr->assign('backLink', Request::url(null, null, null, 'people', 'all'));
00717          $templateMgr->assign('backLinkLabel', 'manager.people.allUsers');
00718          $templateMgr->display('common/error.tpl');
00719 
00720       } else {
00721          $site =& Request::getSite();
00722          $conference =& Request::getConference();
00723          $roleDao =& DAORegistry::getDAO('RoleDAO');
00724          $roles =& $roleDao->getRolesByUserId($user->getId(), $conference->getId());
00725 
00726          $countryDao =& DAORegistry::getDAO('CountryDAO');
00727          $country = null;
00728          if ($user->getCountry() != '') {
00729             $country = $countryDao->getCountry($user->getCountry());
00730          }
00731          $templateMgr->assign('country', $country);
00732 
00733          $templateMgr->assign('isSchedConfManagement', Request::getSchedConf() ? true : false);
00734          $templateMgr->assign('isConferenceManagement', Request::getSchedConf() ? false : true);
00735 
00736          $templateMgr->assign_by_ref('user', $user);
00737          $templateMgr->assign_by_ref('userRoles', $roles);
00738          $templateMgr->assign('localeNames', AppLocale::getAllLocales());
00739          $templateMgr->display('manager/people/userProfile.tpl');
00740       }
00741    }
00742 }
00743 
00744 ?>

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