本文整理汇总了PHP中permissions::DELETE方法的典型用法代码示例。如果您正苦于以下问题:PHP permissions::DELETE方法的具体用法?PHP permissions::DELETE怎么用?PHP permissions::DELETE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类permissions
的用法示例。
在下文中一共展示了permissions::DELETE方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildPermissionsArray
function buildPermissionsArray($force = 0, $down = 0)
{
if (!$force && $this->builtPermissions) {
return;
}
$scope = get_class($this);
$site = $this->owning_site;
$id = $this->id;
// the SQL queries for obtaining the permissions vary with the scope type. Thus, we have 4 cases, 1 for each scope type.
// editors can be either institute, everyone, a username or a ugroup name
// we need two queries for any one scope
// CASE 1: scope is SITE
if ($scope == 'site') {
$query = "\nSELECT\n\tuser_uname as editor, ugroup_name as editor2, site_editors_type as editor_type,\n\tMAKE_SET(IFNULL((permission_value+0),0), 'v', 'a', 'e', 'd', 'di') as permissions\nFROM\n\tsite\n\t\tINNER JOIN\n\tsite_editors ON\n\t\tsite_id = " . $this->id . "\n\t\t\tAND\n\t\tsite_id = FK_site\n\t\tLEFT JOIN\n\tuser ON\n\t\tsite_editors.FK_editor = user_id\n\t\tLEFT JOIN\n\tugroup ON\n\t\tsite_editors.FK_editor = ugroup_id\n\t\tLEFT JOIN\n\tpermission ON\n\t\tsite_id = FK_scope_id\n\t\t\tAND\n\t\tpermission_scope_type = 'site'\n\t\t\tAND\n\t\tpermission.FK_editor <=> site_editors.FK_editor\n\t\t\tAND\n\t\tpermission_editor_type = site_editors_type\n";
} else {
if ($scope == 'section') {
$query = "\nSELECT\n\tuser_uname as editor, ugroup_name as editor2, site_editors_type as editor_type,\n\tMAKE_SET(IFNULL((p1.permission_value+0),0) | IFNULL((p2.permission_value+0),0), 'v', 'a', 'e', 'd', 'di') as permissions\nFROM\n\tsite\n\t\tINNER JOIN\n\tsection\n\t\tON site_id = section.FK_site\n\t\t\tAND\n\t\tsection_id = " . $this->id . "\n\t\tINNER JOIN\n\tsite_editors ON\n\t\tsite_id = site_editors.FK_site\n\t\tLEFT JOIN\n\tuser ON\n\t\tsite_editors.FK_editor = user_id\n\t\tLEFT JOIN\n\tugroup ON\n\t\tsite_editors.FK_editor = ugroup_id\n\t\tLEFT JOIN\n\tpermission as p1 ON\n\t\tsite_id = p1.FK_scope_id\n\t\t\tAND\n\t\tp1.permission_scope_type = 'site'\n\t\t\tAND\n\t\tp1.FK_editor <=> site_editors.FK_editor\n\t\t\tAND\n\t\tp1.permission_editor_type = site_editors_type\n\t\tLEFT JOIN \n\tpermission as p2 ON\n\t\tsection_id = p2.FK_scope_id\n\t\t\tAND\n\t\tp2.permission_scope_type = 'section'\n\t\t\tAND\n\t\tp2.FK_editor <=> site_editors.FK_editor\n\t\t\tAND\n\t\tp2.permission_editor_type = site_editors_type\n";
} else {
if ($scope == 'page') {
$query = "\nSELECT\n\tuser_uname as editor, ugroup_name as editor2, site_editors_type as editor_type,\n\tMAKE_SET(IFNULL((p1.permission_value+0),0) | IFNULL((p2.permission_value+0),0) | IFNULL((p3.permission_value+0),0), 'v', 'a', 'e', 'd', 'di') as permissions\nFROM\n\tsite\n\t\tINNER JOIN\n\tsection\n\t\tON site_id = section.FK_site\n\t\tINNER JOIN\n\tpage\n\t\tON section_id = page.FK_section\n\t\t\tAND\n\t\tpage_id = " . $this->id . "\n\t\tINNER JOIN\n\tsite_editors ON\n\t\tsite_id = site_editors.FK_site\n\t\tLEFT JOIN\n\tuser ON\n\t\tsite_editors.FK_editor = user_id\n\t\tLEFT JOIN\n\tugroup ON\n\t\tsite_editors.FK_editor = ugroup_id\n\t\tLEFT JOIN\n\tpermission as p1 ON\n\t\tsite_id = p1.FK_scope_id\n\t\t\tAND\n\t\tp1.permission_scope_type = 'site'\n\t\t\tAND\n\t\tp1.FK_editor <=> site_editors.FK_editor\n\t\t\tAND\n\t\tp1.permission_editor_type = site_editors_type\n\t\tLEFT JOIN \n\tpermission as p2 ON\n\t\tsection_id = p2.FK_scope_id\n\t\t\tAND\n\t\tp2.permission_scope_type = 'section'\n\t\t\tAND\n\t\tp2.FK_editor <=> site_editors.FK_editor\n\t\t\tAND\n\t\tp2.permission_editor_type = site_editors_type\n\t\tLEFT JOIN\n\tpermission as p3 ON\n\t\tpage_id = p3.FK_scope_id\n\t\t\tAND\n\t\tp3.permission_scope_type = 'page'\n\t\t\tAND\n\t\tp3.FK_editor <=> site_editors.FK_editor\n\t\t\tAND\n\t\tp3.permission_editor_type = site_editors_type\n";
} else {
if ($scope == 'story') {
$query = "\n\t\t\t\tSELECT\n\t\t\t\t\tuser_uname as editor, ugroup_name as editor2, site_editors_type as editor_type,\n\t\t\t\t\tMAKE_SET(IFNULL((p1.permission_value+0),0) | IFNULL((p2.permission_value+0),0) | IFNULL((p3.permission_value+0),0) | IFNULL((p4.permission_value+0),0), 'v', 'a', 'e', 'd', 'di') as permissions\n\t\t\t\tFROM\n\t\t\t\t\tsite\n\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\tsection\n\t\t\t\t\t\tON site_id = section.FK_site\n\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\tpage\n\t\t\t\t\t\tON section_id = page.FK_section\n\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\tstory\n\t\t\t\t\t\tON page_id = story.FK_page\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tstory_id = '" . addslashes($this->id) . "'\n\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\tsite_editors ON\n\t\t\t\t\t\tsite_id = site_editors.FK_site\n\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\tuser ON\n\t\t\t\t\t\tsite_editors.FK_editor = user_id\n\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\tugroup ON\n\t\t\t\t\t\tsite_editors.FK_editor = ugroup_id\n\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\tpermission as p1 ON\n\t\t\t\t\t\tsite_id = p1.FK_scope_id\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp1.permission_scope_type = 'site'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp1.FK_editor <=> site_editors.FK_editor\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp1.permission_editor_type = site_editors_type\n\t\t\t\t\t\tLEFT JOIN \n\t\t\t\t\tpermission as p2 ON\n\t\t\t\t\t\tsection_id = p2.FK_scope_id\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp2.permission_scope_type = 'section'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp2.FK_editor <=> site_editors.FK_editor\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp2.permission_editor_type = site_editors_type\n\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\tpermission as p3 ON\n\t\t\t\t\t\tpage_id = p3.FK_scope_id\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp3.permission_scope_type = 'page'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp3.FK_editor <=> site_editors.FK_editor\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp3.permission_editor_type = site_editors_type\n\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\tpermission as p4 ON\n\t\t\t\t\t\tstory_id = p4.FK_scope_id\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp4.permission_scope_type = 'story'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp4.FK_editor <=> site_editors.FK_editor\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tp4.permission_editor_type = site_editors_type\n\t\t\t\t";
}
}
}
}
// execute the query
// echo $query;
$r = db_query($query);
//echo "Query result: ".$r."<br />";
// reset the editor array
if ($r) {
$this->editors = array();
$this->permissions = array();
}
// for every permisson entry, add it to the permissions array
while ($row = db_fetch_assoc($r)) {
// decode 'final_permissions';
// 'final_permissions' is a field returned by the query and contains a string of the form "'a','vi','e'" etc.
$a = array();
$dbPerms = explode(",", $row[permissions]);
$a[v] = in_array('v', $dbPerms);
$a[a] = in_array('a', $dbPerms);
$a[e] = in_array('e', $dbPerms);
$a[d] = in_array('d', $dbPerms);
$a[di] = in_array('di', $dbPerms);
// Trash the db perms variable.
$dbPerms = NULL;
unset($dbPerms);
// if the editor is a user then the editor's name is just the user name
// if the editor is 'institute' or 'everyone' then set the editor's name correspondingly
if ($row[editor_type] == 'user') {
$t_editor = $row[editor];
} else {
if ($row[editor_type] == 'ugroup') {
$t_editor = $row[editor2];
} else {
$t_editor = $row[editor_type];
}
}
// Everyone and institute can't have add, edit, or delete permissions.
// Somehow, these were added sometimes. If this is the case, prevent
// these from being set and reset those for the site.
if ($t_editor == 'everyone' || $t_editor == 'institute') {
// If we have a bad permission, do cleanup.
if ($a[a] || $a[e] || $a[d]) {
// Make sure that zeros get passed on.
$a[a] = 0;
$a[e] = 0;
$a[d] = 0;
// Clean up the permissions
$this->owningSiteObj->setUserPermissionDown('add', $t_editor, 0);
$this->owningSiteObj->setUserPermissionDown('edit', $t_editor, 0);
$this->owningSiteObj->setUserPermissionDown('delete', $t_editor, 0);
$this->owningSiteObj->updatePermissionsDB(TRUE);
}
}
// echo "<br /><br />Editor: $t_editor; Add: $a[a]; Edit: $a[e]; Delete: $a[d]; View: $a[v]; Discuss: $a[di];";
// set the permissions for this editor
// $this->permissions[strtolower($t_editor)] = array(
$this->permissions[$t_editor] = array(permissions::ADD() => $a[a] || $this->permissions[$t_editor] && $this->permissions[$t_editor][permissions::ADD()], permissions::EDIT() => $a[e] || $this->permissions[$t_editor] && $this->permissions[$t_editor][permissions::EDIT()], permissions::DELETE() => $a[d] || $this->permissions[$t_editor] && $this->permissions[$t_editor][permissions::DELETE()], permissions::VIEW() => $a[v] || $this->permissions[$t_editor] && $this->permissions[$t_editor][permissions::VIEW()], permissions::DISCUSS() => $a[di] || $this->permissions[$t_editor] && $this->permissions[$t_editor][permissions::DISCUSS()]);
// now add the editor to the editor array
// $this->editors[]=strtolower($t_editor);
if ($t_editor) {
$this->editors[] = $t_editor;
}
}
// print_r($this->permissions);
$this->builtPermissions = 1;
if ($down) {
$ar = $this->_object_arrays[$scope];
if ($ar) {
$a =& $this->{$ar};
if ($a) {
foreach ($a as $i => $o) {
$a[$i]->buildPermissionsArray($force, $down);
}
}
}
//.........这里部分代码省略.........
示例2: fetchSiteAtOnceForeverAndEverAndDontForgetThePermissionsAsWell_Amen
//.........这里部分代码省略.........
$story->fetcheddown = 1;
$story->fetched_forever_and_ever = 1;
}
$query = "\n\t\t\tSELECT\n\t\t\t\tuser_uname as editor, ugroup_name as editor2, site_editors_type as editor_type,\n\t\t\t\tMAKE_SET(IFNULL((permission_value+0),0), 'v', 'a', 'e', 'd', 'di') as permissions\n\t\t\tFROM\n\t\t\t\tt_sites\n\t\t\t\t\tINNER JOIN\n\t\t\t\tsite_editors ON\n\t\t\t\t\tsite_id = FK_site\n\t\t\t\t\tLEFT JOIN\n\t\t\t\tuser\n\t\t\t\t\tON site_editors.FK_editor = user_id\n\t\t\t\t\tLEFT JOIN\n\t\t\t\tugroup\n\t\t\t\t\tON site_editors.FK_editor = ugroup_id\n\t\t\t\t\tLEFT JOIN\n\t\t\t\tpermission ON\n\t\t\t\t\tsite_id = FK_scope_id\n\t\t\t\t\t\tAND\n\t\t\t\t\tpermission_scope_type = 'site'\n\t\t\t\t\t\tAND\n\t\t\t\t\tpermission.FK_editor <=> site_editors.FK_editor\n\t\t\t\t\t\tAND\n\t\t\t\t\tpermission_editor_type = site_editors_type\n\t\t";
$r = db_query($query);
$this->editors = array();
$this->permissions = array();
$this->cachedPermissions = array();
// for every permisson entry, add it to the permissions array
while ($row = db_fetch_assoc($r)) {
// decode 'final_permissions';
// 'final_permissions' is a field returned by the query and contains a string of the form "'a','vi','e'" etc.
$a = array();
$a[a] = strpos($row[permissions], 'a') !== false ? 1 : 0;
// look for 'a' in 'final_permissions'
$a[e] = strpos($row[permissions], 'e') !== false ? 1 : 0;
// !== is very important here, because a position 0 is interpreted by != as FALSE
$a[d] = strpos($row[permissions], 'd') !== false && strpos($row[permissions], 'd') !== strpos($row[permissions], 'di') ? 1 : 0;
$a[v] = strpos($row[permissions], 'v') !== false ? 1 : 0;
$a[di] = strpos($row[permissions], 'di') !== false ? 1 : 0;
// if the editor is a user then the editor's name is just the user name
// if the editor is 'institute' or 'everyone' then set the editor's name correspondingly
if ($row[editor_type] == 'user') {
$t_editor = $row[editor];
} else {
if ($row[editor_type] == 'ugroup') {
$t_editor = $row[editor2];
} else {
$t_editor = $row[editor_type];
}
}
// echo "<br /><br />Editor: $t_editor; Add: $a[a]; Edit: $a[e]; Delete: $a[d]; View: $a[v]; Discuss: $a[di]; On the Site";
// set the permissions for this editor
$this->permissions[$t_editor] = array(permissions::ADD() => $a[a] || $this->permissions[$t_editor] && $this->permissions[$t_editor][permissions::ADD()], permissions::EDIT() => $a[e] || $this->permissions[$t_editor] && $this->permissions[$t_editor][permissions::EDIT()], permissions::DELETE() => $a[d] || $this->permissions[$t_editor] && $this->permissions[$t_editor][permissions::DELETE()], permissions::VIEW() => $a[v] || $this->permissions[$t_editor] && $this->permissions[$t_editor][permissions::VIEW()], permissions::DISCUSS() => $a[di] || $this->permissions[$t_editor] && $this->permissions[$t_editor][permissions::DISCUSS()]);
if ($a[v]) {
$this->canview[$t_editor] = 1;
}
/* $this->cachedPermissions = array(
$t_editor."ADD"=>$a[a],
$t_editor."EDIT"=>$a[e],
$t_editor."DELETE"=>$a[d],
$t_editor."VIEW"=>$a[v],
$t_editor."DISCUSS"=>$a[di]
);*/
// now add the editor to the editor array
$this->editors[] = $t_editor;
}
// now, inherit the permissions to the children
foreach (array_keys($this->sections) as $key => $section_id) {
$this->sections[$section_id]->editors = $this->editors;
$this->sections[$section_id]->permissions = $this->permissions;
}
$this->builtPermissions = 1;
$query = "\n\t\t\tSELECT\n\t\t\t\tsection_id, user_uname as editor, ugroup_name as editor2, site_editors_type as editor_type,\n\t\t\t\tMAKE_SET(IFNULL((permission_value+0),0), 'v', 'a', 'e', 'd', 'di') as permissions\n\t\t\tFROM\n\t\t\t\tt_sections\n\t\t\t\t\tINNER JOIN\n\t\t\t\tsite_editors ON\n\t\t\t\t\tsite_id = site_editors.FK_site\n\t\t\t\t\tLEFT JOIN\n\t\t\t\tuser ON\n\t\t\t\t\tsite_editors.FK_editor = user_id\n\t\t\t\t\tLEFT JOIN\n\t\t\t\tugroup ON\n\t\t\t\t\tsite_editors.FK_editor = ugroup_id\n\t\t\t\t\tINNER JOIN\n\t\t\t\tpermission ON\n\t\t\t\t\tsection_id = FK_scope_id\n\t\t\t\t\t\tAND\n\t\t\t\t\tpermission_scope_type = 'section'\n\t\t\t\t\t\tAND\n\t\t\t\t\tpermission.FK_editor <=> site_editors.FK_editor\n\t\t\t\t\t\tAND\n\t\t\t\t\tpermission_editor_type = site_editors_type\n\t\t";
$r = db_query($query);
// for every permisson entry, add it to the permissions array
while ($row = db_fetch_assoc($r)) {
// decode 'final_permissions';
// 'final_permissions' is a field returned by the query and contains a string of the form "'a','vi','e'" etc.
$a = array();
if (strpos($row[permissions], 'a') !== false) {
$a[permissions::ADD()] = 1;
}
// look for 'a' in 'final_permissions'
if (strpos($row[permissions], 'e') !== false) {
$a[permissions::EDIT()] = 1;