本文整理汇总了PHP中Permission::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::getId方法的具体用法?PHP Permission::getId怎么用?PHP Permission::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::getId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showPermissionsList
/**
* zobrazi zoznam vsetkych
* @global array $ALIEN
*/
public static function showPermissionsList()
{
if (!Authorization::getCurrentUser()->hasPermission(38)) {
new Notification("Prístup zamietnutý.", "error");
header("Location: ?page=home", false, 301);
ob_end_flush();
exit;
}
global $ALIEN;
$ALIEN['HEADER'] = 'Zoznam existujúcich oprávnení';
$limit = sizeof(Authorization::$Permissions);
for ($i = 1; $i <= $limit; $i++) {
$permission = new Permission(Authorization::$Permissions[$i]['label']);
echo '<div class="item"><img src="images/icons/shield.png"> ID: ' . $permission->getId() . ' | <strong>' . $permission->getLabel() . '</strong> | ' . $permission->getDescription() . '</div>';
}
}
示例2: 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 Permission $value A Permission object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(Permission $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getId();
}
// if key === null
self::$instances[$key] = $obj;
}
}
示例3: addPermissionToPartner
function addPermissionToPartner($permissionCfg, $partnerId = null)
{
// init new db permission object
if (is_null($partnerId)) {
$partnerId = $permissionCfg->partnerId;
}
PermissionPeer::setUseCriteriaFilter(false);
$permission = PermissionPeer::getByNameAndPartner($permissionCfg->name, $partnerId);
PermissionPeer::setUseCriteriaFilter(true);
if (!$permission) {
$permission = new Permission();
}
foreach ($permissionCfg as $key => $value) {
if ($key == 'partnerPackages') {
continue;
}
$setterCallback = array($permission, "set{$key}");
call_user_func_array($setterCallback, array($value));
}
if (!$permission->getFriendlyName()) {
$permission->setFriendlyName($permission->getName());
}
if ($partnerId != null) {
$permission->setPartnerId($partnerId);
}
$permission->setStatus(PermissionStatus::ACTIVE);
// add to database
KalturaLog::log('Adding new permission with name [' . $permission->getName() . '] to partner id [' . $permission->getPartnerId() . ']');
try {
if ($permission->getId()) {
$permission->save();
} else {
PermissionPeer::addToPartner($permission, $permission->getPartnerId());
}
} catch (kPermissionException $e) {
if ($e->getCode() === kPermissionException::PERMISSION_ALREADY_EXISTS) {
KalturaLog::log('Permission name [' . $permission->getName() . '] already exists for partner id [' . $permission->getPartnerId() . ']');
} else {
throw $e;
}
}
}
示例4: 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 Permission $value A Permission object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(Permission $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getId();
}
if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
self::$instances[$key] = $obj;
kMemoryManager::registerPeer('PermissionPeer');
}
}
}
示例5: addPartnerGroupAction
/**
* Add a partner group permission to the local map for the given action
* @param array $map map to fill
* @param Permission $permission partner group permission object
*/
private static function addPartnerGroupAction(array &$map, Permission $permission)
{
$partnerGroup = $permission->getPartnerGroup();
if (!$permission->getPartnerGroup()) {
KalturaLog::notice('No partner group defined for permission id [' . $permission->getId() . '] with type partner group [' . $permission->getType() . ']');
return;
}
$partnerGroup = explode(',', trim($partnerGroup, ','));
$permissionItems = $permission->getPermissionItems();
foreach ($permissionItems as $item) {
if ($item->getType() != PermissionItemType::API_ACTION_ITEM) {
KalturaLog::notice('Permission item id [' . $item->getId() . '] is not of type PermissionItemType::API_ACTION_ITEM but still defined in partner group permission id [' . $permission->getId() . ']');
continue;
}
$service = strtolower($item->getService());
$action = strtolower($item->getAction());
if (!isset($map[self::PARTNER_GROUP_ARRAY_NAME][$service])) {
$map[self::PARTNER_GROUP_ARRAY_NAME][$service] = array();
$map[self::PARTNER_GROUP_ARRAY_NAME][$service][$action] = array();
} else {
if (!isset($map[self::PARTNER_GROUP_ARRAY_NAME][$service][$action])) {
$map[self::PARTNER_GROUP_ARRAY_NAME][$service][$action] = array();
}
}
$map[self::PARTNER_GROUP_ARRAY_NAME][$service][$action] = array_merge($map[self::PARTNER_GROUP_ARRAY_NAME][$service][$action], $partnerGroup);
}
}
示例6: getObjectsWithPermission
public static function getObjectsWithPermission(Permission $permission, $user = null)
{
$retval = array();
if (!$user) {
$user = User::getCurrentUser();
}
if ($user) {
$db = AbstractDb::getObject();
$object_class = $permission->getTargetObjectClass();
$table = strtolower($object_class) . '_stakeholders';
$permissionIdStr = $db->escapeString($permission->getId());
$sql = "SELECT DISTINCT object_id FROM {$table} JOIN role_has_permissions USING (role_id) WHERE user_id='{$user->getId()}' AND permission_id = '{$permissionIdStr}'";
$db->execSql($sql, $rows, false);
if ($rows) {
foreach ($rows as $row) {
$retval[$row['object_id']] = call_user_func(array($object_class, 'getObject'), $row['object_id']);
}
}
}
return $retval;
}
示例7: getOrCreatePartnerGroupPermission
/**
* Create a special partner group permission for given partner id, or get an existing one
* @param int $partnerId
* @param string $partnerGroup
*/
function getOrCreatePartnerGroupPermission($partnerId, $partnerGroup)
{
$permissionName = 'PARTNER_' . $partnerId . '_GROUP_' . $partnerGroup . '_PERMISSION';
PermissionPeer::clearInstancePool();
$c = new Criteria();
$c->addAnd(PermissionPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
$c->addAnd(PermissionPeer::NAME, $permissionName, Criteria::EQUAL);
$c->addAnd(PermissionPeer::TYPE, PermissionType::PARTNER_GROUP, Criteria::EQUAL);
$permission = PermissionPeer::doSelectOne($c);
if (!$permission) {
// create permission if not yet created
$permission = new Permission();
$permission->setPartnerId($partnerId);
$permission->setName($permissionName);
$permission->setFriendlyName('Partner ' . $partnerId . ' permission for group ' . $partnerGroup);
$permission->setDescription('Partner ' . $partnerId . ' permission for group ' . $partnerGroup);
$permission->setType(PermissionType::PARTNER_GROUP);
$permission->setPartnerGroup($partnerGroup);
$permission->setStatus(PermissionStatus::ACTIVE);
$permission->save();
} else {
if ($permission->getPartnerGroup() != $partnerGroup) {
$msg = '***** ERROR - Permission id [' . $permission->getId() . '] partner group [' . $permission->getPartnerGroup() . '] is different from the required partner group [' . $partnerGroup . ']';
KalturaLog::alert($msg);
echo $msg . PHP_EOL;
}
}
return $permission;
}
示例8: setPermission
/**
* Declares an association between this object and a Permission object.
*
* @param Permission $v
* @return PermissionToPermissionItem The current object (for fluent API support)
* @throws PropelException
*/
public function setPermission(Permission $v = null)
{
if ($v === null) {
$this->setPermissionId(NULL);
} else {
$this->setPermissionId($v->getId());
}
$this->aPermission = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the Permission object, it will not be re-added.
if ($v !== null) {
$v->addPermissionToPermissionItem($this);
}
return $this;
}