本文整理汇总了PHP中Network::is_admin方法的典型用法代码示例。如果您正苦于以下问题:PHP Network::is_admin方法的具体用法?PHP Network::is_admin怎么用?PHP Network::is_admin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::is_admin方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup_module
function setup_module($column, $moduleName, $obj)
{
global $content_type, $users, $post_type_message, $post_type, $network_info, $paging;
switch ($moduleName) {
case 'ImagesModule':
$obj->block_type = 'Gallery';
$obj->page = "homepage";
$obj->title = __("Recent Media");
break;
case 'EventCalendarSidebarModule':
$obj->assoc_type = "network";
$obj->assoc_id = $network_info->network_id;
$obj->title = 'Events';
if (isset($_SESSION['user']['id'])) {
$is_admin = Network::is_admin($network_info->network_id, (int) $_SESSION['user']['id']);
} else {
$is_admin = FALSE;
}
if ($is_admin) {
$obj->may_edit = true;
} else {
$obj->may_edit = false;
}
break;
case 'ShowContentModule':
//not sure why this is being used here
// TODO : find out reason of using this and fix it
$obj->cid = @$_GET['cid'];
$obj->mode = PUB;
$obj->block_type = HOMEPAGE;
$obj->content_type = $content_type;
$obj->uid = 0;
$obj->message = $post_type_message[$post_type];
// This message array is defined in config.inc
$obj->Paging["page"] = $paging["page"];
$obj->Paging["show"] = 10;
break;
case 'AdsByGoogleModule':
$obj->block_type = HOMEPAGE;
break;
case 'NewestGroupsModule':
$obj->block_type = HOMEPAGE_SORTBY;
$obj->sort_by = TRUE;
break;
case 'RecentPostModule':
$obj->type = 'homepage';
break;
}
}
示例2: generate_inner_html
function generate_inner_html()
{
if (PA::$network_info->type == MOTHER_NETWORK_TYPE) {
if (PA::$login_uid == SUPER_USER_ID) {
$this->set_perms('all');
} else {
$tasks = $this->get_user_task_permissions(PA::$login_uid);
if (count($tasks) == 0) {
$this->set_perms('none');
} else {
$this->set_perms($tasks);
}
}
} else {
//spawned networks admin has all permissions
if (Network::is_admin(PA::$network_info->network_id, PA::$login_uid) || PA::$login_uid == SUPER_USER_ID) {
//owner of network
$this->set_perms('all');
//todo - quick fix here
$this->task_perms['meta_networks'] = FALSE;
} else {
$tasks = $this->get_user_task_permissions(PA::$login_uid);
if (count($tasks) == 0) {
$this->set_perms('none');
} else {
$this->set_perms($tasks);
}
}
}
$extra = unserialize(PA::$network_info->extra);
$network_content_moderation = FALSE;
if (@$extra['network_content_moderation'] == NET_YES) {
// this can be empty or not set
$network_content_moderation = TRUE;
}
$inner_template = NULL;
switch ($this->mode) {
default:
$inner_template = PA::$blockmodule_path . '/' . get_class($this) . '/center_inner_private.tpl';
}
$obj_inner_template = new Template($inner_template);
$obj_inner_template->set('task_perms', $this->task_perms);
$obj_inner_template->set('network_content_moderation', $network_content_moderation);
$inner_html = $obj_inner_template->fetch();
return $inner_html;
}
示例3: current_user_can
function current_user_can($action)
{
global $network_info;
//TODO write call back functions for each action
if ('configure_network' == $action || 'delete_network' == $action || 'network_announcement' == $action || 'network_bulletins' == $action || 'manage_user' == $action || 'manage_content' == $action || 'new_user_create' == $action || 'network_links' == $action || 'change_skin' == $action || 'configure_splash_page' == $action || 'customize_ui' == $action || 'moderate_content' == $action) {
if ($network_info) {
if (!Network::is_admin($network_info->network_id, $_SESSION['user']['id'])) {
return FALSE;
} else {
return TRUE;
}
} else {
//right now return true simply
//TODO: write code for mother network check
return TRUE;
}
}
}
示例4: generate_inner_html
function generate_inner_html()
{
global $current_theme_path, $base_url, $network_info, $login_uid;
if ($network_info->type == MOTHER_NETWORK_TYPE) {
if ($login_uid == SUPER_USER_ID) {
$this->set_perms('all');
} else {
$role_obj = Roles::get_user_role($login_uid);
if (empty($role_obj)) {
$this->set_perms('none');
} else {
$tasks = Roles::get_tasks_of_role($role_obj->role_id);
$this->set_perms($tasks);
}
}
} else {
//spawned networks only admin roles
if (Network::is_admin($network_info->network_id, $login_uid) || $login_uid == SUPER_USER_ID) {
//owner of network
$this->set_perms('all');
//todo - quick fix here
$this->task_perms['meta_networks'] = FALSE;
} else {
$this->set_perms('none');
}
}
$extra = unserialize($network_info->extra);
$network_content_moderation = FALSE;
if (@$extra['network_content_moderation'] == NET_YES) {
// this can be empty or not set
$network_content_moderation = TRUE;
}
$inner_template = NULL;
switch ($this->mode) {
default:
$inner_template = dirname(__FILE__) . '/center_inner_private.tpl';
}
$obj_inner_template =& new Template($inner_template);
$obj_inner_template->set('base_url', $base_url);
$obj_inner_template->set('task_perms', $this->task_perms);
$obj_inner_template->set('network_content_moderation', $network_content_moderation);
$inner_html = $obj_inner_template->fetch();
return $inner_html;
}
示例5: setup_module
function setup_module($column, $module, $obj)
{
global $login_uid;
switch ($module) {
case 'EventCalendarModule':
$obj->title = 'Network Events';
$obj->assoc_type = 'network';
$obj->assoc_id = PA::$network_info->network_id;
$obj->assoc_title = PA::$network_info->name;
$is_admin = Network::is_admin(PA::$network_info->network_id, $login_uid);
if ($is_admin) {
$obj->may_edit = true;
} else {
$obj->may_edit = false;
}
break;
}
$obj->mode = PUB;
}
示例6: setup_module
function setup_module($column, $module, $obj)
{
global $network_info, $login_uid, $configure_permission;
switch ($module) {
case 'EventCalendarModule':
if (!$configure_permission) {
return 'skip';
}
$obj->title = 'Network Events';
$obj->assoc_type = 'network';
$obj->assoc_id = $network_info->network_id;
$obj->assoc_title = $network_info->name;
$is_admin = Network::is_admin($network_info->network_id, $login_uid);
if ($is_admin) {
$obj->may_edit = true;
} else {
$obj->may_edit = false;
}
break;
}
$obj->mode = PUB;
}
示例7: __construct
/**
Purpose : this function is used to get navigation links for the whole page.
Scope : public
@param - it needs no direct input. But works only on the basis of current page initialized in __construct()
@return - array of links
**/
public function get_links($optional = NULL)
{
//initialization
global $dynamic_page;
if (isset($_SESSION['user']['id'])) {
$extra = unserialize($this->network_info->extra);
if (@$extra['reciprocated_relationship'] == NET_YES) {
$status = APPROVED;
} else {
$status = FALSE;
}
$relations_ids = Relation::get_relations((int) $_SESSION['user']['id'], $status, PA::$network_info->network_id);
$user_groups = Group::get_user_groups((int) $_SESSION['user']['id']);
/* $gid isn't defined in this function, so the following call
* will probably always return FALSE. To get rid of the warning
* under E_ALL, I've replaced the following expression with
* FALSE. Maybe $gid should be get_group_id()? */
$is_owner_of_group = FALSE;
//Group::is_admin($gid,(int)$_SESSION['user']['id']) ;
}
if (isset($relations_ids) && sizeof($relations_ids)) {
$this->set_friend_uid($relations_ids[0]);
}
if (isset($user_groups) && sizeof($user_groups)) {
$this->users_first_group_id($user_groups[0]['gid']);
}
if (PA::$login_uid) {
$this->set_uid(PA::$login_uid);
} else {
$this->set_anonymous();
}
$is_group_content = FALSE;
if (@$_GET['gid']) {
$this->set_group_id($_GET['gid']);
} else {
if ((FILE_FORUM_MESSAGES == $this->current_page || FILE_CONTENT == $this->current_page) && !empty($_REQUEST['ccid']) && $_REQUEST['ccid'] > 0) {
$this->set_group_id($_REQUEST['ccid']);
$is_group_content = TRUE;
} else {
if (PAGE_PERMALINK == $this->current_page && !empty($_GET['cid'])) {
try {
$content_data = Content::load_content($_GET['cid'], $this->get_uid());
} catch (PAException $e) {
if ($e->getCode() != CONTENT_NOT_FOUND) {
throw $e;
}
}
if (isset($content_data)) {
if ($content_data->parent_collection_id > 0) {
$content_collection_data = ContentCollection::load_collection($content_data->parent_collection_id, $this->get_uid());
if ($content_collection_data->type == GROUP_COLLECTION_TYPE) {
$this->set_group_id($content_data->parent_collection_id);
$is_group_content = TRUE;
}
}
}
}
}
}
//test
//$this->current_page='test.php';
// make links for current page
$this->make_links();
$level_1 = $this->get_level_1();
$level_2 = $this->get_level_2();
$level_3 = NULL;
$left_user_public_links = NULL;
if (Network::is_admin($this->network_info->network_id, (int) @$_SESSION['user']['id'])) {
$level_3 = $this->get_level_3('network');
} else {
if (!$this->network_info && $_SESSION['user']['id'] == SUPERUSER) {
$level_3 = $this->get_level_3('network');
}
}
$level_3 = NULL;
switch ($this->current_page) {
/*----------------------------------------------------*/
case PAGE_HOMEPAGE:
$level_3 = NULL;
$level_2['highlight'] = 'home';
break;
case FILE_LOGIN:
$level_2['highlight'] = 'home';
break;
case PAGE_SEARCH:
//fix by Zoran Hron: constants FILE_SEARCH_HOME and FILE_SHOWCONTENT points to the same value !!!
if (!empty($_GET['gid'])) {
$level_2['highlight'] = 'groups';
$level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general'));
} else {
if (!empty($_GET['btn_searchContent'])) {
$level_2['highlight'] = 'search';
} else {
$level_3 = NULL;
//.........这里部分代码省略.........
示例8: array
<?php
$login_required = TRUE;
include "includes/page.php";
require "{$path_prefix}/ext/Album/Album.php";
require "{$path_prefix}/ext/Image/Image.php";
require "{$path_prefix}/ext/Audio/Audio.php";
require "{$path_prefix}/ext/Video/Video.php";
require_once "{$path_prefix}/api/Activities/Activities.php";
$location = $base_url . '/manage_user.php';
$permission = FALSE;
if (Network::is_admin($network_info->network_id, $_SESSION['user']['id'])) {
$permission = TRUE;
}
if (!empty($_GET['msg']) && $_GET['msg'] == 'own_delete') {
$permission = TRUE;
$user_id = $_SESSION['user']['id'];
$location = $base_url . '/homepage.php';
} else {
if (!($user_id = $_GET['uid'])) {
$location .= '?msg=7005';
}
}
if ($user_id && $permission) {
$message_array = array();
if ($network_info->type == MOTHER_NETWORK_TYPE) {
//user delete for SU
//deleting user data from mothership
try {
User::delete_user($user_id);
Activities::delete_for_user($user_id);
示例9: can_manage_forum
private function can_manage_forum($params, $type)
{
$board_type = $params['board']->get_type();
if ($board_type == 'group' && !empty($params['gid'])) {
// it is a group forum
$user_type = Group::get_user_type($params['user_id'], $params['gid']);
if ($user_type == MODERATOR || $user_type == OWNER) {
return true;
}
$group_permiss = @$this->user_permissions['groups'][$params['gid']];
if (!empty($group_permiss)) {
if (in_array('manage_content', $group_permiss)) {
return true;
}
}
}
if ($board_type == 'network') {
$is_net_admin = Network::is_admin($params['board']->get_network_id(), $params['user_id']);
if ($is_net_admin) {
return true;
}
$net_permiss = @$this->user_permissions['network'];
if (!empty($net_permiss)) {
if (in_array('manage_content', $net_permiss)) {
return true;
}
}
}
if ($board_type == 'user') {
if ($params['user_id'] == $params['board']->get_owner_id()) {
return true;
}
}
return false;
}
示例10: __construct
/**
Purpose : this function is used to get navigation links for the whole page.
Scope : public
@param - it needs no direct input. But works only on the basis of current page initialized in __construct()
@return - array of links
**/
public function get_links($optional = NULL)
{
//initialization
global $page_uid, $login_uid;
if (isset($_SESSION['user']['id'])) {
$extra = unserialize($this->network_info->extra);
if (@$extra['reciprocated_relationship'] == NET_YES) {
$status = APPROVED;
} else {
$status = FALSE;
}
$relations_ids = Relation::get_relations((int) $_SESSION['user']['id'], $status);
$user_groups = Group::get_user_groups((int) $_SESSION['user']['id']);
/* $gid isn't defined in this function, so the following call
* will probably always return FALSE. To get rid of the warning
* under E_ALL, I've replaced the following expression with
* FALSE. Maybe $gid should be get_group_id()? */
$is_owner_of_group = FALSE;
//Group::is_admin($gid,(int)$_SESSION['user']['id']) ;
}
if (isset($relations_ids) && sizeof($relations_ids)) {
$this->set_friend_uid($relations_ids[0]);
}
if (isset($user_groups) && sizeof($user_groups)) {
$this->users_first_group_id($user_groups[0]['gid']);
}
if ($login_uid) {
$this->set_uid($login_uid);
} else {
$this->set_anonymous();
}
$is_group_content = FALSE;
if (@$_GET['gid']) {
$this->set_group_id($_GET['gid']);
} else {
if ((FILE_FORUM_MESSAGES == $this->current_page || FILE_CONTENT == $this->current_page) && !empty($_REQUEST['ccid'])) {
$this->set_group_id($_REQUEST['ccid']);
$is_group_content = TRUE;
} else {
if (FILE_CONTENT == $this->current_page && !empty($_GET['cid'])) {
try {
$content_data = Content::load_content($_GET['cid'], $this->get_uid());
} catch (PAException $e) {
if ($e->getCode() != CONTENT_NOT_FOUND) {
throw $e;
}
}
if (isset($content_data)) {
if ($content_data->parent_collection_id > 0) {
$content_collection_data = ContentCollection::load_collection($content_data->parent_collection_id, $this->get_uid());
if ($content_collection_data->type == GROUP_COLLECTION_TYPE) {
$this->set_group_id($content_data->parent_collection_id);
$is_group_content = TRUE;
}
}
}
}
}
}
//test
//$this->current_page='test.php';
// make links for current page
$this->make_links();
$level_1 = $this->get_level_1();
$level_2 = $this->get_level_2();
$level_3 = NULL;
$left_user_public_links = NULL;
if (Network::is_admin($this->network_info->network_id, (int) @$_SESSION['user']['id'])) {
$level_3 = $this->get_level_3('network');
} else {
if (!$this->network_info && $_SESSION['user']['id'] == SUPERUSER) {
$level_3 = $this->get_level_3('network');
}
}
$level_3 = NULL;
switch ($this->current_page) {
/*----------------------------------------------------*/
case FILE_HOMEPAGE:
$level_3 = NULL;
$level_2['highlight'] = 'home';
break;
case FILE_LOGIN:
$level_2['highlight'] = 'home';
break;
case FILE_SEARCH_HOME:
$level_2['highlight'] = 'search';
break;
case FILE_TAG_SEARCH:
$level_2['highlight'] = 'tag_search';
break;
/*----------------------------------------------------*/
/*----------------------------------------------------*/
case FILE_USER:
case FILE_USER_BLOG:
//.........这里部分代码省略.........
示例11: user_can
/**
* function used to check permissions for user to do an activity
* @param $params is array of parameters like $params['action'], $param['uid']..
*/
function user_can($params)
{
global $network_info, $login_uid;
$action = $params['action'];
switch ($action) {
case 'edit_content':
case 'delete_content':
if ($params['uid'] && $params['cid']) {
//super admin can edit/ delete any content
if ($params['uid'] == SUPER_USER_ID) {
return true;
}
// network owner can edit / delete any content in a network
if (Network::is_admin($network_info->network_id, $params['uid'])) {
return true;
}
//Loading content
$content_obj = Content::load_content((int) $params['cid'], $params['uid']);
//author of the content can perform the action
if ($content_obj->author_id == $params['uid']) {
return true;
}
if ($content_obj->parent_collection_id != -1) {
// content is a part of some collection
// Loading collection
$collection_obj = ContentCollection::load_collection((int) $content_obj->parent_collection_id, $params['uid']);
// owner of collection can also edit the content
if ($collection_obj->author_id == $params['uid']) {
return true;
}
}
}
break;
case 'delete_comment':
//network owner can delete any comment
$comment = $params['comment_info'];
//array having the comment details
if ($login_uid == SUPER_USER_ID) {
//Super user can delete any comment
return true;
} else {
if ($network_info->owner_id == $login_uid) {
//Network owner can delete the comment
return true;
} else {
if ($comment['user_id'] == $login_uid) {
//Author of comment can delete the comment
return true;
} else {
if ($comment['recipient_id'] == $login_uid) {
return true;
}
}
}
}
$content = Content::load_content((int) $comment['content_id'], $login_uid);
if ($content->author_id == $login_uid) {
//Author of the content can delete the comment.
return true;
} else {
if ($content->parent_collection_id != -1) {
// means content belongs to some collection
$collection = ContentCollection::load_collection($content->parent_collection_id, $login_id);
if ($collection->author_id == $login_uid) {
//If content on which comment has been posted belongs to some collection then author of that collection can delete the comment
return true;
}
}
}
return false;
// return false in all the other cases
break;
case 'edit_forum':
$perm_array = array($network_info->owner_id, SUPER_USER_ID, $params['group_owner'], $params['forum_owner']);
return in_array($login_uid, $perm_array);
break;
case 'delete_rep':
// Delete the Replies of forum
$perm_array = array($network_info->owner_id, SUPER_USER_ID, $params['group_owner'], $params['forum_owner'], $params['rep_owner']);
return in_array($login_uid, $perm_array);
break;
case 'view_group_content':
if ($params['allow_anonymous']) {
return true;
}
$perm_array = array($network_info->owner_id, SUPER_USER_ID, $params['group_owner']);
$member_type = array(MEMBER, MODERATOR, OWNER);
if (in_array($login_uid, $perm_array) || in_array($params['member_type'], $member_type)) {
return true;
}
break;
case 'view_abuse_report_form':
if (empty($login_uid)) {
return false;
}
$extra = unserialize($network_info->extra);
//.........这里部分代码省略.........