当前位置: 首页>>代码示例>>PHP>>正文


PHP Contact::isAdministrator方法代码示例

本文整理汇总了PHP中Contact::isAdministrator方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::isAdministrator方法的具体用法?PHP Contact::isAdministrator怎么用?PHP Contact::isAdministrator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contact的用法示例。


在下文中一共展示了Contact::isAdministrator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: userHasSystemPermission

 static function userHasSystemPermission(Contact $user, $system_permission)
 {
     if ($user->isAdministrator()) {
         return true;
     }
     if (array_var(self::$permission_cache, $user->getId())) {
         if (array_key_exists($system_permission, self::$permission_cache[$user->getId()])) {
             return array_var(self::$permission_cache[$user->getId()], $system_permission);
         }
     }
     if (array_var(self::$permission_group_ids_cache, $user->getId())) {
         $contact_pg_ids = self::$permission_group_ids_cache[$user->getId()];
     } else {
         $contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV($user->getId(), false);
         self::$permission_group_ids_cache[$user->getId()] = $contact_pg_ids;
     }
     $permission = self::findOne(array('conditions' => "`{$system_permission}` = 1 AND `permission_group_id` IN ({$contact_pg_ids})"));
     if (!array_var(self::$permission_cache, $user->getId())) {
         self::$permission_cache[$user->getId()] = array();
     }
     if (!array_key_exists($system_permission, self::$permission_cache[$user->getId()])) {
         self::$permission_cache[$user->getId()][$system_permission] = !is_null($permission);
     }
     if (!is_null($permission)) {
         return true;
     }
     return false;
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:28,代码来源:SystemPermissions.class.php

示例2: render_system_notices

/**
 * This function will render system notices for this user
 *
 * @param Contact $user
 * @return string
 */
function render_system_notices(Contact $user) {
	if(!$user->isAdministrator()) return;

	$system_notices = array();
	if (config_option('upgrade_last_check_new_version', false)) $system_notices[] = lang('new Feng Office version available', get_url('administration', 'upgrade'));

	if(count($system_notices)) {
		tpl_assign('_system_notices', $system_notices);
		return tpl_fetch(get_template_path('system_notices', 'application'));
	} // if
} // render_system_notices
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:17,代码来源:application.php

示例3: getActiveContextPermissions

 function getActiveContextPermissions(Contact $contact, $object_type_id, $context, $dimension_members, $can_write = false, $can_delete = false)
 {
     if ($contact instanceof Contact && $contact->isAdministrator()) {
         return $dimension_members;
     }
     $allowed_members = array();
     $permission_group_ids = ContactPermissionGroups::getContextPermissionGroupIdsByContactCSV($contact->getId());
     $perm_ids_array = explode(",", $permission_group_ids);
     foreach ($perm_ids_array as $pid) {
         foreach ($dimension_members as $member_id) {
             //check if exists a context permission group for this object type id in this member
             $contact_member_permission = self::findById(array('permission_group_id' => $pid, 'member_id' => $member_id, 'object_type_id' => $object_type_id));
             if ($contact_member_permission instanceof ContactMemberPermission && (!$can_write || $contact_member_permission->getCanWrite() && !$can_delete || $contact_member_permission->getCanDelete())) {
                 $permission_contexts = PermissionContexts::findAll(array('`contact_id` = ' . $contact->getId(), 'permission_group_id' => $pid, 'member_id' => $member_id));
                 //check if the actual context applies to this permission group
                 if (!is_null($permission_contexts)) {
                     $dimensions = array();
                     $context_members = array();
                     foreach ($permission_contexts as $pc) {
                         $member = $pc->getMember();
                         $dimension_id = $member->getDimensionId();
                         if (!in_array($dimension_id, $dimensions)) {
                             $dimensions[] = $dimension_id;
                             $context_members[$dimension_id] = array();
                         }
                         $context_members[$dimension_id][] = $member;
                     }
                     $include = true;
                     foreach ($dimensions as $dim_id) {
                         $members_in_context = array();
                         foreach ($context_members[$dim_id] as $value) {
                             if (in_array($value, $context)) {
                                 $members_in_context[] = $value;
                             }
                         }
                         if (count($members_in_context) == 0) {
                             $include = $include && false;
                         }
                     }
                     if ($include && count($dimensions) != 0) {
                         $allowed_members[] = $member_id;
                     }
                 }
             }
         }
     }
     return $allowed_members;
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:48,代码来源:ContactMemberPermissions.class.php

示例4: userHasSystemPermission

 static function userHasSystemPermission(Contact $user, $system_permission)
 {
     if ($user instanceof Contact && $user->isAdministrator()) {
         return true;
     }
     if (array_var(self::$permission_cache, $user->getId())) {
         if (array_key_exists($system_permission, self::$permission_cache[$user->getId()])) {
             return array_var(self::$permission_cache[$user->getId()], $system_permission);
         }
     }
     if (array_var(self::$permission_group_ids_cache, $user->getId())) {
         $contact_pg_ids = self::$permission_group_ids_cache[$user->getId()];
     } else {
         $contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV($user->getId(), false);
         self::$permission_group_ids_cache[$user->getId()] = $contact_pg_ids;
     }
     $permission = self::findOne(array('conditions' => "`{$system_permission}` = 1 AND `permission_group_id` IN ({$contact_pg_ids})"));
     // check max system permission
     $max_role_system_permissions = MaxSystemPermissions::findOne(array('conditions' => 'permission_group_id = ' . $user->getUserType()));
     if ($max_role_system_permissions instanceof MaxSystemPermission) {
         $max_val = $max_role_system_permissions->getColumnValue($system_permission);
         if (!$max_val) {
             $permission = null;
         }
     }
     if (!array_var(self::$permission_cache, $user->getId())) {
         self::$permission_cache[$user->getId()] = array();
     }
     if (!array_key_exists($system_permission, self::$permission_cache[$user->getId()])) {
         self::$permission_cache[$user->getId()][$system_permission] = !is_null($permission);
     }
     if (!is_null($permission)) {
         return true;
     }
     return false;
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:36,代码来源:SystemPermissions.class.php

示例5: canAddClient

 /**
  * Returns true if specific user can add client company
  *
  * @access public
  * @param User $user
  * @return boolean
  */
 function canAddClient(Contact $user)
 {
     return $user->isAccountOwner() || $user->isAdministrator($this);
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:11,代码来源:Contact.class.php

示例6: can_access

/**
 * Return true is $user can access an $object. False otherwise.
 *
 * @param Contact $user
 * @param array $members
 * @param $object_type_id
 * @return boolean
 */
function can_access(Contact $user, $members, $object_type_id, $access_level)
{
    if ($user->isAdministrator()) {
        return true;
    }
    $write = $access_level == ACCESS_LEVEL_WRITE;
    $delete = $access_level == ACCESS_LEVEL_DELETE;
    if ($user->isGuest() && $access_level != ACCESS_LEVEL_READ || !count($members) > 0) {
        return false;
    }
    try {
        $contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV($user->getId(), false);
        $allow_all_cache = array();
        $dimension_permissions = array();
        foreach ($members as $k => $m) {
            if (!$m instanceof Member) {
                unset($members[$k]);
                continue;
            }
            $dimension = $m->getDimension();
            if (!$dimension->getDefinesPermissions()) {
                continue;
            }
            $dimension_id = $dimension->getId();
            if (!isset($dimension_permissions[$dimension_id])) {
                $dimension_permissions[$dimension_id] = false;
            }
            if (!$dimension_permissions[$dimension_id]) {
                if ($m->canContainObject($object_type_id)) {
                    //dimension defines permissions and user has maximum level of permissions
                    if (isset($allow_all_cache[$dimension_id])) {
                        $allow_all = $allow_all_cache[$dimension_id];
                    } else {
                        $allow_all = $dimension->hasAllowAllForContact($contact_pg_ids);
                        $allow_all_cache[$dimension_id] = $allow_all;
                    }
                    if ($allow_all) {
                        $dimension_permissions[$dimension_id] = true;
                    }
                    //check individual members
                    if (!$dimension_permissions[$dimension_id] && ContactMemberPermissions::contactCanReadObjectTypeinMember($contact_pg_ids, $m->getId(), $object_type_id, $write, $delete, $user)) {
                        $dimension_permissions[$dimension_id] = true;
                    }
                } else {
                    unset($dimension_permissions[$dimension_id]);
                }
            }
        }
        $allowed = true;
        foreach ($dimension_permissions as $perm) {
            if (!$perm) {
                $allowed = false;
            } else {
                return true;
                // if user has permission in one of the object's members then can access = true
            }
        }
        if ($allowed && count($dimension_permissions)) {
            return true;
        }
        // Si hasta aca tienen perm en todas las dim, return true. Si hay alguna que no tiene perm sigo
        //Check Context Permissions
        $member_ids = array();
        foreach ($members as $member_obj) {
            $member_ids[] = $member_obj->getId();
        }
        $allowed_members = ContactMemberPermissions::getActiveContextPermissions($user, $object_type_id, $members, $member_ids, $write, $delete);
        $count = 0;
        foreach ($members as $m) {
            $count++;
            if (!in_array($m->getId(), $allowed_members)) {
                return false;
            } else {
                if ($count == count($members)) {
                    return true;
                }
            }
        }
    } catch (Exception $e) {
        tpl_assign('error', $e);
        return false;
    }
    return false;
}
开发者ID:rorteg,项目名称:fengoffice,代码行数:92,代码来源:permissions.php

示例7: array

	/**
	 * Return true is $user can access an $object. False otherwise.
	 *
	 * @param Contact $user
	 * @param array $members
	 * @param $object_type_id
	 * @return boolean
	 */
	function can_access(Contact $user, $members, $object_type_id, $access_level){
		if($user->isAdministrator()){
			return true;
		}
		$write = $access_level == ACCESS_LEVEL_WRITE;
		$delete = $access_level == ACCESS_LEVEL_DELETE;
		
		if (($user->isGuest() && $access_level!= ACCESS_LEVEL_READ) || !count($members)>0) return false;
		
		try {
			$contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV($user->getId(),false);
			$allow_all_cache = array();
			$dimension_query_methods = array();
			
			$dimension_permissions = array();
			foreach($members as $k => $m){
				if (!$m instanceof Member) {
					unset($members[$k]);
					continue;
				}
				
				$dimension = $m->getDimension();
				if(!$dimension->getDefinesPermissions()){
					continue;
				}
				$dimension_id = $dimension->getId();
				if (!isset($dimension_permissions[$dimension_id])) {
					$dimension_permissions[$dimension_id]=false;
				}
										
				if (!$dimension_permissions[$dimension_id]){
					if ($m->canContainObject($object_type_id)){
						
						if (!isset($dimension_query_methods[$dimension->getId()])) {
							$dimension_query_methods[$dimension->getId()] = $dimension->getPermissionQueryMethod();
						}
						
						//dimension defines permissions and user has maximum level of permissions
						if (isset($allow_all_cache[$dimension_id])) {
							$allow_all = $allow_all_cache[$dimension_id];
						} else {
							$allow_all = $dimension->hasAllowAllForContact($contact_pg_ids);
							$allow_all_cache[$dimension_id] = $allow_all;
						}
						if ($allow_all) {
							$dimension_permissions[$dimension_id]=true;
						}
						
						//check individual members
						if (!$dimension_permissions[$dimension_id] && ContactMemberPermissions::contactCanReadObjectTypeinMember($contact_pg_ids, $m->getId(), $object_type_id, $write, $delete, $user)){
							$dimension_permissions[$dimension_id]=true;
						}
					} else {
						unset($dimension_permissions[$dimension_id]);
					}
				}
			}

			$allowed = true;
			// check that user has permissions in all mandatory query method dimensions
			$mandatory_count = 0;
			foreach ($dimension_query_methods as $dim_id => $qmethod) {
				if ($qmethod == DIMENSION_PERMISSION_QUERY_METHOD_MANDATORY) {
					$mandatory_count++;
					if (!array_var($dimension_permissions, $dim_id)) {
						// if one of the members belong to a mandatory dimension and user does not have permissions on it then return false
						return false;
					}
				}
			}
			
			// If no members in mandatory dimensions then check for not mandatory ones 
			if ($allowed && $mandatory_count == 0) {
				foreach ($dimension_query_methods as $dim_id => $qmethod) {
					if ($qmethod == DIMENSION_PERMISSION_QUERY_METHOD_NOT_MANDATORY) {
						if (array_var($dimension_permissions, $dim_id)) {
							// if has permissions over any member of a non mandatory dimension then return true
							return true;
						} else {
							$allowed = false;
						}
					}
				}
			}

			if ($allowed && count($dimension_permissions)) {
				return true;	
			}
			
			// Si hasta aca tienen perm en todas las dim, return true. Si hay alguna que no tiene perm sigo
			
			//Check Context Permissions
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:permissions.php

示例8: can_access

/**
 * Return true is $user can access an $object. False otherwise.
 *
 * @param Contact $user
 * @param array $members
 * @param $object_type_id
 * @return boolean
 */
function can_access(Contact $user, $members, $object_type_id, $access_level, $allow_super_admin = true)
{
    if ($allow_super_admin && $user->isAdministrator()) {
        return true;
    }
    $write = $access_level == ACCESS_LEVEL_WRITE;
    $delete = $access_level == ACCESS_LEVEL_DELETE;
    if ($user->isGuest() && $access_level != ACCESS_LEVEL_READ) {
        return false;
    }
    try {
        $contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV($user->getId(), false);
        $allow_all_cache = array();
        $dimension_query_methods = array();
        // if no manageable member then check if user has permissions wihout classifying
        $manageable_members = array();
        foreach ($members as $mem) {
            if ($mem instanceof Member && $mem->getDimension()->getIsManageable() && $mem->getDimension()->getDefinesPermissions()) {
                $manageable_members[] = $mem->getId();
            }
        }
        if (count($manageable_members) == 0) {
            $return = false;
            if (config_option('let_users_create_objects_in_root') && $contact_pg_ids != "" && ($user->isAdminGroup() || $user->isExecutive() || $user->isManager())) {
                $cond = $delete ? 'AND can_delete = 1' : ($write ? 'AND can_write = 1' : '');
                $cmp = ContactMemberPermissions::findOne(array('conditions' => "member_id=0 AND object_type_id={$object_type_id} AND permission_group_id IN ({$contact_pg_ids}) {$cond}"));
                $return = $cmp instanceof ContactMemberPermission;
            }
            return $return;
        }
        $max_role_ot_perm = MaxRoleObjectTypePermissions::instance()->findOne(array('conditions' => "object_type_id='{$object_type_id}' AND role_id = '" . $user->getUserType() . "'"));
        $enabled_dimensions = config_option('enabled_dimensions');
        $dimension_permissions = array();
        foreach ($members as $k => $m) {
            if (!$m instanceof Member) {
                unset($members[$k]);
                continue;
            }
            $dimension = $m->getDimension();
            if (!$dimension->getDefinesPermissions() || !in_array($dimension->getId(), $enabled_dimensions)) {
                continue;
            }
            $dimension_id = $dimension->getId();
            if (!isset($dimension_permissions[$dimension_id])) {
                $dimension_permissions[$dimension_id] = false;
            }
            if (!$dimension_permissions[$dimension_id]) {
                if ($m->canContainObject($object_type_id)) {
                    if (!isset($dimension_query_methods[$dimension->getId()])) {
                        $dimension_query_methods[$dimension->getId()] = $dimension->getPermissionQueryMethod();
                    }
                    //dimension defines permissions and user has maximum level of permissions
                    if (isset($allow_all_cache[$dimension_id])) {
                        $allow_all = $allow_all_cache[$dimension_id];
                    } else {
                        $allow_all = $dimension->hasAllowAllForContact($contact_pg_ids);
                        $allow_all_cache[$dimension_id] = $allow_all;
                    }
                    if ($allow_all) {
                        $dimension_permissions[$dimension_id] = true;
                    }
                    //check individual members
                    if (!$dimension_permissions[$dimension_id] && ContactMemberPermissions::contactCanReadObjectTypeinMember($contact_pg_ids, $m->getId(), $object_type_id, $write, $delete, $user)) {
                        if ($max_role_ot_perm) {
                            if ($access_level == ACCESS_LEVEL_DELETE && $max_role_ot_perm->getCanDelete() || $access_level == ACCESS_LEVEL_WRITE && $max_role_ot_perm->getCanWrite() || $access_level == ACCESS_LEVEL_READ) {
                                $dimension_permissions[$dimension_id] = true;
                            }
                        }
                    }
                } else {
                    unset($dimension_permissions[$dimension_id]);
                }
            }
        }
        $allowed = true;
        // check that user has permissions in all mandatory query method dimensions
        $mandatory_count = 0;
        foreach ($dimension_query_methods as $dim_id => $qmethod) {
            if (!in_array($dim_id, $enabled_dimensions)) {
                continue;
            }
            if ($qmethod == DIMENSION_PERMISSION_QUERY_METHOD_MANDATORY) {
                $mandatory_count++;
                if (!array_var($dimension_permissions, $dim_id)) {
                    // if one of the members belong to a mandatory dimension and user does not have permissions on it then return false
                    return false;
                }
            }
        }
        // If no members in mandatory dimensions then check for not mandatory ones
        if ($allowed && $mandatory_count == 0) {
            foreach ($dimension_query_methods as $dim_id => $qmethod) {
//.........这里部分代码省略.........
开发者ID:abhinay100,项目名称:feng_app,代码行数:101,代码来源:permissions.php

示例9: create_user


//.........这里部分代码省略.........
            $sp->setCanAddMailAccounts(array_var($user_data, 'can_add_mail_accounts'));
        }
        if (isset($user_data['can_manage_dimensions'])) {
            $sp->setCanManageDimensions(array_var($user_data, 'can_manage_dimensions'));
        }
        if (isset($user_data['can_manage_dimension_members'])) {
            $sp->setCanManageDimensionMembers(array_var($user_data, 'can_manage_dimension_members'));
        }
        if (isset($user_data['can_manage_tasks'])) {
            $sp->setCanManageTasks(array_var($user_data, 'can_manage_tasks'));
        }
        if (isset($user_data['can_task_assignee'])) {
            $sp->setCanTasksAssignee(array_var($user_data, 'can_task_assignee'));
        }
        if (isset($user_data['can_manage_billing'])) {
            $sp->setCanManageBilling(array_var($user_data, 'can_manage_billing'));
        }
        if (isset($user_data['can_view_billing'])) {
            $sp->setCanViewBilling(array_var($user_data, 'can_view_billing'));
        }
        if (isset($user_data['can_see_assigned_to_other_tasks'])) {
            $sp->setColumnValue('can_see_assigned_to_other_tasks', array_var($user_data, 'can_see_assigned_to_other_tasks'));
        }
        Hook::fire('add_user_permissions', $sp, $other_permissions);
        if (!is_null($other_permissions) && is_array($other_permissions)) {
            foreach ($other_permissions as $k => $v) {
                $sp->setColumnValue($k, array_var($user_data, $k));
            }
        }
        $sp->save();
        $permissions_sent = array_var($_POST, 'manual_permissions_setted') == 1;
        // give permissions for user if user type defined in "give_member_permissions_to_new_users" config option
        $allowed_user_type_ids = config_option('give_member_permissions_to_new_users');
        if ($contact->isAdministrator() || !$permissions_sent && in_array($contact->getUserType(), $allowed_user_type_ids)) {
            ini_set('memory_limit', '512M');
            $permissions = array();
            $default_permissions = RoleObjectTypePermissions::instance()->findAll(array('conditions' => 'role_id = ' . $contact->getUserType()));
            $dimensions = Dimensions::findAll();
            foreach ($dimensions as $dimension) {
                if ($dimension->getDefinesPermissions()) {
                    $cdp = ContactDimensionPermissions::findOne(array("conditions" => "`permission_group_id` = " . $contact->getPermissionGroupId() . " AND `dimension_id` = " . $dimension->getId()));
                    if (!$cdp instanceof ContactDimensionPermission) {
                        $cdp = new ContactDimensionPermission();
                        $cdp->setPermissionGroupId($contact->getPermissionGroupId());
                        $cdp->setContactDimensionId($dimension->getId());
                    }
                    $cdp->setPermissionType('check');
                    $cdp->save();
                    // contact member permisssion entries
                    $members = DB::executeAll('SELECT * FROM ' . TABLE_PREFIX . 'members WHERE dimension_id=' . $dimension->getId());
                    foreach ($members as $member) {
                        foreach ($default_permissions as $p) {
                            // Add persmissions to sharing table
                            $perm = new stdClass();
                            $perm->m = $member['id'];
                            $perm->r = 1;
                            $perm->w = $p->getCanWrite();
                            $perm->d = $p->getCanDelete();
                            $perm->o = $p->getObjectTypeId();
                            $permissions[] = $perm;
                        }
                    }
                }
            }
            $_POST['permissions'] = json_encode($permissions);
        } else {
开发者ID:abhinay100,项目名称:feng_app,代码行数:67,代码来源:functions.php


注:本文中的Contact::isAdministrator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。