本文整理汇总了PHP中Role::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::getId方法的具体用法?PHP Role::getId怎么用?PHP Role::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeProcessNewOrgForm
public function executeProcessNewOrgForm(sfWebRequest $request)
{
$f = $request->getParameter("organization");
$p = Doctrine::getTable('Principal')->findOneByFedid($this->getUser()->getUsername());
$o = new Organization();
$o->setName($f["name"]);
$o->setDescription($f["description"]);
$o->setCreatedAt(date('Y-m-d H:i:s'));
$o->save();
$op = new OrganizationPrincipal();
$op->setOrganization($o);
$op->setPrincipal($p);
$op->save();
$i = new Invitation();
$i->setEmail($p->getEmail());
$i->setOrganization($o);
$i->setUuid('1');
$i->setCreatedAt(date('Y-m-d H:i:s'));
$i->setAcceptAt(date('Y-m-d H:i:s'));
$i->setCounter(1);
$i->setInviter($p);
$i->setPrincipal($p);
$i->setStatus("accepted");
$i->save();
$r = new Role();
$r->setName($f["role_name"]);
$r->setOrganization($o);
$r->setShoworder(0);
$r->save();
$o->setDefaultRoleId($r->getId());
$o->save();
$this->redirect("show/index?id=" . $o->getId());
}
示例2: getId
public function getId()
{
if ($this->__isInitialized__ === false) {
return (int) $this->_identifier["id"];
}
$this->__load();
return parent::getId();
}
示例3: testNormalRole
public function testNormalRole()
{
$role = new Role($this->normalRole->getId());
$this->player_b->addRole($role->getId());
$this->assertFalse($role->displayAsLeader());
$this->assertFalse($role->isProtected());
$this->assertEquals("Sample Normal Role", $role->getName());
$this->assertNull($role->getDisplayIcon());
$this->assertNull($role->getDisplayColor());
$this->assertEquals("Sample Normal Role", $role->getDisplayName());
$this->assertEquals(-1, $role->getDisplayOrder());
$this->assertArrayContainsModel($role, Role::getRoles($this->player_b->getId()));
$this->wipe($role);
}
示例4: findSingle
/**
* @param bool $full
*
* @return Role|false
*/
public function findSingle($full = false)
{
$result = parent::findSingle();
if ($result) {
$role = new Role($result);
if ($full === true) {
$repo = new PermissionRepository($this->db);
$role->setPermissions($repo->where('role_id', '=', $role->getId())->order('name', 'ASC')->find());
}
return $role;
} else {
return false;
}
}
示例5: flush
/**
*
* @param Role $role
* @return int id of the Role inserted in base. False if it didn't work.
*/
public static function flush($role)
{
$roleId = $role->getId();
$roleVar = $role->getRoleName();
if ($roleId > 0) {
$sql = 'UPDATE role SET' . 'role_name = ? ' . 'WHERE id_role = ?';
$params = array('si', &$roleVar, &$roleId);
} else {
$sql = 'INSERT INTO role (role_name) VALUES (?)';
$params = array('s', &$roleVar);
}
$idInsert = BaseSingleton::insertOrEdit($sql, $params);
if ($idInsert !== false && $roleId > 0) {
$idInsert = $roleId;
}
return $idInsert;
}
示例6: array
/**
* Set specific role as default role
*
* @param void
* @return null
*/
function set_as_default()
{
if ($this->request->isSubmitted()) {
if ($this->active_role->isNew()) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
if ($this->active_role->getType() == ROLE_TYPE_PROJECT) {
$this->httpError(HTTP_ERR_INVALID_PROPERTIES);
}
// if
ConfigOptions::setValue('default_role', $this->active_role->getId());
flash_success(':name role has been set as default', array('name' => $this->active_role->getName()));
$this->redirectTo('admin_roles');
} else {
$this->httpError(HTTP_ERR_BAD_REQUEST);
}
// if
}
示例7: getId
public function getId()
{
$this->_load();
return parent::getId();
}
示例8: setRole
/**
* Declares an association between this object and a Role object.
*
* @param Role $v
* @return User The current object (for fluent API support)
* @throws PropelException
*/
public function setRole(Role $v = null)
{
if ($v === null) {
$this->setRoleId(NULL);
} else {
$this->setRoleId($v->getId());
}
$this->aRole = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the Role object, it will not be re-added.
if ($v !== null) {
$v->addUser($this);
}
return $this;
}
示例9: canAccessDevelopingPage
public static function canAccessDevelopingPage(Role $role)
{
switch ($role->getId()) {
case Role::ID_SYSTEM_ADMIN:
return true;
}
return false;
}
示例10: construct
/**
* Convenience method to construct a new instance.
*
* @param \User $callingUser {@link \User} who creates/updates this record.
* @param \Role $role The target {@link \Role}
* @param string $newStatus
* @return \self
*/
public static function construct(\User $callingUser, \Role $role, $newStatus)
{
$rar = new self($callingUser->getId(), $callingUser->getFullName(), $role->getId(), $role->getStatus(), $newStatus, $role->getRoleType()->getId(), $role->getRoleType()->getName(), $role->getOwnedEntity()->getId(), $role->getOwnedEntity()->getType(), $role->getUser()->getId(), $role->getUser()->getFullName());
return $rar;
}
示例11: testRemoveGroupRoleActionIsProtected
public function testRemoveGroupRoleActionIsProtected()
{
$this->logIn($this->john);
$this->client->request('GET', "/api/groups/{$this->groupOrga->getId()}/roles/{$this->teacherRole->getId()}/remove.json");
$this->assertEquals(403, $this->client->getResponse()->getStatusCode());
}
示例12: countByRole
/**
* Return number of users using a specific role
*
* @param Role $role
* @return integer
*/
function countByRole($role)
{
return ProjectUsers::count(array('role_id = ?', $role->getId()));
}
示例13: hasRole
public static function hasRole(Role $role, $targetObject, $user = null)
{
$retval = false;
$db = AbstractDb::getObject();
$object_class = get_class($targetObject);
$table = strtolower($object_class) . '_stakeholders';
$object_id = $db->escapeString($targetObject->getId());
$roleIdStr = $db->escapeString($role->getId());
if (!$user) {
$user = User::getCurrentUser();
}
if ($user) {
$sql = "SELECT * FROM {$table} WHERE object_id = '{$object_id}' AND user_id='{$user->getId()}' AND role_id = '{$roleIdStr}';";
$rows = null;
$db->execSql($sql, $rows, false);
if ($rows) {
$retval = true;
}
}
return $retval;
}
示例14: execute
/**
* @see Form::execute()
*/
function execute($request)
{
$userGroupId = $this->getUserGroupId();
$userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
// Check if we are editing an existing user group or creating another one.
if ($userGroupId == null) {
$userGroup = $userGroupDao->newDataObject();
$role = new Role($this->getData('roleId'));
$userGroup->setRoleId($role->getId());
$userGroup->setContextId($this->getPressId());
$userGroup->setPath($role->getPath());
$userGroup->setDefault(false);
$userGroup = $this->_setUserGroupLocaleFields($userGroup, $request);
$userGroupId = $userGroupDao->insertUserGroup($userGroup);
} else {
$userGroup = $userGroupDao->getById($userGroupId);
$userGroup = $this->_setUserGroupLocaleFields($userGroup, $request);
$userGroupDao->updateLocaleFields($userGroup);
}
// After we have created/edited the user group, we assign/update its stages.
if ($this->getData('assignedStages')) {
$this->_setOnDbUserGroupStageAssignment($userGroupId);
}
}
示例15: 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->getId();
}
// if key === null
self::$instances[$key] = $obj;
}
}