mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
style validation fix
This commit is contained in:
parent
f1d47a25ed
commit
017c7fee53
42 changed files with 526 additions and 497 deletions
|
@ -231,16 +231,16 @@ namespace controllers\publics;
|
|||
//Iterate over files to re-create individual $_FILES array
|
||||
$files_arrays = [];
|
||||
|
||||
if ($files === false)
|
||||
if (false === $files)
|
||||
{
|
||||
$files_arrays = [];
|
||||
}
|
||||
elseif (!is_array($files['name'])) //Only one file uploaded
|
||||
{
|
||||
elseif (!is_array($files['name']))
|
||||
{ //Only one file uploaded
|
||||
$files_arrays[] = $files;
|
||||
}
|
||||
else //multiple files
|
||||
{
|
||||
else
|
||||
{ //multiple files
|
||||
foreach ($files as $property_name => $files_values)
|
||||
{
|
||||
foreach ($files_values as $file_key => $property_value)
|
||||
|
@ -320,8 +320,8 @@ namespace controllers\publics;
|
|||
if ($id_phone)
|
||||
{
|
||||
$phone = $this->internal_phone->get_for_user($this->user['id'], $id_phone);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($id_phone && !$phone)
|
||||
{
|
||||
$return = self::DEFAULT_RETURN;
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Page for showing calls list
|
||||
* Page for showing calls list.
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
|
@ -51,12 +51,14 @@ namespace controllers\publics;
|
|||
{
|
||||
switch ($entity['direction'])
|
||||
{
|
||||
case \models\Call::DIRECTION_INBOUND :
|
||||
case \models\Call::DIRECTION_INBOUND:
|
||||
$entity['origin_formatted'] = \controllers\internals\Tool::phone_link($entity['origin']);
|
||||
|
||||
break;
|
||||
|
||||
case \models\Call::DIRECTION_OUTBOUND :
|
||||
|
||||
case \models\Call::DIRECTION_OUTBOUND:
|
||||
$entity['destination_formatted'] = \controllers\internals\Tool::phone_link($entity['destination']);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -66,10 +68,10 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete a list of calls
|
||||
* Delete a list of calls.
|
||||
*
|
||||
* @param array int $_GET['ids'] : Ids of calls to delete
|
||||
* @param string $csrf : csrf token
|
||||
* @param string $csrf : csrf token
|
||||
*
|
||||
* @return boolean;
|
||||
*/
|
||||
|
|
|
@ -206,13 +206,12 @@ use Monolog\Logger;
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function call on call reception notification
|
||||
* We return nothing, and we let the adapter do his things.
|
||||
*
|
||||
* @param int $id_phone : Phone id
|
||||
* @param int $id_phone : Phone id
|
||||
*
|
||||
* @return bool : true on success, false on error
|
||||
*/
|
||||
|
@ -269,16 +268,15 @@ use Monolog\Logger;
|
|||
}
|
||||
|
||||
$this->logger->info('Callback inbound_call successfully received inbound call : ' . json_encode($call));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function call on end call notification
|
||||
* We return nothing, and we let the adapter do his things.
|
||||
*
|
||||
* @param int $id_phone : Phone id
|
||||
* @param int $id_phone : Phone id
|
||||
*
|
||||
* @return bool : true on success, false on error
|
||||
*/
|
||||
|
@ -334,7 +332,7 @@ use Monolog\Logger;
|
|||
}
|
||||
|
||||
$this->logger->info('Callback end call successfully update call : ' . json_encode($call));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ namespace controllers\publics;
|
|||
|
||||
if ($how_many_more > 0)
|
||||
{
|
||||
$result_text .= ", et $how_many_more autres.";
|
||||
$result_text .= ", et {$how_many_more} autres.";
|
||||
}
|
||||
|
||||
$return['result'] = $result_text;
|
||||
|
|
|
@ -85,12 +85,12 @@ namespace controllers\publics;
|
|||
|
||||
return $this->redirect(\descartes\Router::url('Contact', 'list'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function will delete a list of contacts depending on a condition
|
||||
* This function will delete a list of contacts depending on a condition.
|
||||
*
|
||||
* @param string $_POST['condition'] : Condition to use to delete contacts
|
||||
* @param mixed $csrf
|
||||
* @param mixed $csrf
|
||||
*
|
||||
* @return boolean;
|
||||
*/
|
||||
|
@ -338,11 +338,11 @@ namespace controllers\publics;
|
|||
break;
|
||||
|
||||
default:
|
||||
if ($read_file['extension'] === 'csv')
|
||||
if ('csv' === $read_file['extension'])
|
||||
{
|
||||
$result = $this->internal_contact->import_csv($id_user, $read_file['content']);
|
||||
}
|
||||
elseif ($read_file['extension'] === 'json')
|
||||
elseif ('json' === $read_file['extension'])
|
||||
{
|
||||
$result = $this->internal_contact->import_json($id_user, $read_file['content']);
|
||||
}
|
||||
|
|
|
@ -62,14 +62,13 @@ namespace controllers\publics;
|
|||
$nb_sendeds = $this->internal_sended->count_for_user($id_user);
|
||||
$nb_receiveds = $this->internal_received->count_for_user($id_user);
|
||||
|
||||
|
||||
//Récupération des 10 derniers Sms envoyés, Sms reçus et evenements enregistrés. Par date.
|
||||
$sendeds = $this->internal_sended->get_lasts_by_date_for_user($id_user, 10);
|
||||
$receiveds = $this->internal_received->get_lasts_by_date_for_user($id_user, 10);
|
||||
$events = $this->internal_event->get_lasts_by_date_for_user($id_user, 10);
|
||||
|
||||
//Récupération du nombre de Sms envoyés et reçus depuis 1 mois jours ou depuis le début du quota si il existe
|
||||
|
||||
|
||||
//Création de la date d'il y a 30 jours
|
||||
$now = new \DateTime();
|
||||
$one_month = new \DateInterval('P1M');
|
||||
|
@ -107,7 +106,7 @@ namespace controllers\publics;
|
|||
'sendeds' => 0,
|
||||
'receiveds' => 0,
|
||||
];
|
||||
|
||||
|
||||
$date->add($one_day);
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
$message = [
|
||||
'uid' => 'sended-' . $sended['id'],
|
||||
'uid' => 'sended-' . $sended['id'],
|
||||
'date' => htmlspecialchars($sended['at']),
|
||||
'text' => htmlspecialchars($sended['text']),
|
||||
'type' => 'sended',
|
||||
|
@ -133,7 +133,6 @@ namespace controllers\publics;
|
|||
'status' => $sended['status'],
|
||||
];
|
||||
|
||||
|
||||
$messages[] = $message;
|
||||
}
|
||||
|
||||
|
@ -143,7 +142,7 @@ namespace controllers\publics;
|
|||
{
|
||||
$this->internal_received->mark_as_read_for_user($id_user, $received['id']);
|
||||
}
|
||||
|
||||
|
||||
$medias = [];
|
||||
if ($received['mms'])
|
||||
{
|
||||
|
@ -155,7 +154,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
$messages[] = [
|
||||
'uid' => 'received-' . $received['id'],
|
||||
'uid' => 'received-' . $received['id'],
|
||||
'date' => htmlspecialchars($received['at']),
|
||||
'text' => htmlspecialchars($received['text']),
|
||||
'type' => 'received',
|
||||
|
@ -176,7 +175,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
$messages[] = [
|
||||
'uid' => 'scheduled-' . $scheduled['id'],
|
||||
'uid' => 'scheduled-' . $scheduled['id'],
|
||||
'date' => htmlspecialchars($scheduled['at']),
|
||||
'text' => htmlspecialchars($scheduled['text']),
|
||||
'type' => 'inprogress',
|
||||
|
@ -210,7 +209,7 @@ namespace controllers\publics;
|
|||
* @param string $_POST['text'] : Le contenu du Sms
|
||||
* @param string $_POST['destination'] : Number to send sms to
|
||||
* @param string $_POST['id_phone'] : If of phone to send sms with
|
||||
* @param array $_FILES['medias'] : Medias to upload and link to sms
|
||||
* @param array $_FILES['medias'] : Medias to upload and link to sms
|
||||
*
|
||||
* @return string : json string Le statut de l'envoi
|
||||
*/
|
||||
|
@ -237,9 +236,9 @@ namespace controllers\publics;
|
|||
$destination = $_POST['destination'] ?? false;
|
||||
$id_phone = $_POST['id_phone'] ?? false;
|
||||
$files = $_FILES['medias'] ?? false;
|
||||
|
||||
|
||||
//Iterate over files to re-create individual $_FILES array
|
||||
$files_arrays = [];
|
||||
$files_arrays = [];
|
||||
if ($files && is_array($files['name']))
|
||||
{
|
||||
foreach ($files as $property_name => $files_values)
|
||||
|
@ -248,7 +247,7 @@ namespace controllers\publics;
|
|||
{
|
||||
if (!isset($files_arrays[$file_key]))
|
||||
{
|
||||
$files_arrays[$file_key] = [];
|
||||
$files_arrays[$file_key] = [];
|
||||
}
|
||||
|
||||
$files_arrays[$file_key][$property_name] = $property_value;
|
||||
|
@ -259,7 +258,7 @@ namespace controllers\publics;
|
|||
//Remove empty files input
|
||||
foreach ($files_arrays as $key => $file)
|
||||
{
|
||||
if ($file['error'] === UPLOAD_ERR_NO_FILE)
|
||||
if (UPLOAD_ERR_NO_FILE === $file['error'])
|
||||
{
|
||||
unset($files_arrays[$key]);
|
||||
}
|
||||
|
@ -288,7 +287,6 @@ namespace controllers\publics;
|
|||
$id_phone = null;
|
||||
}
|
||||
|
||||
|
||||
//If mms is enable and we have medias uploaded
|
||||
$media_ids = [];
|
||||
if ($_SESSION['user']['settings']['mms'] && $files_arrays)
|
||||
|
|
|
@ -75,12 +75,12 @@ class Phone extends \descartes\Controller
|
|||
{
|
||||
$phone['callback_status'] = \descartes\Router::url('Callback', 'update_sended_status', ['adapter_uid' => $adapter['meta_uid']], ['api_key' => $api_key]);
|
||||
}
|
||||
|
||||
|
||||
if ($adapter['meta_support_inbound_call_callback'])
|
||||
{
|
||||
$phone['callback_inbound_call'] = \descartes\Router::url('Callback', 'inbound_call', ['id_phone' => $phone['id']], ['api_key' => $api_key]);
|
||||
}
|
||||
|
||||
|
||||
if ($adapter['meta_support_end_call_callback'])
|
||||
{
|
||||
$phone['callback_end_call'] = \descartes\Router::url('Callback', 'end_call', ['id_phone' => $phone['id']], ['api_key' => $api_key]);
|
||||
|
|
|
@ -242,7 +242,7 @@ namespace controllers\publics;
|
|||
* @param ?array $_POST['contacts'] : Numbers to send the message to
|
||||
* @param ?array $_POST['groups'] : Numbers to send the message to
|
||||
* @param ?array $_POST['conditional_groups'] : Numbers to send the message to
|
||||
* @param ?array $_FILES['medias'] : The media to link to a scheduled
|
||||
* @param ?array $_FILES['medias'] : The media to link to a scheduled
|
||||
*/
|
||||
public function create($csrf)
|
||||
{
|
||||
|
@ -265,7 +265,7 @@ namespace controllers\publics;
|
|||
$files = $_FILES['medias'] ?? false;
|
||||
|
||||
//Iterate over files to re-create individual $_FILES array
|
||||
$files_arrays = [];
|
||||
$files_arrays = [];
|
||||
if ($files && is_array($files['name']))
|
||||
{
|
||||
foreach ($files as $property_name => $files_values)
|
||||
|
@ -281,11 +281,11 @@ namespace controllers\publics;
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Remove empty files input
|
||||
foreach ($files_arrays as $key => $file)
|
||||
{
|
||||
if ($file['error'] === UPLOAD_ERR_NO_FILE)
|
||||
if (UPLOAD_ERR_NO_FILE === $file['error'])
|
||||
{
|
||||
unset($files_arrays[$key]);
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ namespace controllers\publics;
|
|||
|
||||
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
|
||||
}
|
||||
|
||||
|
||||
//If mms is enable and we have medias uploaded
|
||||
$media_ids = [];
|
||||
if ($_SESSION['user']['settings']['mms'] && $files_arrays)
|
||||
|
@ -339,15 +339,16 @@ namespace controllers\publics;
|
|||
catch (\Exception $e)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Impossible d\'upload et d\'enregistrer le fichier ' . $file['name'] . ':' . $e->getMessage());
|
||||
|
||||
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
|
||||
}
|
||||
|
||||
$media_ids[] = $new_media_id;
|
||||
$media_ids[] = $new_media_id;
|
||||
}
|
||||
}
|
||||
|
||||
$mms = (bool) count($media_ids);
|
||||
|
||||
|
||||
$scheduled_id = $this->internal_scheduled->create($id_user, $at, $text, $id_phone, $flash, $mms, $numbers, $contacts, $groups, $conditional_groups, $media_ids);
|
||||
if (!$scheduled_id)
|
||||
{
|
||||
|
@ -403,7 +404,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
//Iterate over files to re-create individual $_FILES array
|
||||
$files_arrays = [];
|
||||
$files_arrays = [];
|
||||
if ($files && is_array($files['name']))
|
||||
{
|
||||
foreach ($files as $property_name => $files_values)
|
||||
|
@ -423,7 +424,7 @@ namespace controllers\publics;
|
|||
//Remove empty files input
|
||||
foreach ($files_arrays as $key => $file)
|
||||
{
|
||||
if ($file['error'] === UPLOAD_ERR_NO_FILE)
|
||||
if (UPLOAD_ERR_NO_FILE === $file['error'])
|
||||
{
|
||||
unset($files_arrays[$key]);
|
||||
}
|
||||
|
@ -456,7 +457,7 @@ namespace controllers\publics;
|
|||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//If mms is enable and we have medias uploaded
|
||||
if ($_SESSION['user']['settings']['mms'] && $files_arrays)
|
||||
{
|
||||
|
@ -471,7 +472,7 @@ namespace controllers\publics;
|
|||
continue 2;
|
||||
}
|
||||
|
||||
$media_ids[] = $new_media_id;
|
||||
$media_ids[] = $new_media_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,7 +489,7 @@ namespace controllers\publics;
|
|||
$mms = (bool) count($media_ids);
|
||||
|
||||
$this->internal_scheduled->update_for_user($id_user, $id_scheduled, $at, $text, $id_phone, $flash, $mms, $numbers, $contacts, $groups, $conditional_groups, $media_ids);
|
||||
$nb_update++;
|
||||
++$nb_update;
|
||||
}
|
||||
|
||||
if ($nb_update !== \count($scheduleds))
|
||||
|
|
|
@ -39,8 +39,8 @@ namespace controllers\publics;
|
|||
*
|
||||
* @param string $setting_name : Name of the setting to modify
|
||||
* @param $csrf : CSRF token
|
||||
* @param string $_POST['setting_value'] : Setting's new value
|
||||
* @param bool $_POST['allow_no_value'] : Default false, if true then allow $_POST['setting_value'] to dont exists, and treat it as empty string
|
||||
* @param string $_POST['setting_value'] : Setting's new value
|
||||
* @param bool $_POST['allow_no_value'] : Default false, if true then allow $_POST['setting_value'] to dont exists, and treat it as empty string
|
||||
*
|
||||
* @return boolean;
|
||||
*/
|
||||
|
@ -57,7 +57,7 @@ namespace controllers\publics;
|
|||
$allow_no_value = $_POST['allow_no_value'] ?? false;
|
||||
|
||||
//if no value allowed and no value fund, default to ''
|
||||
if ($allow_no_value && ($setting_value === false))
|
||||
if ($allow_no_value && (false === $setting_value))
|
||||
{
|
||||
$setting_value = '';
|
||||
}
|
||||
|
|
|
@ -88,7 +88,6 @@ namespace controllers\publics;
|
|||
$return['result'] = 'Message vide, il ne sera pas envoyé.';
|
||||
}
|
||||
|
||||
|
||||
//Add credit estimation
|
||||
$return['estimation_credit'] = $this->internal_quota->compute_credits_for_message($return['result']);
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class User extends \descartes\Controller
|
|||
{
|
||||
$quota_percentage = $this->internal_quota->get_usage_percentage($entity['id']);
|
||||
$entity['quota_percentage'] = $quota_percentage * 100;
|
||||
|
||||
|
||||
$quota = $this->internal_quota->get_user_quota($entity['id']);
|
||||
if (!$quota)
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ class User extends \descartes\Controller
|
|||
*
|
||||
* @param array int $_GET['user_ids'] : User ids
|
||||
* @param mixed $csrf
|
||||
* @param int $status : 1 -> active, 0 -> suspended
|
||||
* @param int $status : 1 -> active, 0 -> suspended
|
||||
*
|
||||
* @return boolean;
|
||||
*/
|
||||
|
@ -159,17 +159,17 @@ class User extends \descartes\Controller
|
|||
* Cette fonction insert un nouveau user.
|
||||
*
|
||||
* @param $csrf : Le jeton CSRF
|
||||
* @param string $_POST['email'] : User email
|
||||
* @param optional string $_POST['password'] : User password, (if empty the password is randomly generated)
|
||||
* @param optional boolean $_POST['admin'] : If true user is admin
|
||||
* @param optional boolean $_POST['quota_enable'] : If true create a quota for the user
|
||||
* @param boolean $_POST['quota_enable'] : If true create a quota for the user
|
||||
* @param optional int $_POST['quota_credit'] : credit for quota
|
||||
* @param optional int $_POST['quota_additional'] : additional credit
|
||||
* @param optional string $_POST['quota_start_date'] : quota beginning date
|
||||
* @param optional string $_POST['quota_renewal_interval'] : period to use on renewal to calculate new expiration date. Also use to calculate first expiration date.
|
||||
* @param optional boolean $_POST['quota_auto_renew'] : Should the quota be automatically renewed on expiration
|
||||
* @param optional boolean $_POST['quota_report_unused'] : Should unused credit be reported next month
|
||||
* @param string $_POST['email'] : User email
|
||||
* @param optional string $_POST['password'] : User password, (if empty the password is randomly generated)
|
||||
* @param optional boolean $_POST['admin'] : If true user is admin
|
||||
* @param optional boolean $_POST['quota_enable'] : If true create a quota for the user
|
||||
* @param bool $_POST['quota_enable'] : If true create a quota for the user
|
||||
* @param optional int $_POST['quota_credit'] : credit for quota
|
||||
* @param optional int $_POST['quota_additional'] : additional credit
|
||||
* @param optional string $_POST['quota_start_date'] : quota beginning date
|
||||
* @param optional string $_POST['quota_renewal_interval'] : period to use on renewal to calculate new expiration date. Also use to calculate first expiration date.
|
||||
* @param optional boolean $_POST['quota_auto_renew'] : Should the quota be automatically renewed on expiration
|
||||
* @param optional boolean $_POST['quota_report_unused'] : Should unused credit be reported next month
|
||||
* @param optional boolean $_POST['quota_report_unused_additional'] : Should unused additional credit be transfered next month
|
||||
*/
|
||||
public function create($csrf)
|
||||
|
@ -194,7 +194,6 @@ class User extends \descartes\Controller
|
|||
$quota_report_unused = $_POST['quota_report_unused'] ?? false;
|
||||
$quota_report_unused_additional = $_POST['quota_report_unused_additional'] ?? false;
|
||||
|
||||
|
||||
if (!$email)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Vous devez au moins fournir une adresse e-mail pour l\'utilisateur.');
|
||||
|
@ -209,7 +208,6 @@ class User extends \descartes\Controller
|
|||
return $this->redirect(\descartes\Router::url('User', 'add'));
|
||||
}
|
||||
|
||||
|
||||
//Forge quota for user if needed
|
||||
$quota = null;
|
||||
if ($quota_enable)
|
||||
|
@ -218,15 +216,15 @@ class User extends \descartes\Controller
|
|||
$quota['credit'] = (int) $quota_credit;
|
||||
$quota['additional'] = (int) $quota_additional;
|
||||
|
||||
if ($quota_start_date === false || !\controllers\internals\Tool::validate_date($quota_start_date, 'Y-m-d H:i:s'))
|
||||
if (false === $quota_start_date || !\controllers\internals\Tool::validate_date($quota_start_date, 'Y-m-d H:i:s'))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Vous devez définir une date de début valide pour le quota.');
|
||||
|
||||
return $this->redirect(\descartes\Router::url('User', 'add'));
|
||||
}
|
||||
$quota['start_date'] = new \DateTime($quota_start_date);
|
||||
|
||||
if ($quota_renew_interval === false || !\controllers\internals\Tool::validate_period($quota_renew_interval))
|
||||
|
||||
if (false === $quota_renew_interval || !\controllers\internals\Tool::validate_period($quota_renew_interval))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Vous devez définir une durée de quota parmis la liste proposée.');
|
||||
|
||||
|
@ -242,7 +240,6 @@ class User extends \descartes\Controller
|
|||
$quota['report_unused_additional'] = (bool) $quota_report_unused_additional;
|
||||
}
|
||||
|
||||
|
||||
$id_user = $this->internal_user->create($email, $password, $admin, null, \models\User::STATUS_ACTIVE, true, $quota);
|
||||
if (!$id_user)
|
||||
{
|
||||
|
@ -251,7 +248,6 @@ class User extends \descartes\Controller
|
|||
return $this->redirect(\descartes\Router::url('User', 'add'));
|
||||
}
|
||||
|
||||
|
||||
$mailer = new \controllers\internals\Mailer();
|
||||
$email_send = $mailer->enqueue($email, EMAIL_CREATE_USER, ['email' => $email, 'password' => $password]);
|
||||
if (!$email_send)
|
||||
|
@ -263,9 +259,9 @@ class User extends \descartes\Controller
|
|||
|
||||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the edition page for the users
|
||||
* Return the edition page for the users.
|
||||
*
|
||||
* @param int... $ids : users ids
|
||||
*/
|
||||
|
@ -285,7 +281,7 @@ class User extends \descartes\Controller
|
|||
{
|
||||
$user['quota'] = $this->internal_quota->get_user_quota($user['id']);
|
||||
}
|
||||
|
||||
|
||||
$now = new \DateTime();
|
||||
$now = $now->format('Y-m-d H:i:00');
|
||||
|
||||
|
@ -294,10 +290,9 @@ class User extends \descartes\Controller
|
|||
'now' => $now,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update a list of users
|
||||
* Update a list of users.
|
||||
*
|
||||
* @param $csrf : Le jeton CSRF
|
||||
* @param array $_POST['users'] : Array of the users and new values, id as key. Quota may also be defined.
|
||||
|
@ -310,7 +305,7 @@ class User extends \descartes\Controller
|
|||
|
||||
return $this->redirect(\descartes\Router::url('User', 'add'));
|
||||
}
|
||||
|
||||
|
||||
$nb_update = 0;
|
||||
$users = $_POST['users'] ?? [];
|
||||
foreach ($users as $id_user => $user)
|
||||
|
@ -343,7 +338,6 @@ class User extends \descartes\Controller
|
|||
return $this->redirect(\descartes\Router::url('User', 'add'));
|
||||
}
|
||||
|
||||
|
||||
//Forge quota for user if needed
|
||||
$quota = false;
|
||||
if ($quota_enable)
|
||||
|
@ -353,18 +347,18 @@ class User extends \descartes\Controller
|
|||
$quota['consumed'] = (int) $quota_consumed;
|
||||
$quota['additional'] = (int) $quota_additional;
|
||||
|
||||
if ($quota_start_date === false || !\controllers\internals\Tool::validate_date($quota_start_date, 'Y-m-d H:i:s'))
|
||||
if (false === $quota_start_date || !\controllers\internals\Tool::validate_date($quota_start_date, 'Y-m-d H:i:s'))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'L\'utilisateur #' . (int) $id_user . ' n\'as pas pu être mis à jour car la date de début du quota associé n\'est pas valide.');
|
||||
|
||||
continue;
|
||||
}
|
||||
$quota['start_date'] = new \DateTime($quota_start_date);
|
||||
|
||||
if ($quota_renew_interval === false || !\controllers\internals\Tool::validate_period($quota_renew_interval))
|
||||
|
||||
if (false === $quota_renew_interval || !\controllers\internals\Tool::validate_period($quota_renew_interval))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'L\'utilisateur #' . (int) $id_user . ' n\'as pas pu être mis à jour car la durée du quota associé n\'est pas valide.');
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
$quota['renew_interval'] = $quota_renew_interval;
|
||||
|
@ -376,13 +370,11 @@ class User extends \descartes\Controller
|
|||
$quota['report_unused'] = (bool) $quota_report_unused;
|
||||
$quota['report_unused_additional'] = (bool) $quota_report_unused_additional;
|
||||
|
||||
|
||||
//Format dates
|
||||
$quota['start_date'] = $quota['start_date']->format('Y-m-d H:i:s');
|
||||
$quota['expiration_date'] = $quota['expiration_date']->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
|
||||
$updated_user = [
|
||||
'email' => $email,
|
||||
'admin' => $admin,
|
||||
|
@ -397,22 +389,22 @@ class User extends \descartes\Controller
|
|||
if (!$success)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'L\'utilisateur #' . (int) $id_user . ' n\'as pas pu être mis à jour.');
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$nb_update++;
|
||||
++$nb_update;
|
||||
}
|
||||
|
||||
if ($nb_update != count($users))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Certains utilisateurs n\'ont pas pu être mis à jour.');
|
||||
|
||||
|
||||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
||||
}
|
||||
|
||||
|
||||
\FlashMessage\FlashMessage::push('success', 'Tous les utilisateurs ont bien été mis à jour.');
|
||||
|
||||
|
||||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue