mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
fix style
This commit is contained in:
parent
cc233f726a
commit
aac464704e
34 changed files with 147 additions and 107 deletions
|
@ -114,11 +114,11 @@ namespace controllers\internals;
|
|||
{
|
||||
$contact['datas'] = json_decode($contact['datas']);
|
||||
$contact = (object) $contact;
|
||||
|
||||
|
||||
//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
|
||||
*
|
||||
* @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,18 +107,20 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a user status.
|
||||
*
|
||||
* @param string $id : User id
|
||||
* @param string $id : User id
|
||||
* @param string $status : User status, default \models\User::STATUS_ACTIVE
|
||||
*/
|
||||
public function update_user_status(string $id, string $status)
|
||||
|
@ -131,14 +135,14 @@ 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
|
||||
* @param string $id : User id
|
||||
*/
|
||||
public function delete_user(string $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;
|
||||
|
@ -335,14 +335,12 @@ namespace controllers\internals;
|
|||
if ((int) ($users_settings[$scheduled['id_user']]['templating'] ?? false))
|
||||
{
|
||||
$contact['datas'] = json_decode($contact['datas'], true);
|
||||
|
||||
|
||||
//Add metas of contact by adding contact without datas
|
||||
$metas = $contact;
|
||||
unset($metas['datas']);
|
||||
unset($metas['id_user']);
|
||||
|
||||
$datas = ['contact' => $contact['datas'], 'contact_metas' => $metas];
|
||||
unset($metas['datas'], $metas['id_user']);
|
||||
|
||||
$datas = ['contact' => $contact['datas'], 'contact_metas' => $metas];
|
||||
|
||||
$render = $internal_templating->render($scheduled['text'], $datas);
|
||||
|
||||
|
|
|
@ -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.';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue