/** * 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'); }
/** * Logic to save */ function save() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // Get the model $model = $this->getModel('groups'); // Save $result = $model->save(); $cid = $model->getId(); $tabposition = JRequest::getInt('tabposition', 0); $task = JRequest::getCmd('task'); switch ($task) { case 'apply': $link = 'index.php?option=com_rsticketspro&controller=groups&task=edit&cid=' . $cid . '&tabposition=' . $tabposition; if ($result) { $this->setRedirect($link, JText::_('RST_GROUP_SAVED_OK')); } else { $this->setRedirect($link, JText::_('RST_GROUP_SAVED_ERROR')); } break; case 'save': $link = 'index.php?option=com_rsticketspro&view=groups'; if ($result) { $this->setRedirect($link, JText::_('RST_GROUP_SAVED_OK')); } else { $this->setRedirect($link, JText::_('RST_GROUP_SAVED_ERROR')); } break; } }
/** * Returns a session storage handler object, only creating it if it doesn't already exist. * * @param name $name The session store to instantiate * @param array $options Array of options * * @return JSessionStorage * * @since 11.1 */ public static function getInstance($name = 'none', $options = array()) { static $instances; if (!isset($instances)) { $instances = array(); } $name = strtolower(JFilterInput::getInstance()->clean($name, 'word')); if (empty($instances[$name])) { $class = 'JSessionStorage' . ucfirst($name); if (!class_exists($class)) { $path = dirname(__FILE__) . '/storage/' . $name . '.php'; if (file_exists($path)) { require_once $path; } else { // No call to JError::raiseError here, as it tries to close the non-existing session jexit('Unable to load session storage class: ' . $name); } } $instances[$name] = new $class($options); } return $instances[$name]; }
/** * 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'); }
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); }
function sendEmail() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $post = JRequest::get('post'); $this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models'); $model = $this->getModel('location'); $location = $model->getData(); $contact_name = $post['contact_name']; $contact_email = $post['contact_email']; $contact_message = $post['contact_message']; if ($contact_name == null || $contact_message == null) { echo JText::_('Please enter a name and message to send.'); return false; } else { if (false) { return false; } else { JUtility::sendMail($contact_email, $contact_name, $location->email, 'Contact Message for: ' . $location->name, $contact_message, 0, null, null, null, $contact_email, $contact_name); echo JText::_('Message Sent'); return true; } } return false; }
public function save() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // init vars $post = YRequest::get('post'); try { // bind post $this->application->bind($post, array('params')); // set params $params = $this->application->getParams()->remove('global.')->set('group', @$post['group'])->set('template', @$post['template'])->set('global.config.', @$post['params']['config'])->set('global.template.', @$post['params']['template']); if (isset($post['addons']) && is_array($post['addons'])) { foreach ($post['addons'] as $addon => $value) { $params->set("global.{$addon}.", $value); } } $this->application->params = $params->toString(); // save application YTable::getInstance('application')->save($this->application); // set redirect $msg = JText::_('Application Saved'); $link = $this->link_base . '&changeapp=' . $this->application->id; } catch (YException $e) { // raise notice on exception JError::raiseNotice(0, JText::_('Error Saving Application') . ' (' . $e . ')'); // set redirect $msg = null; $link = $this->baseurl . '&task=add'; } $this->setRedirect($link, $msg); }
function emailFriend() { JRequest::checkToken() or jexit('Invalid Token'); require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_member.php'; $app = JFactory::getApplication(); if (JobBoardHelper::verifyHumans()) { if (!JobBoardMemberHelper::matchHumanCode(JRequest::getString('human_ver', ''))) { $post = JArrayHelper::toObject(JRequest::get('post')); $post->errors = 1; if (isset($post->human_ver)) { unset($post->human_ver); } $app->setUserState('com_jobboard.sfields', $post); $app->redirect(JRoute::_('index.php?option=com_jobboard&view=share&errors=1&job_id=' . $post->job_id . '&Itemid=' . JRequest::getInt('Itemid')), JText::_('COM_JOBBOARD_FORM_CAPTCHA_FAILMSG'), 'error'); return; } } $message = new JObject(); $message->job_id = JRequest::getVar('job_id', '', '', 'int'); $catid = JRequest::getVar('catid', '', '', 'int'); $message->job_title = JRequest::getVar('job_title', '', '', 'string'); $message->job_city = JRequest::getVar('job_city', '', '', 'string'); $message->personal_message = JRequest::getVar('personal_message', '', '', 'string'); $uri =& JURI::getInstance(); $message->link = $uri->getScheme() . '://' . $uri->getHost() . JRequest::getVar('job_path', '', '', 'string'); $fields_valid = $this->validateFields(); $message->sender_email = $fields_valid->sender_email; $message->sender_name = $fields_valid->sender_name; $message->rec_emails = $fields_valid->rec_emails; if ($fields_valid->errors === true) { $errmsg = $fields_valid->errmsg . '</ul>'; $app->setUserState('sfields', $message); $link = JRoute::_('index.php?option=com_jobboard&view=share&errors=1&job_id=' . $message->job_id . '&Itemid=' . $itemid); $this->setRedirect($link, $errmsg, ''); return; } else { if (stristr($message->rec_emails, ',') === TRUE) { $rec_emailarray = explode(',', $message->rec_emails); foreach ($rec_emailarray as $email_recipient) { $this->sendEmail($message, trim($email_recipient)); } } else { $this->sendEmail($message, trim($message->rec_emails)); } $mesgModel =& $this->getModel('Message'); $saved = $mesgModel->saveMessage($message); if ($saved) { $msg = ' ' . JText::_('SEND_MSG_SUCCESS'); $link = JRoute::_('index.php?option=com_jobboard&view=job&id=' . $message->job_id, false); $this->setRedirect($link, $msg, ''); return; } else { $msg = ' ' . JText::_('ERR_WAIT'); $link = JRoute::_('index.php?option=com_jobboard&view=job&id=' . $message->job_id, false); $this->setRedirect($link, $msg, ''); return; } } parent::display(); }
public function help() { $user = JFactory::getUser(); $jinput = JFactory::getApplication()->input; // Check Token! $token = JSession::getFormToken(); $call_token = $jinput->get('token', 0, 'ALNUM'); if ($user->id != 0 && $token == $call_token) { $task = $this->getTask(); switch ($task) { case 'getText': try { $idValue = $jinput->get('id', 0, 'INT'); if ($idValue) { $result = $this->getHelpDocumentText($idValue); } else { $result = ''; } echo $result; // stop execution gracefully jexit(); } catch (Exception $e) { // stop execution gracefully jexit(); } break; } } else { // stop execution gracefully jexit(); } }
public function makemainurl() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // find and store edited item id $cid = JRequest::getVar('cid', array(0), 'default', 'array'); // check invalid data if (!is_array($cid) || count($cid) != 1 || intval($cid[0]) == 0) { $redirect = array('c' => "duplicates", 'tmpl' => 'component', 'cid[]' => JRequest::getInt('mainurl_id')); $this->setRedirect($this->_getDefaultRedirect($redirect), JText16::_('COM_SH404SEF_SELECT_ONE_URL'), 'error'); // send back response through default view $this->display(); } // now make that url the main url // while also setting the previous // with this url current rank // get the model to do it, actually // Get/Create the model if ($model =& $this->getModel($this->_defaultModel, 'Sh404sefModel')) { // store initial context in model $model->setContext($this->_context); // call the delete method on our list $model->makeMainUrl(intval($cid[0])); // check errors and enqueue them for display if any $errors = $model->getErrors(); if (!empty($errors)) { $this > enqueuemessages($errors, 'error'); } } // send back response through default view $this->display(); }
/** * 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'); }
/** * Display method * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ function display($tpl = null) { $document = JFactory::getDocument(); $document->setMimeEncoding('application/json'); $showcaseID = JRequest::getVar('showcase_id'); $objJSNShowcase = JSNISFactory::getObj('classes.jsn_is_showcase'); $objShowcaseTheme = JSNISFactory::getObj('classes.jsn_is_showcasetheme'); $themeProfile = $objShowcaseTheme->getThemeProfile($showcaseID); if ($showcaseID > 0 && !is_null($themeProfile)) { $showcaseData = $objJSNShowcase->getShowcaseByID($showcaseID); } elseif ($showcaseID > 0 && is_null($themeProfile)) { $theme = JRequest::getVar('theme'); $showcaseTable = JTable::getInstance('showcase', 'Table'); $showcaseTable->showcase_id = $showcaseID; $showcaseTable->theme_name = $theme; $showcaseData = $showcaseTable; } else { $theme = JRequest::getVar('theme'); $showcaseTable = JTable::getInstance('showcase', 'Table'); $showcaseTable->showcase_id = 0; $showcaseTable->theme_name = $theme; $showcaseData = $showcaseTable; } $objJSNUtils = JSNISFactory::getObj('classes.jsn_is_utils'); $URL = dirname($objJSNUtils->overrideURL()) . '/'; $dataObj = $objJSNShowcase->getShowcase2JSON($showcaseData, $URL); echo json_encode($dataObj); jexit(); }
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); }
function apply() { JRequest::checkToken() or jexit('Invalid Token'); $applicant = JRequest::get('POST'); jimport('joomla.utilities.date'); $now = new JDate(); if ($applicant['job_id'] != 0) { $unsol_id = $applicant['id']; $applicant['id'] = false; $applicant['request_date'] = $now->toMySQL(); $record =& JTable::getInstance('Applicant', 'Table'); if (!$record->save($applicant)) { // uh oh failed to save JError::raiseError('500', JTable::getError()); } $unsol =& JTable::getInstance('Unsolicited', 'Table'); if (!$unsol->delete($unsol_id)) { // uh oh failed to delete JError::raiseError('500', JTable::getError()); } $this->extendApply($applicant); } else { $applicant['last_updated'] = $now->toMySQL(); $unsol_record =& JTable::getInstance('Unsolicited', 'Table'); if (!$unsol_record->save($applicant)) { // uh oh failed to save JError::raiseError('500', JTable::getError()); } $this->extendApply($applicant); } }
public function display($cachable = false, $urlparams = false) { header('Content-type: text/html; charset=ISO-8859-1'); $params = JComponentHelper::getParams('com_jak2filter'); $indexing = (int) $params->get('indexing_cron', 1); $interval = (int) $params->get('indexing_interval', 900); $interval = $interval * 60; $cronkey = $params->get('indexing_cron_key', 'indexing'); if (!$indexing) { return; } $db = JFactory::getDbo(); $query = "SELECT updatetime FROM #__jak2filter WHERE `name` = 'cron'"; $db->setQuery($query); $updatetime = $db->loadResult(); $updatetime = !$updatetime ? 0 : strtotime($updatetime); $key = JRequest::getVar('jakey'); $run = $updatetime + $interval < time() || $key == $cronkey; if ($run) { $now = date('Y-m-d H:i:s'); $query = "\n\t\t\t\t\tINSERT INTO #__jak2filter\n\t\t\t\t\tSET \n\t\t\t\t\t\t`name` = 'cron',\n\t\t\t\t\t\t`updatetime` = " . $db->quote($now) . ",\n\t\t\t\t\t\t`value` = 1\n\t\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t\t\t`updatetime` = " . $db->quote($now) . ",\n\t\t\t\t\t\t`value` = 1\n\t\t\t\t\t"; $db->setQuery($query); $db->query(); // $helper = new JAK2FilterHelper(); $helper->indexingData('cron'); } else { $msg = JText::sprintf('The cron job will be run on %s', date('Y-m-d H:i:s', $updatetime + $interval)); jexit($msg); } }
/** * Method to change the state of a list of records. */ 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, 'trash' => -2); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); if (empty($ids)) { JError::raiseWarning(500, JText::_('JError_No_items_selected')); } else { // Get the model. $model = $this->getModel(); // Change the state of the records. if (!$model->publish($ids, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1) { $text = 'JSuccess_N_Items_published'; } else { if ($value == 0) { $text = 'JSuccess_N_Items_unpublished'; } else { $text = 'JSuccess_N_Items_trashed'; } } $this->setMessage(JText::sprintf($text, count($ids))); } } $this->setRedirect('index.php?option=com_messages&view=messages'); }
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)); }
public function save() { JRequest::checkToken('request') or jexit('Invalid Token'); $mainframe = JFactory::getApplication(); $post = JRequest::get('post'); $ids = isset($post['id']) ? $post['id'] : ''; $starts = isset($post['start']) ? $post['start'] : ''; $ends = isset($post['end']) ? $post['end'] : ''; $titles = isset($post['title']) ? $post['title'] : ''; $removal = isset($post['itemRemove']) ? $post['itemRemove'] : ''; $model = DiscussHelper::getModel('Ranks', true); if (!empty($removal)) { $rids = explode(',', $removal); $model->removeRanks($rids); } if (!empty($ids)) { if (count($ids) > 0) { for ($i = 0; $i < count($ids); $i++) { $data = array(); $data['id'] = $ids[$i]; $data['start'] = $starts[$i]; $data['end'] = $ends[$i]; $data['title'] = $titles[$i]; $ranks = DiscussHelper::getTable('Ranks'); $ranks->bind($data); $ranks->store(); } } //end if } //end if $message = JText::_('COM_EASYDISCUSS_RANKING_SUCCESSFULLY_UPDATED'); DiscussHelper::setMessageQueue($message, DISCUSS_QUEUE_SUCCESS); $mainframe->redirect('index.php?option=com_easydiscuss&view=ranks'); }
function display($tpl = null) { global $mainframe, $option; jimport('joomla.utilities.simplexml'); $showCaseID = JRequest::getInt('showcase_id', 0); if ($showCaseID == 0) { $menu =& JSite::getMenu(); $item = $menu->getActive(); $params =& $menu->getParams($item->id); $showcase_id = $params->get('showcase_id', 0); } else { $showcase_id = $showCaseID; } $objUtils = JSNISFactory::getObj('classes.jsn_is_utils'); $URL = $objUtils->overrideURL(); $objJSNShowcase = JSNISFactory::getObj('classes.jsn_is_showcase'); $row = $objJSNShowcase->getShowCaseByID($showcase_id); if (count($row) <= 0) { header("HTTP/1.0 404 Not Found"); exit; } $objJSNJSON = JSNISFactory::getObj('classes.jsn_is_json'); $dataObj = $objJSNShowcase->getShowcase2JSON($row, $URL); echo $objJSNJSON->encode($dataObj); jexit(); }
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 a record (and redirect to main page) * @return void */ function save() { JRequest::checkToken() or jexit('Invalid Token'); $post = JRequest::get('post'); $task = JRequest::getVar('task'); $model =& $this->getModel('hotellinkedit'); if ($model->store($post)) { switch ($task) { case 'apply': $link = 'index.php?option=com_hotelguide&view=hotellinkedit&cid[]=' . (int) $model->get('id'); break; case 'saveandnew': $link = 'index.php?option=com_hotelguide&view=hotellinkedit'; break; default: $link = 'index.php?option=com_hotelguide&view=hotellinks'; break; } $msg = JText::_('HG_LINK_SAVED'); } else { $link = 'index.php?option=com_hotelguide&view=hotellinks'; $msg = JText::_('HG_ERROR_SAVING_LINK'); } $this->setRedirect($link, $msg); }
/** * Save the configuration */ function save() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $component = JRequest::getCmd('component'); $table =& JTable::getInstance('component'); if (!$table->loadByOption($component)) { JError::raiseWarning(500, 'Not a valid component'); return false; } $post = JRequest::get('post'); $post['option'] = $component; $table->bind($post); // pre-save checks if (!$table->check()) { JError::raiseWarning(500, $table->getError()); return false; } // save the changes if (!$table->store()) { JError::raiseWarning(500, $table->getError()); return false; } //$this->setRedirect( 'index.php?option=com_config', $msg ); $this->edit(); }
/** * 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); }
/** * 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 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); }
/** * Handle the save task * * @author RickG */ function save($data = 0){ JRequest::checkToken() or jexit( 'Invalid Token' ); $model = VmModel::getModel('config'); $data = JRequest::get('post'); $data['offline_message'] = JRequest::getVar('offline_message','','post','STRING',JREQUEST_ALLOWHTML); if(strpos($data['offline_message'],'|')!==false){ $data['offline_message'] = str_replace('|','',$data['offline_message']); } if ($model->store($data)) { $msg = JText::_('COM_VIRTUEMART_CONFIG_SAVED'); // Load the newly saved values into the session. VmConfig::loadConfig(); } else { $msg = $model->getError(); } $redir = 'index.php?option=com_virtuemart'; if(JRequest::getCmd('task') == 'apply'){ $redir = $this->redirectPath; } $this->setRedirect($redir, $msg); }
/** * 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; } }
/** * 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'); }
/** * 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'); }
/** * Get the requested event * This comes from the URL parameters ?type=<type>&id=<id>, * or from the URL extension /<type>-<id> */ public function getEvent() { $input = JFactory::getApplication()->input; if ($input->get("type") && $input->get("id")) { $type = strtolower($input->get("type")); $id = (int) $input->get("id"); switch ($type) { case "walk": $factory = SWG::walkInstanceFactory(); break; case "social": $factory = SWG::socialFactory(); break; case "weekend": $factory = SWG::weekendFactory(); break; default: jexit("Invalid event type"); } $factory->includeAttendedBy = true; $factory->includeAttendees = true; $event = $factory->getSingle($id); if ($event == null) { jexit("Invalid event"); } return $event; } else { jexit("TODO: Redirect"); } }