当前位置: 首页>>代码示例>>PHP>>正文


PHP SecurityToken::enable方法代码示例

本文整理汇总了PHP中SecurityToken::enable方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityToken::enable方法的具体用法?PHP SecurityToken::enable怎么用?PHP SecurityToken::enable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SecurityToken的用法示例。


在下文中一共展示了SecurityToken::enable方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tearDown

 public function tearDown()
 {
     SecurityToken::enable();
     $this->folder->deleteDatabaseOnly();
     Filesystem::removeFolder($this->folder->getFullPath());
     parent::tearDown();
 }
开发者ID:camfindlay,项目名称:silverstripe-versionedfiles,代码行数:7,代码来源:VersionedFileTest.php

示例2: testIsEnabledStatic

 public function testIsEnabledStatic()
 {
     $this->assertTrue(SecurityToken::is_enabled());
     SecurityToken::disable();
     $this->assertFalse(SecurityToken::is_enabled());
     SecurityToken::enable();
     $this->assertTrue(SecurityToken::is_enabled());
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:8,代码来源:SecurityTokenTest.php

示例3: tearDown

 public function tearDown()
 {
     if ($this->securityEnabled) {
         SecurityToken::enable();
     } else {
         SecurityToken::disable();
     }
     parent::tearDown();
 }
开发者ID:tcaiger,项目名称:mSupplyNZ,代码行数:9,代码来源:CommentingControllerTest.php

示例4: tearDown

 public function tearDown()
 {
     if ($this->securityWasEnabled) {
         SecurityToken::enable();
     } else {
         SecurityToken::disable();
     }
     Injector::unnest();
     Config::unnest();
     parent::tearDown();
 }
开发者ID:helpfulrobot,项目名称:silverstripe-spellcheck,代码行数:11,代码来源:SpellControllerTest.php

示例5: testDisableSecurityToken

 public function testDisableSecurityToken()
 {
     SecurityToken::enable();
     $form = $this->getStubForm();
     $this->assertTrue($form->getSecurityToken()->isEnabled());
     $form->disableSecurityToken();
     $this->assertFalse($form->getSecurityToken()->isEnabled());
     SecurityToken::disable();
     // restore original
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:10,代码来源:FormTest.php

示例6: tearDown

 function tearDown()
 {
     SecurityToken::enable();
     parent::tearDown();
     unset($this->mainSession);
 }
开发者ID:hamishcampbell,项目名称:silverstripe-sapphire,代码行数:6,代码来源:FunctionalTest.php

示例7: testSecurityToken

 public function testSecurityToken()
 {
     $enabled = SecurityToken::is_enabled();
     // enable security tokens
     SecurityToken::enable();
     $productId = $this->mp3player->ID;
     // link should contain the security-token
     $link = ShoppingCart_Controller::add_item_link($this->mp3player);
     $this->assertRegExp('{^shoppingcart/add/Product/' . $productId . '\\?SecurityID=[a-f0-9]+$}', $link);
     // should redirect back to the shop
     $response = $this->get($link);
     $this->assertEquals($response->getStatusCode(), 302);
     // disable security token for cart-links
     Config::inst()->update('ShoppingCart_Controller', 'disable_security_token', true);
     $link = ShoppingCart_Controller::add_item_link($this->mp3player);
     $this->assertEquals('shoppingcart/add/Product/' . $productId, $link);
     // should redirect back to the shop
     $response = $this->get($link);
     $this->assertEquals($response->getStatusCode(), 302);
     SecurityToken::disable();
     Config::inst()->update('ShoppingCart_Controller', 'disable_security_token', false);
     $link = ShoppingCart_Controller::add_item_link($this->mp3player);
     $this->assertEquals('shoppingcart/add/Product/' . $productId, $link);
     // should redirect back to the shop
     $response = $this->get($link);
     $this->assertEquals($response->getStatusCode(), 302);
     SecurityToken::enable();
     // should now return a 400 status
     $response = $this->get($link);
     $this->assertEquals($response->getStatusCode(), 400);
     // restore previous setting
     if (!$enabled) {
         SecurityToken::disable();
     }
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:35,代码来源:ShoppingCartControllerTest.php

示例8: tearDown

 public function tearDown()
 {
     SecurityToken::enable();
     parent::tearDown();
     unset($this->mainSession);
     if (static::get_disable_themes()) {
         Config::inst()->update('SSViewer', 'theme', $this->originalTheme);
     }
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:9,代码来源:FunctionalTest.php

示例9: __construct

 /**
  * creates a form object with a free configurable markup
  *
  * @param ContentController $controller  the calling controller instance
  * @param array             $params      optional parameters
  * @param array             $preferences optional preferences
  * @param bool              $barebone    defines if a form should only be instanciated or be used too
  *
  * @return CustomHtmlForm
  *
  * @author Sebastian Diel <sdiel@pixeltricks.de>,
  *         Sascha Koehler <skoehler@pixeltricks.de>
  * @since 13.01.2015
  */
 public function __construct($controller, $params = null, $preferences = null, $barebone = false)
 {
     $this->extend('onBeforeConstruct', $controller, $params, $preferences, $barebone);
     global $project;
     $this->barebone = $barebone;
     $this->controller = $controller;
     if (is_array($params)) {
         $this->customParameters = $params;
     }
     // Hook for setting preferences via a method call
     $this->preferences();
     if (is_array($preferences)) {
         foreach ($preferences as $title => $setting) {
             if (!empty($title)) {
                 $this->basePreferences[$title] = $setting;
             }
         }
     }
     $name = $this->getSubmitAction();
     if (!$barebone) {
         $this->getFormFields();
     }
     if ($this->securityTokenEnabled) {
         SecurityToken::enable();
     } else {
         SecurityToken::disable();
     }
     parent::__construct($this->getFormController($controller, $preferences), $name, new FieldList(), new FieldList());
     if (!$barebone) {
         $this->getFormFields();
         $this->fillInFieldValues();
     }
     // Hook for setting preferences via a method call; we need to do this
     // a second time so that the standard Silverstripe mechanism can take
     // influence, too (i.e. _config.php files, init methods, etc).
     $this->preferences();
     if (is_array($preferences)) {
         foreach ($preferences as $title => $setting) {
             if (!empty($title)) {
                 $this->basePreferences[$title] = $setting;
             }
         }
     }
     // Counter for the form class, init or increment
     if (!isset(self::$classInstanceCounter[$this->class])) {
         self::$classInstanceCounter[$this->class] = 0;
     }
     if (!$barebone) {
         self::$classInstanceCounter[$this->class]++;
     }
     // new assignment required, because the controller will be overwritten in the form class
     $this->controller = $controller;
     // create group structure
     if (isset($this->formFields)) {
         $this->fieldGroups['formFields'] = $this->getFormFields();
     } else {
         $this->fieldGroups['formFields'] = array();
     }
     $this->name = str_replace('/', '', $this->class . '_' . $name . '_' . self::$classInstanceCounter[$this->class]);
     $this->jsName = $this->name;
     $this->SSformFields = $this->getForm();
     $this->SSformFields['fields']->setForm($this);
     $this->SSformFields['actions']->setForm($this);
     parent::setFields($this->SSformFields['fields']);
     parent::setActions($this->SSformFields['actions']);
     // define form action
     $this->setFormAction($this->buildFormAction());
     $this->setHTMLID($this->getName());
     /*
      * load and init JS validators
      * form integration via FormAttributes()
      */
     if (!$barebone) {
         $javascriptSnippets = $this->getJavascriptValidatorInitialisation();
         if (!$this->getLoadShoppingCartModules()) {
             SilvercartShoppingCart::setLoadShoppingCartModules(false);
         }
         if ($this->getCreateShoppingCartForms() && class_exists('SilvercartShoppingCart')) {
             SilvercartShoppingCart::setCreateShoppingCartForms(false);
         }
         $this->controller->addJavascriptSnippet($javascriptSnippets['javascriptSnippets']);
         $this->controller->addJavascriptOnloadSnippet($javascriptSnippets['javascriptOnloadSnippets']);
         $this->controller->addJavascriptOnloadSnippet($this->getJavascriptFieldInitialisations());
     }
     // Register the default module directory from mysite/_config.php
     self::registerModule($project);
//.........这里部分代码省略.........
开发者ID:silvercart,项目名称:customhtmlform,代码行数:101,代码来源:CustomHtmlForm.php

示例10: testMarkAsSpamLink

 function testMarkAsSpamLink()
 {
     $post = $this->objFromFixture('Post', 'Post1');
     //enable token
     SecurityToken::enable();
     // should be false since we're not logged in.
     if ($member = Member::currentUser()) {
         $member->logOut();
     }
     $this->assertFalse($post->EditLink());
     $this->assertFalse($post->MarkAsSpamLink());
     // logged in as the moderator. Should be able to mark the post as spam.
     $member = $this->objFromFixture('Member', 'moderator');
     $member->logIn();
     $this->assertContains($post->Thread()->URLSegment . '/markasspam/' . $post->ID, $post->MarkAsSpamLink());
     // because this is the first post test for the class which is used in javascript
     $this->assertContains("class=\"markAsSpamLink firstPost\"", $post->MarkAsSpamLink());
     $member->logOut();
     // log in as another member who is not in a position to mark post as spam this post
     $member = $this->objFromFixture('Member', 'test2');
     $member->logIn();
     $this->assertFalse($post->MarkAsSpamLink());
     // log in as someone who can moderate this post (and therefore mark as spam)
     $member = $this->objFromFixture('Member', 'moderator');
     $member->logIn();
     //check for the existance of a CSRF token
     $this->assertContains("SecurityID=", $post->MarkAsSpamLink());
     // should be able to edit post since they're moderators
     $this->assertContains($post->Thread()->URLSegment . '/markasspam/' . $post->ID, $post->MarkAsSpamLink());
     // test that a 2nd post doesn't have the first post ID hook
     $memberOthersPost = $this->objFromFixture('Post', 'Post2');
     $this->assertFalse(strstr($memberOthersPost->MarkAsSpamLink(), "firstPost"));
 }
开发者ID:helpfulrobot,项目名称:silverstripe-forum,代码行数:33,代码来源:PostTest.php


注:本文中的SecurityToken::enable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。