本文整理匯總了PHP中PermissionPeer::setUseCriteriaFilter方法的典型用法代碼示例。如果您正苦於以下問題:PHP PermissionPeer::setUseCriteriaFilter方法的具體用法?PHP PermissionPeer::setUseCriteriaFilter怎麽用?PHP PermissionPeer::setUseCriteriaFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PermissionPeer
的用法示例。
在下文中一共展示了PermissionPeer::setUseCriteriaFilter方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}
}
}
示例2: tearDown
/**
* Cleans up the environment after running a test.
*/
protected function tearDown()
{
UserRolePeer::clearInstancePool();
PermissionPeer::clearInstancePool();
PermissionItemPeer::clearInstancePool();
kuserPeer::clearInstancePool();
PartnerPeer::clearInstancePool();
$this->client = null;
PermissionPeer::setUseCriteriaFilter(false);
foreach ($this->addedPermissionIds as $id) {
try {
$obj = PermissionPeer::retrieveByPK($id);
if ($obj) {
$obj->delete();
}
} catch (PropelException $e) {
}
}
PermissionPeer::setUseCriteriaFilter(true);
$this->addedPermissionIds = array();
parent::tearDown();
}
開發者ID:EfncoPlugins,項目名稱:Media-Management-based-on-Kaltura,代碼行數:25,代碼來源:PermissionServiceUnitTest.php
示例3: postInsert
/**
* Code to be run after inserting to database
* @param PropelPDO $con
*/
public function postInsert(PropelPDO $con = null)
{
PermissionPeer::setUseCriteriaFilter(false);
$this->reload();
PermissionPeer::setUseCriteriaFilter(true);
kEventsManager::raiseEvent(new kObjectCreatedEvent($this));
if ($this->copiedFrom) {
kEventsManager::raiseEvent(new kObjectCopiedEvent($this->copiedFrom, $this));
}
}
示例4: copyPermissions
public static function copyPermissions(Partner $fromPartner, Partner $toPartner)
{
KalturaLog::log('Copying permissions from partner [' . $fromPartner->getId() . '] to partner [' . $toPartner->getId() . ']');
PermissionPeer::setUseCriteriaFilter(false);
$c = new Criteria();
$c->addAnd(PermissionPeer::PARTNER_ID, $fromPartner->getId(), Criteria::EQUAL);
$c->addDescendingOrderByColumn(PermissionPeer::CREATED_AT);
$permissions = PermissionPeer::doSelect($c);
PermissionPeer::setUseCriteriaFilter(true);
foreach ($permissions as $permission) {
$newPermission = $permission->copyToPartner($toPartner->getId());
$newPermission->save();
}
}
示例5: filterDependenciesByNames
public static function filterDependenciesByNames($permissionNames, $partnerId)
{
$c = new Criteria();
$c->addAnd(PermissionPeer::NAME, explode(',', $permissionNames), Criteria::IN);
$c->addAnd(PermissionPeer::PARTNER_ID, array(strval($partnerId), strval(PartnerPeer::GLOBAL_PARTNER)), Criteria::IN);
PermissionPeer::setUseCriteriaFilter(false);
$permissionObjects = PermissionPeer::doSelect($c);
PermissionPeer::setUseCriteriaFilter(true);
$permissionObjects = PermissionPeer::filterDependencies($permissionObjects, $partnerId);
$permissionNames = array();
foreach ($permissionObjects as $object) {
$permissionNames[] = $object->getName();
}
$permissionNames = implode(',', $permissionNames);
return $permissionNames;
}
示例6: reload
/**
* Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
*
* This will only work if the object has been saved and has a valid primary key set.
*
* @param boolean $deep (optional) Whether to also de-associated any related objects.
* @param PropelPDO $con (optional) The PropelPDO connection to use.
* @return void
* @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
*/
public function reload($deep = false, PropelPDO $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("Cannot reload a deleted object.");
}
if ($this->isNew()) {
throw new PropelException("Cannot reload an unsaved object.");
}
if ($con === null) {
$con = Propel::getConnection(PermissionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
// We don't need to alter the object instance pool; we're just modifying this instance
// already in the pool.
PermissionPeer::setUseCriteriaFilter(false);
$stmt = PermissionPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
PermissionPeer::setUseCriteriaFilter(true);
$row = $stmt->fetch(PDO::FETCH_NUM);
$stmt->closeCursor();
if (!$row) {
throw new PropelException('Cannot find matching row in the database to reload object values.');
}
$this->hydrate($row, 0, true);
// rehydrate
if ($deep) {
// also de-associate any related objects?
$this->collPermissionToPermissionItems = null;
$this->lastPermissionToPermissionItemCriteria = null;
}
// if (deep)
}
示例7: sleep
$c->setOffset($offset);
PermissionPeer::clearInstancePool();
$permissions = PermissionPeer::doSelect($c, $con);
$offset += $countLimitEachLoop;
sleep(1);
}
$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);