Commit 023a4575 authored by thedut's avatar thedut
Browse files

Issue #2875664 by thedut : fixing Drupal coding standard.

parent ed782e4d
Loading
Loading
Loading
Loading
+10 −10
Changes for dbee.install: 10 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -73,10 +73,10 @@ function dbee_uninstall() {
 *
 * Manage disctinct servers configurations.
 *
 * @param $bytes
 * @param int $bytes
 *   An integer, the number of bytes for the key. Default to 16 (=128bits).
 *
 * @return
 * @return string
 *   A string, the encryption key, or FALSE if error.
 */
function _dbee_encryption_key_value($bytes = 16) {
@@ -107,14 +107,14 @@ function _dbee_encryption_key_value($bytes = 16) {
 * creating the file, and if it fails, use the configuration provider (in
 * database). Steps and errors are logged.
 *
 * @param $key_id
 * @param string $key_id
 *   A string, the entity machine name.
 * @param $bytes
 * @param int $bytes
 *   An integer, the number of bytes for the key. Default to 16 (=128bits).
 * @param $filename
 * @param string $filename
 *   A string, filename to store the key. Default is 'key.key'.
 *
 * @return
 * @return bool
 *   A boolean, TRUE if the Key entity already exists or has been successfully
 *   created or FALSE if an error occurs.
 */
@@ -211,15 +211,15 @@ function _dbee_create_encryption_key($key_id, $bytes = 16, $filename = 'key.key'
 * Encryption Profile entity is provided by the Encrypt contrib module. Look for
 * an existing entity, and if not exists create it. Steps and errors are logged.
 *
 * @param $encrypt_profile_id
 * @param string $encrypt_profile_id
 *   A string, the Encrypt Profile entity machine name.
 * @param $key_id
 * @param string $key_id
 *   A string, the Key entity machine name.
 * @param $encryption_method
 * @param string $encryption_method
 *   A string, the encryption method. Default is 'real_aes', corresponding to
 *   the real_aes contrib module.
 *
 * @return
 * @return bool
 *   A boolean, TRUE if the Encryption Profile entity already exists or has been
 *   successfully created or FALSE if an error occurs.
 */
+11 −8
Changes for dbee.module: 11 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ function dbee_decrypt($string, $prev_encrypt = FALSE) {
 * @return array
 *   An array, keyed by 'mail', 'init'. Values are the encrypted mails.
 */
function dbee_store($mails) {
function dbee_store(array $mails) {
  if (!is_array($mails)) {
    return [];
  }
@@ -145,13 +145,16 @@ function dbee_store($mails) {
 * Provide the encrypted values for 2 fields of the {users_field_data} table
 * (the 'mail', 'init' fields).
 *
 * @param $encrypted
 * @param array $encrypted
 *   An array of crypted mails, keys are 'mail', 'init'.
 * @param bool $prev_encrypt
 *   A boolean, If TRUE, use a previous dbee encryption profile to decrypt,
 *   used on changing encryption settings. Default to FALSE.
 *
 * @return array
 *   An array, keyed by 'mail', 'init'. Values are the encrypted mails.
 */
function dbee_unstore($encrypted, $prev_encrypt = FALSE) {
function dbee_unstore(array $encrypted, $prev_encrypt = FALSE) {
  if (!is_array($encrypted)) {
    return [];
  }
@@ -713,18 +716,18 @@ function _dbee_where_clause(&$query, $users_alias, $dbee_alias) {
 * Convert database wilcards to php regex patterns. Use cache if called several
 * times during the script.
 *
 * @param $keys
 * @param array $keys
 *   An array of research strings, using database wilcards ('%' and '_').
 * @param $field
 * @param string $field
 *   A string, the field into the {users_field_data} table : can be 'mail'
 *   (default) or 'init'.
 * @param $operator
 * @param string $operator
 *   A string, the operator on the WHERE clause. Default is 'LIKE'.
 *
 * @return
 * @return array
 *   An array, the user uids that match the keys (no index).
 */
function _dbee_where_mailfields2uid($keys, $field = 'mail', $operator = 'LIKE', $insensitive_search = FALSE) {
function _dbee_where_mailfields2uid(array $keys, $field = 'mail', $operator = 'LIKE', $insensitive_search = FALSE) {

  if (empty($keys) || (!is_array($keys)) || !in_array($field, ['mail', 'init'])) {
    return [];
+11 −13
Changes for dbee.users.inc: 11 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -17,13 +17,13 @@ define('DBEE_ALL_USERS_CRYPT_LIMIT', 15);
 * when the encryption options are updated. it acts as simple callback or batch
 * operation if there are more than 15 users in database.
 *
 * @param $action
 * @param string $action
 *   A string. Possible values are 'decrypt', 'encrypt', and 'change'. If set to
 *   'change', the $decrypt_params or the $encrypt_params must be provided.
 * @param $dbee_context
 * @param string $dbee_context
 *   A string (optional). Context for processing, values are 'uninstall' and
 *   'change', default to FALSE.
 * @param $force_batch
 * @param bool $force_batch
 *   A boolean (optional). If TRUE the processes will be executed as batch
 *   operations, regardless of number of registerd users. Default to FALSE.
 */
@@ -71,20 +71,18 @@ function dbee_update_crypt_all($action, $dbee_context = FALSE, $force_batch = FA
/**
 * Batch process for changing encryption of users (10 users per operation).
 *
 * @param $action
 * @param string $action
 *   A string. Possible values are 'decrypt', 'encrypt', and 'change'. If set to
 *   'change', the $decrypt_params or the $encrypt_params must be provided.
 * @param $dbee_context
 * @param string $dbee_context
 *   A string (optional). Context for processing, values are 'uninstall' and
 *   'change', default to FALSE.
 * @param $n_users
 *   A numeric, the total number of users.
 * @param $context
 * @param array $context
 *   An array provided by reference, stores batch procesing informations.
 *
 * @see dbee_update_crypt_all()
 */
function dbee_update_crypt_users_all_batch_proceed($action, $dbee_context, &$context) {
function dbee_update_crypt_users_all_batch_proceed($action, $dbee_context, array &$context) {
  if (!function_exists('dbee_unstore')) {
    // On batch operation, after the module is disabled, the dbee.module file is
    // not loaded anymore. We load it now for decrypting emails after the
@@ -222,16 +220,16 @@ function dbee_update_crypt_users_all_batch_finished($success, $results, $operati
/**
 * Encrypts or decrypts one user email addresses.
 *
 * @param $db_values
 * @param array $db_values
 *   An array of user database stored values. Keys are 'uid', 'mail', 'init'.
 * @param $action
 * @param string $action
 *   A string. Possible values are 'decrypt', 'encrypt', and 'change'. If set to
 *   'change', the $decrypt_params or the $encrypt_params must be provided.
 *
 * @return
 * @return bool
 *   A boolean, TRUE if the user has been updated.
 */
function dbee_update_crypt_user($db_values, $action) {
function dbee_update_crypt_user(array $db_values, $action) {

  $updated = FALSE;
  if ($action == 'decrypt') {
+3 −1
Changes for src/Tests/DbeeContactMailTestCase.php: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -21,7 +21,9 @@ class DbeeContactMailTestCase extends DbeeWebTestBase {
  public static $modules = ['contact', 'dbee'];

  /**
   * Create users with appropriate permissions.
   *
   * @inheritdoc
   */
  public function setUp() {
    // Enable any modules required for the test.
@@ -31,7 +33,7 @@ class DbeeContactMailTestCase extends DbeeWebTestBase {
  }

  /**
   *
   * Test sending email from user contact page.
   */
  protected function testContactMail() {
    $this->drupalLogin($this->senderUser);
+3 −1
Changes for src/Tests/DbeeCoreFunctionsTestCase.php: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@ class DbeeCoreFunctionsTestCase extends DbeeWebTestBaseSwitch {
  protected $AdminModulesAccount;

  /**
   * Create users with appropriate permissions.
   *
   * @inheritdoc
   */
  public function setUp() {
    // Enable any modules required for the test.
@@ -38,7 +40,7 @@ class DbeeCoreFunctionsTestCase extends DbeeWebTestBaseSwitch {
  }

  /**
   *
   * Test Drupal core functions with emails.
   */
  protected function testCoreFunctions() {
    // Test the user_save(), user_load(), user_load_by_mail() core functions.
Loading