fix style
This commit is contained in:
parent
cc233f726a
commit
aac464704e
|
@ -355,6 +355,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
|||
$status = \models\Sended::STATUS_DELIVERED;
|
||||
|
||||
break;
|
||||
|
||||
case 'NOT_ALLOWED':
|
||||
case 'INVALID_DESTINATION_ADDRESS':
|
||||
case 'OUT_OF_DATE':
|
||||
|
@ -363,6 +364,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
|
|||
$status = \models\Sended::STATUS_FAILED;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$status = \models\Sended::STATUS_UNKNOWN;
|
||||
|
||||
|
|
|
@ -355,6 +355,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
$status = \models\Sended::STATUS_DELIVERED;
|
||||
|
||||
break;
|
||||
|
||||
case 'NOT_ALLOWED':
|
||||
case 'INVALID_DESTINATION_ADDRESS':
|
||||
case 'OUT_OF_DATE':
|
||||
|
@ -363,6 +364,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
$status = \models\Sended::STATUS_FAILED;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$status = \models\Sended::STATUS_UNKNOWN;
|
||||
|
||||
|
|
|
@ -347,11 +347,13 @@ namespace adapters;
|
|||
$status = \models\Sended::STATUS_DELIVERED;
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 16:
|
||||
$status = \models\Sended::STATUS_FAILED;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$status = \models\Sended::STATUS_UNKNOWN;
|
||||
|
||||
|
|
|
@ -346,11 +346,13 @@ namespace adapters;
|
|||
$status = \models\Sended::STATUS_DELIVERED;
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 16:
|
||||
$status = \models\Sended::STATUS_FAILED;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$status = \models\Sended::STATUS_UNKNOWN;
|
||||
|
||||
|
|
|
@ -257,10 +257,12 @@ namespace adapters;
|
|||
$return['status'] = \models\Sended::STATUS_DELIVERED;
|
||||
|
||||
break;
|
||||
|
||||
case \models\Sended::STATUS_FAILED:
|
||||
$return['status'] = \models\Sended::STATUS_FAILED;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$return['status'] = \models\Sended::STATUS_UNKNOWN;
|
||||
|
||||
|
|
|
@ -325,10 +325,12 @@ class TwilioVirtualNumberAdapter implements AdapterInterface
|
|||
$status = \models\Sended::STATUS_DELIVERED;
|
||||
|
||||
break;
|
||||
|
||||
case 'failed':
|
||||
$status = \models\Sended::STATUS_FAILED;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$status = \models\Sended::STATUS_UNKNOWN;
|
||||
|
||||
|
|
|
@ -117,8 +117,8 @@ namespace controllers\internals;
|
|||
|
||||
//Add metas of contact by adding contact without datas
|
||||
$metas = clone $contact;
|
||||
unset($metas->datas);
|
||||
unset($metas->id_user);
|
||||
$metas->datas = null;
|
||||
$metas->id_user = null;
|
||||
|
||||
$datas = ['contact' => $contact->datas, 'contact_metas' => $metas];
|
||||
$is_valid = $ruler->evaluate_condition($condition, $datas);
|
||||
|
|
|
@ -68,9 +68,10 @@ namespace controllers\internals;
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if a user exists based on email
|
||||
* Check if a user exists based on email.
|
||||
*
|
||||
* @param string $email : User email
|
||||
*
|
||||
* @return exit code 1 on false, 0 else
|
||||
*/
|
||||
public function user_exists(string $email)
|
||||
|
@ -79,6 +80,7 @@ namespace controllers\internals;
|
|||
$internal_user = new \controllers\internals\User($bdd);
|
||||
|
||||
$user = $internal_user->get_by_email($email);
|
||||
|
||||
exit($user ? 0 : 1);
|
||||
}
|
||||
|
||||
|
@ -105,11 +107,13 @@ namespace controllers\internals;
|
|||
$api_key = $api_key ?? $internal_user->generate_random_api_key();
|
||||
$success = $internal_user->update($user['id'], $email, $password, $admin, $api_key, $status, $encrypt_password);
|
||||
echo json_encode(['id' => $user['id']]);
|
||||
|
||||
exit($success ? 0 : 1);
|
||||
}
|
||||
|
||||
$new_user_id = $internal_user->create($email, $password, $admin, $api_key, $status, $encrypt_password);
|
||||
echo json_encode(['id' => $new_user_id]);
|
||||
|
||||
exit($new_user_id ? 0 : 1);
|
||||
}
|
||||
|
||||
|
@ -131,12 +135,12 @@ namespace controllers\internals;
|
|||
}
|
||||
|
||||
$success = $internal_user->update_status($user['id'], $status);
|
||||
|
||||
exit($success ? 0 : 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a user
|
||||
* Delete a user.
|
||||
*
|
||||
* @param string $id : User id
|
||||
*/
|
||||
|
@ -146,6 +150,7 @@ namespace controllers\internals;
|
|||
$internal_user = new \controllers\internals\User($bdd);
|
||||
|
||||
$success = $internal_user->delete($id);
|
||||
|
||||
exit($success ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace controllers\internals;
|
|||
* @param string $adapter : The adapter to use the phone
|
||||
* @param string json $adapter_datas : A JSON string representing adapter's datas (for example credentials for an api)
|
||||
*
|
||||
* @return int|bool : false on error, new id on success
|
||||
* @return bool|int : false on error, new id on success
|
||||
*/
|
||||
public function create(int $id_user, string $name, string $adapter, string $adapter_datas)
|
||||
{
|
||||
|
|
|
@ -244,7 +244,7 @@ namespace controllers\internals;
|
|||
if (!isset($users_phones[$scheduled['id_user']]))
|
||||
{
|
||||
$phones = $internal_phone->gets_for_user($scheduled['id_user']);
|
||||
$users_phones[$scheduled['id_user']] = $phones ? $phones : [];
|
||||
$users_phones[$scheduled['id_user']] = $phones ?: [];
|
||||
}
|
||||
|
||||
$phone_to_use = null;
|
||||
|
@ -338,12 +338,10 @@ namespace controllers\internals;
|
|||
|
||||
//Add metas of contact by adding contact without datas
|
||||
$metas = $contact;
|
||||
unset($metas['datas']);
|
||||
unset($metas['id_user']);
|
||||
unset($metas['datas'], $metas['id_user']);
|
||||
|
||||
$datas = ['contact' => $contact['datas'], 'contact_metas' => $metas];
|
||||
|
||||
|
||||
$render = $internal_templating->render($scheduled['text'], $datas);
|
||||
|
||||
if (!$render['success'])
|
||||
|
|
|
@ -97,26 +97,32 @@ namespace controllers\internals;
|
|||
$logo = 'fa-user';
|
||||
|
||||
break;
|
||||
|
||||
case 'CONTACT_ADD':
|
||||
$logo = 'fa-user';
|
||||
|
||||
break;
|
||||
|
||||
case 'GROUP_ADD':
|
||||
$logo = 'fa-group';
|
||||
|
||||
break;
|
||||
|
||||
case 'CONDITIONAL_GROUP_ADD':
|
||||
$logo = 'fa-bullseye';
|
||||
|
||||
break;
|
||||
|
||||
case 'SCHEDULED_ADD':
|
||||
$logo = 'fa-calendar';
|
||||
|
||||
break;
|
||||
|
||||
case 'COMMAND_ADD':
|
||||
$logo = 'fa-terminal';
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$logo = 'fa-question';
|
||||
}
|
||||
|
@ -169,7 +175,8 @@ namespace controllers\internals;
|
|||
if (!isset($_SESSION['connect']) || !$_SESSION['connect'])
|
||||
{
|
||||
header('Location: /');
|
||||
die();
|
||||
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,26 +224,32 @@ namespace controllers\internals;
|
|||
$result['content'] = 'Impossible de télécharger le fichier car il dépasse les ' . ini_get('upload_max_filesize') / (1000 * 1000) . ' Mégaoctets.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
$result['content'] = 'Le fichier dépasse la limite de taille.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
$result['content'] = 'L\'envoi du fichier a été interrompu.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
$result['content'] = 'Aucun fichier n\'a été envoyé.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
$result['content'] = 'Le serveur ne dispose pas de fichier temporaire permettant l\'envoi de fichiers.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
$result['content'] = 'Impossible d\'envoyer le fichier car il n\'y a plus de place sur le serveur.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
$result['content'] = 'Le serveur a interrompu l\'envoi du fichier.';
|
||||
|
||||
|
@ -284,26 +297,32 @@ namespace controllers\internals;
|
|||
$result['content'] = 'Impossible de télécharger le fichier car il dépasse les ' . ini_get('upload_max_filesize') / (1000 * 1000) . ' Mégaoctets.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
$result['content'] = 'Le fichier dépasse la limite de taille.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
$result['content'] = 'L\'envoi du fichier a été interrompu.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
$result['content'] = 'Aucun fichier n\'a été envoyé.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
$result['content'] = 'Le serveur ne dispose pas de fichier temporaire permettant l\'envoi de fichiers.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
$result['content'] = 'Impossible d\'envoyer le fichier car il n\'y a plus de place sur le serveur.';
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
$result['content'] = 'Le serveur a interrompu l\'envoi du fichier.';
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new phone
|
||||
* Create a new phone.
|
||||
*
|
||||
* @param string $_POST['name'] : Phone name
|
||||
* @param string $_POST['adapter'] : Phone adapter
|
||||
|
@ -434,7 +434,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
$phone_id = $this->internal_phone->create($this->user['id'], $name, $adapter, $adapter_datas);
|
||||
if ($phone_id === false)
|
||||
if (false === $phone_id)
|
||||
{
|
||||
$return['error'] = self::ERROR_CODES['CANNOT_CREATE'];
|
||||
$return['message'] = self::ERROR_MESSAGES['CANNOT_CREATE'];
|
||||
|
|
|
@ -52,6 +52,7 @@ use Monolog\Logger;
|
|||
http_response_code(401);
|
||||
echo json_encode(['error' => 'Invalid API key. You must provide a valid GET or POST api_key param.']);
|
||||
$this->logger->error('Callback call failed with invalid api key : ' . $api_key);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Return commands as json
|
||||
* Return commands as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Return conditionnals groups as json
|
||||
* Return conditionnals groups as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Return contacts as json
|
||||
* Return contacts as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
@ -288,16 +288,19 @@ namespace controllers\publics;
|
|||
|
||||
//Try to import file
|
||||
$invalid_type = false;
|
||||
|
||||
switch ($read_file['mime_type'])
|
||||
{
|
||||
case 'text/csv':
|
||||
$result = $this->internal_contact->import_csv($id_user, $read_file['content']);
|
||||
|
||||
break;
|
||||
|
||||
case 'application/json':
|
||||
$result = $this->internal_contact->import_json($id_user, $read_file['content']);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$invalid_type = true;
|
||||
}
|
||||
|
@ -338,16 +341,19 @@ namespace controllers\publics;
|
|||
|
||||
//Try to export contacts
|
||||
$invalid_type = false;
|
||||
|
||||
switch ($format)
|
||||
{
|
||||
case 'csv':
|
||||
$result = $this->internal_contact->export_csv($id_user);
|
||||
|
||||
break;
|
||||
|
||||
case 'json':
|
||||
$result = $this->internal_contact->export_json($id_user);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$invalid_type = true;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Return discussions as json
|
||||
* Return discussions as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Return events as json
|
||||
* Return events as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
|
|
@ -45,9 +45,8 @@ namespace controllers\publics;
|
|||
$this->render('group/list');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return groups as json
|
||||
* Return groups as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ class Phone extends \descartes\Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Return phones as json with additionnals datas about callbacks
|
||||
* Return phones as json with additionnals datas about callbacks.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Return received as json
|
||||
* Return received as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Return unred received as json
|
||||
* Return unred received as json.
|
||||
*/
|
||||
public function list_unread_json()
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Mark messages as
|
||||
* Mark messages as.
|
||||
*
|
||||
* @param string $status : New status of the message, read or unread
|
||||
* @param array int $_GET['ids'] : Ids of receiveds to delete
|
||||
|
@ -103,11 +103,11 @@ namespace controllers\publics;
|
|||
$ids = $_GET['ids'] ?? [];
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
if ($status === \models\Received::STATUS_UNREAD)
|
||||
if (\models\Received::STATUS_UNREAD === $status)
|
||||
{
|
||||
$this->internal_received->mark_as_unread_for_user($_SESSION['user']['id'], $id);
|
||||
}
|
||||
elseif ($status === \models\Received::STATUS_READ)
|
||||
elseif (\models\Received::STATUS_READ === $status)
|
||||
{
|
||||
$this->internal_received->mark_as_read_for_user($_SESSION['user']['id'], $id);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Return scheduleds as json
|
||||
* Return scheduleds as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Return sendeds as json
|
||||
* Return sendeds as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
@ -60,7 +60,6 @@ namespace controllers\publics;
|
|||
echo json_encode(['data' => $entities]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cette fonction va supprimer une liste de sendeds.
|
||||
*
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Return smsstops as json
|
||||
* Return smsstops as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
|
|
@ -70,8 +70,7 @@ namespace controllers\publics;
|
|||
|
||||
//Add metas of contact by adding contact without datas
|
||||
$metas = $contact;
|
||||
unset($metas['datas']);
|
||||
unset($metas['id_user']);
|
||||
unset($metas['datas'], $metas['id_user']);
|
||||
|
||||
$datas = [
|
||||
'contact' => $contact['datas'],
|
||||
|
|
|
@ -46,7 +46,7 @@ class User extends \descartes\Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Return users as json
|
||||
* Return users as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace controllers\publics;
|
|||
}
|
||||
|
||||
/**
|
||||
* Return commands as json
|
||||
* Return commands as json.
|
||||
*/
|
||||
public function list_json()
|
||||
{
|
||||
|
|
|
@ -125,6 +125,7 @@ abstract class AbstractDaemon
|
|||
if (-1 === $sid)
|
||||
{ //Error
|
||||
$this->logger->critical("Cannot make the child process with pid {$pid} independent.");
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -138,6 +139,7 @@ abstract class AbstractDaemon
|
|||
if (!$success)
|
||||
{
|
||||
$this->logger->critical('Cannot create PID directory : ' . $this->pid_dir);
|
||||
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace models;
|
|||
{
|
||||
/**
|
||||
* Return a list of groups for a user.
|
||||
* Add a column nb_contacts
|
||||
* Add a column nb_contacts.
|
||||
*
|
||||
* @param int $id_user : user id
|
||||
* @param ?int $limit : Number of entry to return or null
|
||||
|
@ -34,12 +34,12 @@ namespace models;
|
|||
GROUP BY g.id
|
||||
';
|
||||
|
||||
if ($limit !== null)
|
||||
if (null !== $limit)
|
||||
{
|
||||
$limit = (int) $limit;
|
||||
|
||||
$query .= ' LIMIT ' . $limit;
|
||||
if ($offset !== null)
|
||||
if (null !== $offset)
|
||||
{
|
||||
$offset = (int) $offset;
|
||||
$query .= ' OFFSET ' . $offset;
|
||||
|
@ -52,6 +52,7 @@ namespace models;
|
|||
|
||||
return $this->_run_query($query, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a group by his name for a user.
|
||||
*
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace models;
|
|||
|
||||
/**
|
||||
* Return a list of received messages for a user.
|
||||
* Add a column contact_name and phone_name when available
|
||||
* Add a column contact_name and phone_name when available.
|
||||
*
|
||||
* @param int $id_user : user id
|
||||
* @param ?int $limit : Number of entry to return or null
|
||||
|
@ -42,12 +42,12 @@ namespace models;
|
|||
WHERE received.id_user = :id_user
|
||||
';
|
||||
|
||||
if ($limit !== null)
|
||||
if (null !== $limit)
|
||||
{
|
||||
$limit = (int) $limit;
|
||||
|
||||
$query .= ' LIMIT ' . $limit;
|
||||
if ($offset !== null)
|
||||
if (null !== $offset)
|
||||
{
|
||||
$offset = (int) $offset;
|
||||
$query .= ' OFFSET ' . $offset;
|
||||
|
@ -61,10 +61,9 @@ namespace models;
|
|||
return $this->_run_query($query, $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of unread received messages for a user.
|
||||
* Add a column contact_name and phone_name when available
|
||||
* Add a column contact_name and phone_name when available.
|
||||
*
|
||||
* @param int $id_user : user id
|
||||
* @param ?int $limit : Number of entry to return or null
|
||||
|
@ -86,12 +85,12 @@ namespace models;
|
|||
AND status = :status
|
||||
';
|
||||
|
||||
if ($limit !== null)
|
||||
if (null !== $limit)
|
||||
{
|
||||
$limit = (int) $limit;
|
||||
|
||||
$query .= ' LIMIT ' . $limit;
|
||||
if ($offset !== null)
|
||||
if (null !== $offset)
|
||||
{
|
||||
$offset = (int) $offset;
|
||||
$query .= ' OFFSET ' . $offset;
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace models;
|
|||
|
||||
/**
|
||||
* Return a list of sended messages for a user.
|
||||
* Add a column contact_name and phone_name when available
|
||||
* Add a column contact_name and phone_name when available.
|
||||
*
|
||||
* @param int $id_user : user id
|
||||
* @param ?int $limit : Number of entry to return or null
|
||||
|
@ -43,12 +43,12 @@ namespace models;
|
|||
WHERE sended.id_user = :id_user
|
||||
';
|
||||
|
||||
if ($limit !== null)
|
||||
if (null !== $limit)
|
||||
{
|
||||
$limit = (int) $limit;
|
||||
|
||||
$query .= ' LIMIT ' . $limit;
|
||||
if ($offset !== null)
|
||||
if (null !== $offset)
|
||||
{
|
||||
$offset = (int) $offset;
|
||||
$query .= ' OFFSET ' . $offset;
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace models;
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete a user
|
||||
* Delete a user.
|
||||
*
|
||||
* @param int $id : Id de l'utilisateur a supprimer
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue