Minor: Format code

pull/5010/head
Angel Fernando Quiroz Campos 2 years ago
parent a3e5a03599
commit b63d4271e6
  1. 2
      main/auth/profile.php
  2. 2
      main/auth/reset.php
  3. 1
      main/cron/update_ldap_users.php
  4. 1
      main/inc/lib/statistics.lib.php
  5. 108
      main/inc/lib/usermanager.lib.php

@ -690,7 +690,7 @@ if ($form->validate()) {
[
'item_id' => $user->getId(),
'variable' => 'password_updated_at',
'value' => $date
'value' => $date,
]
);
}

@ -102,7 +102,7 @@ if ($form->validate()) {
[
'item_id' => $user->getId(),
'variable' => 'password_updated_at',
'value' => $date
'value' => $date,
]
);
}

@ -29,6 +29,7 @@ if (api_get_configuration_value('ldap_encrypt_admin_password')) {
$ldapbind = @ldap_bind($ds, $extldap_config['admin_dn'], $ldap_pass);
if ($ldapbind === false) {
echo 'EXTLDAP ERROR : cannot connect with admin login/password';
return false;
}

@ -1085,7 +1085,6 @@ class Statistics
$table->set_header(6, get_lang('IPAddress'));
$table->set_header(7, get_lang('Date'));
$content .= $table->return_table();
}
$content .= '<div class="alert alert-info">'.get_lang('ImportantActivities').' : '.'<br>';

@ -1675,7 +1675,7 @@ class UserManager
[
'item_id' => $user->getId(),
'variable' => 'password_updated_at',
'value' => $date
'value' => $date,
]
);
}
@ -1803,8 +1803,6 @@ class UserManager
null,
$creatorEmail
);
} else {
$layoutContent = $tplContent->get_template('mail/user_edit_content.tpl');
$emailBody = $tplContent->fetch($layoutContent);
@ -8044,6 +8042,59 @@ SQL;
}';
}
/**
* Get a list of users with the given e-mail address + their "active" field value (0 or 1).
*
* @param string $mail User id
*
* @return array List of users e-mails + active field
*/
public static function getUsersByMail(string $mail): array
{
$resultData = Database::select(
'id, active',
Database::get_main_table(TABLE_MAIN_USER),
[
'where' => ['email = ?' => $mail],
],
'all',
null
);
if ($resultData === false) {
return [];
}
return $resultData;
}
/**
* Get whether we can send an e-mail or not.
* If the e-mail is not in the database, send the mail.
* If the e-mail is in the database but none of its occurences is active, don't send.
*
* @param string $mail The e-mail address to check
*
* @return bool Whether we can send an e-mail or not
*/
public function isEmailingAllowed(string $mail): bool
{
$list = self::getUsersByMail($mail);
if (empty($list)) {
// No e-mail matches, send the mail
return true;
}
$send = false;
foreach ($list as $id => $user) {
if ($user['active'] == 1) {
// as soon as we find at least one active user, send the mail
return true;
}
}
return false;
}
/**
* @return EncoderFactory
*/
@ -8137,55 +8188,4 @@ SQL;
return $url;
}
/**
* Get a list of users with the given e-mail address + their "active" field value (0 or 1)
*
* @param string $mail User id
*
* @return array List of users e-mails + active field
*/
public static function getUsersByMail(string $mail): array
{
$resultData = Database::select(
'id, active',
Database::get_main_table(TABLE_MAIN_USER),
[
'where' => ['email = ?' => $mail],
],
'all',
null
);
if ($resultData === false) {
return [];
}
return $resultData;
}
/**
* Get whether we can send an e-mail or not.
* If the e-mail is not in the database, send the mail.
* If the e-mail is in the database but none of its occurences is active, don't send.
* @param string $mail The e-mail address to check
* @return bool Whether we can send an e-mail or not
*/
public function isEmailingAllowed(string $mail): bool
{
$list = self::getUsersByMail($mail);
if (empty($list)) {
// No e-mail matches, send the mail
return true;
}
$send = false;
foreach ($list as $id => $user) {
if ($user['active'] == 1) {
// as soon as we find at least one active user, send the mail
return true;
}
}
return false;
}
}

Loading…
Cancel
Save