結論
ifp 當前用戶是否有 控制器--方法 的權限 包括add edit del send view等 方法必帶
ifpp 當前用戶是否有 插件 的權限
ife 當前用戶是否有 控制器--方法 的權限 編輯或添加 第二個參數是當前的數據數組 如果數組包含id 則驗證edit方法 如果數組不包含 則驗證add方法 第二個參數如果不帶 完全等於ifp
ife是ifp的簡化用法
下面是思路
先去搜索這幾個函數的解析
$str = preg_replace('/{ifp\\s+(.+?)}/', '<?php if(cv($1)) { ?>', $str);
$str = preg_replace('/{ifpp\\s+(.+?)}/', '<?php if(cp($1)) { ?>', $str);
$str = preg_replace('/{ife\\s+(\\S+)\\s+(\\S+)}/', '<?php if( ce($1 ,$2) ) { ?>', $str);
function cv($permtypes = '') {
$perm = com_run('perm::check_perm', $permtypes);
return $perm;
}
if (!function_exists('cp')) {
function cp($pluginname = '') {
$perm = com('perm');
if ($perm) {
return $perm->check_plugin($pluginname);
}
return true;
}
}
function ce($permtype = '', $item = NULL) {
$perm = com_run('perm::check_edit', $permtype, $item);
return $perm;
}
cv為例子
com_run 的意思 com(perm) 類 執行check_perm
com(perm) = $model = EWEI_SHOPV2_CORE . 'com/' . strtolower($name) . '.php';
也就是Perm_EweiShopV2ComModel類
的check_perm 方法
這個方法 根據& 和| 來拆分參數 並調用check
check再往下看 調用了用戶角色表 那應該就是校檢權限
ifp和ife的區別在於check_perm和check_edit
看check_edit函數里面的一段
if (!($this->check_perm($permtype)))
{
return false;
}
if (empty($item['id']))
{
$add_perm = $permtype . '.add';
if (!($this->check($add_perm)))
{
return false;
}
return true;
}
$edit_perm = $permtype . '.edit';
if (!($this->check($edit_perm)))
{
return false;
}
核心區別是 check_edit 會自動轉化為edit或add
其他就跟check_perm一樣了
所以結論
ifp 當前用戶是否有 控制器--方法 的權限 包括add edit del 可能有查看吧 方法必帶
ifpp 當前用戶是否有 插件 的權限
ife 當前用戶是否有 控制器--方法 的權限 編輯或添加 第二個參數是當前的數據數組 如果數組包含id 則驗證edit方法 如果數組不包含 則驗證add方法
ife是ifp的簡化用法
上面是跟下代碼的大概推論 去驗證了下
ife
比如{ife 'goods' $item} 后面的item參數 是用來驗證是否要驗證add還是驗證edit方法
{ife 'merch.user' $item} ife的寫法都是這樣 控制器+model(不加add/edit/del/..方法) +當前的實際數組
ifp
{ifp 'messages.delete'}
{ifp 'meeting.live.notice.send'}
一定是 控制器+model+具體方法(add/edit/del/send..方法)
ifpp沒見到用
所以猜測基本正確