當前位置: 首頁>>代碼示例>>PHP>>正文


PHP commonModel::checkPrivByVars方法代碼示例

本文整理匯總了PHP中commonModel::checkPrivByVars方法的典型用法代碼示例。如果您正苦於以下問題:PHP commonModel::checkPrivByVars方法的具體用法?PHP commonModel::checkPrivByVars怎麽用?PHP commonModel::checkPrivByVars使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在commonModel的用法示例。


在下文中一共展示了commonModel::checkPrivByVars方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkPrivByVars

 /**
  * Check privilege by vars. 
  * 
  * @param  string $module 
  * @param  string $method 
  * @param  string|array $vars 
  * @static
  * @access public
  * @return void
  */
 public static function checkPrivByVars($module, $method, $vars)
 {
     global $app;
     if (!is_array($vars)) {
         parse_str($vars, $vars);
     }
     $method = strtolower($method);
     /* Check priv by {$moduleName}ID. */
     $checkByID['customer'] = ',assign,edit,delete,linkcontact,';
     $checkByID['order'] = ',assign,edit,delete,close,activate,';
     $checkByID['resume'] = ',edit,delete,';
     $checkByID['address'] = ',edit,delete,';
     if ($app->appName == 'crm') {
         $checkByID['contact'] = ',edit,delete,';
     }
     foreach ($checkByID as $moduleName => $methodName) {
         if ($module == $moduleName and strpos($methodName, ",{$method},") !== false) {
             $idName = "{$moduleName}ID";
             $idListName = 'canEdit' . ucwords($moduleName) . 'IdList';
             if (!isset($vars[$idName])) {
                 return false;
             }
             $idList = isset($app->user->{$idListName}) ? $app->user->{$idListName} : '';
             if (strpos($idList, ",{$vars[$idName]},") === false) {
                 return false;
             }
         }
     }
     /* Check priv by objectType and objectID. */
     $checkByType['action'] = ',createrecord,';
     $checkByType['address'] = ',create,';
     foreach ($checkByType as $moduleName => $methodName) {
         if ($module == $moduleName and strpos($methodName, ",{$method},") !== false) {
             if (!isset($vars['objectType']) or !isset($vars['objectID'])) {
                 return false;
             }
             $idName = $vars['objectType'] . 'ID';
             $idListName = 'canEdit' . ucwords($vars['objectType']) . 'IdList';
             $idList = isset($app->user->{$idListName}) ? $app->user->{$idListName} : '';
             return commonModel::checkPrivByVars($vars['objectType'], 'edit', "{$idName}={$vars['objectID']}");
         }
     }
     /* Check priv use another method. module|method */
     $checkByGroup['resume']['create'] = 'contact|edit';
     foreach ($checkByGroup as $moduleName => $methodNames) {
         foreach ($methodNames as $methodName => $settings) {
             list($newModuleName, $newMethodName) = explode('|', $settings);
             if ($module == $moduleName and $method == $methodName) {
                 return commonModel::checkPrivByVars($newModuleName, $newMethodName, $vars);
             }
         }
     }
     return true;
 }
開發者ID:leowh,項目名稱:colla,代碼行數:64,代碼來源:model.php


注:本文中的commonModel::checkPrivByVars方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。