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)); }
/** * Logs with an arbitrary level. * * @param mixed $level The log level. * @param string $message The log message. * @param array $context Additional message context. * * @return null * * @since 4.0 * @throws InvalidArgumentException */ public function log($level, $message, array $context = array()) { // Make sure the log level is valid if (!array_key_exists($level, $this->priorityMap)) { throw new InvalidArgumentException('An invalid log level has been given.'); } // Map the level to Joomla's priority $priority = $this->priorityMap[$level]; $category = null; $date = null; // If a message category is given, map it if (!empty($context['category'])) { $category = $context['category']; } // If a message timestamp is given, map it if (!empty($context['date'])) { $date = $context['date']; } // Joomla's logging API will only process a string or a JLogEntry object, if $message is an object without __toString() we can't use it if (!is_string($message) && !$message instanceof \JLogEntry) { if (!is_object($message) || !method_exists($message, '__toString')) { throw new InvalidArgumentException('The message must be a string, a JLogEntry object, or an object implementing the __toString() method.'); } $message = (string) $message; } $this->logger->add($message, $priority, $category, $date, $context); }
/** * Logs an entry * * @param array|string $entry * @see JLog::addEntry options * @return mixed */ public function log($entry, $level = LOG_LEVEL_INFO) { if (!is_array($entry)) { $entry = array('comment' => $entry, 'level' => $level); } $this->_log->addEntry($entry); return $this; }
/** * Fetch a filelist element * * @param string $name Element name * @param string $value Element value * @param JXMLElement &$node JXMLElement node object containing the settings for the element * @param string $control_name Control name * * @return string * * @deprecated 12.1 Use JFormFieldFileList::getOptions instead * @since 11.1 */ public function fetchElement($name, $value, &$node, $control_name) { // Deprecation warning. JLog::add('JElementFileList::fetchElement() is deprecated.', JLog::WARNING, 'deprecated'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); // path to images directory $path = JPATH_ROOT . '/' . $node->attributes('directory'); $filter = $node->attributes('filter'); $exclude = $node->attributes('exclude'); $stripExt = $node->attributes('stripext'); $files = JFolder::files($path, $filter); $options = array(); if (!$node->attributes('hide_none')) { $options[] = JHtml::_('select.option', '-1', JText::_('JOPTION_DO_NOT_USE')); } if (!$node->attributes('hide_default')) { $options[] = JHtml::_('select.option', '', JText::_('JOPTION_USE_DEFAULT')); } if (is_array($files)) { foreach ($files as $file) { if ($exclude) { if (preg_match(chr(1) . $exclude . chr(1), $file)) { continue; } } if ($stripExt) { $file = JFile::stripExt($file); } $options[] = JHtml::_('select.option', $file, $file); } } return JHtml::_('select.genericlist', $options, $control_name . '[' . $name . ']', array('id' => 'param' . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }
public function publish() { // Check for request forgeries JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); // Get items to publish from the request. $id = JFactory::getApplication()->input->getInt('id', 0); $data = array('publish' => 1, 'unpublish' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); if (!$id) { JLog::add(JText::_('COM_DJCATALOG2_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror'); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers $cid = array($id); JArrayHelper::toInteger($cid); // Publish the items. if (!$model->publish($cid, $value)) { JLog::add($model->getError(), JLog::WARNING, 'jerror'); } else { if ($value == 1) { $ntext = 'COM_DJCATALOG2_ITEM_PUBLISHED'; } else { $ntext = 'COM_DJCATALOG2_ITEM_UNPUBLISHED'; } $this->setMessage(JText::_($ntext)); } } $this->setRedirect(JRoute::_(DJCatalogHelperRoute::getMyItemsRoute(), false)); }
/** * Constructor * * @param mixed $response The Response data. * @param string $message The main response message. * @param boolean $error True, if the success flag shall be set to false, defaults to false. * * @since 2.5 * @deprecated 4.0 Use JResponseJson instead. */ public function __construct($response = null, $message = null, $error = false) { JLog::add('Class JJsonResponse is deprecated. Use class JResponseJson instead.', JLog::WARNING, 'deprecated'); $this->message = $message; // Get the message queue. $messages = JFactory::getApplication()->getMessageQueue(); // Build the sorted messages list. if (is_array($messages) && count($messages)) { foreach ($messages as $message) { if (isset($message['type']) && isset($message['message'])) { $lists[$message['type']][] = $message['message']; } } } // If messages exist add them to the output. if (isset($lists) && is_array($lists)) { $this->messages = $lists; } // Check if we are dealing with an error. if ($response instanceof Exception) { // Prepare the error response. $this->success = false; $this->error = true; $this->message = $response->getMessage(); } else { // Prepare the response data. $this->success = !$error; $this->error = $error; $this->data = $response; } }
/** * Method to get the user group field input markup. * * @return string The field input markup. * * @since 11.1 */ protected function getInput() { JLog::add('JFormFieldUsergroup is deprecated. Use JFormFieldUserGroupList instead.', JLog::WARNING, 'deprecated'); $options = array(); $attr = ''; // Initialize some field attributes. $attr .= !empty($this->class) ? ' class="' . $this->class . '"' : ''; $attr .= $this->disabled ? ' disabled' : ''; $attr .= $this->size ? ' size="' . $this->size . '"' : ''; $attr .= $this->multiple ? ' multiple' : ''; $attr .= $this->required ? ' required aria-required="true"' : ''; $attr .= $this->autofocus ? ' autofocus' : ''; // Initialize JavaScript field attributes. $attr .= !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : ''; $attr .= !empty($this->onclick) ? ' onclick="' . $this->onclick . '"' : ''; // Iterate through the children and build an array of options. foreach ($this->element->children() as $option) { // Only add <option /> elements. if ($option->getName() != 'option') { continue; } $disabled = (string) $option['disabled']; $disabled = $disabled == 'true' || $disabled == 'disabled' || $disabled == '1'; // Create a new option object based on the <option /> element. $tmp = JHtml::_('select.option', (string) $option['value'], trim((string) $option), 'value', 'text', $disabled); // Set some option attributes. $tmp->class = (string) $option['class']; // Set some JavaScript option attributes. $tmp->onclick = (string) $option['onclick']; // Add the option object to the result set. $options[] = $tmp; } return JHtml::_('access.usergroup', $this->name, $this->value, $attr, $options, $this->id); }
/** * Constructor * * @param JDatabaseDriver $db Database driver object. * * @since 11.1 * @deprecated 13.3 Use SQL queries to interact with the session table. */ public function __construct(JDatabaseDriver $db) { JLog::add('JTableSession is deprecated. Use SQL queries directly to interact with the session table.', JLog::WARNING, 'deprecated'); parent::__construct('#__session', 'session_id', $db); $this->guest = 1; $this->username = ''; }
/** * Get a parsed XML Feed Source * * @param string $url Url for feed source. * @param integer $cache_time Time to cache feed for (using internal cache mechanism). * * @return mixed SimplePie parsed object on success, false on failure. * * @since 12.2 * @deprecated 4.0 Use JFeedFactory($url) instead. * * @note In 3.2 will be proxied to JFeedFactory() */ public static function getFeedParser($url, $cache_time = 0) { JLog::add(__METHOD__ . ' is deprecated. Use JFeedFactory() or supply Simple Pie instead.', JLog::WARNING, 'deprecated'); $cache = JFactory::getCache('feed_parser', 'callback'); if ($cache_time > 0) { $cache->setLifeTime($cache_time); } $simplepie = new SimplePie(null, null, 0); $simplepie->enable_cache(false); $simplepie->set_feed_url($url); $simplepie->force_feed(true); $contents = $cache->get(array($simplepie, 'init'), null, false, false); if ($contents) { return $simplepie; } JLog::add(JText::_('JLIB_UTIL_ERROR_LOADING_FEED_DATA'), JLog::WARNING, 'jerror'); return false; }
public function delete() { // Check for request forgeries JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN')); // Get items to remove from the request. $id = JFactory::getApplication()->input->getInt('id', 0); if (!$id) { JLog::add(JText::_('COM_DJREVIEWS_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror'); return false; } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers jimport('joomla.utilities.arrayhelper'); $cid = array($id); JArrayHelper::toInteger($cid); // Remove the items. if ($model->delete($cid)) { $this->setMessage(JText::_('COM_DJREVIEWS_ITEM_DELETED')); } else { $this->setMessage($model->getError()); } } require_once JPath::clean(JPATH_ROOT . '/components/com_djreviews/lib/api.php'); DJReviewsAPI::recalculate(); return true; }
function onUserLoginFailure($response) { jimport('joomla.error.log'); $log = JLog::getInstance(); $errorlog = array(); switch ($response['status']) { case JAUTHENTICATE_STATUS_CANCEL: $errorlog['status'] = $response['type'] . " CANCELED: "; $errorlog['comment'] = $response['error_message']; $log->addEntry($errorlog); break; case JAUTHENTICATE_STATUS_FAILURE: $errorlog['status'] = $response['type'] . " FAILURE: "; if ($this->params->get('log_username', 0)) { $errorlog['comment'] = $response['error_message'] . ' ("' . $response['username'] . '")'; } else { $errorlog['comment'] = $response['error_message']; } $log->addEntry($errorlog); break; default: $errorlog['status'] = $response['type'] . " UNKNOWN ERROR: "; $errorlog['comment'] = $response['error_message']; $log->addEntry($errorlog); break; } }
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 preflight($type, $parent) { if (!JFile::exists(JPATH_ROOT . '/components/com_mijoshop/mijoshop/mijoshop.php')) { JLog::add('MijoShop component (com_mijoshop) is not installed. Please, install it first.', JLog::ERROR, 'jerror'); return false; } }
public function save($key = null, $urlVar = null) { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $data = $this->input->post->get('jform', array(), 'array'); $itemId = ArrayHelper::getValue($data, "id"); $redirectData = array("task" => $this->getTask(), "id" => $itemId); $model = $this->getModel(); /** @var $model GamificationModelRank */ $form = $model->getForm($data, false); /** @var $form JForm */ if (!$form) { throw new Exception(JText::_("COM_GAMIFICATION_ERROR_FORM_CANNOT_BE_LOADED"), 500); } // 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_GAMIFICATION_ERROR_SYSTEM')); } $this->displayMessage(JText::_('COM_GAMIFICATION_LEVEL_SAVED'), $redirectData); }
/** * 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); }
/** * 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"); // Prepare return data $redirectOptions = array("task" => $this->getTask(), "id" => $itemId); $model = $this->getModel(); /** @var $model VirtualCurrencyModelTransaction * */ $form = $model->getForm($data, false); /** @var $form JForm * */ if (!$form) { throw new Exception(JText::_("COM_VIRTUALCURRENCY_ERROR_FORM_CANNOT_BE_LOADED"), 500); } // Validate the form $validData = $model->validate($form, $data); // Check for errors. if ($validData === false) { $this->displayNotice($form->getErrors(), $redirectOptions); return; } try { $itemId = $model->save($validData); // Prepare return data $redirectOptions["id"] = $itemId; } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_VIRTUALCURRENCY_ERROR_SYSTEM')); } $this->displayMessage(JText::_("COM_VIRTUALCURRENCY_TRANSACTION_SAVED"), $redirectOptions); }
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); }
/** * Gets a list of the actions that can be performed. * * @param string $extension The extension. * @param integer $categoryId The category ID. * * @return JObject * * @since 1.6 * @deprecated 3.2 Use JHelperContent::getActions() instead */ public static function getActions($extension, $categoryId = 0) { // Log usage of deprecated function JLog::add(__METHOD__ . '() is deprecated, use JHelperContent::getActions() with new arguments order instead.', JLog::WARNING, 'deprecated'); // Get list of actions return JHelperContent::getActions($extension, 'category', $categoryId); }
/** * 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); }
/** * 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(); }
public function getProjectFunds() { // Create response object $response = new Prism\Response\Json(); $app = JFactory::getApplication(); /** @var $app JApplicationAdministrator */ $itemId = $app->input->getInt('id'); // Check for errors. if (!$itemId) { $response->setTitle(JText::_('COM_CROWDFUNDINGFINANCE_FAIL'))->setText(JText::_('COM_CROWDFUNDINGFINANCE_ERROR_INVALID_PROJECT'))->failure(); echo $response; JFactory::getApplication()->close(); } try { // Get statistics $project = new Crowdfunding\Statistics\Project(JFactory::getDbo(), $itemId); $data = $project->getFundedAmount(); } catch (Exception $e) { JLog::add($e->getMessage()); $response->setTitle(JText::_('COM_CROWDFUNDINGFINANCE_FAIL'))->setText(JText::_('COM_CROWDFUNDINGFINANCE_ERROR_SYSTEM'))->failure(); echo $response; JFactory::getApplication()->close(); throw new Exception(JText::_('COM_CROWDFUNDINGFINANCE_ERROR_SYSTEM')); } $response->setData($data)->success(); echo $response; JFactory::getApplication()->close(); }
/** * Method to publish a list of items * * @return void * */ public function publish() { global $jlistConfig; require_once JPATH_COMPONENT_SITE . '/helpers/jdownloadshelper.php'; // 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'); $data = array('publish' => 1, 'unpublish' => 0); $task = $this->getTask(); $state = JArrayHelper::getValue($data, $task, 0, 'int'); if (empty($cid)) { JLog::add(JText::_('JGLOBAL_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror'); $this->setRedirect(JRoute::_('index.php?option=com_jdownloads&view=downloads', false)); } else { if ($state == 1 && $jlistConfig['use.alphauserpoints']) { // load the model $model = $this->getModel(); foreach ($cid as $id) { // load the items data $item = $model->getItem($id); // add the AUP points JDHelper::setAUPPointsUploads($item->submitted_by, $item->file_title); } } parent::publish(); } }
/** * Returns a JPathway object * * @param string $client The name of the client * @param array $options An associative array of options * * @return JPathway A JPathway object. * * @since 1.5 * @throws RuntimeException */ public static function getInstance($client, $options = array()) { if (empty(self::$instances[$client])) { // Create a JPathway object $classname = 'JPathway' . ucfirst($client); if (!class_exists($classname)) { // @deprecated 4.0 Everything in this block is deprecated but the warning is only logged after the file_exists // Load the pathway object $info = JApplicationHelper::getClientInfo($client, true); if (is_object($info)) { $path = $info->path . '/includes/pathway.php'; if (file_exists($path)) { JLog::add('Non-autoloadable JPathway subclasses are deprecated, support will be removed in 4.0.', JLog::WARNING, 'deprecated'); include_once $path; } } } if (class_exists($classname)) { self::$instances[$client] = new $classname($options); } else { throw new RuntimeException(JText::sprintf('JLIB_APPLICATION_ERROR_PATHWAY_LOAD', $client), 500); } } return self::$instances[$client]; }
/** * Checks to see if the payerID matches a previous payerID in the virtuemart DB * We only care about the Username for Joomla, but the password is really the payerID * That is passed from Virtuemart. The payerID is then used to check the ID from * Joomla with the ID in the Virtuemart user_info. We do this just to make sure it is * The correct user trying to login and not someone else * * @access public * @param string $username Username for authentication * @param string $password Password for authentication * @param object $response Authentication response object * @return boolean * @since 1.5 */ function onAuthenticate($credentials, $options, &$response) { $db =& JFactory::getDBO(); $query = 'SELECT * FROM `#__users` WHERE username='******'username']); $db->setQuery($query); $result = $db->loadObject(); $options = array('format' => "{DATE}\t{TIME}\t{USER_ID}\t{COMMENT}"); $log =& JLog::getInstance(); if (!$result) { $response->status = JAUTHENTICATE_STATUS_FAILURE; $response->error_message = 'User does not exist'; $log->addEntry(array('comment' => 'User does not exist')); } else { $log->addEntry(array('comment' => 'Found User')); $query = 'SELECT * FROM `#__vm_user_info` WHERE extra_field_3 =' . $db->Quote($credentials['password']) . ' AND user_id =' . $db->Quote($result->id) . ' ORDER by mdate DESC'; $db->setQuery($query); $result2 = $db->loadObject(); //Check to see if we found a user with the User Id and Payer Id match //If so login the user and if not do not login. if (!$result2) { $log->addEntry(array('comment' => 'No user found with Payer ID in Virtuemart')); $response->status = JAUTHENTICATE_STATUS_FAILURE; $response->error_message = 'No user found with Payer ID in Virtuemart'; } else { $log->addEntry(array('comment' => 'User Found Logging in...')); $response->email = $result->email; $response->status = JAUTHENTICATE_STATUS_SUCCESS; } } }
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 delete() { /* * получаем имя файла из записи по ID * удаляем файл * выполняем родительский метод */ $cid = JFactory::getApplication()->input->get('cid', array(), 'array'); if (is_array($cid) && count($cid) > 0) { $arFilesToDelete = array(); foreach ($cid as $id) { $db = JFactory::getDBO(); $q = "SELECT `id`, `filename` FROM #__downfiles WHERE id = {$id}"; $res = $db->setQuery($q); $data_row = $res->loadAssoc(); $arFilesToDelete[] = $data_row["filename"]; } jimport('joomla.filesystem.file'); foreach ($arFilesToDelete as $fname) { JFile::delete(JPATH_ROOT . '/' . $fname); } } else { JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror'); } parent::delete(); }
/** * 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); }
/** * Method to get the field options for the list of installed editors. * * @return array The field option objects. * * @since 11.1 */ protected function getOptions() { JLog::add('JFormFieldEditors is deprecated. Use JFormFieldPlugins instead (with folder="editors").', JLog::WARNING, 'deprecated'); // Get the database object and a new query object. $db = JFactory::getDBO(); $query = $db->getQuery(true); // Build the query. $query->select('element AS value, name AS text'); $query->from('#__extensions'); $query->where('folder = ' . $db->quote('editors')); $query->where('enabled = 1'); $query->order('ordering, name'); // Set the query and load the options. $db->setQuery($query); $options = $db->loadObjectList(); $lang = JFactory::getLanguage(); foreach ($options as $i => $option) { $lang->load('plg_editors_' . $option->value, JPATH_ADMINISTRATOR, null, false, false) || $lang->load('plg_editors_' . $option->value, JPATH_PLUGINS . '/editors/' . $option->value, null, false, false) || $lang->load('plg_editors_' . $option->value, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load('plg_editors_' . $option->value, JPATH_PLUGINS . '/editors/' . $option->value, $lang->getDefault(), false, false); $options[$i]->text = JText::_($option->text); } // Check for a database error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. * * @since 11.4 */ protected function getOptions() { $folder = $this->element['folder']; if (!empty($folder)) { // Get list of plugins $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('element AS value, name AS text'); $query->from('#__extensions'); $query->where('folder = ' . $db->q($folder)); $query->where('enabled = 1'); $query->order('ordering, name'); $db->setQuery($query); $options = $db->loadObjectList(); $lang = JFactory::getLanguage(); foreach ($options as $i => $item) { $source = JPATH_PLUGINS . '/' . $folder . '/' . $item->value; $extension = 'plg_' . $folder . '_' . $item->value; $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension . '.sys', $source, null, false, false) || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false); $options[$i]->text = JText::_($item->text); } } else { JLog::add(JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'), JLog::WARNING, 'jerror'); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
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'); $redirectData = array('task' => $this->getTask(), 'id' => $itemId); $model = $this->getModel(); /** @var $model SocialCommunityModelLocation */ $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_LOCATION_SAVED'), $redirectData); }