diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index b4ddd548..c94141e6 100644 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -1,17 +1,16 @@ URLs - * A page is identified during request handling via its "URLSegment" database column. - * As pages can be nested, the full path of a URL might contain multiple segments. - * Each segment is stored in its filtered representation (through {@link URLSegmentFilter}). - * The full path is constructed via {@link Link()}, {@link RelativeLink()} and {@link AbsoluteLink()}. - * You can allow these segments to contain multibyte characters through {@link URLSegmentFilter::$default_allow_multibyte}. + * A page is identified during request handling via its "URLSegment" database column. As pages can be nested, the full + * path of a URL might contain multiple segments. Each segment is stored in its filtered representation (through + * {@link URLSegmentFilter}). The full path is constructed via {@link Link()}, {@link RelativeLink()} and + * {@link AbsoluteLink()}. You can allow these segments to contain multibyte characters through + * {@link URLSegmentFilter::$default_allow_multibyte}. * - * @property integer ID ID of the SiteTree object. * @property string URLSegment * @property string Title * @property string MenuTitle @@ -21,17 +20,17 @@ * @property string ShowInMenus * @property string ShowInSearch * @property string Sort Integer value denoting the sort order. - * @property string HasBrokenFile - * @property string HasBrokenLink * @property string ReportClass * @property string CanViewType Type of restriction for viewing this object. * @property string CanEditType Type of restriction for editing this object. * - * @method ManyManyList LinkTracking() List of site pages linked on this page. - * @method ManyManyList ImageTracking() List of Images linked on this page. - * @method ManyManyList ViewerGroups() List of groups that can view this object. - * @method ManyManyList EditorGroups() List of groups that can edit this object. - * @method ManyManyList BackLinkTracking() List of site pages that link to this page. + * @method ManyManyList ViewerGroups List of groups that can view this object. + * @method ManyManyList EditorGroups List of groups that can edit this object. + * @method ManyManyList BackLinkTracking List of site pages that link to this page. + * + * @mixin Hierarchy + * @mixin Versioned + * @mixin SiteTreeLinkTracking * * @package cms */ @@ -162,8 +161,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid /** * If this is false, the class cannot be created in the CMS by regular content authors, only by ADMINs. * @var boolean - * @config - */ + * @config + */ private static $can_create = true; /** @@ -228,7 +227,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid private static $enforce_strict_hierarchy = true; /** - * The value used for the meta generator tag. Leave blank to omit the tag. + * The value used for the meta generator tag. Leave blank to omit the tag. * * @config * @var string @@ -317,8 +316,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * Note that if no model can be found, this method will fall over to a extended alternateGetByLink method provided * by a extension attached to {@link SiteTree} * - * @param string $link - * @param bool $cache + * @param string $link The link of the page to search for + * @param bool $cache True (default) to use caching, false to force a fresh search from the database * @return SiteTree */ static public function get_by_link($link, $cache = true) { @@ -388,9 +387,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Return a subclass map of SiteTree - * that shouldn't be hidden through - * {@link SiteTree::$hide_ancestor} + * Return a subclass map of SiteTree that shouldn't be hidden through {@link SiteTree::$hide_ancestor} * * @return array */ @@ -413,7 +410,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } } - // If any of the descendents don't want any of the elders to show up, cruelly render the elders surplus to requirements. + // If any of the descendents don't want any of the elders to show up, cruelly render the elders surplus to + // requirements if($kill_ancestors) { $kill_ancestors = array_unique($kill_ancestors); foreach($kill_ancestors as $mark) { @@ -429,10 +427,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid /** * Replace a "[sitetree_link id=n]" shortcode with a link to the page with the corresponding ID. * - * @param array $arguments - * @param mixed $content - * @param object|null $parser - * @return string|void + * @param array $arguments + * @param string $content + * @param TextParser $parser + * @return string */ static public function link_shortcode_handler($arguments, $content = null, $parser = null) { if(!isset($arguments['id']) || !is_numeric($arguments['id'])) return; @@ -453,14 +451,14 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid return $link; } } - + /** * Return the link for this {@link SiteTree} object, with the {@link Director::baseURL()} included. * - * @param string $action Optional controller action (method). - * Note: URI encoding of this parameter is applied automatically through template casting, - * don't encode the passed parameter. - * Please use {@link Controller::join_links()} instead to append GET parameters. + * @param string $action Optional controller action (method). + * Note: URI encoding of this parameter is applied automatically through template casting, + * don't encode the passed parameter. Please use {@link Controller::join_links()} instead to + * append GET parameters. * @return string */ public function Link($action = null) { @@ -482,9 +480,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Base link used for previewing. Defaults to absolute URL, - * in order to account for domain changes, e.g. on multi site setups. - * Does not contain hints about the stage, see {@link SilverStripeNavigator} for details. + * Base link used for previewing. Defaults to absolute URL, in order to account for domain changes, e.g. on multi + * site setups. Does not contain hints about the stage, see {@link SilverStripeNavigator} for details. * * @param string $action See {@link Link()} * @return string @@ -500,7 +497,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid /** * Return the link for this {@link SiteTree} object relative to the SilverStripe root. * - * By default, it this page is the current home page, and there is no action specified then this will return a link + * By default, if this page is the current home page, and there is no action specified then this will return a link * to the root of the site. However, if you set the $action parameter to TRUE then the link will not be rewritten * and returned in its full form. * @@ -529,9 +526,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid return Controller::join_links($base, '/', $action); } - + /** * Get the absolute URL for this page on the Live site. + * + * @param bool $includeStageEqualsLive Whether to append the URL with ?stage=Live to force Live mode + * @return string */ public function getAbsoluteLiveLink($includeStageEqualsLive = true) { $oldStage = Versioned::current_stage(); @@ -549,7 +549,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * @return String + * Generates a link to edit this page in the CMS. + * + * @return string */ public function CMSEditLink() { return Controller::join_links(singleton('CMSPageEditController')->Link('show'), $this->ID); @@ -566,7 +568,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Returns TRUE if this is the currently active page that is being used to handle a request. + * Returns true if this is the currently active page being used to handle this request. * * @return bool */ @@ -575,8 +577,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Check if this page is in the currently active section (e.g. it is either current or one of it's children is - * currently being viewed. + * Check if this page is in the currently active section (e.g. it is either current or one of its children is + * currently being viewed). * * @return bool */ @@ -587,9 +589,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Check if the parent of this page has been removed (or made otherwise unavailable), and - * is still referenced by this child. Any such orphaned page may still require access via - * the cms, but should not be shown as accessible to external users. + * Check if the parent of this page has been removed (or made otherwise unavailable), and is still referenced by + * this child. Any such orphaned page may still require access via the CMS, but should not be shown as accessible + * to external users. * * @return bool */ @@ -621,8 +623,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Return "link", "current" or section depending on if this page is the current page, or not on the current page but - * in the current section. + * Return "link", "current" or "section" depending on if this page is the current page, or not on the current page + * but in the current section. * * @return string */ @@ -639,8 +641,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid /** * Check if this page is in the given current section. * - * @param string $sectionName Name of the section to check. - * @return boolean True if we are in the given section. + * @param string $sectionName Name of the section to check + * @return bool True if we are in the given section */ public function InSection($sectionName) { $page = Director::get_current_page(); @@ -653,11 +655,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Create a duplicate of this node. Doesn't affect joined data - create a - * custom overloading of this if you need such behaviour. + * Create a duplicate of this node. Doesn't affect joined data - create a custom overloading of this if you need + * such behaviour. * - * @param bool $doWrite - * @return SiteTree The duplicated object. + * @param bool $doWrite Whether to write the new object before returning it + * @return self The duplicated object */ public function duplicate($doWrite = true) { @@ -675,12 +677,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid return $page; } - /** - * Duplicates each child of this node recursively and returns the - * duplicate node. + * Duplicates each child of this node recursively and returns the top-level duplicate node. * - * @return SiteTree The duplicated object. + * @return self The duplicated object */ public function duplicateWithChildren() { $clone = $this->duplicate(); @@ -699,10 +699,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid return $clone; } - /** - * Duplicate this node and its children as a child of the node with the - * given ID + * Duplicate this node and its children as a child of the node with the given ID * * @param int $id ID of the new node's new parent */ @@ -714,13 +712,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Return a breadcrumb trail to this page. Excludes "hidden" pages - * (with ShowInMenus=0). + * Return a breadcrumb trail to this page. Excludes "hidden" pages (with ShowInMenus=0) by default. * - * @param int $maxDepth The maximum depth to traverse. - * @param boolean $unlinked Do not make page names links - * @param boolean|string $stopAtPageType ClassName of a page to stop the upwards traversal. - * @param boolean $showHidden Include pages marked with the attribute ShowInMenus = 0 + * @param int $maxDepth The maximum depth to traverse. + * @param bool $unlinked Do not make page names links + * @param bool|string $stopAtPageType ClassName of a page to stop the upwards traversal. + * @param bool $showHidden Include pages marked with the attribute ShowInMenus = 0 * @return HTMLText The breadcrumb trail. */ public function Breadcrumbs($maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = false) { @@ -749,8 +746,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid /** * Make this page a child of another page. * - * If the parent page does not exist, resolve it to a valid ID - * before updating this page's reference. + * If the parent page does not exist, resolve it to a valid ID before updating this page's reference. * * @param SiteTree|int $item Either the parent object, or the parent ID */ @@ -766,7 +762,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid /** * Get the parent of this page. * - * @return SiteTree Parent of this page. + * @return SiteTree Parent of this page */ public function getParent() { if ($this->getField("ParentID")) { @@ -775,8 +771,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Return a string of the form "parent - page" or - * "grandparent - parent - page". + * Return a string of the form "parent - page" or "grandparent - parent - page" using page titles * * @param int $level The maximum amount of levels to traverse. * @param string $separator Seperating string @@ -793,8 +788,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * This function should return true if the current user can execute this action. - * It can be overloaded to customise the security model for an application. + * This function should return true if the current user can execute this action. It can be overloaded to customise + * the security model for an application. * * Slightly altered from parent behaviour in {@link DataObject->can()}: * - Checks for existence of a method named "can<$perm>()" on the object @@ -804,10 +799,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * * @uses DataObjectDecorator->can() * - * @param string $perm The permission to be checked, such as 'View'. - * @param Member $member The member whose permissions need checking. - * Defaults to the currently logged in user. - * @return boolean True if the the member is allowed to do the given action. + * @param string $perm The permission to be checked, such as 'View' + * @param Member $member The member whose permissions need checking. Defaults to the currently logged in user. + * @return bool True if the the member is allowed to do the given action */ public function can($perm, $member = null) { if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) { @@ -827,14 +821,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid return ($member && Permission::checkMember($member, $perm)); } - /** - * This function should return true if the current user can add children - * to this page. It can be overloaded to customise the security model for an - * application. + * This function should return true if the current user can add children to this page. It can be overloaded to + * customise the security model for an application. * - * Denies permission if any of the following conditions is TRUE: - * - alternateCanAddChildren() on a extension returns FALSE + * Denies permission if any of the following conditions is true: + * - alternateCanAddChildren() on a extension returns false * - canEdit() is not granted * - There are no classes defined in {@link $allowed_children} * @@ -842,8 +834,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @uses canEdit() * @uses $allowed_children * - * @param Member|int|null $member - * @return boolean True if the current user can add children. + * @param Member|int $member + * @return bool True if the current user can add children */ public function canAddChildren($member = null) { if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) { @@ -859,14 +851,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid return $this->canEdit($member) && $this->stat('allowed_children') != 'none'; } - /** - * This function should return true if the current user can view this - * page. It can be overloaded to customise the security model for an - * application. + * This function should return true if the current user can view this page. It can be overloaded to customise the + * security model for an application. * - * Denies permission if any of the following conditions is TRUE: - * - canView() on any extension returns FALSE + * Denies permission if any of the following conditions is true: + * - canView() on any extension returns false * - "CanViewType" directive is set to "Inherit" and any parent page return false for canView() * - "CanViewType" directive is set to "LoggedInUsers" and no user is logged in * - "CanViewType" directive is set to "OnlyTheseUsers" and user is not in the given groups @@ -874,8 +864,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @uses DataExtension->canView() * @uses ViewerGroups() * - * @param Member|int|null $member - * @return boolean True if the current user can view this page. + * @param Member|int $member + * @return bool True if the current user can view this page */ public function canView($member = null) { if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) { @@ -940,9 +930,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * * @todo Implement in CMS UI. * - * @param String $stage + * @param string $stage * @param Member $member - * @return boolean + * @return bool */ public function canViewStage($stage = 'Live', $member = null) { $oldMode = Versioned::get_reading_mode(); @@ -955,21 +945,20 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * This function should return true if the current user can delete this - * page. It can be overloaded to customise the security model for an - * application. + * This function should return true if the current user can delete this page. It can be overloaded to customise the + * security model for an application. * - * Denies permission if any of the following conditions is TRUE: - * - canDelete() returns FALSE on any extension - * - canEdit() returns FALSE - * - any descendant page returns FALSE for canDelete() + * Denies permission if any of the following conditions is true: + * - canDelete() returns false on any extension + * - canEdit() returns false + * - any descendant page returns false for canDelete() * * @uses canDelete() * @uses SiteTreeExtension->canDelete() * @uses canEdit() * * @param Member $member - * @return boolean True if the current user can delete this page. + * @return bool True if the current user can delete this page */ public function canDelete($member = null) { if($member instanceof Member) $memberID = $member->ID; @@ -993,13 +982,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * This function should return true if the current user can create new - * pages of this class, regardless of context. It can be overloaded - * to customise the security model for an application. + * This function should return true if the current user can create new pages of this class, regardless of class. It + * can be overloaded to customise the security model for an application. * - * By default, permission to create at the root level is based on the SiteConfig - * configuration, and permission to create beneath a parent is based on the - * ability to edit that parent page. + * By default, permission to create at the root level is based on the SiteConfig configuration, and permission to + * create beneath a parent is based on the ability to edit that parent page. * * Use {@link canAddChildren()} to control behaviour of creating children under this page. * @@ -1008,9 +995,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * * @param Member $member * @param array $context Optional array which may contain array('Parent' => $parentObj) - * If a parent page is known, it will be checked for validity. - * If omitted, it will be assumed this is to be created as a top level page. - * @return boolean True if the current user can create pages on this class. + * If a parent page is known, it will be checked for validity. + * If omitted, it will be assumed this is to be created as a top level page. + * @return bool True if the current user can create pages on this class. */ public function canCreate($member = null) { if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) { @@ -1043,23 +1030,24 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * This function should return true if the current user can edit this - * page. It can be overloaded to customise the security model for an - * application. + * This function should return true if the current user can edit this page. It can be overloaded to customise the + * security model for an application. * - * Denies permission if any of the following conditions is TRUE: - * - canEdit() on any extension returns FALSE + * Denies permission if any of the following conditions is true: + * - canEdit() on any extension returns false * - canView() return false * - "CanEditType" directive is set to "Inherit" and any parent page return false for canEdit() - * - "CanEditType" directive is set to "LoggedInUsers" and no user is logged in or doesn't have the CMS_Access_CMSMAIN permission code + * - "CanEditType" directive is set to "LoggedInUsers" and no user is logged in or doesn't have the + * CMS_Access_CMSMAIN permission code * - "CanEditType" directive is set to "OnlyTheseUsers" and user is not in the given groups * * @uses canView() * @uses EditorGroups() * @uses DataExtension->canEdit() * - * @param Member $member Set to FALSE if you want to explicitly test permissions without a valid user (useful for unit tests) - * @return boolean True if the current user can edit this page. + * @param Member $member Set to false if you want to explicitly test permissions without a valid user (useful for + * unit tests) + * @return bool True if the current user can edit this page */ public function canEdit($member = null) { if($member instanceof Member) $memberID = $member->ID; @@ -1087,18 +1075,17 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * This function should return true if the current user can publish this - * page. It can be overloaded to customise the security model for an - * application. + * This function should return true if the current user can publish this page. It can be overloaded to customise + * the security model for an application. * - * Denies permission if any of the following conditions is TRUE: - * - canPublish() on any extension returns FALSE - * - canEdit() returns FALSE + * Denies permission if any of the following conditions is true: + * - canPublish() on any extension returns false + * - canEdit() returns false * * @uses SiteTreeExtension->canPublish() * * @param Member $member - * @return boolean True if the current user can publish this page. + * @return bool True if the current user can publish this page. */ public function canPublish($member = null) { if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser(); @@ -1122,7 +1109,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Stub method to get the site config, provided so it's easy to override + * Stub method to get the site config, unless the current class can provide an alternate. + * + * @return SiteConfig */ public function getSiteConfig() { @@ -1135,13 +1124,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Pre-populate the cache of canEdit, canView, canDelete, canPublish permissions. - * This method will use the static can_(perm)_multiple method for efficiency. - * - * @param string $permission The permission: edit, view, publish, approve, etc. - * @param array $ids An array of page IDs - * @param callback|null $batchCallback The function/static method to call to calculate permissions. Defaults - * to 'SiteTree::can_(permission)_multiple' + * Pre-populate the cache of canEdit, canView, canDelete, canPublish permissions. This method will use the static + * can_(perm)_multiple method for efficiency. + * + * @param string $permission The permission: edit, view, publish, approve, etc. + * @param array $ids An array of page IDs + * @param callable|string $batchCallback The function/static method to call to calculate permissions. Defaults + * to 'SiteTree::can_(permission)_multiple' */ static public function prepopulate_permission_cache($permission = 'CanEditType', $ids, $batchCallback = null) { if(!$batchCallback) $batchCallback = "SiteTree::can_{$permission}_multiple"; @@ -1153,26 +1142,27 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid . "with callback '$batchCallback'", E_USER_WARNING); } } - + /** - * This method is NOT a full replacement for the individual can*() methods, e.g. {@link canEdit()}. - * Rather than checking (potentially slow) PHP logic, it relies on the database group associations, - * e.g. the "CanEditType" field plus the "SiteTree_EditorGroups" many-many table. - * By batch checking multiple records, we can combine the queries efficiently. - * - * Caches based on $typeField data. To invalidate the cache, use {@link SiteTree::reset()} - * or set the $useCached property to FALSE. - * - * @param Array $ids Of {@link SiteTree} IDs - * @param Int $memberID Member ID - * @param String $typeField A property on the data record, e.g. "CanEditType". - * @param String $groupJoinTable A many-many table name on this record, e.g. "SiteTree_EditorGroups" - * @param String $siteConfigMethod Method to call on {@link SiteConfig} for toplevel items, e.g. "canEdit" - * @param String $globalPermission If the member doesn't have this permission code, don't bother iterating deeper. - * @param Boolean $useCached - * @return Array An map of {@link SiteTree} ID keys, to boolean values + * This method is NOT a full replacement for the individual can*() methods, e.g. {@link canEdit()}. Rather than + * checking (potentially slow) PHP logic, it relies on the database group associations, e.g. the "CanEditType" field + * plus the "SiteTree_EditorGroups" many-many table. By batch checking multiple records, we can combine the queries + * efficiently. + * + * Caches based on $typeField data. To invalidate the cache, use {@link SiteTree::reset()} or set the $useCached + * property to FALSE. + * + * @param array $ids Of {@link SiteTree} IDs + * @param int $memberID Member ID + * @param string $typeField A property on the data record, e.g. "CanEditType". + * @param string $groupJoinTable A many-many table name on this record, e.g. "SiteTree_EditorGroups" + * @param string $siteConfigMethod Method to call on {@link SiteConfig} for toplevel items, e.g. "canEdit" + * @param string $globalPermission If the member doesn't have this permission code, don't bother iterating deeper + * @param bool $useCached + * @return array An map of {@link SiteTree} ID keys to boolean values */ - static public function batch_permission_check($ids, $memberID, $typeField, $groupJoinTable, $siteConfigMethod, $globalPermission = null, $useCached = true) { + public static function batch_permission_check($ids, $memberID, $typeField, $groupJoinTable, $siteConfigMethod, + $globalPermission = null, $useCached = true) { if($globalPermission === NULL) $globalPermission = array('CMS_ACCESS_LeftAndMain', 'CMS_ACCESS_CMSMain'); // Sanitise the IDs @@ -1205,8 +1195,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $SQL_idList = implode($ids, ", "); - // if page can't be viewed, don't grant edit permissions - // to do - implement can_view_multiple(), so this can be enabled + // If page can't be viewed, don't grant edit permissions to do - implement can_view_multiple(), so this can + // be enabled //$ids = array_keys(array_filter(self::can_view_multiple($ids, $memberID))); // Get the groups that the given member belongs to @@ -1221,7 +1211,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $table = ($stage=='Stage') ? "SiteTree" : "SiteTree_$stage"; $result = array_fill_keys( - ($ids) ? DB::query("SELECT \"ID\" FROM \"$table\" WHERE \"ID\" IN (".implode(", ", $ids).")")->column() : array(), + ($ids) ? DB::query("SELECT \"ID\" FROM \"$table\" WHERE \"ID\" IN (".implode(", ", $ids).")")->column() : array(), false ); @@ -1242,15 +1232,16 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid AND \"SiteTree\".\"ID\" IN ($SQL_idList)"); if($potentiallyInherited) { - // Group $potentiallyInherited by ParentID; we'll look at the permission of all those - // parents and then see which ones the user has permission on + // Group $potentiallyInherited by ParentID; we'll look at the permission of all those parents and + // then see which ones the user has permission on $groupedByParent = array(); foreach($potentiallyInherited as $item) { if($item->ParentID) { if(!isset($groupedByParent[$item->ParentID])) $groupedByParent[$item->ParentID] = array(); $groupedByParent[$item->ParentID][] = $item->ID; } else { - // Might return different site config based on record context, e.g. when subsites module is used + // Might return different site config based on record context, e.g. when subsites module + // is used $siteConfig = $item->getSiteConfig(); $result[$item->ID] = $siteConfig->{$siteConfigMethod}($memberID); } @@ -1283,15 +1274,15 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid return array(); } } - + /** * Get the 'can edit' information for a number of SiteTree pages. - * - * @param array $ids An array of IDs of the SiteTree pages to look up. - * @param int $memberID ID of member. - * @param bool $useCached Return values from the permission cache if they exist. - * @return array A map where the IDs are keys and the values are booleans stating whether the given - * page can be edited. + * + * @param array $ids An array of IDs of the SiteTree pages to look up + * @param int $memberID ID of member + * @param bool $useCached Return values from the permission cache if they exist + * @return array A map where the IDs are keys and the values are booleans stating whether the given page can be + * edited */ static public function can_edit_multiple($ids, $memberID, $useCached = true) { return self::batch_permission_check($ids, $memberID, 'CanEditType', 'SiteTree_EditorGroups', 'canEditPages', null, $useCached); @@ -1299,9 +1290,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid /** * Get the 'can edit' information for a number of SiteTree pages. - * @param array $ids An array of IDs of the SiteTree pages to look up. - * @param int $memberID ID of member. - * @param bool $useCached Return values from the permission cache if they exist. + * + * @param array $ids An array of IDs of the SiteTree pages to look up + * @param int $memberID ID of member + * @param bool $useCached Return values from the permission cache if they exist * @return array */ static public function can_delete_multiple($ids, $memberID, $useCached = true) { @@ -1358,23 +1350,19 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $deletable = array(); } - // Convert the array of deletable IDs into a map of the original IDs with true/false as the - // value + // Convert the array of deletable IDs into a map of the original IDs with true/false as the value return array_fill_keys($deletable, true) + array_fill_keys($ids, false); } - /** * Collate selected descendants of this page. * - * {@link $condition} will be evaluated on each descendant, and if it is - * succeeds, that item will be added to the $collator array. + * {@link $condition} will be evaluated on each descendant, and if it is succeeds, that item will be added to the + * $collator array. * - * @param string $condition The PHP condition to be evaluated. The page - * will be called $item - * @param array $collator An array, passed by reference, to collect all - * of the matching descendants. - * @return true|void + * @param string $condition The PHP condition to be evaluated. The page will be called $item + * @param array $collator An array, passed by reference, to collect all of the matching descendants. + * @return bool */ public function collateDescendants($condition, &$collator) { if($children = $this->Children()) { @@ -1386,13 +1374,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } } - /** * Return the title, description, keywords and language metatags. - * + * * @todo Move