/**
  * Delete a record
  *
  * @return     void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Do we have any IDs?
     if (!empty($ids)) {
         $notify = new Message\Notify($this->database);
         // Loop through each ID and delete the necessary items
         foreach ($ids as $id) {
             $id = intval($id);
             $row = new Message\Component($this->database);
             $row->load($id);
             // Remove any associations
             $notify->deleteType($row->action);
             // Remove the record
             $row->delete($id);
         }
     }
     // Output messsage and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('Message Action removed'));
 }
Exemple #2
0
 /**
  * Delete a record
  *
  * @return  void
  */
 public function settingsTask()
 {
     $id = Request::getInt('id', 0);
     $member = User::getInstance($id);
     if (!$member || !$member->get('id')) {
         // Output messsage and redirect
         App::abort(404, Lang::txt('Unknown or invalid member ID'));
     }
     $database = App::get('db');
     $xmc = Message\Component::blank();
     $components = $xmc->getRecords();
     /*if ($components)
     		{
     			$this->setError(Lang::txt('No vlaues found'));
     		}*/
     $settings = array();
     foreach ($components as $component) {
         $settings[$component->get('action')] = array();
     }
     // Fetch message methods
     $notimethods = Event::trigger('xmessage.onMessageMethods', array());
     // A var for storing the default notification method
     $default_method = null;
     // Instantiate our notify object
     $notify = Message\Notify::blank();
     // Get the user's selected methods
     $methods = $notify->getRecords($member->get('id'));
     if ($methods->count()) {
         foreach ($methods as $method) {
             $settings[$method->get('type')]['methods'][] = $method->get('method');
             $settings[$method->get('type')]['ids'][$method->get('method')] = $method->get('id');
         }
     } else {
         $default_method = \Plugin::params('members', 'messages')->get('default_method');
     }
     // Fill in any settings that weren't set.
     foreach ($settings as $key => $val) {
         if (count($val) <= 0) {
             // If the user has never changed their settings, set up the defaults
             if ($default_method !== null) {
                 $settings[$key]['methods'][] = 'internal';
                 $settings[$key]['methods'][] = $default_method;
                 $settings[$key]['ids']['internal'] = 0;
                 $settings[$key]['ids'][$default_method] = 0;
             } else {
                 $settings[$key]['methods'] = array();
                 $settings[$key]['ids'] = array();
             }
         }
     }
     $this->view->set('member', $member)->set('settings', $settings)->set('notimethods', $notimethods)->set('components', $components)->display();
 }