本文整理汇总了PHP中PermissionPeer::addToPartner方法的典型用法代码示例。如果您正苦于以下问题:PHP PermissionPeer::addToPartner方法的具体用法?PHP PermissionPeer::addToPartner怎么用?PHP PermissionPeer::addToPartner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PermissionPeer
的用法示例。
在下文中一共展示了PermissionPeer::addToPartner方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
}
示例2: addAction
/**
* Adds a new permission object to the account.
*
* @action add
* @param KalturaPermission $permission The new permission
* @return KalturaPermission The added permission object
*
* @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL
* @throws KalturaErrors::PROPERTY_VALIDATION_NOT_UPDATABLE
*/
public function addAction(KalturaPermission $permission)
{
$permission->validatePropertyNotNull('name');
if (strpos($permission->name, ',') !== false) {
throw new KalturaAPIException(KalturaErrors::INVALID_FIELD_VALUE, 'name');
}
if (!$permission->friendlyName) {
$permission->friendlyName = $permission->name;
}
if (!$permission->status) {
$permission->status = KalturaPermissionStatus::ACTIVE;
}
$dbPermission = $permission->toInsertableObject();
$dbPermission->setType(PermissionType::NORMAL);
// only normal permission types are added through this services
$dbPermission->setPartnerId($this->getPartnerId());
try {
PermissionPeer::addToPartner($dbPermission, $this->getPartnerId());
} catch (kPermissionException $e) {
$code = $e->getCode();
if ($code === kPermissionException::PERMISSION_ALREADY_EXISTS) {
throw new KalturaAPIException(KalturaErrors::PERMISSION_ALREADY_EXISTS, $dbPermission->getName(), $this->getPartnerId());
}
if ($code === kPermissionException::PERMISSION_ITEM_NOT_FOUND) {
throw new KalturaAPIException(KalturaErrors::PERMISSION_ITEM_NOT_FOUND);
}
throw $e;
}
$permission = new KalturaPermission();
$permission->fromObject($dbPermission);
return $permission;
}
示例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: Criteria
$c = new Criteria();
$c->add(UserRolePeer::PERMISSION_NAMES, "%dropFolder.CONTENT_INGEST_DROP_FOLDER_MATCH%", Criteria::LIKE);
$c->setLimit($countLimitEachLoop);
$userRoles = UserRolePeer::doSelect($c, $con);
while (count($userRoles)) {
foreach ($userRoles as $userRole) {
$partnerId = $userRole->getPartnerId();
PermissionPeer::setUseCriteriaFilter(false);
$permission = PermissionPeer::getByNameAndPartner('CONTENT_INGEST_DROP_FOLDER_MATCH', array($partnerId));
PermissionPeer::setUseCriteriaFilter(true);
if (!$permission) {
$permission = new Permission();
$permission->setName('CONTENT_INGEST_DROP_FOLDER_MATCH');
$permission->setDependsOnPermissionNames('DROPFOLDER_PLUGIN_PERMISSION');
$permission->setType(PermissionType::SPECIAL_FEATURE);
$permission->setPartnerId($partnerId);
$permission->setStatus(PermissionStatus::ACTIVE);
// add to database
KalturaLog::log('Adding new permission with name [' . $permission->getName() . '] to partner id [' . $permission->getPartnerId() . ']');
PermissionPeer::addToPartner($permission, $permission->getPartnerId());
}
}
$c->setOffset($offset);
UserRolePeer::clearInstancePool();
$userRoles = UserRolePeer::doSelect($c, $con);
$offset += $countLimitEachLoop;
sleep(1);
}
$script = realpath(dirname(__FILE__) . '/../../../../') . '/scripts/utils/permissions/addPermissionsAndItems.php';
$config = realpath(dirname(__FILE__)) . '/../../../../plugins/drop_folder/config/drop_folder_permissions.ini';
passthru("php {$script} {$config}");