本文整理汇总了PHP中Role::getRoleId方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::getRoleId方法的具体用法?PHP Role::getRoleId怎么用?PHP Role::getRoleId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role::getRoleId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnPageLoad
function OnPageLoad()
{
if (is_object($this->data_object)) {
echo new XhtmlElement('h1', Html::Encode('Delete role: ' . $this->data_object->getRoleName()));
} else {
echo new XhtmlElement('h1', 'Delete role');
$this->deleted = true;
}
if ($this->deleted) {
?>
<p>The role has been deleted.</p>
<p><a href="roles.php">View all roles</a></p>
<?php
} else {
?>
<p>Deleting a role cannot be undone.</p>
<p>Are you sure you want to delete this role?</p>
<form method="post" class="deleteButtons">
<div>
<input type="submit" value="Delete role" name="delete" />
<input type="submit" value="Cancel" name="cancel" />
</div>
</form>
<?php
$this->AddSeparator();
require_once 'stoolball/user-edit-panel.class.php';
$panel = new UserEditPanel($this->GetSettings(), 'this role');
$panel->AddLink('edit this role', "role.php?item=" . $this->data_object->getRoleId());
echo $panel;
}
}
示例2: testMostSpecificRuleAppliesIfNoExactRuleIsFound
public function testMostSpecificRuleAppliesIfNoExactRuleIsFound()
{
$this->repository->addRule($this->role1, $this->resource1, true);
$this->repository->addRule($this->role1, $this->resource2, false);
$rule = $this->repository->getMostApplyingRule($this->role2, $this->resource2);
$this->assertSame($this->role1->getRoleId(), $rule->getRoleId());
$this->assertSame($this->resource2->getResourceId(), $rule->getResourceId());
}
示例3: getMostApplyingRule
/**
* Returns the rule, that applies most to $role and $resource
*
* @param \gatekeeper\Role $role Role to search for
* @param \gatekeeper\Resource $resource Resource to search for
* @return \gatekeeper\Rule
* @throws \gatekeeper\ThereIsNoApplyingRuleException if the is no applying
* rule
*/
public function getMostApplyingRule(Role $role, Resource $resource)
{
do {
$roleId = $role->getRoleId();
foreach ($this->getRules() as $rule) {
if ($rule->getRoleId() !== $roleId) {
continue;
}
$tmpResource = $resource;
do {
/// Perhaps breadth first search?!
$resourceId = $tmpResource->getResourceId();
if ($rule->getResourceId() === $resourceId) {
return $rule;
}
try {
$tmpResource = $tmpResource->getParentResource();
} catch (HasNoParentResourceException $e) {
$tmpResource = null;
}
} while ($tmpResource !== null);
}
try {
$role = $role->getParentRole();
} catch (HasNoParentRoleException $e) {
$role = null;
}
} while ($role !== null);
throw new ThereIsNoApplyingRuleException();
}
示例4: array
/**
* Returns the rules associated with a Resource and a Role, or null if no such rules exist
*
* If either $resource or $role is null, this means that the rules returned are for all Resources or all Roles,
* respectively. Both can be null to return the default rule set for all Resources and all Roles.
*
* If the $create parameter is true, then a rule set is first created and then returned to the caller.
*
* @param Zend\Acl\Resource $resource
* @param Zend\Acl\Role $role
* @param boolean $create
* @return array|null
*/
protected function &_getRules(Resource $resource = null, Role $role = null, $create = false)
{
// create a reference to null
$null = null;
$nullRef =& $null;
// follow $resource
do {
if (null === $resource) {
$visitor =& $this->_rules['allResources'];
break;
}
$resourceId = $resource->getResourceId();
if (!isset($this->_rules['byResourceId'][$resourceId])) {
if (!$create) {
return $nullRef;
}
$this->_rules['byResourceId'][$resourceId] = array();
}
$visitor =& $this->_rules['byResourceId'][$resourceId];
} while (false);
// follow $role
if (null === $role) {
if (!isset($visitor['allRoles'])) {
if (!$create) {
return $nullRef;
}
$visitor['allRoles']['byPrivilegeId'] = array();
}
return $visitor['allRoles'];
}
$roleId = $role->getRoleId();
if (!isset($visitor['byRoleId'][$roleId])) {
if (!$create) {
return $nullRef;
}
$visitor['byRoleId'][$roleId]['byPrivilegeId'] = array();
}
return $visitor['byRoleId'][$roleId];
}
示例5: prune
/**
* Exclude object from result
*
* @param Role $role Object to remove from the list of results
*
* @return RoleQuery The current query, for fluid interface
*/
public function prune($role = null)
{
if ($role) {
$this->addUsingAlias(RolePeer::ROLE_ID, $role->getRoleId(), Criteria::NOT_EQUAL);
}
return $this;
}
示例6: addInstanceToPool
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doSelect*()
* methods in your stub classes -- you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by doSelect*()
* and retrieveByPK*() calls.
*
* @param Role $value A Role object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(Role $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getRoleId();
}
// if key === null
self::$instances[$key] = $obj;
}
}
示例7: SaveRole
/**
* Saves a security role
* @param $role Role
*/
public function SaveRole(Role $role)
{
$roles = $this->GetSettings()->GetTable('Role');
$permissions_table = $this->GetSettings()->GetTable('PermissionRoleLink');
# if no id, it's a new object; otherwise update the object
if ($role->getRoleId()) {
$sql = "UPDATE {$roles} SET \r\n role = " . Sql::ProtectString($this->GetDataConnection(), $role->getRoleName()) . " \r\n WHERE role_id = " . Sql::ProtectNumeric($role->getRoleId());
$this->LoggedQuery($sql);
# Remove existing permissions
$sql = "DELETE FROM {$permissions_table} WHERE role_id = " . Sql::ProtectNumeric($role->getRoleId());
$this->LoggedQuery($sql);
} else {
$sql = "INSERT INTO {$roles} SET role = " . Sql::ProtectString($this->GetDataConnection(), $role->getRoleName());
$this->LoggedQuery($sql);
$role->setRoleId($this->GetDataConnection()->insertID());
}
# Add replacement permissions
$role_id = Sql::ProtectNumeric($role->getRoleId());
$permissions = $role->Permissions()->ToArray();
foreach ($permissions as $permission => $scopes) {
foreach ($scopes as $scope => $ignore_value) {
$resource_uri = $scope == PermissionType::GLOBAL_PERMISSION_SCOPE ? "NULL" : Sql::ProtectString($this->GetDataConnection(), $scope);
$sql = "INSERT INTO {$permissions_table} SET \r\n permission_id = " . Sql::ProtectNumeric($permission) . ",\r\n resource_uri = {$resource_uri}, \r\n role_id = {$role_id}";
$this->LoggedQuery($sql);
}
}
}
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:31,代码来源:authentication-manager.class.php