本文整理汇总了PHP中BigTree::setPermissions方法的典型用法代码示例。如果您正苦于以下问题:PHP BigTree::setPermissions方法的具体用法?PHP BigTree::setPermissions怎么用?PHP BigTree::setPermissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigTree
的用法示例。
在下文中一共展示了BigTree::setPermissions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createModule
function createModule($name, $group, $class, $table, $permissions, $icon, $route = false)
{
// Find an available module route.
$route = $route ? $route : BigTreeCMS::urlify($name);
if (!ctype_alnum(str_replace("-", "", $route)) || strlen($route) > 127) {
return false;
}
// Go through the hard coded modules
$existing = array();
$d = opendir(SERVER_ROOT . "core/admin/modules/");
while ($f = readdir($d)) {
if ($f != "." && $f != "..") {
$existing[] = $f;
}
}
// Go through the directories (really ajax, css, images, js)
$d = opendir(SERVER_ROOT . "core/admin/");
while ($f = readdir($d)) {
if ($f != "." && $f != "..") {
$existing[] = $f;
}
}
// Go through the hard coded pages
$d = opendir(SERVER_ROOT . "core/admin/pages/");
while ($f = readdir($d)) {
if ($f != "." && $f != "..") {
// Drop the .php
$existing[] = substr($f, 0, -4);
}
}
// Go through already created modules
$q = sqlquery("SELECT route FROM bigtree_modules");
while ($f = sqlfetch($q)) {
$existing[] = $f["route"];
}
// Get a unique route
$x = 2;
$oroute = $route;
while (in_array($route, $existing)) {
$route = $oroute . "-" . $x;
$x++;
}
$name = sqlescape(BigTree::safeEncode($name));
$route = sqlescape($route);
$class = sqlescape($class);
$group = $group ? "'" . sqlescape($group) . "'" : "NULL";
$gbp = BigTree::json($permissions, true);
$icon = sqlescape($icon);
sqlquery("INSERT INTO bigtree_modules (`name`,`route`,`class`,`icon`,`group`,`gbp`) VALUES ('{$name}','{$route}','{$class}','{$icon}',{$group},'{$gbp}')");
$id = sqlid();
if ($class) {
// Create class module.
$f = fopen(SERVER_ROOT . "custom/inc/modules/{$route}.php", "w");
fwrite($f, "<?\n");
fwrite($f, "\tclass {$class} extends BigTreeModule {\n");
fwrite($f, ' var $Table = "' . $table . '";' . "\n");
fwrite($f, "\t}\n");
fwrite($f, "?>\n");
fclose($f);
BigTree::setPermissions(SERVER_ROOT . "custom/inc/modules/{$route}.php");
// Remove cached class list.
unlink(SERVER_ROOT . "cache/bigtree-module-class-list.json");
}
$this->track("bigtree_modules", $id, "created");
return $id;
}