本文整理汇总了PHP中eZPolicyLimitation::findByType方法的典型用法代码示例。如果您正苦于以下问题:PHP eZPolicyLimitation::findByType方法的具体用法?PHP eZPolicyLimitation::findByType怎么用?PHP eZPolicyLimitation::findByType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZPolicyLimitation
的用法示例。
在下文中一共展示了eZPolicyLimitation::findByType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchRoles
function fetchRoles($sectionID)
{
$policies = $roleIDs = $usedRoleIDs = $roles = $roleLimitations = array();
$limitations = eZPolicyLimitation::findByType('Section', $sectionID, true, false);
foreach ($limitations as $policyEntry) {
$policy = $policyEntry->policy();
$policies[] = $policy;
$roleID = $policy->attribute('role_id');
$roleIDs[] = $roleID;
if (!isset($roleLimitations[$roleID])) {
$roleLimitations[$roleID] = array();
}
$roleLimitations[$roleID][] = $policy;
}
foreach ($policies as $policy) {
$roleID = $policy->attribute('role_id');
if (in_array($roleID, $roleIDs) && !in_array($roleID, $usedRoleIDs)) {
$roles[] = $policy->attribute('role');
$usedRoleIDs[] = $roleID;
}
}
return array('result' => array('roles' => $roles, 'limited_policies' => $roleLimitations));
}
示例2: move
function move($newParentNodeID, $nodeID = 0)
{
if ($nodeID == 0) {
$node = $this;
$nodeID = $node->attribute('node_id');
} else {
$node = eZContentObjectTreeNode::fetch($nodeID);
}
$oldPath = $node->attribute('path_string');
$oldParentNodeID = $node->attribute('parent_node_id');
$newParentNodeID = (int) $newParentNodeID;
if ($oldParentNodeID != $newParentNodeID) {
$node->updateAndStoreModified();
// Who moves which content should be logged.
$object = $node->object();
eZAudit::writeAudit('content-move', array('Node ID' => $node->attribute('node_id'), 'Old parent node ID' => $oldParentNodeID, 'New parent node ID' => $newParentNodeID, 'Object ID' => $object->attribute('id'), 'Content Name' => $object->attribute('name'), 'Comment' => 'Moved the node to the given node: eZContentObjectTreeNode::move()'));
$newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID);
$newParentPath = $newParentNode->attribute('path_string');
$newParentDepth = $newParentNode->attribute('depth');
$newPath = $newParentPath . $nodeID;
$oldDepth = $node->attribute('depth');
$oldPathLength = strlen($oldPath);
$moveQuery = "UPDATE\n ezcontentobject_tree\n SET\n parent_node_id = {$newParentNodeID}\n WHERE\n node_id = {$nodeID}";
$db = eZDB::instance();
$subStringString = $db->subString('path_string', $oldPathLength);
$newPathString = $db->concatString(array("'{$newPath}'", $subStringString));
$moveQuery1 = "UPDATE\n ezcontentobject_tree\n SET\n path_identification_string = " . $db->concatString(array("'" . $db->escapeString($newParentNode->PathIdentificationString) . "'", $db->subString("path_identification_string", mb_strlen($node->PathIdentificationString) + 1))) . ",\n path_string = {$newPathString},\n depth = depth + {$newParentDepth} - {$oldDepth} + 1\n WHERE\n path_string LIKE '{$oldPath}%'";
$db->begin();
$db->query($moveQuery);
$db->query($moveQuery1);
/// role system clean up
// Clean up policies and limitations
$expireRoleCache = false;
$limitationsToFix = eZPolicyLimitation::findByType('SubTree', $node->attribute('path_string'), false);
if (count($limitationsToFix) > 0) {
$limitationIDString = $db->generateSQLINStatement($limitationsToFix, 'limitation_id');
$subStringString = $db->subString('value', $oldPathLength);
$newValue = $db->concatString(array("'{$newPath}'", $subStringString));
$query = "UPDATE\n ezpolicy_limitation_value\n SET\n value = {$newValue}\n WHERE\n value LIKE '{$oldPath}%' AND {$limitationIDString}";
$db->query($query);
$expireRoleCache = true;
}
// clean up limitations on role assignment level
$countRows = $db->arrayQuery("SELECT COUNT(*) AS row_count FROM ezuser_role WHERE limit_identifier='Subtree' AND limit_value LIKE '{$oldPath}%'");
$assignmentsToFixCount = $countRows[0]['row_count'];
if ($assignmentsToFixCount > 0) {
$subStringString = $db->subString('limit_value', $oldPathLength);
$newValue = $db->concatString(array("'{$newPath}'", $subStringString));
$db->query("UPDATE\n ezuser_role\n SET\n limit_value = {$newValue}\n WHERE\n limit_identifier='Subtree' AND limit_value LIKE '{$oldPath}%'");
$expireRoleCache = true;
}
if ($expireRoleCache) {
eZRole::expireCache();
}
// Update "is_invisible" node attribute.
$newNode = eZContentObjectTreeNode::fetch($nodeID);
eZContentObjectTreeNode::updateNodeVisibility($newNode, $newParentNode);
$db->commit();
}
}
示例3: canBeRemoved
function canBeRemoved($sectionID = false)
{
if ($sectionID === false) {
$sectionID = $this->attribute('id');
}
$objects = eZPersistentObject::fetchObjectList(eZContentObject::definition(), null, array('section_id' => $sectionID));
$limitations = eZPolicyLimitation::findByType('Section', $sectionID, true, false);
$userRoles = eZRole::fetchRolesByLimitation('section', $sectionID);
if (count($objects) > 0 or count($limitations) > 0 or count($userRoles) > 0) {
return false;
} else {
return true;
}
}