mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
fix codestyle
This commit is contained in:
parent
350dbb5b59
commit
adef27f862
37 changed files with 556 additions and 488 deletions
|
@ -90,8 +90,8 @@ namespace controllers\publics;
|
|||
|
||||
exit(self::ERROR_CODES['INVALID_CREDENTIALS']);
|
||||
}
|
||||
|
||||
if ($this->user['status'] !== \models\User::STATUS_ACTIVE)
|
||||
|
||||
if (\models\User::STATUS_ACTIVE !== $this->user['status'])
|
||||
{
|
||||
$return = self::DEFAULT_RETURN;
|
||||
$return['error'] = self::ERROR_CODES['SUSPENDED_USER'];
|
||||
|
@ -121,6 +121,7 @@ namespace controllers\publics;
|
|||
$return['error'] = self::ERROR_CODES['INVALID_PARAMETER'];
|
||||
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'] . 'entry_type must be one of : ' . implode(', ', $entry_types) . '.';
|
||||
$this->auto_http_code(false);
|
||||
|
||||
return $this->json($return);
|
||||
}
|
||||
|
||||
|
@ -165,6 +166,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
$this->auto_http_code(true);
|
||||
|
||||
return $this->json($return);
|
||||
}
|
||||
|
||||
|
@ -182,7 +184,7 @@ namespace controllers\publics;
|
|||
*
|
||||
* @return : Id of scheduled created
|
||||
*/
|
||||
public function post_scheduled ()
|
||||
public function post_scheduled()
|
||||
{
|
||||
$at = $_POST['at'] ?? false;
|
||||
$text = $_POST['text'] ?? false;
|
||||
|
@ -193,10 +195,10 @@ namespace controllers\publics;
|
|||
$groups = $_POST['groups'] ?? [];
|
||||
$conditional_groups = $_POST['conditional_groups'] ?? [];
|
||||
|
||||
$numbers = is_array($numbers) ? $numbers : [$numbers];
|
||||
$contacts = is_array($contacts) ? $contacts : [$contacts];
|
||||
$groups = is_array($groups) ? $groups : [$groups];
|
||||
$conditional_groups = is_array($conditional_groups) ? $conditional_groups : [$conditional_groups];
|
||||
$numbers = \is_array($numbers) ? $numbers : [$numbers];
|
||||
$contacts = \is_array($contacts) ? $contacts : [$contacts];
|
||||
$groups = \is_array($groups) ? $groups : [$groups];
|
||||
$conditional_groups = \is_array($conditional_groups) ? $conditional_groups : [$conditional_groups];
|
||||
|
||||
if (!$at)
|
||||
{
|
||||
|
@ -209,6 +211,7 @@ namespace controllers\publics;
|
|||
$return['error'] = self::ERROR_CODES['MISSING_PARAMETER'];
|
||||
$return['message'] = self::ERROR_MESSAGES['MISSING_PARAMETER'] . ($at ? '' : 'at ') . ($text ? '' : 'text');
|
||||
$this->auto_http_code(false);
|
||||
|
||||
return $this->json($return);
|
||||
}
|
||||
|
||||
|
@ -218,6 +221,7 @@ namespace controllers\publics;
|
|||
$return['error'] = self::ERROR_CODES['INVALID_PARAMETER'];
|
||||
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'] . 'at must be a date of format "Y-m-d H:i:s".';
|
||||
$this->auto_http_code(false);
|
||||
|
||||
return $this->json($return);
|
||||
}
|
||||
|
||||
|
@ -241,6 +245,7 @@ namespace controllers\publics;
|
|||
$return['error'] = self::ERROR_CODES['MISSING_PARAMETER'];
|
||||
$return['message'] = self::ERROR_MESSAGES['MISSING_PARAMETER'] . 'You must specify at least one valid number, contact, group or conditional_group.';
|
||||
$this->auto_http_code(false);
|
||||
|
||||
return $this->json($return);
|
||||
}
|
||||
|
||||
|
@ -250,6 +255,7 @@ namespace controllers\publics;
|
|||
$return['error'] = self::ERROR_CODES['INVALID_PARAMETER'];
|
||||
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'] . 'id_phone : You must specify an id_phone number among thoses of user phones.';
|
||||
$this->auto_http_code(false);
|
||||
|
||||
return $this->json($return);
|
||||
}
|
||||
|
||||
|
@ -260,12 +266,14 @@ namespace controllers\publics;
|
|||
$return['error'] = self::ERROR_CODES['CANNOT_CREATE'];
|
||||
$return['message'] = self::ERROR_MESSAGES['CANNOT_CREATE'];
|
||||
$this->auto_http_code(false);
|
||||
|
||||
return $this->json($return);
|
||||
}
|
||||
|
||||
$return = self::DEFAULT_RETURN;
|
||||
$return['response'] = $scheduled_id;
|
||||
$this->auto_http_code(true);
|
||||
|
||||
return $this->json($return);
|
||||
}
|
||||
|
||||
|
@ -292,6 +300,7 @@ namespace controllers\publics;
|
|||
|
||||
$return['response'] = true;
|
||||
$this->auto_http_code(true);
|
||||
|
||||
return $this->json($return);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,9 +114,10 @@ use Monolog\Logger;
|
|||
}
|
||||
|
||||
//Do not update if current status is delivered or failed
|
||||
if ($sended['status'] === \models\Sended::STATUS_DELIVERED || $sended['status'] === \models\Sended::STATUS_FAILED)
|
||||
if (\models\Sended::STATUS_DELIVERED === $sended['status'] || \models\Sended::STATUS_FAILED === $sended['status'])
|
||||
{
|
||||
$this->logger->info('Callback status update message ignore because status is already ' . $sended['status'] . '.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -125,18 +126,17 @@ use Monolog\Logger;
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function call on sms reception notification
|
||||
* We return nothing, and we let the adapter do his things.
|
||||
*
|
||||
* @param string $adapter_uid : Uid of the adapter to use
|
||||
* @param int $id_phone : Phone id
|
||||
* @param int $id_phone : Phone id
|
||||
*
|
||||
* @return bool : true on success, false on error
|
||||
*/
|
||||
public function reception (string $adapter_uid, int $id_phone)
|
||||
public function reception(string $adapter_uid, int $id_phone)
|
||||
{
|
||||
$this->logger->info('Callback reception call with adapter uid : ' . $adapter_uid);
|
||||
|
||||
|
@ -171,6 +171,7 @@ use Monolog\Logger;
|
|||
if ($response['error'])
|
||||
{
|
||||
$this->logger->error('Callback reception with adapter ' . $adapter_uid . ' failed : ' . $response['error_message']);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -180,10 +181,12 @@ use Monolog\Logger;
|
|||
if ($response['error'])
|
||||
{
|
||||
$this->logger->error('Failed receive message : ' . json_encode($sms) . ' with error : ' . $response['error_message']);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->logger->info('Callback reception successfully received message : ' . json_encode($sms));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace controllers\publics;
|
|||
return $this->redirect(\descartes\Router::url('Connect', 'login'));
|
||||
}
|
||||
|
||||
if ($user['status'] !== \models\User::STATUS_ACTIVE)
|
||||
if (\models\User::STATUS_ACTIVE !== $user['status'])
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Votre compte est actuellement suspendu.');
|
||||
|
||||
|
@ -119,7 +119,7 @@ namespace controllers\publics;
|
|||
$token = $Tokenista->generate(3600, ['id_user' => $user['id']]);
|
||||
|
||||
$reset_link = \descartes\Router::url('Connect', 'reset_password', ['id_user' => $user['id'], 'token' => $token]);
|
||||
|
||||
|
||||
$mailer = new \controllers\internals\Mailer();
|
||||
$email_send = $mailer->enqueue($email, EMAIL_RESET_PASSWORD, ['reset_link' => $reset_link]);
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ namespace controllers\publics;
|
|||
return $this->redirect(\descartes\Router::url('Contact', 'list'));
|
||||
}
|
||||
|
||||
$msg = ($result == 1 ? '1' : 'Pas de') . ' nouveau contact inséré.';
|
||||
$msg = (1 === $result ? '1' : 'Pas de') . ' nouveau contact inséré.';
|
||||
if ($result > 1)
|
||||
{
|
||||
$msg = $result . ' nouveaux contacts ont été insérés.';
|
||||
|
|
|
@ -52,6 +52,7 @@ class Phone extends \descartes\Controller
|
|||
if (!$adapter)
|
||||
{
|
||||
$phone['adapter'] = 'Inconnu';
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -111,7 +112,7 @@ class Phone extends \descartes\Controller
|
|||
* Create a new phone.
|
||||
*
|
||||
* @param $csrf : CSRF token
|
||||
* @param string $_POST['name'] : Phone name
|
||||
* @param string $_POST['name'] : Phone name
|
||||
* @param string $_POST['adapter'] : Phone adapter
|
||||
* @param array $_POST['adapter_datas'] : Phone adapter datas
|
||||
*/
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace controllers\publics;
|
|||
$this->internal_received->mark_as_read_for_user($_SESSION['user']['id'], $received['id']);
|
||||
}
|
||||
|
||||
if ($received['id_phone'] !== null)
|
||||
if (null !== $received['id_phone'])
|
||||
{
|
||||
$phone = $this->internal_phone->get_for_user($_SESSION['user']['id'], $received['id_phone']);
|
||||
if ($phone)
|
||||
|
@ -80,7 +80,7 @@ namespace controllers\publics;
|
|||
{
|
||||
$this->internal_received->mark_as_read_for_user($_SESSION['user']['id'], $received['id']);
|
||||
|
||||
if ($received['id_phone'] !== null)
|
||||
if (null !== $received['id_phone'])
|
||||
{
|
||||
$phone = $this->internal_phone->get_for_user($_SESSION['user']['id'], $received['id_phone']);
|
||||
if ($phone)
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace controllers\publics;
|
|||
|
||||
foreach ($sendeds as $key => $sended)
|
||||
{
|
||||
if ($sended['id_phone'] !== null)
|
||||
if (null !== $sended['id_phone'])
|
||||
{
|
||||
$phone = $this->internal_phone->get_for_user($_SESSION['user']['id'], $sended['id_phone']);
|
||||
if ($phone)
|
||||
|
|
|
@ -45,18 +45,17 @@ class User extends \descartes\Controller
|
|||
$users = $this->internal_user->list();
|
||||
$this->render('user/list', ['users' => $users]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update status of users
|
||||
* Update status of users.
|
||||
*
|
||||
* @param array int $_GET['ids'] : User ids
|
||||
* @param mixed $csrf
|
||||
* @param int $status : 1 -> active, 0 -> suspended
|
||||
* @param int $status : 1 -> active, 0 -> suspended
|
||||
*
|
||||
* @return boolean;
|
||||
*/
|
||||
public function update_status ($csrf, int $status)
|
||||
public function update_status($csrf, int $status)
|
||||
{
|
||||
if (!$this->verify_csrf($csrf))
|
||||
{
|
||||
|
@ -65,7 +64,7 @@ class User extends \descartes\Controller
|
|||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
||||
}
|
||||
|
||||
if ($status == 0)
|
||||
if (0 === $status)
|
||||
{
|
||||
$status = \models\User::STATUS_SUSPENDED;
|
||||
}
|
||||
|
@ -83,7 +82,6 @@ class User extends \descartes\Controller
|
|||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cette fonction va supprimer une liste de users.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue