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


PHP Permission::getFriendlyName方法代码示例

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


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

示例1: addPermission

function addPermission($permissionCfg)
{
    // verify obligatory fields
    if (!$permissionCfg->name) {
        throw new Exception('Permission name must be set');
    }
    if (is_null($permissionCfg->partnerId) || $permissionCfg->partnerId === '') {
        throw new Exception('Permission partner id must be set');
    }
    // init new db permission object
    $permission = new Permission();
    foreach ($permissionCfg as $key => $value) {
        $setterCallback = array($permission, "set{$key}");
        call_user_func_array($setterCallback, array($value));
    }
    if (!$permission->getFriendlyName()) {
        $permission->setFriendlyName($permission->getName());
    }
    if (!$permission->getStatus()) {
        $permission->setStatus(PermissionStatus::ACTIVE);
    }
    // add to database
    KalturaLog::log('Adding new permission with name [' . $permission->getName() . '] to partner id [' . $permission->getPartnerId() . ']');
    try {
        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;
        }
    }
}
开发者ID:richhl,项目名称:kalturaCE,代码行数:33,代码来源:addPermissionsAndItems.php

示例2: 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;
        }
    }
}
开发者ID:DBezemer,项目名称:server,代码行数:42,代码来源:addPermissionsAndItems.php

示例3: Permission

        // live stream
        $allowedLiveStream = $partner->getFromCustomData("liveEnabled", null, 0);
        if ($allowedLiveStream) {
            $livePermission = new Permission();
            $livePermission->setPartnerId($partner->getId());
            $livePermission->setName(PermissionName::FEATURE_LIVE_STREAM);
            $livePermission->setFriendlyName('Live stream feature');
            $livePermission->setDescription('Permission to use live stream');
            $livePermission->setStatus(PermissionStatus::ACTIVE);
            $livePermission->setType(PermissionType::SPECIAL_FEATURE);
            $newPermissions[] = $livePermission;
        }
        if (!$dryRun) {
            foreach ($newPermissions as $permission) {
                KalturaLog::log('SAVING new permission for partner [' . $partner->getId() . ']:');
                PermissionPeer::enableForPartner($permission->getName(), $permission->getType(), $partner->getId(), $permission->getFriendlyName(), $permission->getDescription());
                KalturaLog::log(print_r($permission, true));
            }
        } else {
            foreach ($newPermissions as $permission) {
                KalturaLog::log('DRY RUN ONLY - new permission for partner [' . $partner->getId() . ']:');
                KalturaLog::log(print_r($permission, true));
                // dry run - no saving!
            }
        }
        file_put_contents($lastPartnerFile, $lastPartner);
    }
    $partners = getPartners($lastPartner, $partnerLimitEachLoop);
}
$msg = 'Done - ' . ($dryRun ? 'DRY RUN!' : 'REAL RUN!');
KalturaLog::log($msg);
开发者ID:richhl,项目名称:kalturaCE,代码行数:31,代码来源:01_set_partner_service_and_plugin_permissions.php


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