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


PHP CostbenefitprojectionHelper::accessCompany方法代码示例

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


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

示例1: allowEdit

 /**
  * Method override to check if you can edit an existing record.
  *
  * @param   array   $data  An array of input data.
  * @param   string  $key   The name of the key for the primary key.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 protected function allowEdit($data = array(), $key = 'id')
 {
     // get user object.
     $user = JFactory::getUser();
     // get record id.
     $recordId = (int) isset($data[$key]) ? $data[$key] : 0;
     if (!$user->authorise('core.options', 'com_costbenefitprojection')) {
         // make absolutely sure that this company can be edited
         $companies = CostbenefitprojectionHelper::hisCompanies($user->id);
         if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($recordId, $companies)) {
             return false;
         }
     }
     // ensure lockdown
     $userIs = CostbenefitprojectionHelper::userIs($user->id);
     if (1 != $userIs && !CostbenefitprojectionHelper::accessCompany($recordId)) {
         // this company is locked
         return false;
     }
     // Access check.
     $access = $user->authorise('company.access', 'com_costbenefitprojection.company.' . (int) $recordId) && $user->authorise('company.access', 'com_costbenefitprojection');
     if (!$access) {
         return false;
     }
     if ($recordId) {
         // The record has been set. Check the record permissions.
         $permission = $user->authorise('company.edit', 'com_costbenefitprojection.company.' . (int) $recordId);
         if (!$permission && !is_null($permission)) {
             if ($user->authorise('company.edit.own', 'com_costbenefitprojection.company.' . $recordId)) {
                 // Now test the owner is the user.
                 $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
                 if (empty($ownerId)) {
                     // Need to do a lookup from the model.
                     $record = $this->getModel()->getItem($recordId);
                     if (empty($record)) {
                         return false;
                     }
                     $ownerId = $record->created_by;
                 }
                 // If the owner matches 'me' then allow.
                 if ($ownerId == $user->id) {
                     if ($user->authorise('company.edit.own', 'com_costbenefitprojection')) {
                         return true;
                     }
                 }
             }
             return false;
         }
     }
     // Since there is no permission, revert to the component permissions.
     return $user->authorise('company.edit', $this->option);
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:62,代码来源:company.php


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