コード例 #1
0
 /**
  * Mock a file search using AssetAdmin
  *
  * @param string $name
  * @param string $from Created from date
  * @param string $to Createi to date
  * @param string $category
  * @return SS_List
  */
 protected function getResultsForSearch($name = '', $from = '', $to = '', $category = '')
 {
     $request = new SS_HTTPRequest(null, 'admin/assets/show', array('q' => array('Name' => $name, 'CreatedFrom' => $from, 'CreatedTo' => $to, 'AppCategory' => $category), 'action_doSearch' => 'Apply Filter'));
     $admin = new AssetAdmin();
     $admin->setRequest($request);
     return $admin->getList();
 }
 /**
  * Gets the form used for viewing a time log
  */
 public function getEditForm($id = null, $fields = null)
 {
     $record = $this->currentPage();
     if ($this->action == 'view' && $record) {
         $fields = new FieldList(new HeaderField('LogHeader', _t('KapostBridgeLogViewer.VIEWING_ENTRY', '_Viewing Log Entry: {datetime}', array('datetime' => $record->dbObject('Created')->FormatFromSettings())), 3), new ReadonlyField('UserAgent', _t('KapostBridgeLogViewer.USER_AGENT', '_Requestor User Agent')), new ReadonlyField('Method', _t('KapostBridgeLogViewer.METHOD', '_Method')), ToggleCompositeField::create('RequestData', _t('KapostBridgeLogViewer.KAPOST_REQUEST', '_Kapost Request'), new FieldList(ReadonlyField::create('RequestFormatted', '')->setTemplate('KapostBridgeLogField')->addExtraClass('log-contents cms-panel-layout')))->setHeadingLevel(3), ToggleCompositeField::create('ResponseData', _t('KapostBridgeLogViewer.SILVERSTRIPE_RESPONSE', '_SilverStripe Response'), new FieldList(ReadonlyField::create('ResponseFormatted', '')->setTemplate('KapostBridgeLogField')->addExtraClass('log-contents cms-panel-layout')))->setHeadingLevel(3));
         $refObj = $record->ReferenceObject;
         if (!empty($refObj) && $refObj !== false && $refObj->exists()) {
             if (method_exists($refObj, 'CMSEditLink')) {
                 $fields->insertBefore(new KapostLogLinkField('CMSEditLink', _t('KapostBridgeLogViewer.REFERENCED_OBJECT', '_Referenced Object'), $refObj->CMSEditLink(), _t('KapostBridgeLogViewer.VIEW_REFERENCED_OBJECT', '_View Referenced Object')), 'RequestData');
             } else {
                 if ($refObj instanceof File) {
                     $refObjLink = Controller::join_links(LeftAndMain::config()->url_base, AssetAdmin::config()->url_segment, 'EditForm/field/File/item', $refObj->ID, 'edit');
                     $fields->insertBefore(new KapostLogLinkField('CMSEditLink', _t('KapostBridgeLogViewer.REFERENCED_OBJECT', '_Referenced Object'), $refObjLink, _t('KapostBridgeLogViewer.VIEW_REFERENCED_OBJECT', '_View Referenced Object')), 'RequestData');
                 }
             }
         }
     } else {
         $fields = new FieldList();
     }
     $form = new CMSForm($this, 'EditForm', $fields, new FieldList());
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-edit-form center');
     $form->setAttribute('data-layout-type', 'border');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $form->setHTMLID('Form_EditForm');
     if ($record) {
         $form->loadDataFrom($record);
     }
     return $form;
 }
コード例 #3
0
<?php

/**
 * Secure Files Module Configuration
 *
 * @package securefiles
 * @author Hamish Campbell <*****@*****.**>
 * @copyright copyright (c) 2010, Hamish Campbell
 */
define('MODULE_SECUREFILES_PATH', basename(dirname(__FILE__)));
Director::addRules(50, array(ASSETS_DIR . '/$Action' => 'SecureFileController'));
AssetAdmin::require_css(MODULE_SECUREFILES_PATH . '/css/SecureFiles.css');
// -------------------------------
/**
 *  Apply optional permission methods here. Include them in the reverse
 *  order that you would like them to appear in the CMS.
 */
// Assign file security by individual member:
// DataObject::add_extension('File', 'SecureFileMemberPermissionDecorator');
// Assign file security by member group:
// DataObject::add_extension('File', 'SecureFileGroupPermissionDecorator');
// Create time-limited access tokens:
// DataObject::add_extension('File', 'SecureFileTokenPermissionDecorator');
// -------------------------------
DataObject::add_extension('File', 'SecureFileDecorator');
/**
 * For large files or heavily trafficed sites use x-sendfile headers to by-pass
 * file handling in PHP. Supported in lighttpd and in Apache with mod_xsendfile
 * available at http://tn123.ath.cx/mod_xsendfile/
 */
// SecureFileController::use_x_sendfile_method();
コード例 #4
0
 protected function getFileEditForm()
 {
     $admin = new AssetAdmin();
     $folder = Controller::join_links($admin->Link(), 'show', $this->folder->ID);
     $file = Controller::join_links($admin->Link(), 'EditForm/field/File/item', $this->file->ID, 'edit');
     $this->get($folder);
     $this->get($file);
 }
コード例 #5
0
<?php

/**
 * The subsites module modifies the behaviour of the CMS - in the SiteTree and Group databases - to store information
 * about a number of sub-sites, rather than a single site.
 */
SiteTree::add_extension('SiteTreeSubsites');
ContentController::add_extension('ControllerSubsites');
CMSPageAddController::add_extension('CMSPageAddControllerExtension');
LeftAndMain::add_extension('LeftAndMainSubsites');
LeftAndMain::add_extension('ControllerSubsites');
Group::add_extension('GroupSubsites');
File::add_extension('FileSubsites');
ErrorPage::add_extension('ErrorPageSubsite');
SiteConfig::add_extension('SiteConfigSubsites');
SS_Report::add_excluded_reports('SubsiteReportWrapper');
//Display in cms menu
AssetAdmin::add_extension('SubsiteMenuExtension');
SecurityAdmin::add_extension('SubsiteMenuExtension');
CMSMain::add_extension('SubsiteMenuExtension');
CMSPagesController::add_extension('SubsiteMenuExtension');
SubsiteAdmin::add_extension('SubsiteMenuExtension');
CMSSettingsController::add_extension('SubsiteMenuExtension');
 /**
  * 
  * {@inheritdoc}
  * 
  * @param SS_HTTPRequest $request
  * @return HTMLText
  */
 public function addfolder($request)
 {
     $parentId = SecuredFilesystem::get_numeric_identifier($this, 'ParentID');
     $folder = DataObject::get_by_id("Folder", $parentId);
     if ($folder && $folder->exists()) {
         if (!$folder->Secured) {
             $message = _t('SecuredFilesystem.messages.ERROR_ACCESS_ONLY_IN_FILES');
             return SecuredFilesystem::show_access_message($this, $message);
         }
         return parent::addfolder($request);
     } else {
         $message = _t('SecuredFilesystem.messages.ERROR_FOLDER_NOT_EXISTS');
         return SecuredFilesystem::show_access_message($this, $message);
     }
 }
 /**
  * Exercises SecuredFilesystem::get_numeric_identifier() with both types of expected controller
  * Ensures expected outputs given a variety of inputs
  *
  * @todo Add 'ParentID' ensure this works as expected
  * @todo  Test with "unexpected" class, assert exedcption or error thrown as expecced (Zero is returned)
  */
 public function testGetNumericIdentifierPost()
 {
     $controller = $this->getTestController(array('ID' => '40'), 'POST', AssetAdmin::create());
     $result = SecuredFilesystem::get_numeric_identifier($controller, 'ID');
     $this->assertInternalType('integer', $result);
     $this->assertEquals(40, $result);
     $controller = $this->getTestController(array('ID' => '40'), 'POST', CMSFileAddController::create());
     $result = SecuredFilesystem::get_numeric_identifier($controller, 'ID');
     $this->assertInternalType('integer', $result);
     $this->assertEquals(40, $result);
     $controller = $this->getTestController(array('ID' => '0'), 'POST', AssetAdmin::create());
     $result = SecuredFilesystem::get_numeric_identifier($controller, 'ID');
     $this->assertInternalType('integer', $result);
     $this->assertEquals(0, $result);
     $controller = $this->getTestController(array('ID' => '0'), 'POST', CMSFileAddController::create());
     $result = SecuredFilesystem::get_numeric_identifier($controller, 'ID');
     $this->assertInternalType('integer', $result);
     $this->assertEquals(0, $result);
     $controller = $this->getTestController(array('ParentID' => '40'), 'POST', AssetAdmin::create());
     $result = SecuredFilesystem::get_numeric_identifier($controller, 'ParentID');
     $this->assertInternalType('integer', $result);
     $this->assertEquals(40, $result);
     $controller = $this->getTestController(array('ParentID' => '40'), 'POST', CMSFileAddController::create());
     $result = SecuredFilesystem::get_numeric_identifier($controller, 'ParentID');
     $this->assertInternalType('integer', $result);
     $this->assertEquals(40, $result);
     $controller = $this->getTestController(array('ParentID' => '0'), 'POST', AssetAdmin::create());
     $result = SecuredFilesystem::get_numeric_identifier($controller, 'ParentID');
     $this->assertInternalType('integer', $result);
     $this->assertEquals(0, $result);
     $controller = $this->getTestController(array('ParentID' => '0'), 'POST', CMSFileAddController::create());
     $result = SecuredFilesystem::get_numeric_identifier($controller, 'ParentID');
     $this->assertInternalType('integer', $result);
     $this->assertEquals(0, $result);
     $controller = $this->getTestController(array('DUMMY' => '40'), 'POST', AssetAdmin::create());
     $result = SecuredFilesystem::get_numeric_identifier($controller, 'ID');
     $this->assertInternalType('integer', $result);
     $this->assertEquals(0, $result);
     $controller = $this->getTestController(array('DUMMY' => '40'), 'POST', CMSFileAddController::create());
     $result = SecuredFilesystem::get_numeric_identifier($controller, 'ID');
     $this->assertInternalType('integer', $result);
     $this->assertEquals(0, $result);
     $controller = $this->getTestController(array('ID' => '40'), 'POST', Controller::create());
     $result = SecuredFilesystem::get_numeric_identifier($controller, 'ID');
     $this->assertInternalType('integer', $result);
     $this->assertEquals(0, $result);
 }