public function delete() { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); // Get items to remove from the request. $cid = JFactory::getApplication()->input->get('cid', array(), 'array'); if (!is_array($cid) || count($cid) < 1) { JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror'); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers jimport('joomla.utilities.arrayhelper'); JArrayHelper::toInteger($cid); // Remove the items. if ($model->delete($cid)) { $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); } else { $this->setMessage($model->getError()); } } $version = new JVersion(); if ($version->isCompatible('3.0')) { // Invoke the postDelete method to allow for the child class to access the model. $this->postDeleteHook($model, $cid); } $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); }
/** * Method to run this controller. * * @throws \InvalidArgumentException * @return mixed */ protected function doExecute() { if (empty($this->cid)) { $this->setRedirect($this->getFailRedirect(), \JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'), Message::ERROR_RED); return false; } $pks = $this->cid; foreach ($pks as $i => $pk) { $this->table->reset(); if (!$this->table->load($pk)) { continue; } $data = $this->table->getProperties(true); if (!$this->allowEdit($data)) { $this->addMessage(\JText::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED')); continue; } try { $this->table->checkIn($pk); } catch (\Exception $e) { $this->addMessage($this->table->getError()); } } $message = \JText::plural($this->textPrefix . '_N_ITEMS_CHECKED_IN', count($pks)); $this->setRedirect($this->getSuccessRedirect(), $message, Message::MESSAGE_GREEN); return true; }
/** * Deep Copy projects * * @return void */ public function copy() { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); // Get items to publish from the request. $cid = JFactory::getApplication()->input->get('cid', array(), 'array'); if (empty($cid)) { JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror'); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers JArrayHelper::toInteger($cid); // Copy the items. try { if ($model->copy($cid)) { $this->setMessage(JText::plural('COM_TRACKS_PROJECTS_N_ITEMS_COPIED', count($cid))); } else { $this->setMessage($model->getError(), 'error'); } } catch (Exception $e) { $this->setMessage($e->getMessage(), 'error'); } } $extension = $this->input->get('extension'); $extensionURL = $extension ? '&extension=' . $extension : ''; // Set redirect $this->setRedirect($this->getRedirectToListRoute($extensionURL)); }
/** * Removes an item. * * @return void */ function delete() { $app = JFactory::getApplication(); $map = $app->input->getVar('map'); // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); // Get items to remove from the request. $cid = $app->input->getVar('cid', array(), '', 'array'); if (!is_array($cid) || count($cid) < 1) { JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers jimport('joomla.utilities.arrayhelper'); JArrayHelper::toInteger($cid); // Remove the items. if ($model->delete($cid)) { $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); } else { $this->setMessage($model->getError()); } } $this->setRedirect(JRoute::_('index.php?option=com_mapfrance&view=areas&map=' . $map, false)); }
public function changevalue() { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); // Get items to change the values from the request. $cid = JFactory::getApplication()->input->get('cid', array(), 'array'); $data = array('showinsubscribers' => 1, 'hideinsubscribers' => 0, 'setrequired' => 1, 'unsetrequired' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); if (empty($cid)) { JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror'); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers JArrayHelper::toInteger($cid); // Change value of the items. try { $model->changevalue($cid, $value, $task); if ($value == 1) { $ntext = $this->text_prefix . '_N_ITEMS_' . strtoupper($task); } elseif ($value == 0) { $ntext = $this->text_prefix . '_N_ITEMS_' . strtoupper($task); } $this->setMessage(JText::plural($ntext, count($cid))); } catch (Exception $e) { $this->setMessage(JText::_('JLIB_DATABASE_ERROR_ANCESTOR_NODES_LOWER_STATE'), 'error'); } } $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); }
static function repliesLabel($replies = 0, $activity = null) { static $format = null; if (is_null($format)) { $params = JComponentHelper::getParams('com_projectfork'); $format = $params->get('date_format'); if (!$format) { $format = JText::_('DATE_FORMAT_LC1'); } } $html = array(); $text = JText::plural('COM_PROJECTFORK_N_REPLIES', (int) $replies); if ($replies == 0) { $html[] = '<span class="label">' . $text . '</span>'; } else { $title = ''; $class = ''; $style = ''; if ($activity && $activity != JFactory::getDbo()->getNullDate()) { $title = ' title="' . PFDate::relative($activity) . '::' . JHtml::_('date', $activity, $format) . '"'; $style = ' style="cursor: help"'; $class = ' hasTip'; } $html[] = '<span class="label label-success' . $class . '"' . $title . $style . '>' . $text . '</span>'; } return implode('', $html); }
/** * @since 1.6 */ public function sticky_publish() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $user = JFactory::getUser(); $ids = JRequest::getVar('cid', array(), '', 'array'); $values = array('sticky_publish' => 1, 'sticky_unpublish' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); if (empty($ids)) { JError::raiseWarning(500, JText::_('COM_NTRIP_NO_ALBUMS_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Change the state of the records. if (!$model->stick($ids, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1) { $ntext = 'COM_NTRIP_N_ALBUMS_STUCK'; } else { $ntext = 'COM_NTRIP_N_ALBUMS_UNSTUCK'; } $this->setMessage(JText::plural($ntext, count($ids))); } } $this->setRedirect('index.php?option=com_jnt_hanhphuc&view=albums'); }
public function required() { JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $cid = $app->input->get('cid', array(), 'array'); $data = array('required' => 1, 'unrequired' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); if (empty($cid)) { JError::raiseWarning(500, JText::_('COM_JUDIRECTORY_NO_ITEM_SELECTED')); } else { $model = $this->getModel(); JArrayHelper::toInteger($cid); if (!$model->required($cid, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1) { $ntext = $this->text_prefix . '_N_ITEMS_REQUIRED'; } elseif ($value == 0) { $ntext = $this->text_prefix . '_N_ITEMS_UNREQUIRED'; } $this->setMessage(JText::plural($ntext, count($cid))); } } $extension = $app->input->get('extension'); $extensionURL = $extension ? '&extension=' . $extension : ''; $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $extensionURL, false)); }
/** * Method to change the block status on a record. * * @return void * * @since 0.3.0 */ public function changeBlock() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $ids = $this->input->get('cid', array(), 'array'); $values = array('block' => 1, 'unblock' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); // Convert from customer ID to Joomla user ID $joomlaUserIds = array(); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_solidres/tables', 'SolidresTable'); $customerTable = JTable::getInstance('Customer', 'SolidresTable'); foreach ($ids as $id) { $customerTable->load($id); $joomlaUserIds[] = $customerTable->user_id; } if (empty($joomlaUserIds)) { JError::raiseWarning(500, JText::_('SR_CUSTOMERS_NO_ITEM_SELECTED')); } else { // Get the model. JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models', 'UsersModel'); $model = JModelLegacy::getInstance('User', 'UsersModel', array('ignore_request' => true)); // Change the state of the records. if (!$model->block($joomlaUserIds, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1) { $this->setMessage(JText::plural('SR_N_CUSTOMERS_BLOCKED', count($joomlaUserIds))); } elseif ($value == 0) { $this->setMessage(JText::plural('SR_N_CUSTOMERS_UNBLOCKED', count($joomlaUserIds))); } } } $this->setRedirect('index.php?option=com_solidres&view=customers'); }
/** * Method to publish records. * * @return void * * @since 3.0 */ public function publish() { $client = JFactory::getApplication()->input->get('client', '', 'STRING'); $cid = JFactory::getApplication()->input->get('cid', array(), 'array'); $data = array('publish' => 1, 'unpublish' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); // Get some variables from the request if (empty($cid)) { JLog::add(JText::_('COM_TJFIELDS_NO_REGION_SELECTED'), JLog::WARNING, 'jerror'); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers JArrayHelper::toInteger($cid); // Publish the items. try { $model->publish($cid, $value); if ($value === 1) { $ntext = 'COM_TJFIELDS_N_REGIONS_PUBLISHED'; } elseif ($value === 0) { $ntext = 'COM_TJFIELDS_N_REGIONS_UNPUBLISHED'; } $this->setMessage(JText::plural($ntext, count($cid))); } catch (Exception $e) { $this->setMessage($e->getMessage(), 'error'); } } $this->setRedirect('index.php?option=com_tjfields&view=regions&client=' . $client); }
/** * Method to run this controller. * * @throws \InvalidArgumentException * @return mixed */ protected function doExecute() { if (empty($this->cid)) { throw new \InvalidArgumentException(\JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'), 500); } $pks = $this->cid; foreach ($pks as $i => $pk) { $this->table->reset(); if (!$this->table->load($pk)) { continue; } $data = $this->table->getProperties(true); if (!$this->allowEdit($data)) { $this->setMessage(\JText::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED')); continue; } try { $this->table->checkIn($pk); } catch (\Exception $e) { $this->setMessage($this->table->getError()); } } $message = \JText::plural($this->textPrefix . '_N_ITEMS_CHECKED_IN', count($pks)); $this->redirectToList($message); return true; }
public function import() { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); // Get items to import from the request. $cid = JRequest::getVar('cid', array(), '', 'array'); $data = JRequest::getVar('import', array(), '', 'array'); if (empty($cid)) { JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers JArrayHelper::toInteger($cid); // Import the items. if (!$model->import($cid, $data)) { JError::raiseWarning(500, $model->getError()); } else { $ntext = $this->text_prefix . '_N_ITEMS_IMPORTED'; $this->setMessage(JText::plural($ntext, count($cid))); } } $extension = JRequest::getCmd('extension'); $extensionURL = $extension ? '&extension=' . JRequest::getCmd('extension') : ''; $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $extensionURL, false)); }
public function cartable() { $cid = JFactory::getApplication()->input->get('cid', array(), 'array'); $data = array('cartable' => 1, 'notcartable' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); if (!is_array($cid) || count($cid) < 1) { JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror'); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers jimport('joomla.utilities.arrayhelper'); JArrayHelper::toInteger($cid); // Remove the items. if ($model->cartable($cid, $value)) { if ($value == 1) { $ntext = $this->text_prefix . '_N_ITEMS_CARTABLE'; } else { $ntext = $this->text_prefix . '_N_ITEMS_NOTCARTABLE'; } $this->setMessage(JText::plural($ntext, count($cid))); } else { $this->setMessage($model->getError()); } } $this->setRedirect(JRoute::_('index.php?option=com_eventgallery&view=events', false)); }
public function create() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); /** @var $app JApplicationAdministrator */ // Get form data $pks = $app->input->post->get('cid', array(), 'array'); $model = $this->getModel("Profile", "SocialCommunityModel"); /** @var $model SocialCommunityModelProfile */ $redirectOptions = array("view" => $this->view_list); JArrayHelper::toInteger($pks); // Check for validation errors. if (empty($pks)) { $this->displayWarning(JText::_("COM_SOCIALCOMMUNITY_INVALID_ITEM"), $redirectOptions); return; } try { $pks = $model->filterProfiles($pks); if (!$pks) { $this->displayWarning(JText::_("COM_SOCIALCOMMUNITY_INVALID_ITEM"), $redirectOptions); return; } $model->create($pks); } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM')); } $this->displayMessage(JText::plural('COM_SOCIALCOMMUNITY_N_PROFILES_CREATED', count($pks)), $redirectOptions); }
/** * Method to remove a record. */ public function delete() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JInvalid_Token')); // Initialise variables. $user = JFactory::getUser(); $ids = JRequest::getVar('cid', array(), '', 'array'); if (!JFactory::getUser()->authorise('core.admin', $this->option)) { JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR')); jexit(); } elseif (empty($ids)) { JError::raiseWarning(500, JText::_('COM_USERS_NO_LEVELS_SELECTED')); } else { // Get the model. $model = $this->getModel(); JArrayHelper::toInteger($ids); // Remove the items. if (!$model->delete($ids)) { JError::raiseWarning(500, $model->getError()); } else { $this->setMessage(JText::plural('COM_USERS_N_LEVELS_DELETED', count($ids))); } } $this->setRedirect('index.php?option=com_users&view=levels'); }
public function delete() { JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN')); $cid = JFactory::getApplication()->input->get('id', array(), 'array'); if (!is_array($cid) || count($cid) < 1) { JError::raiseWarning(500, JText::_('COM_JUDIRECTORY_NO_ITEM_SELECTED')); $this->setRedirect($this->getReturnPage()); } else { $model = $this->getModel(); jimport('joomla.utilities.arrayhelper'); JArrayHelper::toInteger($cid); if ($model->delete($cid)) { $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); } else { $this->setMessage($model->getError()); } $isListingPublished = JUDirectoryFrontHelperListing::isListingPublished($cid[0]); if ($isListingPublished) { $mainCategoryId = JUDirectoryFrontHelperCategory::getMainCategoryId($cid[0]); $this->setRedirect(JRoute::_(JUDirectoryHelperRoute::getCategoryRoute($mainCategoryId), false)); } else { $this->setRedirect($this->getReturnPage()); } } }
public function toggleInList() { // Check for request forgeries JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); // Get items to publish from the request. $cid = JRequest::getVar('cid', array(), '', 'array'); $data = array('showInListView' => 1, 'hideFromListView' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); if (empty($cid)) { JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers JArrayHelper::toInteger($cid); // Publish the items. if (!$model->addToListView($cid, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1) { $ntext = $this->text_prefix . '_N_ITEMS_ADDED_TO_LIST_VIEW'; } else { $ntext = $this->text_prefix . '_N_ITEMS_REMOVED_FROM_LIST_VIEW'; } $this->setMessage(JText::plural($ntext, count($cid))); } } $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); }
/** * Enable auto-update. * * @throws Exception * @return void */ public function enableau() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $redirectOptions = array("view" => "urls"); $cid = $this->input->post->get("cid", array(), "array"); $cid = Joomla\Utilities\ArrayHelper::toInteger($cid); $data = array('enableau' => 1, 'disableau' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); if (empty($cid)) { $this->displayNotice(JText::_($this->text_prefix . '_ERROR_NO_ITEM_SELECTED'), $redirectOptions); return; } try { $model = $this->getModel(); $model->updateAutoupdate($cid, $value); } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_ITPMETA_ERROR_SYSTEM')); } if ($value == 1) { $msg = $this->text_prefix . '_N_ITEMS_AUTOUPDATE_ENABLED'; } else { $msg = $this->text_prefix . '_N_ITEMS_AUTOUPDATE_DISABLED'; } $this->displayMessage(JText::plural($msg, count($cid)), $redirectOptions); }
public function delete() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $cid = $app->input->get('cid', array(), 'array'); if (!is_array($cid) || count($cid) < 1) { JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers jimport('joomla.utilities.arrayhelper'); JArrayHelper::toInteger($cid); // Remove the items. if ($model->delete($cid)) { $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); } else { $this->setMessage($model->getError()); } } $vars = ''; $extension = $app->input->get('extension', ''); if ($extension) { $vars = '&extension=' . $extension; } $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $vars, false)); }
/** * Enable/Disable an extension (if supported). * * @since 1.6 */ public function publish() { // Check for request forgeries. JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $user = JFactory::getUser(); $ids = JRequest::getVar('cid', array(), '', 'array'); $values = array('publish' => 1, 'unpublish' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); if (empty($ids)) { JError::raiseWarning(500, JText::_('COM_INSTALLER_ERROR_NO_EXTENSIONS_SELECTED')); } else { // Get the model. $model = $this->getModel('manage'); // Change the state of the records. if (!$model->publish($ids, $value)) { JError::raiseWarning(500, implode('<br />', $model->getErrors())); } else { if ($value == 1) { $ntext = 'COM_INSTALLER_N_EXTENSIONS_PUBLISHED'; } else { if ($value == 0) { $ntext = 'COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED'; } } $this->setMessage(JText::plural($ntext, count($ids))); } } $this->setRedirect(JRoute::_('index.php?option=com_installer&view=manage', false)); }
public function create() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get form data $pks = $this->input->post->get('cid', array(), 'array'); $model = $this->getModel('Profile', 'GamificationModel'); /** @var $model GamificationModelProfile */ $pks = Joomla\Utilities\ArrayHelper::toInteger($pks); // Check for validation errors. if (!$pks) { $this->defaultLink .= '&view=' . $this->view_list; $this->setMessage(JText::_('COM_GAMIFICATION_INVALID_ITEM'), 'notice'); $this->setRedirect(JRoute::_($this->defaultLink, false)); return; } try { $pks = $model->filterProfiles($pks); if (!$pks) { $this->defaultLink .= '&view=' . $this->view_list; $this->setMessage(JText::_('COM_GAMIFICATION_INVALID_ITEM'), 'notice'); $this->setRedirect(JRoute::_($this->defaultLink, false)); return; } $model->create($pks); } catch (Exception $e) { JLog::add($e->getMessage(), JLog::ERROR, 'com_gamification'); throw new Exception(JText::_('COM_GAMIFICATION_ERROR_SYSTEM')); } $msg = JText::plural('COM_GAMIFICATION_N_PROFILES_CREATED', count(pks)); $link = $this->defaultLink . '&view=' . $this->view_list; $this->setRedirect(JRoute::_($link, false), $msg); }
/** * Method to remove a record. * * @return void * * @since 1.6 */ public function delete() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get the model. $model = $this->getModel(); // Load the filter state. $app = JFactory::getApplication(); $type = $app->getUserState($this->context . '.filter.type'); $model->setState('filter.type', $type); $begin = $app->getUserState($this->context . '.filter.begin'); $model->setState('filter.begin', $begin); $end = $app->getUserState($this->context . '.filter.end'); $model->setState('filter.end', $end); $categoryId = $app->getUserState($this->context . '.filter.category_id'); $model->setState('filter.category_id', $categoryId); $clientId = $app->getUserState($this->context . '.filter.client_id'); $model->setState('filter.client_id', $clientId); $model->setState('list.limit', 0); $model->setState('list.start', 0); $count = $model->getTotal(); // Remove the items. if (!$model->delete()) { JError::raiseWarning(500, $model->getError()); } else { $this->setMessage(JText::plural('COM_BANNERS_TRACKS_N_ITEMS_DELETED', $count)); } $this->setRedirect('index.php?option=com_banners&view=tracks'); }
/** * Stick items * * @return void * * @since 1.6 */ public function sticky_publish() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $ids = $this->input->get('cid', array(), 'array'); $values = array('sticky_publish' => 1, 'sticky_unpublish' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); if (empty($ids)) { JError::raiseWarning(500, JText::_('COM_BANNERS_NO_BANNERS_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Change the state of the records. if (!$model->stick($ids, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1) { $ntext = 'COM_BANNERS_N_BANNERS_STUCK'; } else { $ntext = 'COM_BANNERS_N_BANNERS_UNSTUCK'; } $this->setMessage(JText::plural($ntext, count($ids))); } } $this->setRedirect('index.php?option=com_banners&view=banners'); }
/** * Method to toggle the featured setting of a list of articles. * * @return void * * @since 1.6 */ public function featured() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $user = JFactory::getUser(); $ids = $this->input->get('cid', array(), 'array'); $values = array('featured' => 1, 'unfeatured' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); // Access checks. foreach ($ids as $i => $id) { $permissions = SibdietHelper::getUserPermissions(); if (!in_array('nutrients', $permissions) || !$user->authorise('core.edit.state', 'com_sibdiet.nutrient.' . (int) $id)) { // Prune items that you can't change. unset($ids[$i]); JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); } } if (empty($ids)) { JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Publish the items. if (!$model->featured($ids, $value)) { JError::raiseWarning(500, $model->getError()); } if ($value == 1) { $message = JText::plural('COM_SIBDIET_N_ITEMS_FEATURED', count($ids)); } else { $message = JText::plural('COM_SIBDIET_N_ITEMS_UNFEATURED', count($ids)); } } $this->setRedirect('index.php?option=com_sibdiet&view=nutrients', false, $message); }
public function read() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get items to publish from the request. $cid = $this->input->get('cid', array(), 'array'); $data = array('read' => 1, 'notread' => 0); $task = $this->getTask(); $value = ArrayHelper::getValue($data, $task, 0, 'int'); $redirectOptions = array("view" => "notifications"); // Make sure the item ids are integers ArrayHelper::toInteger($cid); if (empty($cid)) { $this->displayNotice(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), $redirectOptions); return; } try { $model = $this->getModel(); $model->read($cid, $value); } catch (RuntimeException $e) { $this->displayWarning($e->getMessage(), $redirectOptions); return; } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_GAMIFICATION_ERROR_SYSTEM')); } if ($value == 1) { $msg = $this->text_prefix . '_N_ITEMS_READ'; } else { $msg = $this->text_prefix . '_N_ITEMS_NOT_READ'; } $this->displayMessage(JText::plural($msg, count($cid)), $redirectOptions); }
public function delete() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $ids = $this->input->get('cid', array(), 'array'); if (!JFactory::getUser()->authorise('core.admin', $this->option)) { JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR')); jexit(); } elseif (empty($ids)) { JError::raiseWarning(500, JText::_('COM_HEARTCARE_NO_DEVICE_SELECTED')); } else { // Get the model. $model = $this->getModel(); JArrayHelper::toInteger($ids); // Remove the items. if (!$model->delete($ids)) { JError::raiseWarning(500, $model->getError()); } else { foreach ($ids as $id) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->delete($db->quoteName('#__comprofiler')); $query->where($db->quoteName('id') . ' = ' . (int) $id); $db->setQuery($query); $db->execute(); } $this->setMessage(JText::plural('COM_HEARTCARE_N_DEVICE_DELETED', count($ids))); } } $this->setRedirect('index.php?option=com_heartcare&view=users'); }
/** * Remove an item. * * @return void * * @since 1.6 */ public function delete() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $user = JFactory::getUser(); $app = JFactory::getApplication(); $cids = (array) $this->input->get('cid', array(), 'array'); if (count($cids) < 1) { $app->enqueueMessage(JText::_('COM_MENUS_NO_MENUS_SELECTED'), 'notice'); } else { // Access checks. foreach ($cids as $i => $id) { if (!$user->authorise('core.delete', 'com_menus.menu.' . (int) $id)) { // Prune items that you can't change. unset($cids[$i]); $app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), 'error'); } } if (count($cids) > 0) { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers $cids = ArrayHelper::toInteger($cids); // Remove the items. if (!$model->delete($cids)) { $this->setMessage($model->getError()); } else { $this->setMessage(JText::plural('COM_MENUS_N_MENUS_DELETED', count($cids))); } } } $this->setRedirect('index.php?option=com_menus&view=menus'); }
/** * Remove an item. * * @throws Exception * @return void * * @since 12.2 */ public function delete() { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); /* @var $app JApplicationAdministrator */ // Gets the data from the form $cid = $this->input->post->get('cid', array(), 'array'); $cid = Joomla\Utilities\ArrayHelper::toInteger($cid); $urlId = $app->getUserState("url.id"); $redirectData = array("view" => "url", "layout" => "edit", "id" => $urlId); if (!$cid) { $this->displayWarning(JText::_("COM_ITPMETA_ERROR_INVALID_ITEMS"), $redirectData); return; } try { $model = $this->getModel(); $model->delete($cid); } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_ITPMETA_ERROR_SYSTEM')); } $msg = JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)); $this->displayMessage($msg, $redirectData); }
public function inWords($past, $now = "now") { date_default_timezone_set($this->timezone); $past = strtotime($past); $now = strtotime($now); $timeAgo = ""; $timeDifference = $now - $past; if ($timeDifference <= 29) { $timeAgo = JText::_("COM_JUDIRECTORY_LESS_THAN_A_MINUTE"); } else { if ($timeDifference > 29 && $timeDifference <= 89) { $timeAgo = JText::plural("COM_JUDIRECTORY_MINUTE", 1); } else { if ($timeDifference > 89 && $timeDifference <= $this->secondsPerMinute * 44 + 29) { $minutes = floor($timeDifference / $this->secondsPerMinute); $timeAgo = JText::plural("COM_JUDIRECTORY_MINUTE", $minutes); } else { if ($timeDifference > $this->secondsPerMinute * 44 + 29 && $timeDifference < $this->secondsPerMinute * 89 + 29) { $timeAgo = JText::plural("COM_JUDIRECTORY_HOUR", 1); } else { if ($timeDifference > $this->secondsPerMinute * 89 + 29 && $timeDifference <= $this->secondsPerHour * 23 + $this->secondsPerMinute * 59 + 29) { $hours = floor($timeDifference / $this->secondsPerHour); $timeAgo = JText::plural("COM_JUDIRECTORY_HOUR", $hours); } else { if ($timeDifference > $this->secondsPerHour * 23 + $this->secondsPerMinute * 59 + 29 && $timeDifference <= $this->secondsPerHour * 47 + $this->secondsPerMinute * 59 + 29) { $timeAgo = JText::plural("COM_JUDIRECTORY_DAY", 1); } else { if ($timeDifference > $this->secondsPerHour * 47 + $this->secondsPerMinute * 59 + 29 && $timeDifference <= $this->secondsPerDay * 29 + $this->secondsPerHour * 23 + $this->secondsPerMinute * 59 + 29) { $days = floor($timeDifference / $this->secondsPerDay); $timeAgo = JText::plural("COM_JUDIRECTORY_DAY", $days); } else { if ($timeDifference > $this->secondsPerDay * 29 + $this->secondsPerHour * 23 + $this->secondsPerMinute * 59 + 29 && $timeDifference <= $this->secondsPerDay * 59 + $this->secondsPerHour * 23 + $this->secondsPerMinute * 59 + 29) { $timeAgo = JText::plural("COM_JUDIRECTORY_MONTH", 1); } else { if ($timeDifference > $this->secondsPerDay * 59 + $this->secondsPerHour * 23 + $this->secondsPerMinute * 59 + 29 && $timeDifference < $this->secondsPerYear) { $months = round($timeDifference / $this->secondsPerMonth); if ($months == 1) { $months = 2; } $timeAgo = JText::plural("COM_JUDIRECTORY_MONTH", $months); } else { if ($timeDifference >= $this->secondsPerYear && $timeDifference < $this->secondsPerYear * 2) { $timeAgo = JText::plural("COM_JUDIRECTORY_YEAR", 1); } else { $years = floor($timeDifference / $this->secondsPerYear); $timeAgo = JText::plural("COM_JUDIRECTORY_YEAR", $years); } } } } } } } } } } $timeAgo .= " " . JText::_("COM_JUDIRECTORY_AGO"); return $timeAgo; }
public function duplicate() { $pks = $this->input->getVar('cid', array(), 'post', 'array'); $model = $this->getModel(); $model->duplicate($pks); $this->setMessage(JText::plural('FORM_DUPLICATED', count($pks))); $this->setRedirect('index.php?option=com_baforms&view=forms'); }