/**
  * beforeFilter
  *
  *
  * @access public
  * @return void
  */
 function beforeFilter()
 {
     parent::beforeFilter();
     $this->set('title_for_layout', __('Advanced Search', true));
     $currentUser = $this->User->getCurrentLoggedInUser();
     $this->set('currentUser', $currentUser);
     $coursesList = User::getMyCourseList();
     $this->set('coursesList', $coursesList);
     $personalizeData = $this->Personalize->find('all', array('conditions' => 'user_id = ' . $this->Auth->user('id')));
     $this->userPersonalize->setPersonalizeList($personalizeData);
     if ($personalizeData && $this->userPersonalize->inPersonalizeList('Search.ListMenu.Limit.Show')) {
         $this->show = $this->userPersonalize->getPersonalizeValue('Search.ListMenu.Limit.Show');
         $this->set('userPersonalize', $this->userPersonalize);
     } else {
         $this->show = '15';
         //$this->update($attributeCode = 'Search.ListMenu.Limit.Show', $attributeValue = $this->show);
     }
 }
Example #2
0
 /**
  * _checkResetPasswordPermission
  *
  * @param mixed $userId
  * @param mixed $courseId
  *
  * @access private
  * @return array of user data
  */
 private function _checkResetPasswordPermission($userId, $courseId)
 {
     if (!User::hasPermission('functions/user')) {
         $this->Session->setFlash('Error: You do not have permission to reset passwords', true);
         $this->redirect('/home');
     }
     // Read the user
     $userData = $this->User->findById($userId);
     if (empty($userData)) {
         $this->Session->setFlash(__('User Not Found!', true));
         $this->redirect("index");
     }
     $role = $this->User->getRoleName($userId);
     if (!User::hasPermission('functions/user/' . $role)) {
         $this->Session->setFlash('Error: You do not have permission to reset the password for this user.', true);
         if (is_null($courseId)) {
             $this->redirect('index');
         } else {
             $this->redirect('/users/goToClassList/' . $courseId);
         }
     }
     // super admins and faculty admins can reset passwords for all users
     // instructors can only reset passwords for students and tutors in their course(s)
     if (!User::hasPermission('controllers/departments')) {
         // instructors
         $courses = User::getMyCourseList();
         $models = array('UserTutor', 'UserEnrol');
         $accessibleUsers = array();
         foreach ($models as $model) {
             $users = $this->{$model}->find('list', array('conditions' => array('course_id' => array_keys($courses)), 'fields' => array('user_id')));
             $accessibleUsers = array_merge($accessibleUsers, $users);
         }
         if (!in_array($userId, $accessibleUsers)) {
             $this->Session->setFlash(__('Error: You do not have permission to reset the password for this user', true));
             if (is_null($courseId)) {
                 $this->redirect('index');
             } else {
                 $this->redirect('/users/goToClassList/' . $courseId);
             }
         }
     }
     return $userData;
 }
Example #3
0
 /**
  * getAccessibleCourses
  *
  * @access public
  * @return list of course ids
  */
 function getAccessibleCourses()
 {
     if (User::hasPermission('functions/user/admin')) {
         return array_keys(User::getMyDepartmentsCourseList('list'));
     } else {
         return array_keys(User::getMyCourseList());
     }
 }