/** * Method to toggle the featured setting of a list of articles. * * @return void * @since 1.6 */ function featured() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $user = JFactory::getUser(); $ids = JRequest::getVar('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) { if (!$user->authorise('core.edit.state', 'com_content.article.' . (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()); } } $this->setRedirect('index.php?option=com_content&view=articles'); }
/** * Task to switch the administrator language. * * @return void */ public function switchAdminLanguage() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $cid = $this->input->get('cid', ''); $model = $this->getModel('installed'); // Fetching the language name from the xx-XX.xml $file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/' . $cid . '.xml'; $info = JInstaller::parseXMLInstallFile($file); $languageName = $info['name']; if ($model->switchAdminLanguage($cid)) { // Switching to the new language for the message $language = JFactory::getLanguage(); $newLang = JLanguage::getInstance($cid); JFactory::$language = $newLang; JFactory::getApplication()->loadLanguage($language = $newLang); $newLang->load('com_languages', JPATH_ADMINISTRATOR); $msg = JText::sprintf('COM_LANGUAGES_MSG_SWITCH_ADMIN_LANGUAGE_SUCCESS', $languageName); $type = 'message'; } else { $msg = $model->getError(); $type = 'error'; } $this->setRedirect('index.php?option=com_languages&view=installed', $msg, $type); }
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)); }
public function importData() { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); // check if import is allowed for this user. $user = JFactory::getUser(); if ($user->authorise('help_document.import', 'com_costbenefitprojection') && $user->authorise('core.import', 'com_costbenefitprojection')) { // Get the import model $model = $this->getModel('Help_documents'); // get the headers to import $headers = $model->getExImPortHeaders(); if (CostbenefitprojectionHelper::checkObject($headers)) { // Load headers to session. $session = JFactory::getSession(); $headers = json_encode($headers); $session->set('help_document_VDM_IMPORTHEADERS', $headers); $session->set('backto_VDM_IMPORT', 'help_documents'); $session->set('dataType_VDM_IMPORTINTO', 'help_document'); // Redirect to import view. $message = JText::_('COM_COSTBENEFITPROJECTION_IMPORT_SELECT_FILE_FOR_HELP_DOCUMENTS'); $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=import', false), $message); return; } } // Redirect to the list screen with error. $message = JText::_('COM_COSTBENEFITPROJECTION_IMPORT_FAILED'); $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=help_documents', false), $message, 'error'); return; }
/** * Method to toggle the featured setting of a list of teamids. * * @return void * */ public function featured() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $user = JFactory::getUser(); $ids = $this->input->getVar('cid', array(), 'array'); $values = array('featured' => 1, 'unfeatured' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); // Get the model. $model = $this->getModel(); // Access checks. foreach ($ids as $i => $id) { $item = $model->getItem($id); if (!$user->authorise('core.edit.state', 'com_knvbapi2.teamid.' . $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::_('COM_KNVBAPI2_TEAMIDS_NO_ITEM_SELECTED')); } else { // Publish the items. if (!$model->featured($ids, $value)) { JError::raiseWarning(500, $model->getError()); } if ($value == 1) { $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_FEATURED', count($ids)); } else { $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_UNFEATURED', count($ids)); } } $this->setRedirect(JRoute::_('index.php?option=com_knvbapi2&view=teamids', false), $message); }
/** * 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); }
} else { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_languages' . DS . 'helpers' . DS . 'jsonresponse.php'; } /** * Content controller class. */ class J2XMLControllerCategories extends JControllerAbstract { function __construct($default = array()) { parent::__construct(); } public function display($cachable = false, $urlparams = false) { JRequest::setVar('view', 'categories'); parent::display($cachable, $urlparams); } function send() { if (!JSession::checkToken('request')) { // Check for a valid token. If invalid, send a 403 with the error message. JError::raiseWarning(403, JText::_('JINVALID_TOKEN')); echo version_compare(JPlatform::RELEASE, '12', 'ge') ? new JResponseJson() : new JJsonResponse(); return; } $cid = JRequest::getVar('cid', array(0), null, 'array'); $sid = JRequest::getVar('w_id', null, null, 'int');
/** * Execute the controller. * * @return void * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Check for request forgeries. JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Get array of selected languages $lids = $this->input->get('cid', array(), 'array'); JArrayHelper::toInteger($lids, array()); // Get the languages model. $model = new InstallationModelLanguages(); if (!$lids) { // No languages have been selected $app->enqueueMessage(JText::_('INSTL_LANGUAGES_NO_LANGUAGE_SELECTED'), 'warning'); } else { // Install selected languages $model->install($lids); // Publish the Content Languages. $model->publishContentLanguages(); $app->enqueueMessage(JText::_('INSTL_LANGUAGES_MORE_LANGUAGES'), 'notice'); } // Redirect to the page. $r = new stdClass(); $r->view = 'defaultlanguage'; $app->sendJsonResponse($r); }
/** * Return AJAX for the requested layout. * * @return string String in JSON or RAW. * * @throws RuntimeException * @throws KunenaExceptionAuthorise */ public function execute() { $format = $this->input->getWord('format', 'html'); $function = 'display' . ucfirst($format); if (!method_exists($this, $function)) { // Invalid page request. throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404); } // Run before executing action. $result = $this->before(); if ($result === false) { $content = new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404); } elseif (!JSession::checkToken()) { // Invalid access token. $content = new KunenaExceptionAuthorise(JText::_('COM_KUNENA_ERROR_TOKEN'), 403); } elseif ($this->config->board_offline && !$this->me->isAdmin()) { // Forum is offline. $content = new KunenaExceptionAuthorise(JText::_('COM_KUNENA_FORUM_IS_OFFLINE'), 503); } elseif ($this->config->regonly && !$this->me->exists()) { // Forum is for registered users only. $content = new KunenaExceptionAuthorise(JText::_('COM_KUNENA_LOGIN_NOTIFICATION'), 401); } else { $display = $this->input->getCmd('display', 'Undefined') . '/Display'; try { $content = KunenaRequest::factory($display, $this->input, $this->options)->setPrimary()->execute()->render(); } catch (Exception $e) { $content = $e; } } return $this->{$function}($content); }
public function save() { die('Save in projectposition controller'); // Check for request forgeries JSession::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN'); echo '<br /><pre>2' . print_r($post, true) . '~</pre><br />'; $post = JRequest::get('post'); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); $post['id'] = (int) $cid[0]; $model = $this->getModel('projectposition'); //if ($model->store($post)) if (1 == 2) { $msg = JText::_('COM_JOOMLEAGUE_ADMIN_P_POSITION_CTRL_TEAM_SAVED'); } else { $msg = JText::_('COM_JOOMLEAGUE_ADMIN_P_POSITION_CTRL_ERROR_SAVING_TEAM') . $model->getError(); } // Check the table in so it can be edited.... we are done with it anyway $model->checkin(); $task = $this->getTask(); if ($task == 'save') { $link = 'index.php?option=com_joomleague&view=projectposition&task=projectposition.display'; } else { $link = 'index.php?option=com_joomleague&task=projectposition.edit&cid[]=' . $post['id']; } //$this->setRedirect($link,$msg); }
/** * Method to toggle the featured setting of a list of contacts. * * @return void * * @since 1.6 */ public function featured() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $ids = $this->input->get('cid', array(), 'array'); $values = array('featured' => 1, 'unfeatured' => 0); $task = $this->getTask(); $value = ArrayHelper::getValue($values, $task, 0, 'int'); // Get the model. /** @var ContactModelContact $model */ $model = $this->getModel(); // Access checks. foreach ($ids as $i => $id) { $item = $model->getItem($id); if (!JFactory::getUser()->authorise('core.edit.state', 'com_contact.category.' . (int) $item->catid)) { // 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::_('COM_CONTACT_NO_ITEM_SELECTED')); } else { // Publish the items. if (!$model->featured($ids, $value)) { JError::raiseWarning(500, $model->getError()); } } $this->setRedirect('index.php?option=com_contact&view=contacts'); }
/** * Add funders to Acy Mailing list. * * @throws Exception */ public function addFunders() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); /** @var $app JApplicationAdministrator */ $response = new Prism\Response\Json(); $projectId = $this->input->post->getInt('acy_pid'); $listId = $this->input->post->getInt('acy_lid'); $model = $this->getModel(); $numberOfAdded = 0; try { $numberOfAdded = $model->addFundersToAcyList($projectId, $listId); } catch (Exception $e) { JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding'); $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'))->failure(); echo $response; $app->close(); } if (!$numberOfAdded) { $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_CANNOT_BE_ADDED_SUBSCRIBERS'))->failure(); } else { $response->setTitle(JText::_('COM_CROWDFUNDING_SUCCESS'))->setText(JText::sprintf('COM_CROWDFUNDING_ADDED_SUBSCRIBERS_D', $numberOfAdded))->success(); } echo $response; $app->close(); }
/** * Execute the controller. * * @return void * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Check for request forgeries. JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Get the setup model. $model = new InstallationModelSetup(); // Check the form $vars = $model->checkForm('database'); // Determine if the configuration file path is writable. $path = JPATH_CONFIGURATION . '/configuration.php'; $useftp = file_exists($path) ? !is_writable($path) : !is_writable(JPATH_CONFIGURATION . '/'); $r = new stdClass(); $r->view = $useftp ? 'ftp' : 'summary'; // Get the database model. $db = new InstallationModelDatabase(); // Attempt to initialise the database. $return = $db->createDatabase($vars); // Check if the database was initialised if (!$return) { $r->view = 'database'; } $app->sendJsonResponse($r); }
public function getStatistics() { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); // Get component parameters $params = JComponentHelper::getParams('com_isbnregistry'); // Get statistics file format $format = $params->get('statistics_format', 'XLS'); // Get form data $data = $this->input->post->get('jform', array(), 'array'); // Get begin $begin = $data['begin']; // Get end $end = $data['end']; // Get type $type = $data['type']; // Redirect if ($this->validateDate($begin) && $this->validateDate($end) && $this->validateType($type)) { $this->setRedirect('index.php?option=com_isbnregistry&view=statistic&format=' . strtolower($format) . '&begin=' . $begin . '&end=' . $end . '&type=' . $type); } else { if (!$this->validateType($type)) { $this->setMessage(JText::_('COM_ISBNREGISTRY_STATISTIC_INVALID_TYPE'), 'error'); } else { $this->setMessage(JText::_('COM_ISBNREGISTRY_STATISTIC_INVALID_DATE'), 'error'); } $this->setRedirect('index.php?option=com_isbnregistry&view=statistic&layout=popup&tmpl=component'); } $this->redirect(); }
/** * save a ad fields */ function save() { // Check for request forgeries JSession::checkToken() or jexit('Invalid Token'); $input = JFactory::getApplication()->input; $model = $this->getModel('settings'); $post = JRequest::get('post'); // allow name only to contain html $model->setState('request', $post); if ($model->store()) { $msg = JText::_('C_SAVE_M_S'); } else { $msg = JText::_('C_SAVE_M_NS'); } $task = $input->get('task', '', 'STRING'); switch ($task) { case 'cancel': $cancelmsg = JText::_('FIELD_CANCEL_MSG'); $this->setRedirect('index.php?option=com_socialads', $msg); break; case 'save': $this->setRedirect(JUri::base() . "index.php?option=com_socialads&view=settings", $msg); break; } }
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)); }
/** * Method to set the home property for a list of items * * @since 1.6 */ function setDefault() { // Check for request forgeries JSession::checkToken('request') or die(JText::_('JINVALID_TOKEN')); // Get items to publish from the request. $cid = JRequest::getVar('cid', array(), '', 'array'); $data = array('setDefault' => 1, 'unsetDefault' => 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->setHome($cid, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1) { $ntext = 'COM_MENUS_ITEMS_SET_HOME'; } else { $ntext = 'COM_MENUS_ITEMS_UNSET_HOME'; } $this->setMessage(JText::plural($ntext, count($cid))); } } $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); }
/** * 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'); }
public function save($key = null, $urlVar = null) { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $data = $this->input->post->get('jform', array(), 'array'); $itemId = Joomla\Utilities\ArrayHelper::getValue($data, "id"); $redirectOptions = array("task" => $this->getTask(), "id" => $itemId); $model = $this->getModel(); /** @var $model CrowdfundingModelComment */ $form = $model->getForm($data, false); /** @var $form JForm */ if (!$form) { throw new Exception(JText::_("COM_CROWDFUNDING_ERROR_FORM_CANNOT_BE_LOADED"), 500); } // Validate the form data $validData = $model->validate($form, $data); // Check for errors if ($validData === false) { $this->displayNotice($form->getErrors(), $redirectOptions); return; } try { $itemId = $model->save($validData); $redirectOptions["id"] = $itemId; } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM')); } $this->displayMessage(JText::_('COM_CROWDFUNDING_COMMENT_SAVED'), $redirectOptions); }
public function revert() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $pks = $app->input->post->get('cid', array(), 'array'); $pk = (int) count($pks) ? $pks[0] : 0; $type = $app->input->post->getString('element_type', 'type'); $model = $this->getModel(); $user = JFactory::getUser(); $res = $user->authorise('core.edit', CCK_COM) ? $model->revert($pk, $type) : false; if ($res) { if ($type == 'search') { $link = _C4_LINK; } elseif ($type == 'type') { $link = _C2_LINK; } $msg = JText::_('COM_CCK_SUCCESSFULLY_RESTORED'); $type = 'message'; } else { $link = _C6_LINK . '&filter_e_type=' . $type; $msg = JText::_('JERROR_AN_ERROR_HAS_OCCURRED'); $type = 'error'; } $this->setRedirect($link, $msg, $type); }
/** * Execute the controller. * * @return void * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Check for request forgeries. JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Get the setup model. $model = new InstallationModelSetup(); // Get the data $data = $app->input->post->get('jform', array(), 'array'); // Store the options in the session. $vars = $model->storeOptions($data); // Get the database model. $ftp = new InstallationModelFtp(); // Attempt to detect the Joomla root from the ftp account. $return = $ftp->verifyFtpSettings($vars); // Build the response object $r = new stdClass(); $r->view = 'ftp'; // If we got a FTP root, add it to the response object if ($return) { $r->valid = $return; } $app->sendJsonResponse($r); }
/** * Method to update members geoupdate location. * * @return void * * @since 1.7.0 */ public function geoupdate() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $user = JFactory::getUser(); $ids = $this->input->get('cid', [], 'array'); // Get the model. /** @var ChurchDirectoryModelGeoStatus $model */ $model = $this->getModel(); // Access checks. foreach ($ids as $i => $id) { $item = $model->getItem($id); if (!$user->authorise('core.edit.state', 'com_churchdirectory.category.' . (int) $item->catid)) { // Prune items that you can't change. unset($ids[$i]); $app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'notice'); } } if (empty($ids)) { $app->enqueueMessage(JText::_('COM_CHURCHDIRECTORY_NO_ITEM_SELECTED'), 'error'); } else { // Publish the items. if (!$model->update($ids)) { $app->enqueueMessage($model->getError(), 'error'); } } $this->setRedirect('index.php?option=com_churchdirectory&view=geostatus'); }
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); }
/** * Save an item */ public function save($key = null, $urlVar = null) { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); /** @var $app JApplicationAdministrator */ $data = $app->input->post->get('jform', array(), 'array'); $itemId = JArrayHelper::getValue($data, "id"); $redirectData = array("task" => $this->getTask(), "id" => $itemId); $model = $this->getModel(); /** @var $model SocialCommunityModelCountry */ $form = $model->getForm($data, false); /** @var $form JForm */ if (!$form) { throw new Exception(JText::_("COM_SOCIALCOMMUNITY_ERROR_FORM_CANNOT_BE_LOADED")); } // Validate the form $validData = $model->validate($form, $data); // Check for errors if ($validData === false) { $this->displayNotice($form->getErrors(), $redirectData); return; } try { $itemId = $model->save($validData); $redirectData["id"] = $itemId; } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM')); } $this->displayMessage(JText::_('COM_SOCIALCOMMUNITY_COUNTRY_SAVED'), $redirectData); }
/** * Method to toggle the featured setting of a list of memberss. * * @return void * * @since 1.7.0 */ public function featured() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $user = JFactory::getUser(); $app = JFactory::getApplication(); $ids = $app->input->get('id', [], 'array'); $task = $this->getTask(); $value = Joomla\Utilities\ArrayHelper::getValue($values, $task, 0, 'int'); // Get the model. $model = $this->getModel(); // Access checks. foreach ($ids as $i => $id) { if (!$user->authorise('core.edit.state')) { // Prune items that you can't change. unset($ids[$i]); $app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'notice'); } } if (empty($ids)) { $app->enqueueMessage(JText::_('COM_CHURCHDIRECTORY_NO_ITEM_SELECTED'), 'warning'); } else { // Publish the items. if (!$model->featured($ids, $value)) { $app->enqueueMessage($model->getError(), 'warning'); } } $this->setRedirect('index.php?option=com_churchdirectory&view=postions'); }
/** * 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'); }
/** * Method to request a username reminder. * * @return boolean * * @since 1.6 */ public function remind() { // Check the request token. JSession::checkToken('post') or jexit(JText::_('JINVALID_TOKEN')); $model = $this->getModel('Remind', 'UsersModel'); $data = $this->input->post->get('jform', array(), 'array'); // Submit the password reset request. $return = $model->processRemindRequest($data); // Check for a hard error. if ($return == false) { // The request failed. // Get the route to the next page. $itemid = UsersHelperRoute::getRemindRoute(); $itemid = $itemid !== null ? '&Itemid=' . $itemid : ''; $route = 'index.php?option=com_users&view=remind' . $itemid; // Go back to the request form. $message = JText::sprintf('Request failed: Your account is not activated yet or is under review. Please contact the admin more for details.', $model->getError()); $this->setRedirect(JRoute::_($route, false), $message, 'notice'); return false; } else { // The request succeeded. // Get the route to the next page. $itemid = UsersHelperRoute::getRemindRoute(); $itemid = $itemid !== null ? '&Itemid=' . $itemid : ''; $route = 'index.php?option=com_users&view=login' . $itemid; // Proceed to step two. $message = JText::_('COM_USERS_REMIND_REQUEST_SUCCESS'); $this->setRedirect(JRoute::_($route, false), $message); return true; } }
function copy() { if (!$this->isAllowed($this->aclCat, 'manage')) { return; } JRequest::checkToken() || JRequest::checkToken('get') || JSession::checkToken('get') || die('Invalid Token'); $cids = JRequest::getVar('cid', array(), '', 'array'); $db = JFactory::getDBO(); $time = time(); $my = JFactory::getUser(); $creatorId = intval($my->id); $addSendDate = ''; if (!empty($this->copySendDate)) { $addSendDate = ', `senddate`'; } foreach ($cids as $oneMailid) { $query = 'INSERT INTO `#__acymailing_mail` (`subject`, `body`, `altbody`, `published`' . $addSendDate . ', `created`, `fromname`, `fromemail`, `replyname`, `replyemail`, `type`, `visible`, `userid`, `alias`, `attach`, `html`, `tempid`, `key`, `frequency`, `params`,`filter`,`metakey`,`metadesc`)'; $query .= " SELECT CONCAT('copy_',`subject`), `body`, `altbody`, 0" . $addSendDate . ", '.{$time}.', `fromname`, `fromemail`, `replyname`, `replyemail`, `type`, `visible`, '.{$creatorId}.', `alias`, `attach`, `html`, `tempid`, " . $db->Quote(acymailing_generateKey(8)) . ', `frequency`, `params`,`filter`,`metakey`,`metadesc` FROM `#__acymailing_mail` WHERE `mailid` = ' . (int) $oneMailid; $db->setQuery($query); $db->query(); $newMailid = $db->insertid(); $db->setQuery('INSERT IGNORE INTO `#__acymailing_listmail` (`listid`,`mailid`) SELECT `listid`,' . $newMailid . ' FROM `#__acymailing_listmail` WHERE `mailid` = ' . (int) $oneMailid); $db->query(); } return $this->listing(); }
/** * Removes an item. * * @return void * * @since 1.6 */ public function delete() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $user = JFactory::getUser(); $ids = $this->input->get('cid', array(), 'array'); // Access checks. foreach ($ids as $i => $id) { if (!$user->authorise('core.delete', 'com_content.article.' . (int) $id)) { // Prune items that you can't delete. unset($ids[$i]); JError::raiseNotice(403, JText::_('JERROR_CORE_DELETE_NOT_PERMITTED')); } } if (empty($ids)) { JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Remove the items. if (!$model->featured($ids, 0)) { JError::raiseWarning(500, $model->getError()); } } $this->setRedirect('index.php?option=com_content&view=featured'); }
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); }