Ejemplo n.º 1
0
 /**
  * Remove one or more entries
  *
  * @return  void
  */
 public function removeTask()
 {
     // Access check.
     if (!User::authorise('core.delete', $this->_option)) {
         Notify::warning(Lang::txt('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'));
         return $this->cancelTask();
     }
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     $ids = Request::getVar('id', array(), '', 'array');
     if (empty($ids)) {
         Notify::error(Lang::txt('COM_REDIRECT_NO_ITEM_SELECTED'));
     }
     $i = 0;
     foreach ($ids as $id) {
         $entry = Link::oneOrFail(intval($id));
         if (!$entry->destroy()) {
             Notify::error($entry->getError());
             continue;
         }
         $i++;
     }
     if ($i) {
         Notify::success(Lang::txts('COM_REDIRECT_N_ITEMS_DELETED', $i));
     }
     $this->cancelTask();
 }
Ejemplo n.º 2
0
 /**
  * Method to publish a list of items
  *
  * @return  void
  */
 public function publishTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Get items to publish from the request.
     $ids = Request::getVar('id', array(), '', 'array');
     $data = array('publish' => 1, 'unpublish' => 0, 'archive' => 2, 'trash' => -2, 'report' => -3);
     $value = \Hubzero\Utility\Arr::getValue($data, $this->_task, 0, 'int');
     if (empty($ids)) {
         Notify::error(Lang::txt('COM_REDIRECT_NO_ITEM_SELECTED'));
     }
     $updated = 0;
     // Loop through all the IDs
     foreach ($ids as $id) {
         $entry = Link::oneOrFail(intval($id));
         $entry->set('published', $value);
         // Remove the items.
         if (!$entry->save()) {
             Notify::error($entry->getError());
             continue;
         }
         $updated++;
     }
     if ($value == 1) {
         $ntext = 'COM_REDIRECT_N_ITEMS_PUBLISHED';
     } elseif ($value == 0) {
         $ntext = 'COM_REDIRECT_N_ITEMS_UNPUBLISHED';
     } elseif ($value == 2) {
         $ntext = 'COM_REDIRECT_N_ITEMS_ARCHIVED';
     } else {
         $ntext = 'COM_REDIRECT_N_ITEMS_TRASHED';
     }
     Notify::success(Lang::txts($ntext, $updated));
     App::redirect(Route::url('index.php?option=' . $this->_option, false));
 }