本文整理匯總了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}");