Пример #1
3
 /**
  * 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');
 }
Пример #2
1
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * @since	1.6
  */
 protected function getInput()
 {
     // Initialise variables.
     $html = array();
     $recordId = (int) $this->form->getValue('id');
     $size = ($v = $this->element['size']) ? ' size="' . $v . '"' : '';
     $class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"';
     // Get a reverse lookup of the base link URL to Title
     $model = JModel::getInstance('menutypes', 'menusModel');
     $rlu = $model->getReverseLookup();
     switch ($this->value) {
         case 'url':
             $value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
             break;
         case 'alias':
             $value = JText::_('COM_MENUS_TYPE_ALIAS');
             break;
         case 'separator':
             $value = JText::_('COM_MENUS_TYPE_SEPARATOR');
             break;
         default:
             $link = $this->form->getValue('link');
             // Clean the link back to the option, view and layout
             $value = JText::_(JArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link)));
             break;
     }
     // Load the javascript and css
     JHtml::_('behavior.framework');
     JHtml::_('behavior.modal');
     $html[] = '<input type="text" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />';
     $html[] = '<input type="button" value="' . JText::_('JSELECT') . '" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&recordId=' . $recordId) . '\'})" />';
     $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
     return implode("\n", $html);
 }
Пример #3
0
 /**
  * Method to set the home property for a list of items
  *
  * @since	1.6
  */
 function setDefault()
 {
     // Check for request forgeries
     JSession::checkToken('request') or die(JText::_('JINVALID_TOKEN'));
     // Get items to publish from the request.
     $cid = JRequest::getVar('cid', array(), '', 'array');
     $data = array('setDefault' => 1, 'unsetDefault' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($data, $task, 0, 'int');
     if (empty($cid)) {
         JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         JArrayHelper::toInteger($cid);
         // Publish the items.
         if (!$model->setHome($cid, $value)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             if ($value == 1) {
                 $ntext = 'COM_MENUS_ITEMS_SET_HOME';
             } else {
                 $ntext = 'COM_MENUS_ITEMS_UNSET_HOME';
             }
             $this->setMessage(JText::plural($ntext, count($cid)));
         }
     }
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
 }
Пример #4
0
 /**
  * Save data into the DB.
  *
  * @param array $data The data of item
  *
  * @return  int
  */
 public function save($data)
 {
     $id = JArrayHelper::getValue($data, "id");
     $name = JArrayHelper::getValue($data, "name");
     $default = JArrayHelper::getValue($data, "default");
     $params = JArrayHelper::getValue($data, "params");
     // Encode parameters to JSON format.
     if (!empty($params)) {
         $params = json_encode($params);
     } else {
         $params = null;
     }
     // Load a record from the database
     $row = $this->getTable();
     /** @var $row UserIdeasTableStatus */
     $row->load($id);
     $row->set("name", $name);
     $row->set("default", $default);
     $row->set("params", $params);
     $this->prepareTable($row);
     $row->store(true);
     // Set the item as default.
     if ($row->get("default")) {
         $this->setDefault($row->get("id"));
     }
     return $row->get("id");
 }
Пример #5
0
 /**
  * Overloaded bind function to pre-process the params.
  *
  * @param    array        Named array
  *
  * @return   null|string  null is operation was satisfactory, otherwise returns an error
  * @see      JTable::bind
  */
 public function bind($array, $ignore = '')
 {
     // For Fields group
     // Convert jform[fields_group][field] to jform[field] or JTable cannot bind data.
     // ==========================================================================================
     $data = array();
     $array = AKHelper::_('array.pivotFromTwoDimension', $array);
     // Set field['param_xxx'] to params
     // ==========================================================================================
     if (empty($array['params'])) {
         $array['params'] = AKHelper::_('array.pivotFromPrefix', 'param_', $array, JArrayHelper::getValue($array, 'params', array()));
     }
     // Set params to JRegistry
     // ==========================================================================================
     if (isset($array['params']) && is_array($array['params'])) {
         $registry = new JRegistry();
         $registry->loadArray($array['params']);
         $array['params'] = (string) $registry;
     }
     // Bind the rules.
     // ==========================================================================================
     if (isset($array['rules']) && is_array($array['rules'])) {
         $rules = new JAccessRules($array['rules']);
         $this->setRules($rules);
     }
     return parent::bind($array, $ignore);
 }
Пример #6
0
 public function toggleInList()
 {
     // Check for request forgeries
     JRequest::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // Get items to publish from the request.
     $cid = JRequest::getVar('cid', array(), '', 'array');
     $data = array('showInListView' => 1, 'hideFromListView' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($data, $task, 0, 'int');
     if (empty($cid)) {
         JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         JArrayHelper::toInteger($cid);
         // Publish the items.
         if (!$model->addToListView($cid, $value)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             if ($value == 1) {
                 $ntext = $this->text_prefix . '_N_ITEMS_ADDED_TO_LIST_VIEW';
             } else {
                 $ntext = $this->text_prefix . '_N_ITEMS_REMOVED_FROM_LIST_VIEW';
             }
             $this->setMessage(JText::plural($ntext, count($cid)));
         }
     }
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
 }
Пример #7
0
function JHP_Geshi_replacer(&$matches)
{
    //	print_r($matches);
    //// 	die();
    jimport('geshi.geshi');
    jimport('domit.xml_saxy_shared');
    $args = SAXY_Parser_Base::parseAttributes($matches[1]);
    // 	print_r($args);
    $text = $matches[2];
    $lang = JArrayHelper::getValue($args, 'lang', 'phpz');
    $lines = JArrayHelper::getValue($args, 'lines', 'true');
    $html_entities_match = array("|\\<br \\/\\>|", "#<#", "#>#", "|&#39;|", '#&quot;#', '#&nbsp;#');
    $html_entities_replace = array("\n", '&lt;', '&gt;', "'", '"', ' ');
    $text = preg_replace($html_entities_match, $html_entities_replace, $text);
    $text = str_replace('&lt;', '<', $text);
    $text = str_replace('&gt;', '>', $text);
    $text = str_replace("\t", '  ', $text);
    $geshi = new GeSHi($text, $lang);
    if ($lines == 'true') {
        $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
    }
    $text = $geshi->parse_code();
    $text = '???' . $text . '???';
    return $text;
}
Пример #8
0
 /**
  * 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;
         }
     }
 }
Пример #9
0
 /**
  * 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');
 }
Пример #10
0
 public function save($key = null, $urlVar = null)
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $data = $this->input->post->get('jform', array(), 'array');
     $itemId = JArrayHelper::getValue($data, "id");
     $redirectOptions = array("task" => $this->getTask(), "id" => $itemId);
     $model = $this->getModel();
     /** @var $model UserIdeasModelItem * */
     $form = $model->getForm($data, false);
     /** @var $form JForm * */
     if (!$form) {
         throw new Exception(JText::_("COM_USERIDEAS_ERROR_FORM_CANNOT_BE_LOADED"), 500);
     }
     // Validate the form
     $validData = $model->validate($form, $data);
     // Check for errors
     if ($validData === false) {
         $this->displayNotice($form->getErrors(), $redirectOptions);
         return;
     }
     try {
         $itemId = $model->save($validData);
         $redirectOptions["id"] = $itemId;
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_USERIDEAS_ERROR_SYSTEM'));
     }
     $this->displayMessage(JText::_('COM_USERIDEAS_ITEM_SAVED'), $redirectOptions);
 }
Пример #11
0
 /**
  * Method to change the block status on a record.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function changeBlock()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Initialise variables.
     $ids = JRequest::getVar('cid', array(), '', 'array');
     $values = array('block' => 1, 'unblock' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('COM_USERS_USERS_NO_ITEM_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Change the state of the records.
         if (!$model->block($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             if ($value == 1) {
                 $this->setMessage(JText::plural('COM_USERS_N_USERS_BLOCKED', count($ids)));
             } elseif ($value == 0) {
                 $this->setMessage(JText::plural('COM_USERS_N_USERS_UNBLOCKED', count($ids)));
             }
         }
     }
     $this->setRedirect('index.php?option=com_users&view=users');
 }
Пример #12
0
 function getTree(&$xmap, &$parent, &$params)
 {
     $link_query = parse_url($parent->link);
     parse_str(html_entity_decode($link_query['query']), $link_vars);
     $view = JArrayHelper::getValue($link_vars, 'view', 0);
     $include_categories = JArrayHelper::getValue($params, 'include_categories', 1, '');
     $include_categories = $include_categories == 1 || $include_categories == 2 && $xmap->view == 'xml' || $include_categories == 3 && $xmap->view == 'html' || $xmap->view == 'navigator';
     $params['include_categories'] = $include_categories;
     $include_items = JArrayHelper::getValue($params, 'include_items', 1, '');
     $include_items = $include_items == 1 || $include_items == 2 && $xmap->view == 'xml' || $include_items == 3 && $xmap->view == 'html' || $xmap->view == 'navigator';
     $params['include_items'] = $include_items;
     $priority = JArrayHelper::getValue($params, 'cat_priority', $parent->priority, '');
     $changefreq = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq, '');
     if ($priority == '-1') {
         $priority = $parent->priority;
     }
     if ($changefreq == '-1') {
         $changefreq = $parent->changefreq;
     }
     $params['cat_priority'] = $priority;
     $params['cat_changefreq'] = $changefreq;
     $priority = JArrayHelper::getValue($params, 'item_priority', $parent->priority, '');
     $changefreq = JArrayHelper::getValue($params, 'item_changefreq', $parent->changefreq, '');
     if ($priority == '-1') {
         $priority = $parent->priority;
     }
     if ($changefreq == '-1') {
         $changefreq = $parent->changefreq;
     }
     $params['item_priority'] = $priority;
     $params['item_changefreq'] = $changefreq;
     self::getCategoryTree($xmap, $parent, $params);
 }
 /**
  * @param XmapDisplayerInterface $xmap
  * @param stdClass $parent
  * @param array $params
  */
 public static function getTree($xmap, stdClass $parent, array &$params)
 {
     $uri = new JUri($parent->link);
     if (!self::$enabled || !in_array($uri->getVar('view'), self::$views)) {
         return;
     }
     $params['include_entries'] = JArrayHelper::getValue($params, 'include_entries', 1);
     $params['include_entries'] = $params['include_entries'] == 1 || $params['include_entries'] == 2 && $xmap->view == 'xml' || $params['include_entries'] == 3 && $xmap->view == 'html';
     $params['include_expired_entries'] = JArrayHelper::getValue($params, 'include_expired_entries', 0);
     $params['include_expired_entries'] = $params['include_expired_entries'] == 1 || $params['include_expired_entries'] == 2 && $xmap->view == 'xml' || $params['include_expired_entries'] == 3 && $xmap->view == 'html';
     $params['category_priority'] = JArrayHelper::getValue($params, 'category_priority', $parent->priority);
     $params['category_changefreq'] = JArrayHelper::getValue($params, 'category_changefreq', $parent->changefreq);
     if ($params['category_priority'] == -1) {
         $params['category_priority'] = $parent->priority;
     }
     if ($params['category_changefreq'] == -1) {
         $params['category_changefreq'] = $parent->changefreq;
     }
     $params['entry_priority'] = JArrayHelper::getValue($params, 'entry_priority', $parent->priority);
     $params['entry_changefreq'] = JArrayHelper::getValue($params, 'entry_changefreq', $parent->changefreq);
     if ($params['entry_priority'] == -1) {
         $params['entry_priority'] = $parent->priority;
     }
     if ($params['entry_changefreq'] == -1) {
         $params['entry_changefreq'] = $parent->changefreq;
     }
     switch ($uri->getVar('view')) {
         case 'front':
             self::getCategoryTree($xmap, $parent, $params, 0);
             break;
         case 'list':
             self::getEntries($xmap, $parent, $params, $uri->getVar('catid'));
             break;
     }
 }
Пример #14
0
 /**
  * Stick items
  *
  * @return  void
  *
  * @since   1.6
  */
 public function sticky_publish()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $ids = $this->input->get('cid', array(), 'array');
     $values = array('sticky_publish' => 1, 'sticky_unpublish' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('COM_BANNERS_NO_BANNERS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Change the state of the records.
         if (!$model->stick($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             if ($value == 1) {
                 $ntext = 'COM_BANNERS_N_BANNERS_STUCK';
             } else {
                 $ntext = 'COM_BANNERS_N_BANNERS_UNSTUCK';
             }
             $this->setMessage(JText::plural($ntext, count($ids)));
         }
     }
     $this->setRedirect('index.php?option=com_banners&view=banners');
 }
Пример #15
0
 /**
  * Method to get a form object.
  *
  * @param   string   $name     The name of the form.
  * @param   string   $source   The form source. Can be XML string if file flag is set to false.
  * @param   array    $options  Optional array of options for the form creation.
  * @param   boolean  $clear    Optional argument to force load a new form.
  * @param   mixed    $xpath    An optional xpath to search for the fields.
  *
  * @return  mixed  JForm object on success, False on error.
  */
 protected function loadForm($name, $source = null, $options = array(), $clear = false, $xpath = false)
 {
     static $form = null;
     // Handle the optional arguments.
     $options['control'] = JArrayHelper::getValue($options, 'control', false);
     // Create a signature hash.
     $hash = md5($source . serialize($options));
     // Check if we can use a previously loaded form.
     if (isset($this->_forms[$hash]) && !$clear) {
         return $this->_forms[$hash];
     }
     // Get the form.
     RForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     RForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     try {
         $form = RForm::getInstance($name, $source, $options, false, $xpath);
         if (isset($options['load_data']) && $options['load_data']) {
             // Get the data for the form.
             $data = $this->loadFormData();
         } else {
             $data = array();
         }
         // Allow for additional modification of the form, and events to be triggered.
         // We pass the data because plugins may require it.
         $this->preprocessForm($form, $data);
         // Load the data into the form after the plugins have operated.
         $form->bind($data);
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Store the form for later.
     $this->_forms[$hash] = $form;
     return $form;
 }
Пример #16
0
 /**
  * get the list's active/selected plug-ins
  * @return array
  */
 public function getPlugins()
 {
     $item = $this->getItem();
     // load up the active plug-ins
     $dispatcher =& JDispatcher::getInstance();
     $plugins = JArrayHelper::getValue($item->params, 'plugins', array());
     $return = array();
     //JModel::addIncludePath(JPATH_SITE.DS.'components'.DS.'com_fabrik'.DS.'models');
     $pluginManager = JModel::getInstance('Pluginmanager', 'FabrikFEModel');
     //@todo prob wont work for any other model that extends this class except for the form/list model
     switch (get_class($this)) {
         case 'FabrikModelList':
             $class = 'list';
             break;
         default:
             $class = 'form';
     }
     $feModel = JModel::getInstance($class, 'FabrikFEModel');
     $feModel->setId($this->getState($class . '.id'));
     foreach ($plugins as $x => $plugin) {
         $o = $pluginManager->getPlugIn($plugin, $this->pluginType);
         $o->getJForm()->model = $feModel;
         $data = (array) $item->params;
         $str = $o->onRenderAdminSettings($data, $x);
         //$str = str_replace(array("\n", "\r"), "", $str);
         $str = addslashes(str_replace(array("\n", "\r"), "", $str));
         $location = $this->getPluginLocation($x);
         $event = $this->getPluginEvent($x);
         $return[] = array('plugin' => $plugin, 'html' => $str, 'location' => $location, 'event' => $event);
     }
     return $return;
 }
Пример #17
0
 public function getForm($data = array(), $loadData = true)
 {
     // Get the form.
     if (empty($data)) {
         $item = $this->getItem();
         $wgtype = $item->wgtype;
     } else {
         $wgtype = JArrayHelper::getValue($data, 'widget');
     }
     $this->setState('item.wgtype', $wgtype);
     $form = $this->loadForm('com_bt_socialconnect.widget', 'widget', array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     if (!$this->canEditState((object) $data)) {
         $form->setFieldAttribute('ordering', 'disabled', 'true');
         $form->setFieldAttribute('published', 'disabled', 'true');
         $form->setFieldAttribute('publish_up', 'disabled', 'true');
         $form->setFieldAttribute('publish_down', 'disabled', 'true');
         $form->setFieldAttribute('ordering', 'filter', 'unset');
         $form->setFieldAttribute('published', 'filter', 'unset');
         $form->setFieldAttribute('publish_up', 'filter', 'unset');
         $form->setFieldAttribute('publish_down', 'filter', 'unset');
     }
     return $form;
 }
Пример #18
0
 /**
  * Save an item
  */
 public function save($key = null, $urlVar = null)
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     /** @var $app JApplicationAdministrator */
     $data = $app->input->post->get('jform', array(), 'array');
     $itemId = JArrayHelper::getValue($data, "id");
     $redirectData = array("task" => $this->getTask(), "id" => $itemId);
     $model = $this->getModel();
     /** @var $model SocialCommunityModelCountry */
     $form = $model->getForm($data, false);
     /** @var $form JForm */
     if (!$form) {
         throw new Exception(JText::_("COM_SOCIALCOMMUNITY_ERROR_FORM_CANNOT_BE_LOADED"));
     }
     // Validate the form
     $validData = $model->validate($form, $data);
     // Check for errors
     if ($validData === false) {
         $this->displayNotice($form->getErrors(), $redirectData);
         return;
     }
     try {
         $itemId = $model->save($validData);
         $redirectData["id"] = $itemId;
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM'));
     }
     $this->displayMessage(JText::_('COM_SOCIALCOMMUNITY_COUNTRY_SAVED'), $redirectData);
 }
Пример #19
0
 /**
  * Enable/Disable an extension (if supported).
  *
  * @since	1.6
  */
 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::_('COM_INSTALLER_ERROR_NO_EXTENSIONS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel('manage');
         // Change the state of the records.
         if (!$model->publish($ids, $value)) {
             JError::raiseWarning(500, implode('<br />', $model->getErrors()));
         } else {
             if ($value == 1) {
                 $ntext = 'COM_INSTALLER_N_EXTENSIONS_PUBLISHED';
             } else {
                 if ($value == 0) {
                     $ntext = 'COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED';
                 }
             }
             $this->setMessage(JText::plural($ntext, count($ids)));
         }
     }
     $this->setRedirect(JRoute::_('index.php?option=com_installer&view=manage', false));
 }
Пример #20
0
 /**
  * looks at the validation condition & evaulates it
  * if evaulation is true then the validation rule is applied
  *@return bol apply validation
  */
 function shouldValidate($data, $c)
 {
     $params =& $this->getParams();
     $post = JRequest::get('post');
     $v = $params->get($this->_pluginName . '-validation_condition', '', '_default', 'array', $c);
     if (!array_key_exists($c, $v)) {
         return true;
     }
     $condition = $v[$c];
     if ($condition == '') {
         return true;
     }
     $w = new FabrikWorker();
     // $$$ rob merge join data into main array so we can access them in parseMessageForPlaceHolder()
     $joindata = JArrayHelper::getValue($post, 'join', array());
     foreach ($joindata as $joinid => $joind) {
         foreach ($joind as $k => $v) {
             if ($k !== 'rowid') {
                 $post[$k] = $v;
             }
         }
     }
     $condition = trim($w->parseMessageForPlaceHolder($condition, $post));
     // $$$ hugh - this screws things up if it's more than one line of code.
     /*
     if (substr(strtolower($condition ), 0, 6) !== 'return') {
     	$condition = "return $condition";
     }
     */
     $res = @eval($condition);
     if (is_null($res)) {
         return true;
     }
     return $res;
 }
Пример #21
0
 /**
  * Render the profiler log data, and echo it..
  *
  * @param   string   $namespace The JProfiler instance ID. Default is the core profiler "Application".
  * @param   boolean  $asString  Return as string.
  *
  * @return  string
  */
 public static function render($namespace = 'Windwalker', $asString = false)
 {
     $app = Container::getInstance()->get('app');
     if ($namespace == 'core' || !$namespace) {
         $namespace = 'Application';
     }
     $buffer = 'No Profiler data.';
     if (isset(self::$profiler[$namespace])) {
         $_PROFILER = self::$profiler[$namespace];
         $buffer = $_PROFILER->getBuffer();
         $buffer = implode("\n<br />\n", $buffer);
     } else {
         $buffer = $app->getUserState('windwalker.system.profiler.' . $namespace);
         $buffer = $buffer ? implode("\n<br />\n", $buffer) : '';
     }
     $buffer = $buffer ? $buffer : 'No Profiler data.';
     // Get last page logs
     $state_buffer = \JArrayHelper::getValue(self::$stateBuffer, $namespace);
     if ($state_buffer) {
         $state_buffer = implode("\n<br />\n", $state_buffer);
         $buffer = $state_buffer . "\n<br />---------<br />\n" . $buffer;
     }
     // Render
     $buffer = "<pre><h3>WindWalker Debug [namespace: {$namespace}]: </h3>" . $buffer . '</pre>';
     $app->setUserState('windwalker.system.profiler.' . $namespace, '');
     if ($asString) {
         return $buffer;
     }
     echo $buffer;
     return '';
 }
Пример #22
0
 /**
  * Enable auto-update.
  *
  * @throws  Exception
  * @return  void
  */
 public function enableau()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $redirectOptions = array("view" => "urls");
     $cid = $this->input->post->get("cid", array(), "array");
     $cid = Joomla\Utilities\ArrayHelper::toInteger($cid);
     $data = array('enableau' => 1, 'disableau' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($data, $task, 0, 'int');
     if (empty($cid)) {
         $this->displayNotice(JText::_($this->text_prefix . '_ERROR_NO_ITEM_SELECTED'), $redirectOptions);
         return;
     }
     try {
         $model = $this->getModel();
         $model->updateAutoupdate($cid, $value);
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_ITPMETA_ERROR_SYSTEM'));
     }
     if ($value == 1) {
         $msg = $this->text_prefix . '_N_ITEMS_AUTOUPDATE_ENABLED';
     } else {
         $msg = $this->text_prefix . '_N_ITEMS_AUTOUPDATE_DISABLED';
     }
     $this->displayMessage(JText::plural($msg, count($cid)), $redirectOptions);
 }
Пример #23
0
 /**
  * @param XmapDisplayerInterface $xmap
  * @param stdClass $parent
  * @param array $params
  */
 public static function getTree($xmap, stdClass $parent, array &$params)
 {
     $uri = new JUri($parent->link);
     if ($xmap->isNews || !self::$enabled || !in_array($uri->getVar('view'), self::$views)) {
         return;
     }
     $params['include_topics'] = JArrayHelper::getValue($params, 'include_topics', 1);
     $params['include_topics'] = $params['include_topics'] == 1 || $params['include_topics'] == 2 && $xmap->view == 'xml' || $params['include_topics'] == 3 && $xmap->view == 'html';
     $params['include_pagination'] = JArrayHelper::getValue($params, 'include_pagination', 0);
     $params['include_pagination'] = $params['include_pagination'] == 1 || $params['include_pagination'] == 2 && $xmap->view == 'xml' || $params['include_pagination'] == 3 && $xmap->view == 'html';
     $params['cat_priority'] = JArrayHelper::getValue($params, 'cat_priority', $parent->priority);
     $params['cat_priority'] = $params['cat_priority'] == -1 ? $parent->priority : $params['cat_priority'];
     $params['cat_changefreq'] = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq);
     $params['cat_changefreq'] = $params['cat_changefreq'] == -1 ? $parent->changefreq : $params['cat_changefreq'];
     $params['topic_priority'] = JArrayHelper::getValue($params, 'topic_priority', $parent->changefreq);
     $params['topic_priority'] = $params['topic_priority'] == -1 ? $parent->priority : $params['topic_priority'];
     $params['topic_changefreq'] = JArrayHelper::getValue($params, 'topic_changefreq', $parent->changefreq);
     $params['topic_changefreq'] = $params['topic_changefreq'] == -1 ? $parent->changefreq : $params['topic_changefreq'];
     if ($params['include_topics']) {
         if ((int) ($limit = JArrayHelper::getValue($params, 'max_topics', 0))) {
             $params['limit'] = $limit;
         } else {
             $params['limit'] = 0;
         }
         if ((int) ($days = JArrayHelper::getValue($params, 'max_age', 0))) {
             $params['days'] = JFactory::getDate()->toUnix() - intval($days) * 86400;
         } else {
             $params['days'] = '';
         }
     }
     self::getCategoryTree($xmap, $parent, $params, $uri->getVar('catid', 0));
 }
Пример #24
0
 /**
  * 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);
 }
Пример #25
0
 /**
  * Save data into the DB
  *
  * @param array $data   The data of item
  *
  * @return  int        Item ID
  */
 public function save($data)
 {
     $id = JArrayHelper::getValue($data, "id");
     $title = JArrayHelper::getValue($data, "title");
     $subject = JArrayHelper::getValue($data, "subject");
     $senderName = JArrayHelper::getValue($data, "sender_name");
     $senderEmail = JArrayHelper::getValue($data, "sender_email");
     $body = JArrayHelper::getValue($data, "body");
     if (!$senderName) {
         $senderName = null;
     }
     if (!$senderEmail) {
         $senderEmail = null;
     }
     // Load a record from the database
     $row = $this->getTable();
     $row->load($id);
     $row->set("title", $title);
     $row->set("subject", $subject);
     $row->set("sender_name", $senderName);
     $row->set("sender_email", $senderEmail);
     $row->set("body", $body);
     $this->prepareTable($row);
     $row->store(true);
     return $row->get("id");
 }
Пример #26
0
 /**
  * Constructor
  *
  * @param   array              $config    An array of configuration options (name, state, dbo, table_path, ignore_request).
  * @param   JoomlaContainer    $container Service container.
  * @param   \JRegistry         $state     The model state.
  * @param   \JDatabaseDriver   $db        The database adapter.
  *
  * @throws \Exception
  */
 public function __construct($config = array(), JoomlaContainer $container = null, \JRegistry $state = null, \JDatabaseDriver $db = null)
 {
     // Guess the option from the class name (Option)Model(View).
     if (empty($this->prefix)) {
         $r = null;
         if (!preg_match('/(.*)Model/i', get_class($this), $r)) {
             throw new \Exception(\JText::_('JLIB_APPLICATION_ERROR_MODEL_GET_NAME'), 500);
         }
         $this->prefix = strtolower($r[1]);
     }
     $this->option = 'com_' . $this->prefix;
     // Guess name
     $this->name = $this->name ?: \JArrayHelper::getValue($config, 'name', $this->getName());
     // Register the paths for the form
     $this->registerTablePaths($config);
     // Set the clean cache event
     $this->eventCleanCache = $this->eventCleanCache ?: \JArrayHelper::getValue($config, 'event_clean_cache', 'onContentCleanCache');
     $this->container = $container ?: $this->getContainer();
     $state = new \JRegistry($config);
     parent::__construct($state, $db);
     // Guess the context as Option.ModelName.
     $this->context = $this->context ?: strtolower($this->option . '.' . $this->getName());
     // Set the internal state marker - used to ignore setting state from the request
     if (empty($config['ignore_request'])) {
         // Protected method to auto-populate the model state.
         $this->populateState();
     }
 }
Пример #27
0
 public function feature()
 {
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $cid = $app->input->get('cid', array(), 'array');
     $data = array('feature' => 1, 'unfeature' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($data, $task, 0, 'int');
     $rootCat = JUDirectoryFrontHelperCategory::getRootCategory();
     if (empty($cid)) {
         JError::raiseWarning(500, JText::_('COM_JUDIRECTORY_NO_ITEM_SELECTED'));
     } else {
         $model = $this->getModel();
         JArrayHelper::toInteger($cid);
         if (!$model->feature($cid, $value)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             if ($value == 1) {
                 $ntext = $this->text_prefix . '_N_ITEMS_FEATURED';
             } elseif ($value == 0) {
                 $ntext = $this->text_prefix . '_N_ITEMS_UNFEATURED';
             }
             $this->setMessage(JText::plural($ntext, count($cid)));
         }
     }
     $extension = $app->input->get('extension');
     $extensionURL = $extension ? '&extension=' . $extension : '';
     $catURL = '&cat_id=' . $app->input->getInt('cat_id', $rootCat->id);
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $catURL . $extensionURL, false));
 }
Пример #28
0
 /**
  * Method to get the record form.
  *
  * @param	array	$data		Data for the form.
  * @param	boolean	$loadData	True if the form is to load its own data (default case), false if not.
  * @return	JForm	A JForm object on success, false on failure
  * @since	1.6
  */
 public function getForm($data = array(), $loadData = true)
 {
     // The folder and element vars are passed when saving the form.
     if (empty($data)) {
         $item = $this->getItem();
         $folder = $item->folder;
         $element = $item->element;
     } else {
         $folder = JArrayHelper::getValue($data, 'folder', '', 'cmd');
         $element = JArrayHelper::getValue($data, 'element', '', 'cmd');
     }
     // These variables are used to add data from the plugin XML files.
     $this->setState('item.folder', $folder);
     $this->setState('item.element', $element);
     // Get the form.
     $form = $this->loadForm('com_plugins.plugin', 'plugin', array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     // Modify the form based on access controls.
     if (!$this->canEditState((object) $data)) {
         // Disable fields for display.
         $form->setFieldAttribute('ordering', 'disabled', 'true');
         $form->setFieldAttribute('enabled', 'disabled', 'true');
         // Disable fields while saving.
         // The controller has already verified this is a record you can edit.
         $form->setFieldAttribute('ordering', 'filter', 'unset');
         $form->setFieldAttribute('enabled', 'filter', 'unset');
     }
     return $form;
 }
Пример #29
0
 /**
  * Save data into the DB
  *
  * @param array $data The data about item
  *
  * @return mixed  Item ID or null
  */
 public function save($data)
 {
     $id = JArrayHelper::getValue($data, "id");
     $units = JArrayHelper::getValue($data, "units");
     $currencyId = JArrayHelper::getValue($data, "currency_id");
     $txnId = JArrayHelper::getValue($data, "txn_id");
     $txnAmount = JArrayHelper::getValue($data, "txn_amount");
     $txnCurrency = JArrayHelper::getValue($data, "txn_currency");
     $txnStatus = JArrayHelper::getValue($data, "txn_status");
     $txnDate = JArrayHelper::getValue($data, "txn_date");
     $senderId = JArrayHelper::getValue($data, "sender_id");
     $receiverId = JArrayHelper::getValue($data, "receiver_id");
     $serviceProvider = JArrayHelper::getValue($data, "service_provider");
     // Load a record from the database
     $row = $this->getTable();
     $row->load($id);
     $row->set("currency_id", $currencyId);
     $row->set("units", $units);
     $row->set("txn_id", $txnId);
     $row->set("txn_amount", $txnAmount);
     $row->set("txn_currency", $txnCurrency);
     $row->set("txn_status", $txnStatus);
     $row->set("txn_date", $txnDate);
     $row->set("txn_date", $txnDate);
     $row->set("sender_id", $senderId);
     $row->set("receiver_id", $receiverId);
     $row->set("service_provider", $serviceProvider);
     $row->store();
     return $row->get("id");
 }
Пример #30
0
 function prepareMenuItem(&$node, &$params)
 {
     $link_query = parse_url($node->link);
     parse_str(html_entity_decode($link_query['query']), $link_vars);
     $evid = intval(JArrayHelper::getValue($link_vars, 'evid', 0));
     $catid = intval(JArrayHelper::getValue($link_vars, 'category_fv', 0));
     $task = JArrayHelper::getValue($link_vars, 'task', 0);
     if (!$catid) {
         $menu =& JSite::getMenu();
         $params = $menu->getParams($node->id);
         $catids = array();
         for ($i = 0; $i <= 10; $i++) {
             if ($catid = $params->get("catid{$i}", 0)) {
                 $catids[] = $catid;
             }
         }
         $catid = implode(',', $catids);
     }
     if ($task == 'icalrepeat.detail' && $evid) {
         $node->uid = 'com_jeventse' . $evid;
         $node->expandible = false;
     } elseif ($task == 'cat.listevents' && $catid) {
         $node->expandible = true;
         $node->uid = 'com_jeventsc' . $catid;
     }
 }