function checkPermission($function) { $c = jomtube_configs::get_instance(); $user =& JFactory::getUser(); if ($user->gid < $c->{$function} && $c->{$function} != 29) { // Redirect to login $uri = JFactory::getURI(); $return = $uri->toString(); $url = 'index.php?option=com_user&view=login'; $url .= '&return=' . base64_encode($return); $r = new JApplication(); $r->redirect($url, JText::_('You do not have permission to upload videos')); return; } }
/** * Overloaded check function * * @return boolean True on success * * @see JTable::check * @since 11.1 */ public function check() { // If the alias field is empty, set it to the title. $this->alias = trim($this->alias); if (empty($this->alias) && ($this->type != 'alias' && $this->type != 'url')) { $this->alias = $this->title; } // Make the alias URL safe. $this->alias = JApplication::stringURLSafe($this->alias); if (trim(str_replace('-', '', $this->alias)) == '') { $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s'); } // Cast the home property to an int for checking. $this->home = (int) $this->home; // Verify that a first level menu item alias is not 'component'. if ($this->parent_id == 1 && $this->alias == 'component') { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_COMPONENT')); return false; } // Verify that a first level menu item alias is not the name of a folder. jimport('joomla.filesystem.folder'); if ($this->parent_id == 1 && in_array($this->alias, JFolder::folders(JPATH_ROOT))) { $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_FOLDER', $this->alias, $this->alias)); return false; } // Verify that the home item a component. if ($this->home && $this->type != 'component') { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_COMPONENT')); return false; } return true; }
public function display() { $portal = $this->getModel()->getItem(); header('X-Portal-ID: ' . $portal->id); $doc =& JFactory::getDocument(); if ($portal->title) { $doc->setTitle($portal->title); } if ($portal->meta_keywords) { $doc->setMetaData('Keywords', $portal->meta_keywords); } if ($portal->meta_description) { $doc->setMetaData('Description', $portal->meta_description); } //TODO: Check if itemId $pathway = JFactory::getApplication()->getPathway(); if (!JApplication::getInstance('site')->getMenu()->getItems('link', 'index.php?option=com_portals&view=portal&id=' . $portal->id, true)) { $category = $this->getService('com://site/portals.model.categories')->id($portal->portals_category_id)->getItem(); if ($category->id) { $item = JApplication::getInstance('site')->getMenu()->getItems('link', 'index.php?option=com_portals&view=category&id=' . $category->id, true); if ($item) { $i = 0; foreach (explode('/', $item->route) as $part) { $pathway->addItem(ucfirst($part), 'index.php?Itemid=' . $item->tree[$i]); $i++; } } $pathway->addItem($portal->title); } } return parent::display(); }
/** * Test JApplication::isSSLConnection * * @return void */ public function testIsSSLConnection() { unset($_SERVER['HTTPS']); $this->assertThat($this->object->isSSLConnection(), $this->equalTo(false)); $_SERVER['HTTPS'] = 'on'; $this->assertThat($this->object->isSSLConnection(), $this->equalTo(true)); }
protected function prepareTable($table) { jimport('joomla.filter.output'); $date = JFactory::getDate(); $user = JFactory::getUser(); $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); $table->alias = JApplication::stringURLSafe($table->alias); if (empty($table->alias)) { $table->alias = JApplication::stringURLSafe($table->title); } if (intval($table->date) == 0) { $table->date = JFactory::getDate()->toSql(); } if (empty($table->id)) { // Set the values //$table->created = $date->toSql(); // Set ordering to the last item if not set if (empty($table->ordering)) { $db = JFactory::getDbo(); $db->setQuery('SELECT MAX(ordering) FROM #__phocagallery_comments WHERE catid = ' . (int) $table->catid); $max = $db->loadResult(); $table->ordering = $max + 1; } } else { // Set the values //$table->modified = $date->toSql(); //$table->modified_by = $user->get('id'); } }
protected function prepareDisplay($preconfig) { if (JCck::getConfig_Param('debug', 0)) { jimport('joomla.error.profiler'); $profiler = new JProfiler(); } $app = JFactory::getApplication(); $this->form = $this->get('Form'); $this->option = $app->input->get('option', ''); $this->item = $this->get('Item'); $this->state = $this->get('State'); $option = $this->option; $params = new JRegistry(); $view = $this->getName(); $isNew = 1; $live = ''; $lives = array(); $variation = ''; jimport('cck.base.form.form'); include_once JPATH_LIBRARIES_CCK . '/base/form/form_inc.php'; if (isset($config['id'])) { JFactory::getSession()->set('cck_hash_seblod_form', JApplication::getHash($id . '|' . $type->name . '|' . $config['id'])); } $this->config =& $config; $this->data =& $data; $this->id =& $id; $this->isNew =& $isNew; $this->params =& $params; $this->stage =& $stage; $this->type =& $type; $title = isset($type->title) ? $type->title : ''; $name = isset($type->name) ? $type->name : ''; $this->addToolbar($title, $name); }
public function store($updateNulls = false) { if (isset($this->alias)) { $this->alias = JApplication::stringURLSafe($this->alias); } if (!empty($this->metakey)) { // Only process if not empty $bad_characters = array("\n", "\r", "\"", "<", ">"); // array of characters to remove $after_clean = JString::str_ireplace($bad_characters, "", $this->metakey); // remove bad characters $keys = explode(',', $after_clean); // create array using commas as delimiter $clean_keys = array(); foreach ($keys as $key) { if (trim($key)) { // Ignore blank keywords $clean_keys[] = trim($key); } } $this->metakey = implode(", ", $clean_keys); // put array back together delimited by ", " } if (empty($this->answer_created_by_id)) { $this->answer_created_by_id = JFactory::getUser()->id; } return parent::store($updateNulls); }
protected function prepareTable($table) { jimport('joomla.filter.output'); $date = JFactory::getDate(); $user = JFactory::getUser(); $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); $table->alias = JApplication::stringURLSafe($table->alias); if (empty($table->alias)) { $table->alias = JApplication::stringURLSafe($table->title); } // Set the publish date to now if ($table->published == 1 && intval($table->publish_up) == 0) { $table->publish_up = $date->toSql(); } /* if (empty($table->id)) { // Set ordering to the last item if not set if (empty($table->ordering)) { $table->ordering = 0; $db = JFactory::getDbo(); $query = 'SELECT MAX(ordering) FROM #__djmt_items'; if($table->catid) $query.= ' WHERE catid='. (int) $table->catid; $db->setQuery($query); $max = $db->loadResult(); $table->ordering = $max+1; } }*/ }
protected static function _findItemId($needles) { // Prepare the reverse lookup array. if (self::$lookup === null) { self::$lookup = array(); $component =& JComponentHelper::getComponent('com_xmap'); $menus =& JApplication::getMenu('site', array()); $items = $menus->getItems('component_id', $component->id); foreach ($items as &$item) { if (isset($item->query) && isset($item->query['view'])) { $view = $item->query['view']; if (!isset(self::$lookup[$view])) { self::$lookup[$view] = array(); } if (isset($item->query['id'])) { self::$lookup[$view][$item->query['id']] = $item->id; } } } } $match = null; foreach ($needles as $view => $id) { if (isset(self::$lookup[$view])) { if (isset(self::$lookup[$view][$id])) { return self::$lookup[$view][$id]; } } } return null; }
/** * Overloaded check function * * @return boolean * @see JTable::check * @since 1.5 */ function check() { // Require helper require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'je_content.php'; jimport('joomla.filter.output'); // Set title $this->title = htmlspecialchars_decode($this->title, ENT_QUOTES); // Set alias $this->alias = JE_ContentHelper::convertAlias($this->title); $this->alias = JApplication::stringURLSafe($this->alias); // Check the publish down date is not earlier than publish up. if (intval($this->publish_down) > 0 && $this->publish_down < $this->publish_up) { // Swap the dates. $temp = $this->publish_up; $this->publish_up = $this->publish_down; $this->publish_down = $temp; } // Set ordering if ($this->state < 0) { // Set ordering to 0 if state is archived or trashed $this->ordering = 0; } else { if (empty($this->ordering)) { // Set ordering to last if ordering was 0 $this->ordering = self::getNextOrder('`catid`=' . $this->_db->Quote($this->catid) . ' AND state>=0'); } } return true; }
/** * Return an instance of a model that loaded base on configuration * @param mixed $config * @param object $state * @param string $coverage * @return JModelList */ private function getItemModel($config, $state, $coverage) { $path = ''; // Load model file if (!$config['path']) { $path = JPATH_ADMINISTRATOR . '/'; } else { $path = $config['path'] . '/'; } require_once $path . $config['modelfile']; // Load component language $this->language->load($config['language'], JPATH_ADMINISTRATOR); // Create model instance $model = new $config['modelname'](array('state' => $state)); $model->getState('filter.search'); $currentCoverage = $this->app->getUserStateFromRequest('components.selected', 'tab'); if ($currentCoverage == $coverage) { $order = $this->app->getUserStateFromRequest("{$currentCoverage}.{$config['modelname']}.order", 'filter_order', $config['order']); $orderDir = $this->app->getUserStateFromRequest("{$currentCoverage}.{$config['modelname']}.orderDir", 'filter_order_Dir', 'asc'); $state->set('list.ordering', $order); $state->set('list.direction', $orderDir); } $state->set('filter.search', $this->keyword); $state->set('filter.published', 'all'); $state->set('filter.state', 'all'); if (isset($config['filters']) && is_array($config['filters'])) { foreach ($config['filters'] as $key => $value) { $state->set($key, $value); } } return $model; }
function check() { jimport('joomla.filter.output'); $this->name = htmlspecialchars_decode($this->name, ENT_QUOTES); if (empty($this->ordering)) { $this->ordering = self::getNextOrder(); } if (empty($this->alias)) { $this->alias = $this->name; } $this->alias = JApplication::stringURLSafe($this->alias); if (trim(str_replace('1', '', $this->alias)) == '') { $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); } $this->alias = str_replace("-", "_", $this->alias); if ($this->type == '0') { return false; } if (is_array($_REQUEST['jform']['type_' . $this->type])) { $_REQUEST['jform']['type_' . $this->type]['value'] = $this->remove_array_empty_values($_REQUEST['jform']['type_' . $this->type]['value']); $_REQUEST['jform']['type_' . $this->type] = serialize($_REQUEST['jform']['type_' . $this->type]); } if ($this->type != 'image') { $this->default_values = $_REQUEST['jform']['type_' . $this->type]; } return true; }
/** * @param $row * @param KunenaForumCategory $category * @param KunenaForumTopic $topic * @param $subject * * @return bool|string */ protected function replyTopic($row, KunenaForumCategory $category, KunenaForumTopic $topic, $subject) { $uri = JFactory::getURI(); if (JSession::checkToken() == false) { $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); return false; } /*if ($this->hasCaptcha() && !$this->verifyCaptcha()) { return $this->showForm ( $row, $category, $topic, $subject ); }*/ // Create topic if it doesn't exist if (!$topic->exists()) { $topic = $this->createTopic($row, $category, $subject); } $params = array('name' => JRequest::getString('name', $this->user->getName(), 'POST'), 'email' => JRequest::getString('email', null, 'POST'), 'subject' => $subject, 'message' => JRequest::getString('message', null, 'POST')); if ($this->hasCaptcha() && !$this->verifyCaptcha()) { $this->app->redirect($uri->toString(), $result); } $message = $topic->newReply($params); $success = $message->save(); if (!$success) { $this->app->enqueueMessage($message->getError(), 'error'); return false; } $message->sendNotification(); if ($message->hold) { $result = JText::_('PLG_KUNENADISCUSS_PENDING_MODERATOR_APPROVAL'); } else { $result = JText::_('PLG_KUNENADISCUSS_MESSAGE_POSTED'); } // Redirect $app = JFactory::getApplication('site'); $app->redirect($uri->toString(), $result); return ''; }
public function store($updateNulls = false) { $isNew = false; if (!$this->id) { // New document $this->downloaded = 0; $isNew = true; } if (isset($this->alias) && isset($this->name) && $this->alias == "") { $this->alias = preg_replace("/ /", "-", strtolower($this->name)); } if (version_compare(JVERSION, '3.0', '>=')) { $this->alias = JApplicationHelper::stringURLSafe($this->alias); } else { $this->alias = JApplication::stringURLSafe($this->alias); } // Trigger events to osdownloads plugins $dispatcher = $this->getDispatcher(); $pluginResults = $dispatcher->trigger('onOSDownloadsBeforeSaveFile', array(&$this, $isNew)); $result = false; if ($pluginResults !== false) { $result = parent::store($updateNulls); $dispatcher->trigger('onOSDownloadsAfterSaveFile', array($result, &$this)); } return $result; }
function loadMultilangData($prepareElementCallback) { $languages = JLanguageHelper::getLanguages(); $app = JApplication::getInstance('site'); $menu = $app->getMenu(); $config = JFactory::getConfig(); $sef = $config->get('sef', 0); $sefRewrite = $config->get('sef_rewrite', 0); $defaultLangCode = JFactory::getLanguage()->getDefault(); $websites = array(); //$websites['*'] = $menu->getDefault('*'); // TODO add? $languageFilterEnabled = JPluginHelper::isEnabled('system', 'languagefilter'); if (!$languageFilterEnabled || $sef != '1') { // TODO check also if sef is enabled return $websites; } $oldLanguageFilterValue = $app->setLanguageFilter(true); // necessary that $menu->getDefault() works foreach ($languages as $language) { $langCode = $language->lang_code; $default = $menu->getDefault($langCode); if ($default && $default->language == $langCode) { $websites[$langCode] = $prepareElementCallback($language, $langCode, $defaultLangCode, $sefRewrite); } } $app->setLanguageFilter($oldLanguageFilterValue); return $websites; }
/** * Create a route for a document * * @param array|KObjectConfig $config * @param bool $fqr * @param bool $escape * @return string Routed URL */ public function document($config = array(), $fqr = false, $escape = true) { $config = new KObjectConfigJson($config); $config->append(array('admin_link' => JFactory::getApplication()->isAdmin())); // Return a generic link for administrator if ($config->admin_link) { return $this->entity($config); } unset($config->admin_link); $document = $config->entity; $query = array('option' => 'com_docman', 'view' => 'document', 'alias' => $document->alias); if ($document->category_slug) { $query['category_slug'] = $document->category_slug; } if (!$config->Itemid) { $menu = JApplication::getInstance('site')->getMenu()->getActive(); if ($menu && $menu->query['view'] === 'userlist') { $query['Itemid'] = $document->itemid; } } $config->append($query); $route = $this->_getRoute($config, $fqr, $escape); $query = $route->getQuery(true); if (isset($query['view']) && $query['view'] === 'download') { unset($query['format']); $route->setQuery($query); } return $route; }
/** * Check */ public function check() { // check title if (trim($this->title) == '') { $this->setError(JText::_('COM_JKIT_TAG_ERROR_TITLE')); return false; } // / create alias from title, and make safe $this->alias = JApplication::stringURLSafe($this->title); if (trim(str_replace('-', '', $this->alias)) == '') { $this->setError(JText::_('COM_JKIT_TAG_ERROR_ALIAS')); return false; } // verify unique alias $table = JTable::getInstance('Tag', 'JKitTable', array('dbo' => $this->getDbo())); if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) { $this->setError(JText::_('COM_JKIT_TAG_ERROR_ALIAS')); return false; } // check translations titles and alias if ($this->language != '*') { $db = JFactory::getDbo(); $langs = JKitHelperLangs::getLangs(); foreach ($langs as $lang) { if ($this->language != $lang->lang_code) { // check translation title $t_title = trim(JRequest::getString('translation_title_' . $lang->lang_code)); if ($t_title == '') { $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_TITLE', $lang->title)); return false; } // check translation alias $t_alias = JApplication::stringURLSafe($t_title); if (trim(str_replace('-', '', $t_alias)) == '') { $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_ALIAS', $lang->title)); return false; } // check translation repeated alias $q_l = $db->quote($lang->lang_code); $q_a = $db->quote($t_alias); $ref_id = $this->id ? " AND `ref_id` != {$this->id}" : ''; $q1 = "SELECT `ref_id` FROM `#__jkit_translations` WHERE `ref_table` = 'tags' AND `alias` = {$q_a} AND `lang` = {$q_l} {$ref_id}"; $t_ids1 = $db->setQuery($q1)->loadColumn(); if ($t_ids1) { $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_ALIAS', $lang->title)); return false; } // check duplicated tags in different languages $tid = $this->id ? " AND id != {$this->id}" : ''; $q2 = "SELECT `id` FROM `#__jkit_tags` WHERE `alias` = {$q_a} AND `language` = {$q_l} {$tid}"; $t_ids2 = $db->setQuery($q2)->loadColumn(); if ($t_ids2) { $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_ALIAS', $lang->title)); return false; } } } } return true; }
/** * Method to add menu's item. * * @return boolean true on success false on failure. */ function addMenuItems() { $db = JFactory::getDBO(); // Get new component id. $component = JComponentHelper::getComponent('com_community'); $component_id = 0; if (is_object($component) && isset($component->id)) { $component_id = $component->id; } $column_name = JOOMLA_MENU_NAME; $column_cid = JOOMLA_MENU_COMPONENT_ID; // Get the default menu type // 2 Joomla bugs occur in /Administrator mode // Bug 1: JFactory::getApplication('site') failed. It always return id = 'administrator'. // Bug 2: JMenu::getDefault('*') failed. JAdministrator::getLanguageFilter() doesn't exist. // If these 2 bugs are fixed, we can call the following syntax: // $defaultMenuType = JFactory::getApplication('sites')->getMenu()->getDefault()->menutype; jimport('joomla.application.application'); $defaultMenuType = JApplication::getInstance('site')->getMenu()->getDefault('workaround_joomla_bug')->menutype; $query = 'SELECT ' . $db->nameQuote('ordering') . ' ' . 'FROM ' . $db->nameQuote('#__menu') . ' ' . 'ORDER BY ' . $db->nameQuote('ordering') . ' DESC LIMIT 1'; $db->setQuery($query); $order = $db->loadResult() + 1; // Update the existing menu items. $row = JTable::getInstance('menu', 'JTable'); $row->menutype = $defaultMenuType; $row->{$column_name} = 'JomSocial'; $row->alias = 'JomSocial'; $row->link = 'index.php?option=com_community&view=frontpage'; $row->type = 'component'; $row->published = '1'; $row->{$column_cid} = $component_id; $row->ordering = $order; $row->id = null; //new item if (!JOOMLA_LEGACY_VERSION) { $row->language = '*'; } $row->check(); if (!$row->store()) { // $row->getError() return false; } //for version 1.6 only. The parent_id is not updated correctly via JTable if (!JOOMLA_LEGACY_VERSION) { $query = 'UPDATE ' . $db->nameQuote('#__menu') . ' SET `parent_id` = ' . $db->quote(1) . ', `level` = ' . $db->quote(1) . ' WHERE `id` = ' . $db->quote($row->id); $db->setQuery($query); $db->query(); if ($db->getErrorNum()) { return false; } } if (!addDefaultToolbarMenus()) { return false; } // update memu items with component id if (!updateMenuItems()) { return false; } return true; }
public function getHash($seed = '') { if (DiscussHelper::getJoomlaVersion() >= '2.5') { return JApplication::getHash($seed); } return JUtility::getHash($seed); }
/** * Overloaded check function * * @return boolean True on success, false on failure * * @see JTable::check * @since 11.1 */ function check() { $this->menutype = JApplication::stringURLSafe($this->menutype); if (empty($this->menutype)) { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENUTYPE_EMPTY')); return false; } // Sanitise data. if (trim($this->title) == '') { $this->title = $this->menutype; } $db = $this->getDbo(); // Check for unique menutype. $db->setQuery( 'SELECT COUNT(id)' . ' FROM #__menu_types' . ' WHERE menutype = '.$db->quote($this->menutype). ' AND id <> '.(int) $this->id ); if ($db->loadResult()) { $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENUTYPE_EXISTS', $this->menutype)); return false; } return true; }
/** * Sends the Email * * @param array $data Array holding data to be emailed. * * @return void * * @since 2.0 */ public function sendMail($data) { if (!$this->params->get('send_mail') || !$this->params->get('usergroup')) { return; } // Get recipients in the group $recipients = JAccess::getUsersByGroup($this->params->get('usergroup')); if ($recipients) { return; } $query = $this->db->getQuery(true); $query->select($this->db->quoteName(array('email, name')))->from('#__users')->where($this->db->quoteName('sendEmail') . ' = 1')->where($this->db->quoteName('id') . ' IN (' . implode(',', $recipients) . ')'); $this->db->setQuery($query); $recipients = $this->db->loadObjectList(); if ($recipients) { return; } $subject = JText::_('PLG_USER_USERLOGINTRACKING_MAIL_SUBJECT'); $body = JText::sprintf('PLG_USER_USERLOGINTRACKING_MAIL_SUBJECT', $data['user']->username, $data['user']->user->id, $data['timestamp'], $data['ip']); $mailer = JFactory::getMailer(); foreach ($recipients as $recipient) { $mailer->addRecipient($recipient->email, $recipient->name); } $mailer->setSender(array($this->app->get('mailfrom'), $this->app->get('fromname'))); $mailer->setSubject($subject); $mailer->setBody($body); $mailer->isHtml(true); $mailer->Send(); return; }
/** * Overloaded check function * * @return boolean * @see JTable::check * @since 1.5 */ function check() { jimport('joomla.filter.output'); // Set name $this->name = htmlspecialchars_decode($this->name, ENT_QUOTES); // Set alias $this->alias = JApplication::stringURLSafe($this->alias); if (empty($this->alias)) { $this->alias = JApplication::stringURLSafe($this->name); } // Check the publish down date is not earlier than publish up. if (intval($this->publish_down) > 0 && $this->publish_down < $this->publish_up) { // Swap the dates. $temp = $this->publish_up; $this->publish_up = $this->publish_down; $this->publish_down = $temp; } // Set ordering if ($this->state < 0) { // Set ordering to 0 if state is archived or trashed $this->ordering = 0; } else { if (empty($this->ordering)) { // Set ordering to last if ordering was 0 $this->ordering = self::getNextOrder('`catid`=' . $this->_db->Quote($this->catid) . ' AND state>=0'); } } return true; }
function getItemid($poll_id) { $component = JComponentHelper::getComponent('com_mijopolls'); $menus = JApplication::getMenu('site', array()); if (MijopollsHelper::is15()) { $items = $menus->getItems('componentid', $component->id); } else { $items = $menus->getItems('component_id', $component->id); } $match = false; $item_id = ''; if (isset($items)) { foreach ($items as $item) { if (@$item->query['view'] == 'poll' && @$item->query['id'] == $poll_id) { $itemid = $item->id; $match = true; break; } } } if ($match) { $item_id = '&Itemid=' . $itemid; } return $item_id; }
/** * Event onAfterInitialise * * @access public * @param null * @return null */ public function onAfterInitialise() { // If this is the Administrator-application, or if debugging is set, do nothing $application = JFactory::getApplication(); if ($application->isAdmin()) { return; } // Disable browser-detection $application->setDetectBrowser(false); // Detect the language $languageTag = JFactory::getLanguage()->getTag(); $languageInput = JRequest::getString('language'); // Get the bindings $bindings = $this->getBindings(); // Check for the binding of the current language if (!empty($languageInput)) { if (isset($bindings[$languageTag])) { $domain = $bindings[$languageTag]; if (stristr(JURI::current(), $domain) == false) { // Add URL-elements to the domain $domain = $this->getUrlFromDomain($domain); // Replace the current domain with the new domain $currentUrl = JURI::current(); $newUrl = str_replace(JURI::base(), $domain, $currentUrl); // Strip out the sef-language-part $languages = JLanguageHelper::getLanguages('sef'); foreach ($languages as $languageSef => $language) { if ($language->lang_code == $languageTag) { //$newUrl = str_replace('/'.$languageSef.'/', '/', $newUrl); // @todo: This d break; } } // Set the cookie $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie(JApplication::getHash('language'), $languageTag, time() + 365 * 86400, $cookie_path, $cookie_domain); // Redirect $application->redirect($newUrl); $application->close(); } } } else { // Check if the current default language is correct foreach ($bindings as $languageCode => $domain) { if (stristr(JURI::current(), $domain) == true) { // Set the cookie $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie(JApplication::getHash('language'), $languageCode, time() + 365 * 86400, $cookie_path, $cookie_domain); // Change the current default language JRequest::setVar('language', $languageCode); JFactory::getLanguage()->setDefault($languageCode); JFactory::getLanguage()->setLanguage($languageCode); break; } } } }
/** * */ public static function getItems($option = '') { static $items; if (empty($option)) { $com = DSC::getApp(); $option = 'com_' . $com->getName(); } $app = JApplication::getInstance('site'); $menus = $app->getMenu(); if (empty($menus)) { return array(); } if (empty($items)) { $items = array(); } if (empty($items[$option])) { $component = JComponentHelper::getComponent($option); foreach ($menus->getItems('component', $option) as $item) { if (!is_object($item)) { continue; } if ($item->component_id == $component->id || $item->componentid == $component->id || !empty($item->query['option']) && $item->query['option'] == $option) { $items[$option][] = $item; } } } if (empty($items[$option])) { return array(); } return $items[$option]; }
public function createNewUser($params) { $user = new JUser(0); JLoader::import('joomla.application.component.helper'); $usersConfig = JComponentHelper::getParams('com_users'); $newUsertype = $usersConfig->get('new_usertype'); // get the New User Group from com_users' settings if (empty($newUsertype)) { $newUsertype = 2; } $params['groups'] = array($newUsertype); $params['sendEmail'] = 0; // Set the user's default language to whatever the site's current language is if (version_compare(JVERSION, '3.0', 'ge')) { $params['params'] = array('language' => JFactory::getConfig()->get('language')); } else { $params['params'] = array('language' => JFactory::getConfig()->getValue('config.language')); } JLoader::import('joomla.user.helper'); $params['block'] = 0; $randomString = JUserHelper::genRandomPassword(); if (version_compare(JVERSION, '3.2', 'ge')) { $hash = JApplication::getHash($randomString); } else { $hash = JFactory::getApplication()->getHash($randomString); } $params['activation'] = $hash; $user->bind($params); $userIsSaved = $user->save(); if ($userIsSaved) { return $user->id; } else { return false; } }
/** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState() { $basename = JRequest::getString(JApplication::getHash($this->_context . '.basename'), '__SITE__', 'cookie'); $this->setState('basename', $basename); $compressed = JRequest::getInt(JApplication::getHash($this->_context . '.compressed'), 1, 'cookie'); $this->setState('compressed', $compressed); }
/** * Ask user to review JoomlaShine product on JED. * * @return void */ private function askForReview() { // Continue only if this is admin page of JoomlaShine product if (self::$_app->isAdmin() and in_array($this->option, JSNVersion::$products)) { // Get product options $config = JSNConfigHelper::get($this->option); if ($config->get('review_popup', 1)) { // Get time difference $time = time(); $last = $config->get('last_ask_for_review', 0); if ($last == 0) { $last = filemtime(JPATH_ROOT . "/administrator/components/{$this->option}/" . substr($this->option, 4) . '.xml'); } // Check if it's time to ask for review if ($time - $last >= REVIEW_POPUP_PERIOD) { // Load script to popup a modal ask user for review JSNHtmlAsset::loadScript('jsn/askforreview', array('url' => JUri::root() . "plugins/system/jsnframework/libraries/joomlashine/choosers/review/index.php?component={$this->option}", 'language' => JSNUtilsLanguage::getTranslated(array('JSN_EXTFW_CHOOSERS_REVIEW_ON_JED')))); // Get config model $model = new JSNConfigModel(); // Store time of last popup $form = $model->getForm(array(), true, JPATH_ROOT . '/administrator/components/' . $this->option . '/config.xml'); $data = array('last_ask_for_review' => $time); try { // Save new configuration $model->save($form, $data); } catch (Exception $e) { // Do nothing as this is a background process } } } } }
public static function getAliasName($alias) { $alias = JApplication::stringURLSafe($alias); if (trim(str_replace('-', '', $alias)) == '') { $alias = JFactory::getDate()->format("Y-m-d-H-i-s"); } return $alias; }
public function check() { if (trim($this->title) == '') { $this->setError(JText::_('COM_JUDOWNLOAD_TITLE_MUST_NOT_BE_EMPTY')); return false; } if (trim($this->alias) == '') { $this->alias = $this->title; } $this->alias = JApplication::stringURLSafe($this->alias); if (trim(str_replace('-', '', $this->alias)) == '') { $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s'); } if (trim(str_replace(' ', '', $this->description)) == '') { $this->description = ''; } if (!empty($this->metakeyword)) { $bad_characters = array("\n", "\r", "\"", "<", ">"); $after_clean = JString::str_ireplace($bad_characters, "", $this->metakeyword); $keys = explode(',', $after_clean); $clean_keys = array(); foreach ($keys as $key) { if (trim($key)) { $clean_keys[] = trim($key); } } $this->metakeyword = implode(", ", $clean_keys); } return true; }