Skip to content

Commit

Permalink
API Apply Framework\Security namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Mooyman committed Jul 6, 2016
1 parent 20efb0e commit af22a83
Show file tree
Hide file tree
Showing 155 changed files with 1,704 additions and 1,049 deletions.
41 changes: 41 additions & 0 deletions .upgrade.yml
Expand Up @@ -115,8 +115,49 @@ mappings:
VersionedGridFieldDetailForm: SilverStripe\ORM\Versioning\VersionedGridFieldDetailForm
VersionedGridFieldItemRequest: SilverStripe\ORM\Versioning\VersionedGridFieldItemRequest
Hierarchy: SilverStripe\ORM\Hierarchy\Hierarchy
Authenticator: SilverStripe\Security\Authenticator
BasicAuth: SilverStripe\Security\BasicAuth
ChangePasswordForm: SilverStripe\Security\ChangePasswordForm
CMSMemberLoginForm: SilverStripe\Security\CMSMemberLoginForm
CMSSecurity: SilverStripe\Security\CMSSecurity
Group: SilverStripe\Security\Group
GroupCsvBulkLoader: SilverStripe\Security\GroupCsvBulkLoader
LoginAttempt: SilverStripe\Security\LoginAttempt
LoginForm: SilverStripe\Security\LoginForm
Member: SilverStripe\Security\Member
Member_GroupSet: SilverStripe\Security\Member_GroupSet
Member_Validator: SilverStripe\Security\Member_Validator
MemberAuthenticator: SilverStripe\Security\MemberAuthenticator
MemberCsvBulkLoader: SilverStripe\Security\MemberCsvBulkLoader
MemberLoginForm: SilverStripe\Security\MemberLoginForm
MemberPassword: SilverStripe\Security\MemberPassword
PasswordEncryptor: SilverStripe\Security\PasswordEncryptor
PasswordEncryptor_Blowfish: SilverStripe\Security\PasswordEncryptor_Blowfish
PasswordEncryptor_PHPHash: SilverStripe\Security\PasswordEncryptor_PHPHash
PasswordEncryptor_LegacyPHPHash: SilverStripe\Security\PasswordEncryptor_LegacyPHPHash
PasswordEncryptor_MySQLPassword: SilverStripe\Security\PasswordEncryptor_MySQLPassword
PasswordEncryptor_MySQLOldPassword: SilverStripe\Security\PasswordEncryptor_MySQLOldPassword
PasswordEncryptor_None: SilverStripe\Security\PasswordEncryptor_None
PasswordEncryptor_NotFoundException: SilverStripe\Security\PasswordEncryptor_NotFoundException
PasswordEncryptor_EncryptionFailed: SilverStripe\Security\PasswordEncryptor_EncryptionFailed
PasswordValidator: SilverStripe\Security\PasswordValidator
Permission: SilverStripe\Security\Permission
Permission_Group: SilverStripe\Security\Permission_Group
PermissionCheckboxSetField: SilverStripe\Security\PermissionCheckboxSetField
PermissionCheckboxSetField_Readonly: SilverStripe\Security\PermissionCheckboxSetField_Readonly
PermissionFailureException: SilverStripe\Security\PermissionFailureException
PermissionProvider: SilverStripe\Security\PermissionProvider
PermissionRole: SilverStripe\Security\PermissionRole
PermissionRoleCode: SilverStripe\Security\PermissionRoleCode
RandomGenerator: SilverStripe\Security\RandomGenerator
RememberLoginHash: SilverStripe\Security\RememberLoginHash
Security: SilverStripe\Security\Security
SecurityToken: SilverStripe\Security\SecurityToken
NullSecurityToken: SilverStripe\Security\NullSecurityToken
skipConfigs:
- db
- casting
- table_name
- fixed_fields
- menu_title
- allowed_actions
1 change: 1 addition & 0 deletions ORM/Connect/MySQLDatabase.php
Expand Up @@ -5,6 +5,7 @@
use Config;
use Exception;
use PaginatedList;
use SilverStripe\Framework\Core\Configurable;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\ArrayList;

Expand Down
4 changes: 3 additions & 1 deletion ORM/Connect/MySQLSchemaManager.php
Expand Up @@ -16,8 +16,10 @@ class MySQLSchemaManager extends DBSchemaManager {
/**
* Identifier for this schema, used for configuring schema-specific table
* creation options
*
* @skipUpgrade
*/
const ID = 'SilverStripe\ORM\Connect\MySQLDatabase';
const ID = 'MySQLDatabase';

public function createTable($table, $fields = null, $indexes = null, $options = null, $advancedOptions = null) {
$fieldSchemas = $indexSchemas = "";
Expand Down
27 changes: 16 additions & 11 deletions ORM/DB.php
Expand Up @@ -9,7 +9,9 @@
use LogicException;
use Cookie;
use Injector;
use SilverStripe\ORM\Connect\DBConnector;
use SilverStripe\ORM\Connect\DBSchemaManager;
use SilverStripe\ORM\Connect\SS_Query;
use SilverStripe\ORM\Queries\SQLExpression;
use SilverStripe\ORM\Connect\SS_Database;

Expand Down Expand Up @@ -53,8 +55,8 @@ class DB {
* Pass an object that's a subclass of SS_Database. This object will be used when {@link DB::query()}
* is called.
*
* @param $connection The connecton object to set as the connection.
* @param $name The name to give to this connection. If you omit this argument, the connection
* @param SS_Database $connection The connecton object to set as the connection.
* @param string $name The name to give to this connection. If you omit this argument, the connection
* will be the default one used by the ORM. However, you can store other named connections to
* be accessed through DB::get_conn($name). This is useful when you have an application that
* needs to connect to more than one database.
Expand Down Expand Up @@ -147,6 +149,7 @@ public static function get_connector($name = 'default') {
*
* Note that the database will be set on the next request.
* Set it to null to revert to the main database.
* @param string $name
*/
public static function set_alternative_database_name($name = null) {
// Skip if CLI
Expand All @@ -161,7 +164,7 @@ public static function set_alternative_database_name($name = null) {
));
}

$key = Config::inst()->get('Security', 'token');
$key = Config::inst()->get('SilverStripe\\Security\\Security', 'token');
if(!$key) {
throw new LogicException('"Security.token" not found, run "sake dev/generatesecuretoken"');
}
Expand Down Expand Up @@ -193,7 +196,7 @@ public static function get_alternative_database_name() {
$iv = Cookie::get("alternativeDatabaseNameIv");

if($name) {
$key = Config::inst()->get('Security', 'token');
$key = Config::inst()->get('SilverStripe\\Security\\Security', 'token');
if(!$key) {
throw new LogicException('"Security.token" not found, run "sake dev/generatesecuretoken"');
}
Expand Down Expand Up @@ -231,10 +234,9 @@ public static function valid_alternative_database_name($name) {
* Given the database configuration, this method will create the correct
* subclass of {@link SS_Database}.
*
* @param array $database A map of options. The 'type' is the name of the subclass of SS_Database to use. For the
* rest of the options, see the specific class.
* @param string $name identifier for the connection
*
* @param array $databaseConfig A map of options. The 'type' is the name of the
* subclass of SS_Database to use. For the rest of the options, see the specific class.
* @param string $label identifier for the connection
* @return SS_Database
*/
public static function connect($databaseConfig, $label = 'default') {
Expand Down Expand Up @@ -296,7 +298,7 @@ public static function query($sql, $errorLevel = E_USER_ERROR) {
*
* @param array|integer $input An array of items needing placeholders, or a
* number to specify the number of placeholders
* @param string The string to join each placeholder together with
* @param string $join The string to join each placeholder together with
* @return string|null Either a list of placeholders, or null
*/
public static function placeholders($input, $join = ', ') {
Expand Down Expand Up @@ -374,6 +376,8 @@ public static function manipulate($manipulation) {

/**
* Get the autogenerated ID from the previous INSERT query.
*
* @param string $table
* @return int
*/
public static function get_generated_id($table) {
Expand Down Expand Up @@ -427,13 +431,14 @@ public static function createDatabase($connect, $username, $password, $database)

/**
* Create a new table.
* @param string $tableName The name of the table
* @param string $table The name of the table
* @param array$fields A map of field names to field types
* @param array $indexes A map of indexes
* @param array $options An map of additional options. The available keys are as follows:
* - 'MSSQLDatabase'/'MySQLDatabase'/'PostgreSQLDatabase' - database-specific options such as "engine"
* for MySQL.
* - 'temporary' - If true, then a temporary table will be created
* @param array $advancedOptions
* @return string The table name generated. This may be different from the table name, for example with
* temporary tables.
*/
Expand Down Expand Up @@ -577,7 +582,7 @@ public static function dontRequireField($table, $fieldName) {
/**
* Checks a table's integrity and repairs it if necessary.
*
* @param string $tableName The name of the table.
* @param string $table The name of the table.
* @return boolean Return true if the table has integrity after the method is complete.
*/
public static function check_and_repair_table($table) {
Expand Down
15 changes: 9 additions & 6 deletions ORM/DataObject.php
Expand Up @@ -19,8 +19,8 @@
use FieldList;
use FormField;
use FormScaffolder;
use Member;
use Permission;


use Object;
use SearchFilter;
use SilverStripe\ORM\Queries\SQLInsert;
Expand All @@ -30,6 +30,9 @@
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\FieldType\DBComposite;
use SilverStripe\ORM\FieldType\DBClassName;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;


/**
* A single database record & abstract class for the data-access-model.
Expand Down Expand Up @@ -907,10 +910,10 @@ public function castedUpdate($data) {
* Caution: Does not delete the merged object.
* Caution: Does now overwrite Created date on the original object.
*
* @param $obj DataObject
* @param $priority String left|right Determines who wins in case of a conflict (optional)
* @param $includeRelations Boolean Merge any existing relations (optional)
* @param $overwriteWithEmpty Boolean Overwrite existing left values with empty right values.
* @param DataObject $rightObj
* @param string $priority left|right Determines who wins in case of a conflict (optional)
* @param bool $includeRelations Merge any existing relations (optional)
* @param bool $overwriteWithEmpty Overwrite existing left values with empty right values.
* Only applicable with $priority='right'. (optional)
* @return Boolean
*/
Expand Down
8 changes: 6 additions & 2 deletions ORM/DatabaseAdmin.php
Expand Up @@ -5,12 +5,15 @@
use Controller;
use SapphireTest;
use Director;
use Security;
use Permission;


use SS_ClassLoader;
use ClassInfo;
use TestOnly;
use Deprecation;
use SilverStripe\Security\Security;
use SilverStripe\Security\Permission;


// Include the DB class
require_once("DB.php");
Expand Down Expand Up @@ -183,6 +186,7 @@ public static function lastBuilt() {
*
* @param boolean $quiet Don't show messages
* @param boolean $populate Populate the database, as well as setting up its schema
* @param bool $testMode
*/
public function doBuild($quiet = false, $populate = true, $testMode = false) {
if($quiet) {
Expand Down
4 changes: 3 additions & 1 deletion ORM/FieldType/DBDate.php
Expand Up @@ -2,13 +2,15 @@

namespace SilverStripe\ORM\FieldType;

use Member;

use Zend_Date;
use DateTime;
use DateField;
use Convert;
use Exception;
use SilverStripe\ORM\DB;
use SilverStripe\Security\Member;


/**
* Represents a date field.
Expand Down
7 changes: 4 additions & 3 deletions ORM/FieldType/DBDatetime.php
Expand Up @@ -4,12 +4,13 @@

use Convert;
use Exception;
use Member;
use DatetimeField;
use Zend_Date;
use TemplateGlobalProvider;
use DateTime;
use SilverStripe\ORM\DB;
use SilverStripe\Security\Member;


/**
* Represents a date-time field.
Expand Down Expand Up @@ -60,11 +61,11 @@ public function setValue($value, $record = null, $markChanged = true) {
if(is_numeric($value)) {
$this->value = date('Y-m-d H:i:s', $value);
} elseif(is_string($value)) {
try {
try{
$date = new DateTime($value);
$this->value = $date->format('Y-m-d H:i:s');
return;
} catch(Exception $e) {
}catch(Exception $e){
$this->value = null;
return;
}
Expand Down
17 changes: 9 additions & 8 deletions ORM/Hierarchy/Hierarchy.php
Expand Up @@ -768,14 +768,15 @@ public function liveChildren($showAll = false, $onlyDeletedFromStage = false) {
* @return DataObject
*/
public function getParent($filter = null) {
if($p = $this->owner->__get("ParentID")) {
$tableClasses = ClassInfo::dataClassesFor($this->owner->class);
$baseClass = array_shift($tableClasses);
return DataObject::get_one($this->owner->class, array(
array("\"$baseClass\".\"ID\"" => $p),
$filter
));
}
$parentID = $this->owner->ParentID;
if(empty($parentID)) {
return null;
}
$idSQL = $this->owner->getSchema()->sqlColumnForField($this->owner, 'ID');
return DataObject::get_one($this->owner->class, array(
array($idSQL => $parentID),
$filter
));
}

/**
Expand Down
1 change: 1 addition & 0 deletions ORM/Queries/SQLExpression.php
Expand Up @@ -4,6 +4,7 @@

use Exception;
use Convert;
use SilverStripe\ORM\Connect\SS_Query;
use SilverStripe\ORM\DB;

/**
Expand Down
11 changes: 8 additions & 3 deletions ORM/Versioning/ChangeSet.php
Expand Up @@ -2,9 +2,11 @@

namespace SilverStripe\ORM\Versioning;

use Member;
use Permission;


use Exception;
use FieldList;
use SilverStripe\ORM\HasManyList;
use TextField;
use ReadonlyField;
use i18n;
Expand All @@ -13,6 +15,9 @@
use SilverStripe\ORM\ValidationException;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;


/**
* The ChangeSet model tracks several VersionedAndStaged objects for later publication as a single
Expand Down Expand Up @@ -57,7 +62,7 @@ class ChangeSet extends DataObject {
);

private static $has_one = array(
'Owner' => 'Member',
'Owner' => 'SilverStripe\\Security\\Member',
);

private static $casting = array(
Expand Down
10 changes: 8 additions & 2 deletions ORM/Versioning/ChangeSetItem.php
Expand Up @@ -4,12 +4,18 @@

use Exception;
use BadMethodCallException;
use Member;
use Permission;


use CMSPreviewable;
use Controller;
use SilverStripe\Filesystem\Thumbnail;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\SS_List;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;


/**
* A single line in a changeset
Expand Down

0 comments on commit af22a83

Please sign in to comment.