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


PHP strings::authorise方法代码示例

本文整理汇总了PHP中strings::authorise方法的典型用法代码示例。如果您正苦于以下问题:PHP strings::authorise方法的具体用法?PHP strings::authorise怎么用?PHP strings::authorise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在strings的用法示例。


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

示例1: getListQuery

 /**
  * Method to build an SQL query to load the list data.
  *
  * @return      string  An SQL query
  */
 protected function getListQuery()
 {
     // Get the current user for authorisation checks
     $this->user = JFactory::getUser();
     $this->userId = $this->user->get('id');
     $this->guest = $this->user->get('guest');
     $this->groups = $this->user->get('groups');
     $this->authorisedGroups = $this->user->getAuthorisedGroups();
     $this->levels = $this->user->getAuthorisedViewLevels();
     $this->app = JFactory::getApplication();
     $this->input = $this->app->input;
     $this->initSet = true;
     // Make sure all records load, since no pagination allowed.
     $this->setState('list.limit', 0);
     // Get a db connection.
     $db = JFactory::getDbo();
     // Create a new query object.
     $query = $db->getQuery(true);
     // Filtering.
     $ids = (array) array_map('intval', explode('_', $this->input->get('cid', null, 'CMD')));
     if (!$this->user->authorise('core.options', 'com_costbenefitprojection') && CostbenefitprojectionHelper::checkArray($ids)) {
         // make absolutely sure that these companies can be viewed
         $companies = CostbenefitprojectionHelper::hisCompanies($this->userId);
         foreach ($ids as $nr => $pk) {
             if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($pk, $companies)) {
                 // remove if not found
                 unset($ids[$nr]);
             }
         }
     }
     // only continue if we have ids
     if (!CostbenefitprojectionHelper::checkArray($ids)) {
         // redirect away if not a correct (TODO for now we go to default view)
         JError::raiseWarning(500, JText::_('No companies selected!'));
         $app = JFactory::getApplication();
         if ($app->isAdmin()) {
             JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection');
         } else {
             JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection&view=cpanel');
         }
     }
     // Get from #__costbenefitprojection_company as a
     $query->select($db->quoteName(array('a.id', 'a.name', 'a.user', 'a.department', 'a.per', 'a.country', 'a.service_provider', 'a.datayear', 'a.working_days', 'a.total_salary', 'a.total_healthcare', 'a.productivity_losses', 'a.males', 'a.females', 'a.medical_turnovers_males', 'a.medical_turnovers_females', 'a.sick_leave_males', 'a.sick_leave_females', 'a.percentmale', 'a.percentfemale', 'a.causesrisks', 'a.published', 'a.access'), array('id', 'name', 'user', 'department', 'per', 'country', 'service_provider', 'datayear', 'working_days', 'total_salary', 'total_healthcare', 'productivity_losses', 'males', 'females', 'medical_turnovers_males', 'medical_turnovers_females', 'sick_leave_males', 'sick_leave_females', 'percentmale', 'percentfemale', 'causesrisks', 'published', 'access')));
     $query->from($db->quoteName('#__costbenefitprojection_company', 'a'));
     // Get from #__costbenefitprojection_country as e
     $query->select($db->quoteName(array('e.id', 'e.name', 'e.alias', 'e.user', 'e.currency', 'e.datayear', 'e.worldzone', 'e.codethree', 'e.codetwo', 'e.working_days', 'e.presenteeism', 'e.medical_turnovers', 'e.sick_leave', 'e.healthcare', 'e.productivity_losses', 'e.publicname', 'e.publicemail', 'e.publicnumber', 'e.publicaddress', 'e.percentmale', 'e.percentfemale', 'e.causesrisks', 'e.maledeath', 'e.femaledeath', 'e.maleyld', 'e.femaleyld', 'e.access'), array('country_id', 'country_name', 'country_alias', 'country_user', 'country_currency', 'country_datayear', 'country_worldzone', 'country_codethree', 'country_codetwo', 'country_working_days', 'country_presenteeism', 'country_medical_turnovers', 'country_sick_leave', 'country_healthcare', 'country_productivity_losses', 'country_publicname', 'country_publicemail', 'country_publicnumber', 'country_publicaddress', 'country_percentmale', 'country_percentfemale', 'country_causesrisks', 'country_maledeath', 'country_femaledeath', 'country_maleyld', 'country_femaleyld', 'country_access')));
     $query->join('LEFT', $db->quoteName('#__costbenefitprojection_country', 'e') . ' ON (' . $db->quoteName('a.country') . ' = ' . $db->quoteName('e.id') . ')');
     // Get from #__costbenefitprojection_currency as f
     $query->select($db->quoteName(array('f.id', 'f.name', 'f.alias', 'f.codethree', 'f.numericcode', 'f.symbol', 'f.thousands', 'f.decimalplace', 'f.decimalsymbol', 'f.positivestyle', 'f.negativestyle', 'f.published', 'f.access', 'f.ordering'), array('currency_id', 'currency_name', 'currency_alias', 'currency_codethree', 'currency_numericcode', 'currency_symbol', 'currency_thousands', 'currency_decimalplace', 'currency_decimalsymbol', 'currency_positivestyle', 'currency_negativestyle', 'currency_published', 'currency_access', 'currency_ordering')));
     $query->join('LEFT', $db->quoteName('#__costbenefitprojection_currency', 'f') . ' ON (' . $db->quoteName('e.currency') . ' = ' . $db->quoteName('f.codethree') . ')');
     // Check if $ids is an array with values.
     $array = $ids;
     if (isset($array) && CostbenefitprojectionHelper::checkArray($array)) {
         $query->where('a.id IN (' . implode(',', $array) . ')');
     } else {
         return false;
     }
     // return the query object
     return $query;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:65,代码来源:combinedresults.php

示例2: getItem

 /**
  * Method to get article data.
  *
  * @param   integer  $pk  The id of the article.
  *
  * @return  mixed  Menu item data object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     $this->user = JFactory::getUser();
     // check if this user has permission to access item
     if (!$this->user->authorise('site.companyresults.access', 'com_costbenefitprojection')) {
         $app = JFactory::getApplication();
         $app->enqueueMessage(JText::_('Not authorised!'), 'error');
         // redirect away if not a correct (TODO for now we go to default view)
         $app->redirect(JRoute::_('index.php?option=com_costbenefitprojection&view=cpanel'));
         return false;
     }
     $this->userId = $this->user->get('id');
     $this->guest = $this->user->get('guest');
     $this->groups = $this->user->get('groups');
     $this->authorisedGroups = $this->user->getAuthorisedGroups();
     $this->levels = $this->user->getAuthorisedViewLevels();
     $this->initSet = true;
     $pk = !empty($pk) ? $pk : (int) $this->getState('companyresults.id');
     if (!$this->user->authorise('core.options', 'com_costbenefitprojection')) {
         // make absolutely sure that this company can be viewed
         $companies = CostbenefitprojectionHelper::hisCompanies($this->userId);
         if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($pk, $companies)) {
             JError::raiseWarning(500, JText::_('Access denied!'));
             // redirect away if not a correct (TODO for now we go to default view)
             $app = JFactory::getApplication();
             if ($app->isAdmin()) {
                 JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection');
             } else {
                 JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection&view=cpanel');
             }
             return false;
         }
     }
     if ($this->_item === null) {
         $this->_item = array();
     }
     if (!isset($this->_item[$pk])) {
         try {
             // Get the advanced encription.
             $advancedkey = CostbenefitprojectionHelper::getCryptKey('advanced');
             // Get the encription object.
             $advanced = new FOFEncryptAes($advancedkey, 256);
             // Get a db connection.
             $db = JFactory::getDbo();
             // Create a new query object.
             $query = $db->getQuery(true);
             // Get from #__costbenefitprojection_company as a
             $query->select($db->quoteName(array('a.id', 'a.name', 'a.user', 'a.department', 'a.per', 'a.country', 'a.service_provider', 'a.datayear', 'a.working_days', 'a.total_salary', 'a.total_healthcare', 'a.productivity_losses', 'a.males', 'a.females', 'a.medical_turnovers_males', 'a.medical_turnovers_females', 'a.sick_leave_males', 'a.sick_leave_females', 'a.percentmale', 'a.percentfemale', 'a.causesrisks', 'a.published', 'a.access'), array('id', 'name', 'user', 'department', 'per', 'country', 'service_provider', 'datayear', 'working_days', 'total_salary', 'total_healthcare', 'productivity_losses', 'males', 'females', 'medical_turnovers_males', 'medical_turnovers_females', 'sick_leave_males', 'sick_leave_females', 'percentmale', 'percentfemale', 'causesrisks', 'published', 'access')));
             $query->from($db->quoteName('#__costbenefitprojection_company', 'a'));
             // Get from #__costbenefitprojection_country as e
             $query->select($db->quoteName(array('e.id', 'e.name', 'e.alias', 'e.user', 'e.currency', 'e.datayear', 'e.worldzone', 'e.codethree', 'e.codetwo', 'e.working_days', 'e.presenteeism', 'e.medical_turnovers', 'e.sick_leave', 'e.healthcare', 'e.productivity_losses', 'e.publicname', 'e.publicemail', 'e.publicnumber', 'e.publicaddress', 'e.percentmale', 'e.percentfemale', 'e.causesrisks', 'e.maledeath', 'e.femaledeath', 'e.maleyld', 'e.femaleyld', 'e.access'), array('country_id', 'country_name', 'country_alias', 'country_user', 'country_currency', 'country_datayear', 'country_worldzone', 'country_codethree', 'country_codetwo', 'country_working_days', 'country_presenteeism', 'country_medical_turnovers', 'country_sick_leave', 'country_healthcare', 'country_productivity_losses', 'country_publicname', 'country_publicemail', 'country_publicnumber', 'country_publicaddress', 'country_percentmale', 'country_percentfemale', 'country_causesrisks', 'country_maledeath', 'country_femaledeath', 'country_maleyld', 'country_femaleyld', 'country_access')));
             $query->join('LEFT', $db->quoteName('#__costbenefitprojection_country', 'e') . ' ON (' . $db->quoteName('a.country') . ' = ' . $db->quoteName('e.id') . ')');
             // Get from #__costbenefitprojection_currency as f
             $query->select($db->quoteName(array('f.id', 'f.name', 'f.alias', 'f.codethree', 'f.numericcode', 'f.symbol', 'f.thousands', 'f.decimalplace', 'f.decimalsymbol', 'f.positivestyle', 'f.negativestyle', 'f.published', 'f.access', 'f.ordering'), array('currency_id', 'currency_name', 'currency_alias', 'currency_codethree', 'currency_numericcode', 'currency_symbol', 'currency_thousands', 'currency_decimalplace', 'currency_decimalsymbol', 'currency_positivestyle', 'currency_negativestyle', 'currency_published', 'currency_access', 'currency_ordering')));
             $query->join('LEFT', $db->quoteName('#__costbenefitprojection_currency', 'f') . ' ON (' . $db->quoteName('e.currency') . ' = ' . $db->quoteName('f.codethree') . ')');
             $query->where('a.id = ' . (int) $pk);
             // Reset the query using our newly populated query object.
             $db->setQuery($query);
             // Load the results as a stdClass object.
             $data = $db->loadObject();
             if (empty($data)) {
                 $app = JFactory::getApplication();
                 // If no data is found redirect to default page and show warning.
                 $app->enqueueMessage(JText::_('COM_COSTBENEFITPROJECTION_NOT_FOUND_OR_ACCESS_DENIED'), 'warning');
                 $app->redirect('index.php?option=com_costbenefitprojection&view=cpanel');
                 return false;
             }
             if (!empty($data->medical_turnovers_females) && $advancedkey && !is_numeric($data->medical_turnovers_females) && $data->medical_turnovers_females === base64_encode(base64_decode($data->medical_turnovers_females, true))) {
                 // Decode medical_turnovers_females
                 $data->medical_turnovers_females = rtrim($advanced->decryptString($data->medical_turnovers_females), "");
             }
             if (!empty($data->females) && $advancedkey && !is_numeric($data->females) && $data->females === base64_encode(base64_decode($data->females, true))) {
                 // Decode females
                 $data->females = rtrim($advanced->decryptString($data->females), "");
             }
             if (!empty($data->sick_leave_males) && $advancedkey && !is_numeric($data->sick_leave_males) && $data->sick_leave_males === base64_encode(base64_decode($data->sick_leave_males, true))) {
                 // Decode sick_leave_males
                 $data->sick_leave_males = rtrim($advanced->decryptString($data->sick_leave_males), "");
             }
             if (CostbenefitprojectionHelper::checkString($data->causesrisks)) {
                 // Decode causesrisks
                 $data->causesrisks = json_decode($data->causesrisks, true);
             }
             if (!empty($data->medical_turnovers_males) && $advancedkey && !is_numeric($data->medical_turnovers_males) && $data->medical_turnovers_males === base64_encode(base64_decode($data->medical_turnovers_males, true))) {
                 // Decode medical_turnovers_males
                 $data->medical_turnovers_males = rtrim($advanced->decryptString($data->medical_turnovers_males), "");
             }
             if (!empty($data->total_salary) && $advancedkey && !is_numeric($data->total_salary) && $data->total_salary === base64_encode(base64_decode($data->total_salary, true))) {
                 // Decode total_salary
                 $data->total_salary = rtrim($advanced->decryptString($data->total_salary), "");
             }
             if (!empty($data->sick_leave_females) && $advancedkey && !is_numeric($data->sick_leave_females) && $data->sick_leave_females === base64_encode(base64_decode($data->sick_leave_females, true))) {
                 // Decode sick_leave_females
//.........这里部分代码省略.........
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:101,代码来源:companyresults.php

示例3: getItem

 /**
  * Method to get article data.
  *
  * @param   integer  $pk  The id of the article.
  *
  * @return  mixed  Menu item data object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     $this->user = JFactory::getUser();
     // check if this user has permission to access item
     if (!$this->user->authorise('site.publicresults.access', 'com_costbenefitprojection')) {
         $app = JFactory::getApplication();
         $app->enqueueMessage(JText::_('Not authorised!'), 'error');
         // redirect away if not a correct (TODO for now we go to default view)
         $app->redirect(JRoute::_('index.php?option=com_costbenefitprojection&view=cpanel'));
         return false;
     }
     $this->userId = $this->user->get('id');
     $this->guest = $this->user->get('guest');
     $this->groups = $this->user->get('groups');
     $this->authorisedGroups = $this->user->getAuthorisedGroups();
     $this->levels = $this->user->getAuthorisedViewLevels();
     $this->initSet = true;
     $pk = !empty($pk) ? $pk : (int) $this->getState('publicresults.id');
     if (!$pk) {
         JError::raiseWarning(500, JText::_('No Direct Access Allowed!'));
         // redirect away if not a correct (TODO for now we go to default view)
         JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection&view=cpanel');
         return false;
     }
     if ($this->_item === null) {
         $this->_item = array();
     }
     if (!isset($this->_item[$pk])) {
         try {
             // Get a db connection.
             $db = JFactory::getDbo();
             // Create a new query object.
             $query = $db->getQuery(true);
             // Get from #__costbenefitprojection_country as a
             $query->select($db->quoteName(array('a.id', 'a.currency', 'a.datayear', 'a.percentmale', 'a.percentfemale', 'a.causesrisks', 'a.published'), array('country', 'currency', 'datayear', 'percentmale', 'percentfemale', 'causesrisks', 'published')));
             $query->from($db->quoteName('#__costbenefitprojection_country', 'a'));
             // Get from #__costbenefitprojection_country as e
             $query->select($db->quoteName(array('e.id', 'e.name', 'e.alias', 'e.user', 'e.currency', 'e.datayear', 'e.worldzone', 'e.codethree', 'e.codetwo', 'e.working_days', 'e.presenteeism', 'e.medical_turnovers', 'e.sick_leave', 'e.healthcare', 'e.productivity_losses', 'e.publicname', 'e.publicemail', 'e.publicnumber', 'e.publicaddress', 'e.percentmale', 'e.percentfemale', 'e.causesrisks', 'e.maledeath', 'e.femaledeath', 'e.maleyld', 'e.femaleyld', 'e.access'), array('country_id', 'country_name', 'country_alias', 'country_user', 'country_currency', 'country_datayear', 'country_worldzone', 'country_codethree', 'country_codetwo', 'country_working_days', 'country_presenteeism', 'country_medical_turnovers', 'country_sick_leave', 'country_healthcare', 'country_productivity_losses', 'country_publicname', 'country_publicemail', 'country_publicnumber', 'country_publicaddress', 'country_percentmale', 'country_percentfemale', 'country_causesrisks', 'country_maledeath', 'country_femaledeath', 'country_maleyld', 'country_femaleyld', 'country_access')));
             $query->join('LEFT', $db->quoteName('#__costbenefitprojection_country', 'e') . ' ON (' . $db->quoteName('a.id') . ' = ' . $db->quoteName('e.id') . ')');
             // Get from #__costbenefitprojection_currency as f
             $query->select($db->quoteName(array('f.id', 'f.name', 'f.alias', 'f.codethree', 'f.numericcode', 'f.symbol', 'f.thousands', 'f.decimalplace', 'f.decimalsymbol', 'f.positivestyle', 'f.negativestyle', 'f.published', 'f.access', 'f.ordering'), array('currency_id', 'currency_name', 'currency_alias', 'currency_codethree', 'currency_numericcode', 'currency_symbol', 'currency_thousands', 'currency_decimalplace', 'currency_decimalsymbol', 'currency_positivestyle', 'currency_negativestyle', 'currency_published', 'currency_access', 'currency_ordering')));
             $query->join('LEFT', $db->quoteName('#__costbenefitprojection_currency', 'f') . ' ON (' . $db->quoteName('e.currency') . ' = ' . $db->quoteName('f.codethree') . ')');
             $query->where('a.id = ' . (int) $pk);
             // Reset the query using our newly populated query object.
             $db->setQuery($query);
             // Load the results as a stdClass object.
             $data = $db->loadObject();
             if (empty($data)) {
                 $app = JFactory::getApplication();
                 // If no data is found redirect to default page and show warning.
                 $app->enqueueMessage(JText::_('COM_COSTBENEFITPROJECTION_NOT_FOUND_OR_ACCESS_DENIED'), 'warning');
                 $app->redirect('index.php?option=com_costbenefitprojection&view=cpanel');
                 return false;
             }
             if (CostbenefitprojectionHelper::checkString($data->country_causesrisks)) {
                 // Decode country_causesrisks
                 $data->country_causesrisks = json_decode($data->country_causesrisks, true);
             }
             // Make sure the content prepare plugins fire on country_publicaddress.
             $data->country_publicaddress = JHtml::_('content.prepare', $data->country_publicaddress);
             // Checking if country_publicaddress has uikit components that must be loaded.
             $this->uikitComp = CostbenefitprojectionHelper::getUikitComp($data->country_publicaddress, $this->uikitComp);
             // set the global causesrisks value.
             $this->a_causesrisks = $data->causesrisks;
             // set the global datayear value.
             $this->a_datayear = $data->datayear;
             // set the global datayear value.
             $this->e_datayear = $data->country_datayear;
             // set the global causesrisks value.
             $this->e_causesrisks = $data->country_causesrisks;
             // set idCountryHealth_dataB to the $data object.
             $data->idCountryHealth_dataB = $this->getIdCountryHealth_dataDadd_B($data->country);
             // set causesrisksIdCauseriskG to the $data object.
             $data->causesrisksIdCauseriskG = $this->getCausesrisksIdCauseriskDadd_G($data->causesrisks);
             // set idCountryHealth_dataBB to the $data object.
             $data->idCountryHealth_dataBB = $this->getIdCountryHealth_dataDadd_BB($data->country);
             // set causesrisksIdCauseriskGG to the $data object.
             $data->causesrisksIdCauseriskGG = $this->getCausesrisksIdCauseriskDadd_GG($data->country_causesrisks);
             // set idCountryInterventionDD to the $data object.
             $data->idCountryInterventionDD = $this->getIdCountryInterventionDadd_DD($data->country);
             // set data object to item.
             $this->_item[$pk] = $data;
         } catch (Exception $e) {
             if ($e->getCode() == 404) {
                 // Need to go thru the error handler to allow Redirect to work.
                 JError::raiseWaring(404, $e->getMessage());
             } else {
                 $this->setError($e);
                 $this->_item[$pk] = false;
             }
         }
     }
     // make sure the sum class knows this is a public request
//.........这里部分代码省略.........
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:101,代码来源:publicresults.php


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