Example #1
0
 /**
  * Removes [a] password rule(s)
  *
  * @return  void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     if (!User::authorise('core.manage', $this->_option) && !User::authorise('core.admin', $this->_option) && !User::authorise('core.delete', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     // Incoming
     $ids = Request::getVar('id', array());
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $i = 0;
     // Do we have any IDs?
     if (!empty($ids)) {
         // Loop through each ID and delete the necessary items
         foreach ($ids as $id) {
             $id = intval($id);
             $row = Rule::oneOrFail($id);
             // Remove the record
             if (!$row->destroy()) {
                 Notify::error($row->getError());
                 continue;
             }
             $i++;
         }
     } else {
         Notify::warning(Lang::txt('COM_MEMBERS_PASSWORD_RULES_DELETE_NO_ROW_SELECTED'));
     }
     // Output messsage and redirect
     if ($i) {
         Notify::success(Lang::txt('COM_MEMBERS_PASSWORD_RULES_DELETE_SUCCESS'));
     }
     $this->cancelTask();
 }