示例#1
0
 /**
  * Resets the terms of use agreement for all users (requiring re-agreement)
  *
  * @return  void
  */
 public function clearTermsTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     if (!User::authorise('core.manage', $this->_option) && !User::authorise('core.admin', $this->_option) && !User::authorise('core.edit', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     // Update registration config value to require re-agreeing upon next login
     $currentTOU = $this->config->get('registrationTOU', 'RHRH');
     $newTOU = substr_replace($currentTOU, 'R', 2, 1);
     $this->config->set('registrationTOU', $newTOU);
     // Get db object
     $dbo = App::get('db');
     $migration = new \Hubzero\Content\Migration\Base($dbo);
     if (!$migration->saveParams('com_members', $this->config)) {
         Notify::error(Lang::txt('COM_MEMBERS_FAILED_TO_UPDATE_REGISTRATION_TOU'));
         return $this->cancelTask();
     }
     // Clear all old TOU states
     if (!Member::clearTerms()) {
         Notify::error(Lang::txt('COM_MEMBERS_FAILED_TO_CLEAR_TOU'));
         return $this->cancelTask();
     }
     // Output message to let admin know everything went well
     Notify::success(Lang::txt('COM_MEMBERS_SUCESSFULLY_CLEARED_TOU'));
     $this->cancelTask();
 }