/** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . '/helpers/users.php'; // Load the submenu. UsersHelper::addSubmenu(JRequest::getCmd('view', 'users')); $view = JRequest::getCmd('view', 'users'); $layout = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('id'); if (!$this->canView($view)) { JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); return; } // Check for edit form. if ($view == 'user' && $layout == 'edit' && !$this->checkEditId('com_users.edit.user', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_users&view=users', false)); return false; } elseif ($view == 'group' && $layout == 'edit' && !$this->checkEditId('com_users.edit.group', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_users&view=groups', false)); return false; } elseif ($view == 'level' && $layout == 'edit' && !$this->checkEditId('com_users.edit.level', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_users&view=levels', false)); return false; } return parent::display(); }
protected function getInput() { if (!NNFrameworkFunctions::extensionInstalled('virtuemart')) { return '<fieldset class="alert alert-danger">' . JText::_('ERROR') . ': ' . JText::sprintf('NN_FILES_NOT_FOUND', JText::_('NN_VIRTUEMART')) . '</fieldset>'; } $this->params = $this->element->attributes(); $this->db = JFactory::getDBO(); $group = $this->get('group', 'categories'); $tables = $this->db->getTableList(); if (!in_array($this->db->getPrefix() . 'virtuemart_' . $group, $tables)) { return '<fieldset class="alert alert-danger">' . JText::_('ERROR') . ': ' . JText::sprintf('NN_TABLE_NOT_FOUND', JText::_('NN_VIRTUEMART')) . '</fieldset>'; } $parameters = NNParameters::getInstance(); $params = $parameters->getPluginParams('nnframework'); $this->max_list_count = $params->max_list_count; if (!is_array($this->value)) { $this->value = explode(',', $this->value); } $options = $this->{'get' . $group}(); $size = (int) $this->get('size'); $multiple = $this->get('multiple'); if ($group == 'categories') { require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php'; return nnHtml::selectlist($options, $this->name, $this->value, $this->id, $size, $multiple); } $attr = ''; $attr .= ' size="' . (int) $size . '"'; $attr .= $multiple ? ' multiple="multiple"' : ''; return JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id); }
/** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . '/helpers/menus.php'; // Load the submenu. MenusHelper::addSubmenu(JRequest::getCmd('view')); $view = JRequest::getCmd('view', 'menus'); $layout = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('id'); // Check for edit form. if ($view == 'menu' && $layout == 'edit' && !$this->checkEditId('com_menus.edit.menu', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menus', false)); return false; } elseif ($view == 'item' && $layout == 'edit' && !$this->checkEditId('com_menus.edit.item', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_menus&view=items', false)); return false; } parent::display(); return $this; }
function display($tpl = null) { global $mainframe, $option; $cid = JRequest::getVar('cid_user'); if (!is_array($cid)) { $mainframe->redirect('index.php?option=' . $option); return; } $user_id = $cid[0]; $model = $this->getModel('user'); $model->load($user_id); $this->_setToolBar(); $say = JText::sprintf('USER_RESOURCES_TITLE', $model->user->username); $root_node = JText::_('RESOURCES_TREE_ROOT_NODE'); $nowdate = JFactory::getDate(); $str_now = JHTML::_('date', $nowdate->toMySQL(), '%Y-%m-%d %H:%M:%S'); $this->assign('nowdate', $str_now); $this->assign('say', $say); $this->assign('root_node', $root_node); $this->assignRef('uid', $user_id); $this->assignRef('option', $option); //hide the menu JRequest::setVar('hidemainmenu', 1); parent::display(); }
/** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $pathway = $app->getPathway(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', JText::_('COM_TESTYOURSELF_DEFAULT_PAGE_TITLE')); } $title = $this->params->get('page_title', ''); $id = (int) @$menu->query['id']; if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } if (empty($title)) { $title = $this->item->name; } $this->document->setTitle($title); if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } }
public function import() { $app = JFactory::getApplication(); $model = F0FModel::getTmpInstance('Imports', 'AkeebasubsModel'); $file = JRequest::getVar('csvfile', '', 'FILES'); $delimiter = $this->input->getInt('csvdelimiters', 0); $field = $this->input->getString('field_delimiter', ''); $enclosure = $this->input->getString('field_enclosure', ''); if ($file['error']) { $this->setRedirect('index.php?option=com_akeebasubs&view=import', JText::_('COM_AKEEBASUBS_IMPORT_ERR_UPLOAD'), 'error'); return true; } if ($delimiter != -99) { list($field, $enclosure) = $model->decodeDelimiterOptions($delimiter); } // Import ok, but maybe I have warnings (ie skipped lines) $result = $model->import($file['tmp_name'], $field, $enclosure); if ($result !== false) { $errors = $model->getErrors(); if ($errors) { $app->enqueueMessage(JText::_('COM_AKEEBASUBS_IMPORT_WITH_WARNINGS'), 'notice'); foreach ($errors as $error) { $app->enqueueMessage($error, 'notice'); } } else { // Import ok, congrat with yourself! $app->enqueueMessage(JText::sprintf('COM_AKEEBASUBS_IMPORT_OK', $result)); } } else { //Uh oh... import failed, let's inform the user why it happened $app->enqueueMessage(JText::sprintf('COM_AKEEBASUBS_IMPORT_FAIL', $model->getError()), 'error'); } $this->setRedirect('index.php?option=com_akeebasubs&view=import'); }
/** * Method is called before user data is stored in the database. * * Changes the password in LDAP if the user changed their password. * * @param array $user Holds the old user data. * @param boolean $isNew True if a new user is stored. * @param array $new Holds the new user data. * * @return boolean Cancels the save if False. * * @since 2.0 */ public function onUserBeforeSave($user, $isNew, $new) { if ($isNew) { // We dont want to deal with new users here return; } // Get username and password to use for authenticating with Ldap $username = JArrayHelper::getValue($user, 'username', false, 'string'); $password = JArrayHelper::getValue($new, 'password_clear', null, 'string'); if (!empty($password)) { $auth = array('authenticate' => SHLdap::AUTH_USER, 'username' => $username, 'password' => $password); try { // We will double check the password for double safety (breaks password reset if on) $authenticate = $this->params->get('authenticate', 0); // Get the user adapter then set the password on it $adapter = SHFactory::getUserAdapter($auth); $adapter->setPassword($password, JArrayHelper::getValue($new, 'current-password', null, 'string'), $authenticate); SHLog::add(JText::sprintf('PLG_LDAP_PASSWORD_INFO_12411', $username), 12411, JLog::INFO, 'ldap'); } catch (Exception $e) { // Log and Error out SHLog::add($e, 12401, JLog::ERROR, 'ldap'); return false; } } }
static function getList(&$params) { //get database $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year'); $query->from('#__content'); $query->where('state = 2 AND checked_out = 0'); $query->group('created_year DESC, created_month DESC'); // Filter by language if (JFactory::getApplication()->getLanguageFilter()) { $query->where('language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'); } $db->setQuery($query, 0, intval($params->get('count'))); $rows = (array) $db->loadObjectList(); $app = JFactory::getApplication(); $menu = $app->getMenu(); $item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true); $itemid = isset($item) && !empty($item->id) ? '&Itemid=' . $item->id : ''; $i = 0; $lists = array(); foreach ($rows as $row) { $date = JFactory::getDate($row->created); $created_month = $date->format('n'); $created_year = $date->format('Y'); $created_year_cal = JHTML::_('date', $row->created, 'Y'); $month_name_cal = JHTML::_('date', $row->created, 'F'); $lists[$i] = new stdClass(); $lists[$i]->link = JRoute::_('index.php?option=com_content&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid); $lists[$i]->text = JText::sprintf('MOD_ARTICLES_ARCHIVE_DATE', $month_name_cal, $created_year_cal); $i++; } return $lists; }
/** * Load a manifest from an XML file * * @param string $xmlpath Path to XML manifest file * * @return boolean Result of load * @since 1.6 */ function loadManifestFromXML($xmlfile) { $this->manifest_file = JFile::stripExt(basename($xmlfile)); $xml = JFactory::getXML($xmlfile); if (!$xml) { $this->_errors[] = JText::sprintf('JLIB_INSTALLER_ERROR_LOAD_XML', $xmlfile); return false; } else { $this->name = (string) $xml->name; $this->packagename = (string) $xml->packagename; $this->update = (string) $xml->update; $this->authorurl = (string) $xml->authorUrl; $this->author = (string) $xml->author; $this->authoremail = (string) $xml->authorEmail; $this->description = (string) $xml->description; $this->packager = (string) $xml->packager; $this->packagerurl = (string) $xml->packagerurl; $this->version = (string) $xml->version; if (isset($xml->files->file) && count($xml->files->file)) { foreach ($xml->files->file as $file) { // NOTE: JExtension doesn't expect a string. // DO NOT CAST $file $this->filelist[] = new JExtension($file); } } return true; } }
/** * Loads the entire menu table into memory (taken from Joomla 1.7.3). * * @return array */ protected static function load() { // Initialise variables. $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('m.id, m.menutype, m.title, m.alias, m.path AS route, m.link, m.type, m.level, m.language'); $query->select('m.browserNav, m.access, m.params, m.home, m.img, m.template_style_id, m.component_id, m.parent_id'); $query->select('e.element as component, m.published'); $query->from('#__menu AS m'); $query->leftJoin('#__extensions AS e ON m.component_id = e.extension_id'); $query->where('m.parent_id > 0'); $query->where('m.client_id = 0'); $query->order('m.lft'); // Set the query $db->setQuery($query); if (!(self::$items = $db->loadObjectList('id'))) { JError::raiseWarning(500, JText::sprintf('JERROR_LOADING_MENUS', $db->getErrorMsg())); return false; } foreach (self::$items as &$item) { // Get parent information. $parent_tree = array(); if (isset(self::$items[$item->parent_id])) { $parent_tree = self::$items[$item->parent_id]->tree; } // Create tree $parent_tree[] = $item->id; $item->tree = $parent_tree; // Create the query array. $url = str_replace('index.php?', '', $item->link); $url = str_replace('&', '&', $url); parse_str($url, $item->query); } }
/** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if (empty($this->item->id)) { $head = JText::_('COM_USERNOTIFY_FORM_SUBMIT_USERSUBS'); } else { $head = JText::_('COM_USERNOTIFY_FORM_EDIT_USERSUBS'); } if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', $head); } $title = $this->params->def('page_title', $head); if ($app->getCfg('sitename_pagetitles', 0)) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } $this->document->setTitle($title); if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } }
function send_certificate() { $app = JFactory::getApplication(); $params = $app->getParams(); $moodle_url = $params->get('MOODLE_URL'); $cert_id = JRequest::getVar('cert_id'); $simple = JRequest::getVar('simple'); $email = JRequest::getString('mailto', '', 'post'); $sender = JRequest::getString('sender', '', 'post'); $from = JRequest::getString('from', '', 'post'); $user = JFactory::getUser(); $username = $user->username; $subject_default = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_SUBJECT', $user->name); $subject = JRequest::getString('subject', $subject_default, 'post'); if (!$subject) { $subject = $subject_default; } $mailer = JFactory::getMailer(); $config = JFactory::getConfig(); $sender = array($config->get('mailfrom'), $config->get('fromname')); $mailer->setSender($sender); $mailer->addRecipient($email); $body = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_BODY', $user->name); $mailer->setSubject($subject); $mailer->setBody($body); $session = JFactory::getSession(); $token = md5($session->getId()); $pdf = file_get_contents($moodle_url . '/auth/joomdle/' . $simple . 'certificate_view.php?id=' . $cert_id . '&certificate=1&action=review&username='******'&token=' . $token); $tmp_path = $config->get('tmp_path'); $filename = 'certificate-' . $cert_id . '-' . $user->name . '.pdf'; file_put_contents($tmp_path . '/' . $filename, $pdf); $mailer->addAttachment($tmp_path . '/' . $filename); $send = $mailer->Send(); unlink($tmp_path . '/' . $filename); if ($send !== true) { JError::raiseNotice(500, JText::_('COM_JOOMDLE_EMAIL_NOT_SENT')); } else { ?> <div style="padding: 10px;"> <div style="text-align:right"> <a href="javascript: void window.close()"> <?php echo JText::_('COM_JOOMDLE_CLOSE_WINDOW'); ?> <?php echo JHtml::_('image', 'mailto/close-x.png', NULL, NULL, true); ?> </a> </div> <h2> <?php echo JText::_('COM_JOOMDLE_EMAIL_SENT'); ?> </h2> </div> <?php } }
/** * method to run after an install/update/uninstall method * * @return void */ function postflight($type, $parent) { $manifest = $parent->getParent()->getManifest(); if ($type != 'uninstall' && !$this->_installAllowed($manifest)) { return false; } // Remove AjaxHelpAry $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select(array('extension_id', 'name', 'params', 'element')); $query->from('#__extensions'); $query->where($db->quoteName('element') . ' = ' . $db->quote('ajaxhelpary')); $query->where($db->quoteName('folder') . ' = ' . $db->quote('ajax')); $db->setQuery($query); $row = $db->loadAssoc(); if (!empty($row)) { $installer = new JInstaller(); $res = $installer->uninstall('plugin', $row['extension_id']); if ($res) { $msg = '<b style="color:green">' . JText::sprintf('COM_INSTALLER_UNINSTALL_SUCCESS', $row['name']) . '</b>'; } else { $msg = '<b style="color:red">' . JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $row['name']) . '</b>'; } $this->messages[] = $msg; } parent::postflight($type, $parent, $publishPlugin = true); }
/** * 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); $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 { $text = 'JSuccess_N_Items_unpublished'; } $this->setMessage(JText::sprintf($text, count($ids))); } } $this->setRedirect('index.php?option=com_plugins&view=plugins'); }
/** * @param SimpleXMLElement $element The JXmlElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form. * @param JForm $form The form object for which the field is being tested. * * @return boolean True if the value is valid, false otherwise. */ public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null) { if (!parent::test($element, $value, $group, $input, $form)) { return false; } else { //[%%START_CUSTOM_CODE%%] if ($input->get('component_object_id') != 0) { $db = JFactory::getDBO(); $query = $db->getQuery(true); // Build the query. $query->select('COUNT(*)'); $query->from('#__componentarchitect_fields'); $query->where('code_name = ' . $db->quote($value)); $query->where('component_object_id = ' . $db->quote($input->get('component_object_id'))); $query->where('id != ' . $db->quote($input->get('id'))); try { // Set and query the database. $db->setQuery($query); $duplicate = (bool) $db->loadResult(); $title = $db->loadResult(); } catch (RuntimeException $e) { throw new RuntimeException(JText::sprintf('COM_COMPONENTARCHITECT_ERROR_DATABASE_FATAL', $e->getMessage())); } if ($duplicate) { // Change to RuntimeException when Joomla! 2.5 no longer supported as JException (deprecated) and will be removed from Joomla return new JException(JText::_('COM_COMPONENTARCHITECT_FIELDS_FIELD_CODE_NAME_ERROR_DUPLICATE'), 1, E_WARNING); } } //[%%END_CUSTOM_CODE%%] return true; } }
function saveJS() { $data = JRequest::get('get'); JRequest::setVar($data['token'], '1', 'post'); JRequest::checkToken() or jexit('Invalid Token save'); $model = VmModel::getModel($this->_cname); $id = $model->store($data); $errors = $model->getErrors(); if (empty($errors)) { $msg = JText::sprintf('COM_VIRTUEMART_STRING_SAVED', $this->mainLangKey); $type = 'save'; } else { $type = 'error'; } foreach ($errors as $error) { $msg = $error . '<br />'; } $json['msg'] = $msg; if ($id) { $json['product_id'] = $id; $json['ok'] = 1; } else { $json['ok'] = 0; } echo json_encode($json); jExit(); }
/** * Method to get a parser, creating it if necessary. * * @param string $format The type of parser to load. * * @return FinderIndexerParser A FinderIndexerParser instance. * * @since 2.5 * @throws Exception on invalid parser. */ public static function getInstance($format) { static $instances; // Only create one parser for each format. if (isset($instances[$format])) { return $instances[$format]; } // Create an array of instances if necessary. if (!is_array($instances)) { $instances = array(); } // Setup the adapter for the parser. $format = JFilterInput::getInstance()->clean($format, 'cmd'); $path = __DIR__ . '/parser/' . $format . '.php'; $class = 'FinderIndexerParser' . ucfirst($format); // Check if a parser exists for the format. if (file_exists($path)) { // Instantiate the parser. include_once $path; $instances[$format] = new $class(); } else { // Throw invalid format exception. throw new Exception(JText::sprintf('COM_FINDER_INDEXER_INVALID_PARSER', $format)); } return $instances[$format]; }
/** * Method to test whether a record can be deleted. * * @param object $record A record object. * * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. * * @since 1.6 */ protected function canDelete($record) { if (!empty($record->id)) { if ($record->state != -2) { return false; } $user = JFactory::getUser(); $permissions = SibdietHelper::getUserPermissions(); // Check that user have access permission to data banks and can delete if (in_array('contags', $permissions)) { // Check that tag not used in diets controller $db = JFactory::getDbo(); $query = $db->getQuery(true)->select("s.id")->from('#__sibdiet_setdiets AS s')->where("FIND_IN_SET('" . $record->id . "', s.tags)"); $db->setQuery($query); try { $used = $db->loadColumn(); } catch (Exception $e) { // catch any database errors. } if (count($used)) { // echo that item is used $this->setError(JText::sprintf('COM_SIBDIET_ERR_CONTAG_USED', $record->title . ' (' . implode(' - ', $used) . ')')); return; } return $user->authorise('core.delete', 'com_sibdiet'); } } return false; }
/** 1.5 **/ public function onSearch($text, $phrase = '', $ordering = '', $areas = null) { $plugin = JPluginHelper::getPlugin('search', 'easyblog'); $params = EB::registry($plugin->params); if (!plgSearchEasyblog::exists()) { return array(); } if (is_array($areas)) { if (!array_intersect($areas, array_keys(plgSearchEasyblog::onContentSearchAreas()))) { return array(); } } $text = trim($text); if ($text == '') { return array(); } $result = plgSearchEasyblog::getResult($text, $phrase, $ordering); if (!$result) { return array(); } // require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'router.php' ); foreach ($result as $row) { $row->section = plgSearchEasyblog::getCategory($row->category_id); $row->section = JText::sprintf('PLG_EASYBLOG_SEARCH_BLOGS_SECTION', $row->section); $row->href = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $blog = EB::table('Blog'); $blog->bind($row); if ($blog->getImage()) { $row->image = $blog->getImage('frontpage'); } } return $result; }
function getMessage($extension = '', $xml = '', $version = '', $addmargin = 0) { if (!$extension || !$xml && !$version) { return; } $alias = preg_replace('#[^a-z\\-]#', '', str_replace('?', '-', strtolower($extension))); if ($xml) { $xml = JApplicationHelper::parseXMLInstallFile(JPATH_SITE . DS . str_replace('/', DS, $xml)); if ($xml && isset($xml['version'])) { $version = $xml['version']; } } if (!$version) { return; } JHTML::_('behavior.mootools'); $document =& JFactory::getDocument(); $document->addScript(JURI::root(true) . '/plugins/system/nonumberelements/js/script.js?v=' . $this->_version); $url = 'http://www.nonumber.nl/ext/version.php?ext=' . $alias . '&version=' . $version; $script = "\n\t\t\twindow.addEvent( 'domready', function() {\n\t\t\t\tnnScripts.loadajax(\n\t\t\t\t\t'" . $url . "',\n\t\t\t\t\t'nnScripts.displayVersion( \\'" . $alias . "\\', data )',\n\t\t\t\t\t'nnScripts.displayVersion( \\'" . $alias . "\\', \\'\\' )'\n\t\t\t\t);\n\t\t\t});\n\t\t"; $document->addScriptDeclaration($script); $msg = html_entity_decode(JText::sprintf('NN_A_NEWER_VERSION_IS_AVAILABLE', 'http://www.nonumber.nl/' . $alias . '/download', '<span id="nonumber_newversionnumber_' . $alias . '"></span>', $version), ENT_COMPAT, 'UTF-8'); $margin = $addmargin ? '10px;' : '3px;'; $msg = '<div style="border:3px solid #F0DC7E;color:#CC0000;margin-bottom:' . $margin . '"><div style="padding: 2px 5px;background-color:#EFE7B8">' . $msg . '</div></div>'; $msg = '<div id="nonumber_version_' . $alias . '" style="display: none;">' . $msg . '</div>'; return $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; } }
static function setMessage($file, $name) { jimport('joomla.filesystem.file'); $file = str_replace('\\', '/', $file); if (strpos($file, '/administrator') === 0) { $file = str_replace('/administrator', JPATH_ADMINISTRATOR, $file); } else { $file = JPATH_SITE . '/' . $file; } $file = str_replace('//', '/', $file); $file_alt = preg_replace('#(com|mod)_([a-z-_]+\\.)#', '\\2', $file); if (!JFile::exists($file) && !JFile::exists($file_alt)) { $msg = JText::sprintf('NN_THIS_EXTENSION_NEEDS_THE_MAIN_EXTENSION_TO_FUNCTION', JText::_($name)); $message_set = 0; $messageQueue = JFactory::getApplication()->getMessageQueue(); foreach ($messageQueue as $queue_message) { if ($queue_message['type'] == 'error' && $queue_message['message'] == $msg) { $message_set = 1; break; } } if (!$message_set) { JFactory::getApplication()->enqueueMessage($msg, 'error'); } } }
private function filter($message, $type = 'exception') { $adapterFile = dirname(__FILE__) . '/adapters/' . $type . '.php'; // If the file does not exist, return missing adapter file error. // e.g. Could not locate adapter file for exception type - file.' if (!JFile::exists($adapterFile)) { $this->set(JText::sprintf('COM_EASYSOCIAL_EXCEPTION_ADAPTER_INVALID_FILE_ERROR', $type)); return; } // Load the adapter require_once $adapterFile; // Construct adapter classname $adapterClass = 'SocialException' . ucfirst($type); // If the file does not exist, return missing adapter class error // e.g. Could not locate adapter class for exception class - SocialExceptionFile.' if (!class_exists($adapterClass)) { $this->set(JText::sprintf('COM_EASYSOCIAL_EXCEPTION_ADAPTER_INVALID_CLASS_ERROR', $adapterClass)); return; } // Ask adapter to parse message $exception = call_user_func_array(array($adapterClass, 'filter'), array($message)); // If adapter did not return any exception if (empty($exception)) { // Set to the default adapter error of unkown adapter error, // e.g. Unknown file error. $this->set(JText::sprintf('COM_EASYSOCIAL_EXCEPTION_ADAPTER_UNKNOWN_ERROR', $type)); // Parse exception } else { $this->parse($exception, SOCIAL_EXCEPTION_MESSAGE); } }
public function save() { // Check for request forgeries JRequest::checkToken() or die('RESTRICTED'); $row = WFExtensionHelper::getPlugin(null, 'jcemediabox', 'system'); $task = $this->getTask(); // remove id for Joomla! 2.5+ if ($row->extension_id) { unset($row->id); } if (!$row->bind(JRequest::get('post'))) { JError::raiseError(500, $row->getError()); } if (!$row->check()) { JError::raiseError(500, $row->getError()); } if (!$row->store()) { JError::raiseError(500, $row->getError()); } $row->checkin(); $msg = JText::sprintf('WF_MEDIABOX_SAVED'); switch ($task) { case 'apply': $this->setRedirect('index.php?option=com_jce&view=mediabox', $msg); break; case 'save': default: $this->setRedirect('index.php?option=com_jce&view=cpanel', $msg); break; } }
function load() { $this->values = array(); if (JRequest::getCmd('from_display', false) == false) { $this->values[] = JHTML::_('select.option', '', JText::_('HIKA_INHERIT')); } $this->values[] = JHTML::_('select.optgroup', '-- ' . JText::_('FROM_HIKASHOP') . ' --'); foreach ($this->default as $d) { $this->values[] = JHTML::_('select.option', $d, JText::_(strtoupper($d))); } if (version_compare(JVERSION, '1.6.0', '>=')) { $this->values[] = JHTML::_('select.optgroup', '-- ' . JText::_('FROM_HIKASHOP') . ' --'); } $closeOpt = ''; $values = $this->getLayout(); foreach ($values as $value) { if (substr($value, 0, 1) == '#') { if (version_compare(JVERSION, '1.6.0', '>=') && !empty($closeOpt)) { $this->values[] = JHTML::_('select.optgroup', $closeOpt); } $value = substr($value, 1); $closeOpt = '-- ' . JText::sprintf('FROM_TEMPLATE', basename($value)) . ' --'; $this->values[] = JHTML::_('select.optgroup', $closeOpt); } else { $this->values[] = JHTML::_('select.option', $value, $value); } } if (version_compare(JVERSION, '1.6.0', '>=') && !empty($closeOpt)) { $this->values[] = JHTML::_('select.optgroup', $closeOpt); } }
/** * Render the button * * @param array &$definition Definition * * @return string */ public function render(&$definition) { $data = new stdClass(); $data->button = JText::sprintf('COM_NENO_TRANSLATION_CREDIT_TOOLBAR_FAKE_BUTTON', number_format($definition[1], 0, ',', '.')); $layout = JLayoutHelper::render('toolbartcbutton', $data, JPATH_NENO_LAYOUTS); return $layout; }
/** * Prepares the document * * @return void * * @throws Exception */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', JText::_('COM_AKRECIPES_DEFAULT_PAGE_TITLE')); } $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $app->get('sitename'); } elseif ($app->get('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); } elseif ($app->get('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); } $this->document->setTitle($title); if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } }
/** * Method to test whether a record can be deleted. * * @param object A record object. * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. */ protected function canDelete($record) { if (!empty($record->id)) { if ($record->state != -2) { return; } $user = JFactory::getUser(); // Check that user have access permission to data banks and can delete if ($user->authorise('core.delete', $this->option)) { // Check that desease not used in these tables $tables = array('defaults', 'setdiets'); $db = JFactory::getDbo(); foreach ($tables as $table) { $query = $db->getQuery(true)->select("s.id")->from('#__sibdiet_' . $table . ' AS s')->where("FIND_IN_SET('" . $record->id . "', s.goals)"); $db->setQuery($query); try { $used = $db->loadColumn(); } catch (Exception $e) { // catch any database errors. } if (count($used)) { // echo that item is used $this->setError(JText::sprintf('COM_SIBDIET_ERR_GOAL_USED', $record->title . ' (' . JText::_('COM_SIBDIET_SUBMENU_' . $table) . ': ' . implode(' - ', $used) . ')')); return; } } return true; } return; } }
/** * Loads the entire menu table into memory. * * @return boolean True on success, false on failure * * @since 1.5 */ public function load() { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('m.id, m.menutype, m.title, m.alias, m.note, m.path AS route, m.link, m.type, m.level, m.language')->select($db->quoteName('m.browserNav') . ', m.access, m.params, m.home, m.img, m.template_style_id, m.component_id, m.parent_id')->select('e.element as component')->from('#__menu AS m')->join('LEFT', '#__extensions AS e ON m.component_id = e.extension_id')->where('m.published = 1')->where('m.parent_id > 0')->where('m.client_id = 0')->order('m.lft'); // Set the query $db->setQuery($query); try { $this->_items = $db->loadObjectList('id'); } catch (RuntimeException $e) { JError::raiseWarning(500, JText::sprintf('JERROR_LOADING_MENUS', $e->getMessage())); return false; } foreach ($this->_items as &$item) { // Get parent information. $parent_tree = array(); if (isset($this->_items[$item->parent_id])) { $parent_tree = $this->_items[$item->parent_id]->tree; } // Create tree. $parent_tree[] = $item->id; $item->tree = $parent_tree; // Create the query array. $url = str_replace('index.php?', '', $item->link); $url = str_replace('&', '&', $url); parse_str($url, $item->query); } return true; }
function getQuotedSids() { $db = JFactory::getDbo(); $params =& $this->getParams(); if (!is_array($params->get('numerator_ids'))) { $numerator_ids = explode(',', $params->get('numerator_ids')); } else { $numerator_ids = $params->get('numerator_ids'); } if (!count($numerator_ids)) { JError::raiseWarning(0, JText::sprintf('STAT %s/%s WRONG CONFIGURATION', $this->_name, $this->id)); return array(0); } if (!is_array($params->get('denominator_ids'))) { $denominator_ids = explode(',', $params->get('denominator_ids')); } else { $denominator_ids = $params->get('denominator_ids'); } if (!count($denominator_ids)) { JError::raiseWarning(0, JText::sprintf('STAT %s/%s WRONG CONFIGURATION', $this->_name, $this->id)); return array(0); } $ids = array('num' => array(), 'den' => array()); foreach ($numerator_ids as $s) { $ids['num'][] = $db->Quote((int) $s); } foreach ($denominator_ids as $s) { $ids['den'][] = $db->Quote((int) $s); } return $ids; }