Exemplo 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'));
 }