Ejemplo n.º 1
0
 /**
  * Sets the emailConfirmed state of a member
  *
  * @return     void
  */
 public function stateTask($state = 1)
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     // Incoming user ID
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Do we have an ID?
     if (empty($ids)) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_NO_ID'), 'error');
         return;
     }
     foreach ($ids as $id) {
         // Load the profile
         $profile = new Profile();
         $profile->load(intval($id));
         if ($state) {
             $profile->set('emailConfirmed', $state);
         } else {
             $confirm = Helpers\Utility::genemailconfirm();
             $profile->set('emailConfirmed', $confirm);
         }
         if (!$profile->update()) {
             App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $profile->getError(), 'error');
             return;
         }
     }
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_CONFIRMATION_CHANGED'));
 }
Ejemplo n.º 2
0
 /**
  * Get the submitter of this entry
  *
  * Accepts an optional property name. If provided
  * it will return that property value. Otherwise,
  * it returns the entire user object
  *
  * @param   string  $property  User property to look up
  * @param   mixed   $default   Value to return if property not found
  * @return  mixed
  */
 public function submitter($property = null, $default = null)
 {
     if (!$this->_data->get('submitter.profile') instanceof Profile) {
         $user = Profile::getInstance($this->get('login'));
         if (!is_object($user) || !$user->get('uidNumber')) {
             $user = new Profile();
         }
         $user->set('name', $this->get('name'));
         $user->set('username', $this->get('login'));
         $user->set('email', $this->get('email'));
         $this->_data->set('submitter.profile', $user);
     }
     if ($property) {
         $property = $property == 'id' ? 'uidNumber' : $property;
         return $this->_data->get('submitter.profile')->get($property, $default);
     }
     return $this->_data->get('submitter.profile');
 }
Ejemplo n.º 3
0
 /**
  * Add a user as a manager of a course
  *
  * @return  void
  */
 public function addTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     if ($this->getError()) {
         return $this->displayTask();
     }
     // Incoming host
     $m = Request::getVar('author', '');
     $mbrs = explode(',', $m);
     $mbrs = array_map('trim', $mbrs);
     foreach ($mbrs as $mbr) {
         $user = null;
         if (!strstr($mbr, ' ')) {
             $user = Profile::getInstance($mbr);
         }
         // Make sure the user exists
         if (!is_object($user) || !$user->get('username')) {
             $user = new Profile();
             $user->set('name', $mbr);
         }
         $author = new Author($this->database);
         $author->cid = $this->citation->id;
         $author->author = $user->get('name');
         $author->uidNumber = $user->get('uidNumber');
         $author->organization = $user->get('organization');
         $author->givenName = $user->get('givenName');
         $author->middleName = $user->get('middleName');
         $author->surname = $user->get('surname');
         $author->email = $user->get('email');
         if (!$author->check()) {
             $this->setError($author->getError());
             continue;
         }
         if (!$author->store()) {
             $this->setError($author->getError());
             continue;
         }
     }
     // Push through to the view
     $this->displayTask();
 }