本文整理汇总了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;
}