后台管理相关功能。
该类在 APPPATH/classes/admin.php 第 13 行声明。
为给定的 controller/action 生成最小等级需求
public static function minimumLevel($action)
{
$level = array(
'index' => 6,
'setting_general' => 8,
'setting_payment' => 8,
'cache' => 9,
'list_logs' => 8,
'list_pages' => 7,
'create_page' => 7,
'edit_page' => 7,
'delete_page' => 7,
'list_comments' => 7,
'delete_comment' => 7,
'login' => 1,
'list_users' => 7,
'edit_user' => 5,
'delete_user' => 7,
'list_orders' => 7,
'list_products' => 7,
'create_product' => 7,
'edit_product' => 7,
'delete_product' => 7,
'sort_products' => 7,
'list_product_categories' => 7,
'create_product_category' => 7,
'edit_product_category' => 7,
'delete_product_category' => 7,
'list_shops' => 7,
'create_shop' => 7,
'edit_shop' => 7,
'delete_shop' => 7,
'list_shippings' => 7,
'create_shipping' => 7,
'edit_shipping' => 7,
'delete_shipping' => 7,
);
if (isset($level[$action]))
return $level[$action];
else
return 9;
}
创建发布选项
integer
$cur
required - 当前节点状态 integer
$level
required - 等级 string
$type
= string(4) "page" - 类型 string
$action
= string(4) "edit" - 动作 string
- 下拉列表public static function publishing_options($cur, $level, $type = 'page', $action = 'edit')
{
$options = array(
'0' => '垃圾筒',
'2' => '草稿',
'3' => '待审核'
);
if ($type == 'page')
$minimum = 7;
else
$minimum = 5;
if ($level >= $minimum)
{
if ($action == 'create')
$publish = '立即发布';
else
$publish = '已发布';
$options['1'] = $publish;
}
$e = '<select id="status" name="status">';
foreach ($options as $key => $option)
{
if ($cur == $key)
$selected = ' selected="selected"';
$e .= '<option value="' . $key . '"' . $selected . '>' . $option . '</option>';
$selected = '';
}
$e .= '</select>';
return $e;
}