当前位置: 首页>>代码示例>>PHP>>正文


PHP JSession类代码示例

本文整理汇总了PHP中JSession的典型用法代码示例。如果您正苦于以下问题:PHP JSession类的具体用法?PHP JSession怎么用?PHP JSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: featured

 /**
  * 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');
 }
开发者ID:joomline,项目名称:Joomla2.5.999,代码行数:36,代码来源:articles.php

示例2: delete

 public function delete()
 {
     // Check for request forgeries
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // Get items to remove from the request.
     $cid = JFactory::getApplication()->input->get('cid', array(), 'array');
     if (!is_array($cid) || count($cid) < 1) {
         JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         jimport('joomla.utilities.arrayhelper');
         JArrayHelper::toInteger($cid);
         // Remove the items.
         if ($model->delete($cid)) {
             $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
         } else {
             $this->setMessage($model->getError());
         }
     }
     $version = new JVersion();
     if ($version->isCompatible('3.0')) {
         // Invoke the postDelete method to allow for the child class to access the model.
         $this->postDeleteHook($model, $cid);
     }
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
 }
开发者ID:AndreKoepke,项目名称:Einsatzkomponente,代码行数:28,代码来源:alarmierungsarten.php

示例3: sticky_publish

 /**
  * 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');
 }
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:34,代码来源:banners.php

示例4: remind

 /**
  * Method to request a username reminder.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function remind()
 {
     // Check the request token.
     JSession::checkToken('post') or jexit(JText::_('JINVALID_TOKEN'));
     $model = $this->getModel('Remind', 'UsersModel');
     $data = $this->input->post->get('jform', array(), 'array');
     // Submit the password reset request.
     $return = $model->processRemindRequest($data);
     // Check for a hard error.
     if ($return == false) {
         // The request failed.
         // Get the route to the next page.
         $itemid = UsersHelperRoute::getRemindRoute();
         $itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
         $route = 'index.php?option=com_users&view=remind' . $itemid;
         // Go back to the request form.
         $message = JText::sprintf('Request failed: Your account is not activated yet or is under review. Please contact the admin more for details.', $model->getError());
         $this->setRedirect(JRoute::_($route, false), $message, 'notice');
         return false;
     } else {
         // The request succeeded.
         // Get the route to the next page.
         $itemid = UsersHelperRoute::getRemindRoute();
         $itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
         $route = 'index.php?option=com_users&view=login' . $itemid;
         // Proceed to step two.
         $message = JText::_('COM_USERS_REMIND_REQUEST_SUCCESS');
         $this->setRedirect(JRoute::_($route, false), $message);
         return true;
     }
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:38,代码来源:remind.php

示例5: featured

 /**
  * Method to toggle the featured setting of a list of memberss.
  *
  * @return    void
  *
  * @since    1.7.0
  */
 public function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Initialise variables.
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $ids = $app->input->get('id', [], 'array');
     $task = $this->getTask();
     $value = Joomla\Utilities\ArrayHelper::getValue($values, $task, 0, 'int');
     // Get the model.
     $model = $this->getModel();
     // Access checks.
     foreach ($ids as $i => $id) {
         if (!$user->authorise('core.edit.state')) {
             // Prune items that you can't change.
             unset($ids[$i]);
             $app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'notice');
         }
     }
     if (empty($ids)) {
         $app->enqueueMessage(JText::_('COM_CHURCHDIRECTORY_NO_ITEM_SELECTED'), 'warning');
     } else {
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             $app->enqueueMessage($model->getError(), 'warning');
         }
     }
     $this->setRedirect('index.php?option=com_churchdirectory&view=postions');
 }
开发者ID:Joomla-Bible-Study,项目名称:joomla_churchdirectory,代码行数:37,代码来源:positions.php

示例6: __construct

} else {
    require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_languages' . DS . 'helpers' . DS . 'jsonresponse.php';
}
/**
 * Content controller class.
 */
class J2XMLControllerCategories extends JControllerAbstract
{
    function __construct($default = array())
    {
        parent::__construct();
    }
    public function display($cachable = false, $urlparams = false)
    {
        JRequest::setVar('view', 'categories');
        parent::display($cachable, $urlparams);
    }
    function send()
    {
        if (!JSession::checkToken('request')) {
            // Check for a valid token. If invalid, send a 403 with the error message.
            JError::raiseWarning(403, JText::_('JINVALID_TOKEN'));
            echo version_compare(JPlatform::RELEASE, '12', 'ge') ? new JResponseJson() : new JJsonResponse();
            return;
        }
        $cid = JRequest::getVar('cid', array(0), null, 'array');
        $sid = JRequest::getVar('w_id', null, null, 'int');
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:27,代码来源:categories.json.php

示例7: getList

 /**
  * Get a list of logged users.
  *
  * @param	JObject	The module parameters.
  * @return	mixed	An array of articles, or false on error.
  */
 public static function getList($params)
 {
     $db = JFactory::getDbo();
     $user = JFactory::getUser();
     $query = $db->getQuery(true);
     $query->select('s.time, s.client_id, u.id, u.name, u.username');
     $query->from('#__session AS s');
     $query->leftJoin('#__users AS u ON s.userid = u.id');
     $query->where('s.guest = 0');
     $db->setQuery($query, 0, $params->get('count', 5));
     try {
         $results = $db->loadObjectList();
     } catch (RuntimeException $e) {
         JError::raiseError(500, $e->getMessage());
         return false;
     }
     foreach ($results as $k => $result) {
         $results[$k]->logoutLink = '';
         if ($user->authorise('core.manage', 'com_users')) {
             $results[$k]->editLink = JRoute::_('index.php?option=com_users&task=user.edit&id=' . $result->id);
             $results[$k]->logoutLink = JRoute::_('index.php?option=com_login&task=logout&uid=' . $result->id . '&' . JSession::getFormToken() . '=1');
         }
         if ($params->get('name', 1) == 0) {
             $results[$k]->name = $results[$k]->username;
         }
     }
     return $results;
 }
开发者ID:RuDers,项目名称:JoomlaSQL,代码行数:34,代码来源:helper.php

示例8: onDisplay

 /**
  * Display the button
  *
  * @return array A four element array of (article_id, article_title, category_id, object)
  */
 function onDisplay($name)
 {
     /*
      * Javascript to insert the link
      * View element calls jSelectArticle when an article is clicked
      * jSelectArticle creates the link tag, sends it to the editor,
      * and closes the select frame.
      */
     $js = "\r\r\n\t\tfunction jSelectArticle(id, title, catid, object, link, lang) {\r\r\n\t\t\tvar hreflang = '';\r\r\n\t\t\tif (lang !== '') {\r\r\n\t\t\t\tvar hreflang = ' hreflang = \"' + lang + '\"';\r\r\n\t\t\t}\r\r\n\t\t\tvar tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';\r\r\n\t\t\tjInsertEditorText(tag, '" . $name . "');\r\r\n\t\t\tSqueezeBox.close();\r\r\n\t\t}";
     $doc = JFactory::getDocument();
     $doc->addScriptDeclaration($js);
     JHtml::_('behavior.modal');
     /*
      * Use the built-in element view to select the article.
      * Currently uses blank class.
      */
     $link = 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
     $button = new JObject();
     $button->set('modal', true);
     $button->set('link', $link);
     $button->set('text', JText::_('PLG_ARTICLE_BUTTON_ARTICLE'));
     $button->set('name', 'article');
     $button->set('options', "{handler: 'iframe', size: {x: 770, y: 400}}");
     return $button;
 }
开发者ID:jimyb3,项目名称:mathematicalteachingsite,代码行数:30,代码来源:article.php

示例9: save

 /**
  * 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);
 }
开发者ID:pashakiz,项目名称:crowdf,代码行数:34,代码来源:country.php

示例10: help

 public function help()
 {
     $user = JFactory::getUser();
     $jinput = JFactory::getApplication()->input;
     // Check Token!
     $token = JSession::getFormToken();
     $call_token = $jinput->get('token', 0, 'ALNUM');
     if ($user->id != 0 && $token == $call_token) {
         $task = $this->getTask();
         switch ($task) {
             case 'getText':
                 try {
                     $idValue = $jinput->get('id', 0, 'INT');
                     if ($idValue) {
                         $result = $this->getHelpDocumentText($idValue);
                     } else {
                         $result = '';
                     }
                     echo $result;
                     // stop execution gracefully
                     jexit();
                 } catch (Exception $e) {
                     // stop execution gracefully
                     jexit();
                 }
                 break;
         }
     } else {
         // stop execution gracefully
         jexit();
     }
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:32,代码来源:help.php

示例11: create

 public function create()
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Get form data
     $pks = $this->input->post->get('cid', array(), 'array');
     $model = $this->getModel('Profile', 'GamificationModel');
     /** @var $model GamificationModelProfile */
     $pks = Joomla\Utilities\ArrayHelper::toInteger($pks);
     // Check for validation errors.
     if (!$pks) {
         $this->defaultLink .= '&view=' . $this->view_list;
         $this->setMessage(JText::_('COM_GAMIFICATION_INVALID_ITEM'), 'notice');
         $this->setRedirect(JRoute::_($this->defaultLink, false));
         return;
     }
     try {
         $pks = $model->filterProfiles($pks);
         if (!$pks) {
             $this->defaultLink .= '&view=' . $this->view_list;
             $this->setMessage(JText::_('COM_GAMIFICATION_INVALID_ITEM'), 'notice');
             $this->setRedirect(JRoute::_($this->defaultLink, false));
             return;
         }
         $model->create($pks);
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_gamification');
         throw new Exception(JText::_('COM_GAMIFICATION_ERROR_SYSTEM'));
     }
     $msg = JText::plural('COM_GAMIFICATION_N_PROFILES_CREATED', count(pks));
     $link = $this->defaultLink . '&view=' . $this->view_list;
     $this->setRedirect(JRoute::_($link, false), $msg);
 }
开发者ID:ITPrism,项目名称:GamificationDistribution,代码行数:32,代码来源:profiles.php

示例12: geoupdate

 /**
  * Method to update members geoupdate location.
  *
  * @return    void
  *
  * @since    1.7.0
  */
 public function geoupdate()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $ids = $this->input->get('cid', [], 'array');
     // Get the model.
     /** @var  ChurchDirectoryModelGeoStatus $model */
     $model = $this->getModel();
     // Access checks.
     foreach ($ids as $i => $id) {
         $item = $model->getItem($id);
         if (!$user->authorise('core.edit.state', 'com_churchdirectory.category.' . (int) $item->catid)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             $app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'notice');
         }
     }
     if (empty($ids)) {
         $app->enqueueMessage(JText::_('COM_CHURCHDIRECTORY_NO_ITEM_SELECTED'), 'error');
     } else {
         // Publish the items.
         if (!$model->update($ids)) {
             $app->enqueueMessage($model->getError(), 'error');
         }
     }
     $this->setRedirect('index.php?option=com_churchdirectory&view=geostatus');
 }
开发者ID:Joomla-Bible-Study,项目名称:joomla_churchdirectory,代码行数:36,代码来源:geostatus.php

示例13: getInput

 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * @since	1.6
  */
 protected function getInput()
 {
     // Load the modal behavior script.
     JHtml::_('behavior.modal', 'a.modal');
     // Build the script.
     $script = array();
     $script[] = '	function onArrowsSelect(data){';
     $script[] = '		UniteAdminRev.onArrowsChange(data);';
     $script[] = '		SqueezeBox.close();';
     $script[] = '	}';
     // Add the script to the document head.
     JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
     // Setup variables for display.
     $html = array();
     $link = 'index.php?option=' . GlobalsUniteRev::COMPONENT_NAME . '&view=slider&layout=arrows&tmpl=component&settingid=' . $this->id;
     $buttonType = $this->value;
     $arrArrowSet = HelperUniteRev::getArrowSet($buttonType);
     $arrowName = $arrArrowSet["name"];
     $html[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . $this->value . '" />';
     $buttonID = $this->id . "-btn";
     $desc = UniteFunctionsRev::getVal($this->element, "description");
     // The the arrow
     $imageArrow = $arrArrowSet["url_right"];
     $html[] = '<span class="chooser-image-wrapper"><img id="' . $this->id . '-img" title="' . $arrowName . '" src="' . $imageArrow . '"></span>';
     //put select button
     $html[] = '	<a id="' . $buttonID . '" class="modal button-secondary button-chooser" href="' . $link . '&amp;' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 900, y: 450}}">Change</a>';
     $html = implode("\n", $html);
     return $html;
 }
开发者ID:DanyCan,项目名称:wisten.github.io,代码行数:35,代码来源:arrows.php

示例14: revert

 public function revert()
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $pks = $app->input->post->get('cid', array(), 'array');
     $pk = (int) count($pks) ? $pks[0] : 0;
     $type = $app->input->post->getString('element_type', 'type');
     $model = $this->getModel();
     $user = JFactory::getUser();
     $res = $user->authorise('core.edit', CCK_COM) ? $model->revert($pk, $type) : false;
     if ($res) {
         if ($type == 'search') {
             $link = _C4_LINK;
         } elseif ($type == 'type') {
             $link = _C2_LINK;
         }
         $msg = JText::_('COM_CCK_SUCCESSFULLY_RESTORED');
         $type = 'message';
     } else {
         $link = _C6_LINK . '&filter_e_type=' . $type;
         $msg = JText::_('JERROR_AN_ERROR_HAS_OCCURRED');
         $type = 'error';
     }
     $this->setRedirect($link, $msg, $type);
 }
开发者ID:hamby,项目名称:SEBLOD,代码行数:25,代码来源:versions.php

示例15: onDisplay

 /**
  * Display the button
  *
  * @param   string  $name  The name of the button to add
  *
  * @return array A four element array of (article_id, article_title, category_id, object)
  */
 public function onDisplay($name)
 {
     $app = JFactory::getApplication();
     if (!$app->isSite()) {
         return false;
     }
     /*
      * Javascript to insert the link
      * View element calls jSelectEvent when an event is clicked
      * jSelectEvent creates the link tag, sends it to the editor,
      * and closes the select frame.
      */
     $js = "\n\t\tfunction jSelectEvent(id, title, object, link, lang)\n\t\t{\n\t\t\tvar hreflang = '';\n\t\t\tif (lang !== '')\n\t\t\t{\n\t\t\t\tvar hreflang = ' hreflang = \"' + lang + '\"';\n\t\t\t}\n\t\t\tvar tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';\n\t\t\tjInsertEditorText(tag, '" . $name . "');\n\t\t\tSqueezeBox.close();\n\t\t}";
     $doc = JFactory::getDocument();
     $doc->addScriptDeclaration($js);
     JHtml::_('behavior.modal');
     /*
      * Use the built-in element view to select the event.
      * Currently uses blank class.
      */
     $app = JFactory::getApplication();
     if ($app->isSite()) {
         $link = 'index.php?option=com_jem&amp;view=eventslist&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
     } else {
         $link = 'index.php?option=com_jem&amp;view=events&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
     }
     $button = new JObject();
     $button->modal = true;
     $button->class = 'btn';
     $button->link = $link;
     $button->text = JText::_('PLG_EVENT_BUTTON_EVENT');
     $button->name = 'calendar';
     $button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
     return $button;
 }
开发者ID:JKoelman,项目名称:JEM-3,代码行数:42,代码来源:event.php


注:本文中的JSession类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。