Merge remote-tracking branch 'origin/3.1'

Conflicts:
	.travis.yml
	code/reports/Report.php
This commit is contained in:
Simon Welsh 2014-03-18 09:23:39 +13:00
commit b497b8f548
8 changed files with 83 additions and 70 deletions

View File

@ -22,11 +22,10 @@ matrix:
env: DB=MYSQL CORE_RELEASE=master
- php: 5.5
env: DB=MYSQL CORE_RELEASE=master
- php: 5.6
env: DB=MYSQL CORE_RELEASE=master
- php: 5.4
env: DB=MYSQL CORE_RELEASE=master BEHAT_TEST=1
allow_failures:
- php: 5.5
env: DB=MYSQL CORE_RELEASE=master
before_script:
- composer self-update
@ -55,4 +54,4 @@ branches:
notifications:
irc:
channels:
- "irc.freenode.org#silverstripe"
- "irc.freenode.org#silverstripe"

View File

@ -57,6 +57,10 @@ class CMSFileAddController extends LeftAndMain {
Requirements::javascript(FRAMEWORK_DIR . '/javascript/AssetUploadField.js');
Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
if($currentPageID = $this->currentPageID()){
Session::set("{$this->class}.currentPage", $currentPageID);
}
$folder = $this->currentPage();
$uploadField = UploadField::create('AssetUploadField', '');

View File

@ -880,7 +880,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
if(!$fromLive
&& !Session::get('unsecuredDraftSite')
&& !Permission::checkMember($member, array('CMS_ACCESS_CMSMain', 'VIEW_DRAFT_CONTENT'))) {
&& !Permission::checkMember($member, array('CMS_ACCESS_LeftAndMain', 'CMS_ACCESS_CMSMain', 'VIEW_DRAFT_CONTENT'))) {
// If we weren't definitely loaded from live, and we can't view non-live content, we need to
// check to make sure this version is the live version and so can be viewed
if (Versioned::get_versionnumber_by_stage($this->class, 'Live', $this->ID) != $this->Version) return false;
@ -1135,7 +1135,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* @param Boolean $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 = 'CMS_ACCESS_CMSMain', $useCached = true) {
static public 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
$ids = array_filter($ids, 'is_numeric');
@ -1255,7 +1257,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* page can be edited.
*/
static public function can_edit_multiple($ids, $memberID, $useCached = true) {
return self::batch_permission_check($ids, $memberID, 'CanEditType', 'SiteTree_EditorGroups', 'canEdit', 'CMS_ACCESS_CMSMain', $useCached);
return self::batch_permission_check($ids, $memberID, 'CanEditType', 'SiteTree_EditorGroups', 'canEdit', null, $useCached);
}
/**

View File

@ -7,7 +7,7 @@ So that I can link to a external website or a page on my site
Background:
Given a "page" "Home"
And a "page" "About Us" has the "Content" "My awesome content"
#And a "file" "assets/folder1/file1.jpg"
And a "file" "assets/file1.jpg"
And I am logged in with "ADMIN" permissions
And I go to "/admin/pages"
And I click on "About Us" in the tree
@ -21,63 +21,60 @@ So that I can link to a external website or a page on my site
And I press the "Insert" button
# TODO Dynamic DB identifiers
Then the "Content" HTML field should contain "<a title="my desc" href="[sitetree_link,id=1]">awesome</a>"
# Required to avoid "unsaved changed" browser dialog
# Required to avoid "unsaved changes" browser dialog
Then I press the "Save draft" button
Scenario: I can link to an external URL
Given I select "awesome" in the "Content" HTML field
And I press the "Insert Link" button
When I check "Another website"
And I fill in "http://silverstripe.org" for "URL"
And I check "Open link in a new window"
And I press the "Insert" button
Then the "Content" HTML field should contain "<a href="http://silverstripe.org" target="_blank">awesome</a>"
# Required to avoid "unsaved changed" browser dialog
# Required to avoid "unsaved changes" browser dialog
Then I press the "Save draft" button
@todo
Scenario: I can link to a file
Given I select "awesome" in the "Content" HTML field
When I press the "Insert Link" button
When I check "Download a file"
And I fill in the "File" dropdown with "file1.jpg"
And I press the "Insert link" button
Then the "Content" HTML field should contain "<a href="assets/folder1/file1.jpg">awesome</a>"
# Required to avoid "unsaved changed" browser dialog
Then the "Content" HTML field should contain "<a href="[file_link,id=1]" target="_blank">awesome</a>"
# Required to avoid "unsaved changes" browser dialog
Then I press the "Save draft" button
@todo
Scenario: I can link to an anchor
Given I fill in the "Content" HTML field with "My awesome content <a name=myanchor>"
Given I fill in the "Content" HTML field with "<p>My awesome content<a name=myanchor></a></p>"
And I select "awesome" in the "Content" HTML field
When I press the "Insert Link" button
When I check "Anchor on this page"
And I fill in the "Select an anchor" dropdown with "myanchor"
# Need to hard-code the id attribute of the <select> here, as there are two form fields to pick from
And I select "myanchor" from "Form_EditorToolbarLinkForm_AnchorSelector"
And I press the "Insert link" button
Then the "Content" HTML field should contain "<a href="#myanchor">awesome</a>"
# Required to avoid "unsaved changed" browser dialog
# Required to avoid "unsaved changes" browser dialog
Then I press the "Save draft" button
@todo
Scenario: I can edit a link
Given I fill in the "Content" HTML field with "My <a href="http://silverstripe.org">awesome</a> content"
And I select "awesome"
Given I fill in the "Content" HTML field with "<p>My <a href=http://silverstripe.org>awesome</a> content"
And I select "awesome" in the "Content" HTML field
When I press the "Insert Link" button
And the "URL" field should contain "http://silverstripe.org"
When I fill in "http://wordpress.org" for "URL"
# We need to hard-code the <input> id attribute, if you say 'Then the URL field', it picks up URLSegment instead.
Then the "Form_EditorToolbarLinkForm_external" field should contain "http://silverstripe.org"
# This doesn't seem to suffer from that issue
When I fill in "http://google.com" for "URL"
And I press the "Insert link" button
Then the "Content" HTML field should contain "<a href="http://wordpress.org">awesome</a>"
# Required to avoid "unsaved changed" browser dialog
Then the "Content" HTML field should contain "<a href="http://google.com">awesome</a>"
# Required to avoid "unsaved changes" browser dialog
Then I press the "Save draft" button
@todo
Scenario: I can delete a link
Given I fill in the "Content" HTML field with "My <a href="http://silverstripe.org">awesome</a> content"
And I select "awesome"
When I press the "Insert Link" button
And I press the "Remove link" button
Then the "Content" HTML field should not contain "<a href="http://silverstripe.org">awesome</a>"
# Required to avoid "unsaved changed" browser dialog
Scenario: I can remove a link
Given I fill in the "Content" HTML field with "My <a href=http://silverstripe.org>awesome</a> content"
And I select "awesome" in the "Content" HTML field
When I press the "Unlink" button
Then the "Content" HTML field should contain "My awesome content"
And the "Content" HTML field should not contain "http://silverstripe.org"
# Required to avoid "unsaved changes" browser dialog
Then I press the "Save draft" button

View File

@ -55,37 +55,22 @@ Feature: Insert an image into a page
# Required to avoid "unsaved changed" browser dialog
Then I press the "Save draft" button
@todo
Scenario: I can insert an image from the CMS file store
Given I press the "Insert Media" button
And I press the "From the CMS" button
And I select "folder1" in the "Find in Folder" dropdown
And I select "file1.jpg"
And I fill in the "ParentID" dropdown with "folder1"
And I click on "file1.jpg" in the "Files" table
When I press the "Insert" button
Then the "Content" HTML field should contain "file1.jpg"
# Required to avoid "unsaved changed" browser dialog
Then I press the "Save draft" button
@todo
Scenario: I can insert multiple images at once
Given I press the "Insert Media" button
And I press the "From the CMS" button
And I select "folder1" in the "Find in Folder" dropdown
And I select "file1.jpg"
And I select "file2.jpg"
When I press the "Insert" button
Then the "Content" HTML field should contain "file1.jpg"
And the "Content" HTML field should contain "file2.jpg"
# Required to avoid "unsaved changed" browser dialog
Then I press the "Save draft" button
@todo
Scenario: I can edit properties of an image before inserting it
Given I press the "Insert Media" button
And I press the "From the CMS" button
And I select "folder1" in the "Find in Folder" dropdown
And I select "file1.jpg"
And I follow "Edit"
And I fill in the "ParentID" dropdown with "folder1"
And I click on "file1.jpg" in the "Files" table
And I press the "Edit" button
When I fill in "Alternative text (alt)" with "My alt"
And I press the "Insert" button
Then the "Content" HTML field should contain "file1.jpg"
@ -93,20 +78,7 @@ Feature: Insert an image into a page
# Required to avoid "unsaved changed" browser dialog
Then I press the "Save draft" button
@todo
Scenario: I can edit dimensions of an image before inserting it
Given I press the "Insert Media" button
And I press the "From the CMS" button
And I select "folder1" in the "Find in Folder" dropdown
And I select "file1.jpg"
And I follow "Edit"
When I fill in "Width" with "10"
When I fill in "Height" with "20"
And I press the "Insert" button
Then the "Content" HTML field should contain "<img src=assets/folder1/file1.jpg width=10 height=20>"
# Required to avoid "unsaved changed" browser dialog
Then I press the "Save draft" button
# TODO This needs to support using drag handles, as we no longer have 'Width' or 'Height' input fields
@todo
Scenario: I can edit dimensions of an existing image
Given the "page" "About us" contains "<img src=assets/folder1/file1.jpg>"

View File

@ -60,3 +60,18 @@ Feature: Manage files
When I go to "/admin/assets/add"
And I follow "Show allowed extensions"
Then I should see "png,"
Scenario: I can filter the files list view using name
Given I expand the "Filter" CMS Panel
And I fill in "Name" with "file1"
And I press the "Apply Filter" button
Then the "Files" table should contain "file1"
And the "Files" table should not contain "file2"
Scenario: I can filter the files list view using filetype
Given a "file" "assets/document.pdf"
And I expand the "Filter" CMS Panel
And I select "Image" from "File type"
And I press the "Apply Filter" button
Then the "Files" table should contain "file1"
And the "Files" table should not contain "document"

View File

@ -454,6 +454,16 @@ class SiteTreeTest extends SapphireTest {
// Can't edit a child of that page that has its permissions overridden
$this->assertFalse($product4->canEdit($editor));
}
public function testCanEditWithAccessToAllSections() {
$page = new Page();
$page->write();
$allSectionMember = $this->objFromFixture('Member', 'allsections');
$securityAdminMember = $this->objFromFixture('Member', 'securityadmin');
$this->assertTrue($page->canEdit($allSectionMember));
$this->assertFalse($page->canEdit($securityAdminMember));
}
public function testEditPermissionsOnDraftVsLive() {
// Create an inherit-permission page

View File

@ -3,7 +3,11 @@ Group:
Title: Editors
admins:
Title: Administrators
allsections:
Title: All Section Editors
securityadmins:
Title: Security Admins
Permission:
admins:
Code: ADMIN
@ -11,7 +15,13 @@ Permission:
editors:
Code: CMS_ACCESS_CMSMain
Group: =>Group.editors
allsections:
Code: CMS_ACCESS_LeftAndMain
Group: =>Group.allsections
securityadmins:
Code: CMS_ACCESS_SecurityAdmin
Group: =>Group.securityadmins
Member:
editor:
FirstName: Test
@ -21,6 +31,10 @@ Member:
FirstName: Test
Surname: Administrator
Groups: =>Group.admins
allsections:
Groups: =>Group.allsections
securityadmin:
Groups: =>Group.securityadmins
Page:
home: