/** * Method to toggle the featured setting of a list of articles. * * @return void * @since 1.6 */ function featured() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $user = JFactory::getUser(); $ids = JRequest::getVar('cid', array(), '', 'array'); $values = array('featured' => 1, 'unfeatured' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); // Access checks. foreach ($ids as $i => $id) { if (!$user->authorise('core.edit.state', 'com_content.article.' . (int) $id)) { // Prune items that you can't change. unset($ids[$i]); JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); } } if (empty($ids)) { JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Publish the items. if (!$model->featured($ids, $value)) { JError::raiseWarning(500, $model->getError()); } } $this->setRedirect('index.php?option=com_content&view=articles'); }
/** * 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(); }
/** * Generates a list of JSON items. * * @return void */ public function display($tpl = null) { $model = $this->getModel(); $this->item = $this->get('Item'); $this->component = $model->getState($model->getName() . '.component'); $this->section = $model->getState($model->getName() . '.section'); $this->asset_id = $model->getState($model->getName() . '.asset_id'); $this->project_id = $model->getState($model->getName() . '.project_id'); $this->inherit = $model->getState($model->getName() . '.inherit'); if (!$this->asset_id && $this->inherit) { $this->asset_id = $this->getComponentProjectAssetId($this->component, $this->project_id); } $this->rules = $this->getAssetRules(); $this->public_groups = array('1', JComponentHelper::getParams('com_users')->get('guest_usergroup', 1)); $user = JFactory::getUser(); if (!$user->authorise('core.admin', $this->component) && !$user->authorise('core.manage', $this->component)) { JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR')); return false; } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } parent::display($tpl); }
function save() { $data = JRequest::getVar('jform', array(), 'post', 'NONE', 4); $id = (int) $data['id']; if (empty($id)) { if (!igGeneralHelper::authorise('core.igalleryfront.create')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } } else { if (!igGeneralHelper::authorise('core.igalleryfront.edit', $id)) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } } $model = $this->getModel(); $msg = ''; if (!$model->save($data)) { JError::raise(2, 500, $model->getError()); } else { $msg = JText::_('SUCCESSFULLY_SAVED'); } switch ($this->task) { case 'apply': $url = 'index.php?option=com_igallery&view=icategory&id=' . $id; break; case 'save': $url = 'index.php?option=com_igallery&view=categories'; } $this->setRedirect(JRoute::_($url, false), $msg); }
/** * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return mixed A string if successful, otherwise a Error object. */ public function display($tpl = null) { $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // Preprocess the list of items to find ordering divisions. foreach ($this->items as &$item) { $this->ordering[$item->parent_id][] = $item->id; } // Levels filter. $options = array(); $options[] = JHtml::_('select.option', '1', JText::_('J1')); $options[] = JHtml::_('select.option', '2', JText::_('J2')); $options[] = JHtml::_('select.option', '3', JText::_('J3')); $options[] = JHtml::_('select.option', '4', JText::_('J4')); $options[] = JHtml::_('select.option', '5', JText::_('J5')); $options[] = JHtml::_('select.option', '6', JText::_('J6')); $options[] = JHtml::_('select.option', '7', JText::_('J7')); $options[] = JHtml::_('select.option', '8', JText::_('J8')); $options[] = JHtml::_('select.option', '9', JText::_('J9')); $options[] = JHtml::_('select.option', '10', JText::_('J10')); $this->f_levels = $options; // We don't need toolbar in the modal window. if ($this->getLayout() !== 'modal') { $this->addToolbar(); } parent::display($tpl); }
/** * swap the ordering of a record in the Xref tables * @param $direction , 1/-1 The increment to reorder by */ function move($direction, $where = '', $orderingkey = 0) { if (empty($this->_skey)) { vmError('No secondary keys defined in VmTableXarray ' . $this->_tbl); return false; } $skeyId = vRequest::getInt($this->_skey, 0); // Initialize variables $db = JFactory::getDBO(); $cid = vRequest::getInt($this->_pkey); $order = vRequest::getInt('order'); //I found now two times "order" instead of ordering. //This sql is broken $query = 'SELECT `id` FROM `' . $this->_tbl . '` WHERE ' . $this->_pkey . ' = ' . (int) $cid[0] . ' AND `tsmart_category_id` = ' . (int) $skeyId; $db->setQuery($query); $id = $db->loadResult(); $keys = array_keys($order); // TODO next 2 lines not used ???? if ($direction > 0) { $idToSwap = $order[$keys[array_search($id, $keys)] + 1]; } else { $idToSwap = $order[$keys[array_search($id, $keys)] - 1]; } if (isset($cid[0])) { $query = 'UPDATE `' . $this->_tbl . '` ' . ' SET `' . $this->_orderingKey . '` = `' . $this->_orderingKey . '` + ' . $direction . ' WHERE `' . $this->_pkey . '` = ' . (int) $cid[0] . ' AND `' . $this->_skey . '` = ' . (int) $skeyId; $db->setQuery($query); if (!$db->execute()) { $err = $db->getErrorMsg(); JError::raiseError(500, get_class($this) . ':: move ' . $err); } } }
/** * Do our custom ACL checks for the back-end views * * @return boolean */ private function akeebaACLCheck() { // Get the view $view = $this->input->getCmd('view', ''); // Fetch the privilege to check, or use the default (akeeba.configure) // privilege. if (array_key_exists($view, self::$viewACLMap)) { $privilege = self::$viewACLMap[$view]; } else { $privilege = 'akeeba.configure'; } // If an empty privileve is defined do not do any ACL check if (empty($privilege)) { return true; } // Throw an error if we are not allowed access to the view if (!JFactory::getUser()->authorise($privilege, 'com_akeeba')) { $this->setRedirect('index.php?option=com_akeeba&view=cpanel'); JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR')); $this->redirect(); return false; } else { return true; } }
function save() { $productfieldgroup = JTable::getInstance('productFieldGroup', 'jshop'); $post = JRequest::get("post"); JPluginHelper::importPlugin('jshoppingadmin'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeSaveProductFieldGroup', array(&$post)); if (!$productfieldgroup->bind($post)) { JError::raiseWarning("", _JSHOP_ERROR_BIND); $this->setRedirect("index.php?option=com_jshopping&controller=productfieldgroups"); return 0; } if (!$id) { $productfieldgroup->ordering = null; $productfieldgroup->ordering = $productfieldgroup->getNextOrder(); } if (!$productfieldgroup->store()) { JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE); $this->setRedirect("index.php?option=com_jshopping&controller=productfieldgroups"); return 0; } $dispatcher->trigger('onAfterSaveProductFieldGroup', array(&$productfieldgroup)); if ($this->getTask() == 'apply') { $this->setRedirect("index.php?option=com_jshopping&controller=productfieldgroups&task=edit&id=" . $productfieldgroup->id); } else { $this->setRedirect("index.php?option=com_jshopping&controller=productfieldgroups"); } }
public function render($layout, $args = array()) { // prevent render to recurse indefinitely static $count = 0; $count++; if ($count < self::MAX_RENDER_RECURSIONS) { // init vars $parts = explode($this->_separator, $layout); $this->_layout = preg_replace('/[^A-Z0-9_\\.-]/i', '', array_pop($parts)); // render layout if ($__layout = JPath::find($this->_getPath(implode(DIRECTORY_SEPARATOR, $parts)), $this->_layout . $this->_extension)) { // import vars and layout output extract($args); ob_start(); include $__layout; $output = ob_get_contents(); ob_end_clean(); $count--; return $output; } $count--; // raise warning, if layout was not found JError::raiseWarning(0, 'Renderer Layout "' . $layout . '" not found. (' . YUtility::debugInfo(debug_backtrace()) . ')'); return null; } // raise warning, if render recurses indefinitly JError::raiseWarning(0, 'Warning! Render recursed indefinitly. (' . YUtility::debugInfo(debug_backtrace()) . ')'); return null; }
/** * Display the view * * @return mixed False on error, null otherwise. */ function display($tpl = null) { // Initialise variables $state = $this->get('State'); $items = $this->get('Items'); $parent = $this->get('Parent'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } if ($items === false) { JError::raiseError(404, JText::_('COM_CONTENT_ERROR_CATEGORY_NOT_FOUND')); return false; } if ($parent == false) { JError::raiseError(404, JText::_('COM_CONTENT_ERROR_PARENT_CATEGORY_NOT_FOUND')); return false; } $params =& $state->params; $items = array($parent->id => $items); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->maxLevelcat = $params->get('maxLevelcat', -1); $this->assignRef('params', $params); $this->assignRef('parent', $parent); $this->assignRef('items', $items); $this->_prepareDocument(); parent::display($tpl); }
/** * Method to display the view. * * @param string The template file to include * @since 1.5 */ public function display($tpl = null) { // This name will be used to get the model $name = $this->getLayout(); // Check that the name is valid - has an associated model. if (!in_array($name, array('confirm', 'complete'))) { $name = 'default'; } if ('default' == $name) { $formname = 'Form'; } else { $formname = ucfirst($this->_name) . ucfirst($name) . 'Form'; } // Get the view data. $this->form = $this->get($formname); $this->state = $this->get('State'); $this->params = $this->state->params; // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx')); $this->prepareDocument(); parent::display($tpl); }
/** * 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; }
/** * Method to store a file to the FTP server * * @param string $local Path to local file to store on the FTP server * @param string $remote FTP path to file to create * * @throws Exception * * @return boolean True if successful */ public function store($local, $remote = null) { //-- Avoid all this mess by throwing appropriate exceptions !! if (false === parent::store($local, $remote)) { throw new Exception(JError::getError()); } }
/** * Method to display the view. * * @param string $tpl A template file to load. [optional] * * @return mixed A string if successful, otherwise a JError object. * * @since 2.5 */ public function display($tpl = null) { // Load plug-in language files. FinderHelperLanguage::loadPluginLanguage(); $this->items = $this->get('Items'); $this->total = $this->get('Total'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->pluginState = $this->get('pluginState'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); FinderHelper::addSubmenu('index'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } if (!$this->pluginState['plg_content_finder']->enabled) { JFactory::getApplication()->enqueueMessage(JText::_('COM_FINDER_INDEX_PLUGIN_CONTENT_NOT_ENABLED'), 'warning'); } elseif ($this->get('TotalIndexed') === 0) { JFactory::getApplication()->enqueueMessage(JText::_('COM_FINDER_INDEX_NO_DATA') . ' ' . JText::_('COM_FINDER_INDEX_TIP'), 'notice'); } JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); // Configure the toolbar. $this->addToolbar(); $this->sidebar = JHtmlSidebar::render(); parent::display($tpl); }
/** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { ContentHelper::addSubmenu('featured'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->authors = $this->get('Authors'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // Levels filter. $options = array(); $options[] = JHtml::_('select.option', '1', JText::_('J1')); $options[] = JHtml::_('select.option', '2', JText::_('J2')); $options[] = JHtml::_('select.option', '3', JText::_('J3')); $options[] = JHtml::_('select.option', '4', JText::_('J4')); $options[] = JHtml::_('select.option', '5', JText::_('J5')); $options[] = JHtml::_('select.option', '6', JText::_('J6')); $options[] = JHtml::_('select.option', '7', JText::_('J7')); $options[] = JHtml::_('select.option', '8', JText::_('J8')); $options[] = JHtml::_('select.option', '9', JText::_('J9')); $options[] = JHtml::_('select.option', '10', JText::_('J10')); $this->f_levels = $options; $this->addToolbar(); $this->sidebar = JHtmlSidebar::render(); parent::display($tpl); }
public function save() { $app = JFactory::getApplication (); if (! JRequest::checkToken ()) { $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' ); $this->redirectBack (); } // perform security checks $this->user = JFactory::getUser(); if ($this->user->id == 0) { JError::raiseError( 403, JText::_('Access Forbidden') ); return; } $this->config = KunenaFactory::getConfig(); $this->saveUser(); $this->me = KunenaFactory::getUser(); $this->saveProfile(); $this->saveAvatar(); $this->saveSettings(); if (!$this->me->save()) { $app = JFactory::getApplication(); $app->enqueueMessage($this->me->getError(), 'notice'); } $msg = JText::_( 'COM_KUNENA_PROFILE_SAVED' ); $this->setRedirect ( CKunenaLink::GetMyProfileURL($this->user->get('id'), '', false), $msg ); }
/** * Method to toggle the featured setting of a list of teamids. * * @return void * */ public function featured() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $user = JFactory::getUser(); $ids = $this->input->getVar('cid', array(), 'array'); $values = array('featured' => 1, 'unfeatured' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); // Get the model. $model = $this->getModel(); // Access checks. foreach ($ids as $i => $id) { $item = $model->getItem($id); if (!$user->authorise('core.edit.state', 'com_knvbapi2.teamid.' . $id)) { // Prune items that you can't change. unset($ids[$i]); JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); } } if (empty($ids)) { JError::raiseWarning(500, JText::_('COM_KNVBAPI2_TEAMIDS_NO_ITEM_SELECTED')); } else { // Publish the items. if (!$model->featured($ids, $value)) { JError::raiseWarning(500, $model->getError()); } if ($value == 1) { $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_FEATURED', count($ids)); } else { $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_UNFEATURED', count($ids)); } } $this->setRedirect(JRoute::_('index.php?option=com_knvbapi2&view=teamids', false), $message); }
/** * Constructor * * @access protected * @param array $options optional parameters */ function __construct($options = array()) { if (!$this->test()) { return JError::raiseError(404, "The apc extension is not available"); } parent::__construct($options); }
/** * Disables the unsupported eAccelerator caching method, replacing it with the * "file" caching method. * * @return void * * @since 3.2 */ function admin_postinstall_eaccelerator_action() { $prev = new JConfig(); $prev = JArrayHelper::fromObject($prev); $data = array('cacheHandler' => 'file'); $data = array_merge($prev, $data); $config = new Registry('config'); $config->loadArray($data); jimport('joomla.filesystem.path'); jimport('joomla.filesystem.file'); // Set the configuration file path. $file = JPATH_CONFIGURATION . '/configuration.php'; // Get the new FTP credentials. $ftp = JClientHelper::getCredentials('ftp', true); // Attempt to make the file writeable if using FTP. if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) { JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE')); } // Attempt to write the configuration file as a PHP class named JConfig. $configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false)); if (!JFile::write($file, $configuration)) { JFactory::getApplication()->enqueueMessage(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error'); return; } // Attempt to make the file unwriteable if using FTP. if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) { JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE')); } }
/** * Test the _ method. * * @return void * * @since 11.1 */ public function test_() { // Add the include path to html test files. JHtml::addIncludePath(array(__DIR__ . '/html/testfiles')); // Test the class method was called and the arguments passed correctly. $this->assertThat(JHtml::_('inspector.method1', 'argument1', 'argument2'), $this->equalTo('JHtmlInspector::method1'), 'JHtmlInspector::method1 could not be called.'); $this->assertThat(JHtmlInspector::$arguments[0], $this->equalTo(array('argument1', 'argument2')), 'The arguments where not correctly passed to JHtmlInspector::method1.'); // Test error cases. // Prepare the error handlers. $this->saveErrorHandlers(); $errorCallback = $this->getMock('errorCallback', array('error1', 'error2', 'error3')); $errorCallback->expects($this->once())->method('error1'); $errorCallback->expects($this->once())->method('error2'); $errorCallback->expects($this->once())->method('error3'); // Ensure that we get an error if we can find the file but the file does not contain the class. JError::setErrorHandling(E_ERROR, 'callback', array($errorCallback, 'error1')); $this->assertThat(JHtml::_('empty.anything'), $this->isFalse()); // Ensure that we get an error if we can't find the file. JError::setErrorHandling(E_ERROR, 'callback', array($errorCallback, 'error2')); $this->assertThat(JHtml::_('nofile.anything'), $this->isFalse()); // Ensure that we get an error if we have the class but not the method. JError::setErrorHandling(E_ERROR, 'callback', array($errorCallback, 'error3')); $this->assertThat(JHtml::_('inspector.nomethod'), $this->isFalse()); // Restore the error handlers. $this->setErrorHandlers($this->savedErrorState); }
/** * Display the Hello World view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ function display($tpl = null) { $app = JFactory::getApplication(); $context = "business.list.admin.business"; // Get data from the model $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->filter_order = $app->getUserStateFromRequest($context . 'filter_order', 'filter_order', 'businessName', 'cmd'); $this->filter_order_Dir = $app->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', 'asc', 'cmd'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } BusinessHelper::addSubmenu('logstamps'); // Set the toolbar $this->addToolBar(); // Display the template parent::display($tpl); // Set the document $this->setDocument(); }
/** * Display the view */ public function display($tpl = null) { if ($this->getLayout() == 'pagebreak') { // TODO: This is really dogy - should change this one day. $eName = JRequest::getVar('e_name'); $eName = preg_replace('#[^A-Z0-9\\-\\_\\[\\]]#i', '', $eName); $document = JFactory::getDocument(); $document->setTitle(JText::_('COM_CONTENT_PAGEBREAK_DOC_TITLE')); $this->assignRef('eName', $eName); parent::display($tpl); return; } // Initialiase variables. $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->state = $this->get('State'); $this->canDo = ContentHelper::getActions($this->state->get('filter.category_id')); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); }
/** * save function * * @return nothing */ public function save() { //$ids = JRequest::getVar('cid', array(), '', 'array'); // Get posted form variables. $task = $this->getTask(); $data = JRequest::getVar('jform', array(), 'post', 'array'); //echo "ECHO:: ".$data['id']; // echo " task:: ".$task; $session =& JFactory::getSession(); $articleid = $session->get('articleid'); $fieldsattachid = $session->get('fieldsattachid'); $model = $this->getModel(); if (!$model->store()) { return JError::raiseWarning(500, $model->getError()); } if ($task == "apply") { $msg = ""; $lastid = $data['id']; if (empty($lastid)) { $lastid = $model->lastid; } $link = 'index.php?option=com_fieldsattach&view=fieldsattachimage&layout=edit&id=' . $lastid . '&tmpl=component&fieldsattachid=' . $fieldsattachid . '&reload=true'; $this->setRedirect($link, $msg); } if ($task == "save") { $msg = ""; //$link= 'index.php?option=com_fieldsattach&view=fieldsattachimages&tmpl=component&articleid='.$articleid.'&fieldsattachid='.$fieldsattachid.'&reset=1' ; $link = 'index.php?option=com_fieldsattach&view=fieldsattachimages&tmpl=component&fieldsattachid=' . $fieldsattachid; $this->setRedirect($link, $msg); } }
/** * Removes an item. * * @return void * * @since 1.6 */ public function delete() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $user = JFactory::getUser(); $ids = $this->input->get('cid', array(), 'array'); // Access checks. foreach ($ids as $i => $id) { if (!$user->authorise('core.delete', 'com_content.article.' . (int) $id)) { // Prune items that you can't delete. unset($ids[$i]); JError::raiseNotice(403, JText::_('JERROR_CORE_DELETE_NOT_PERMITTED')); } } if (empty($ids)) { JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Remove the items. if (!$model->featured($ids, 0)) { JError::raiseWarning(500, $model->getError()); } } $this->setRedirect('index.php?option=com_content&view=featured'); }
/** * Method to get the field options. * * @return array The field option objects. * @since 1.6 */ public function getOptions() { // Initialize variables. $options = array(); /* * SQL query: * * SELECT DISTINCT (school) AS value, school AS text * FROM #__osbitusers * ORDER BY school */ $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('DISTINCT (school) AS value, school AS text'); $query->from('#__osbitusers'); $query->order('school'); // Get the options. $db->setQuery($query); $options = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } return $options; }
function publish() { // global $option; $cid = JRequest::getVar('cid', array()); $row = JTable::getInstance('twines', 'Table'); $publish = 1; if ($this->getTask() == 'unpublish') { $publish = 0; } if (!$row->publish($cid, $publish)) { JError::raiseError(500, $row->getError()); } $s = ''; if (count($cid) > 1) { $s = 's'; } $msg = 'Page' . $s; if ($this->getTask() == 'unpublish') { $msg .= ' unpublished'; } else { $msg .= ' published'; } // $this->setRedirect('index.php?option=' . $option, $msg); $this->setRedirect('index.php?option=com_battle&view=twines', $msg); }
/** * Constructor * * @param array $options Optional parameters. * * @since 11.1 */ public function __construct($options = array()) { if (!$this->test()) { return JError::raiseError(404, JText::_('JLIB_SESSION_EACCELERATOR_EXTENSION_NOT_AVAILABLE')); } parent::__construct($options); }
/** * Displays the list view * @param string $tpl */ public function display($tpl = null) { $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } TagnyilvantartasHelper::addSubmenu('cimkeks'); $this->addToolbar(); if(!version_compare(JVERSION,'3','<')){ $this->sidebar = JHtmlSidebar::render(); } if(version_compare(JVERSION,'3','<')){ $tpl = "25"; } parent::display($tpl); }
/** * Displays the form * * @param string $tpl - The tmpl * * @return mixed|void */ public function display($tpl = null) { if (MatukioHelperSettings::getSettings('rss_feed', 1) == 0) { JError::raiseError(403, JText::_("ALERTNOTAUTH")); } $database = JFactory::getDBO(); $neudatum = MatukioHelperUtilsDate::getCurrentDate(); $where = array(); $database->setQuery("SELECT id, access FROM #__categories WHERE extension='" . JFactory::getApplication()->input->get('option') . "'"); $cats = $database->loadObjectList(); $allowedcat = array(); foreach ($cats as $cat) { if ($cat->access < 1) { $allowedcat[] = $cat->id; } } if (count($allowedcat) > 0) { $allowedcat = implode(',', $allowedcat); $where[] = "a.catid IN ({$allowedcat})"; } $where[] = "a.published = '1'"; $where[] = "a.end > '{$neudatum}'"; $where[] = "a.booked > '{$neudatum}'"; $database->setQuery("SELECT a.*, r.*, cat.title AS category FROM #__matukio_recurring AS r\r\n\t\t LEFT JOIN #__matukio AS a ON r.event_id = a.id\r\n\t\t LEFT JOIN #__categories AS cat ON cat.id = a.catid" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nORDER BY r.begin ASC" . "\nLIMIT 0, 1000"); $rows = $database->loadObjectList(); $this->rows = $rows; parent::display($tpl); }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. * * @since 11.4 */ protected function getOptions() { // Initialise variables $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); } if ($db->getErrorMsg()) { JError::raiseWarning(500, JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY')); return ''; } } else { JError::raiseWarning(500, JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY')); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }