Compare commits
No commits in common. "919b81bdf1cba339b42529d601934df5f9c23d8d" and "eeba3104e2fbde1ca93fc4466de9aac5a40022fa" have entirely different histories.
919b81bdf1
...
eeba3104e2
|
@ -44,11 +44,6 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
*/
|
||||
private $api_url = 'https://api.octopush.com/v1/public';
|
||||
|
||||
/**
|
||||
* Octopush phone number
|
||||
*/
|
||||
private $number;
|
||||
|
||||
|
||||
/**
|
||||
* Adapter constructor, called when instanciated by RaspiSMS.
|
||||
|
|
|
@ -68,14 +68,6 @@ namespace controllers\internals;
|
|||
return false;
|
||||
}
|
||||
|
||||
//Check if the received message is a SMS STOP and we must register it
|
||||
$internal_smsstop = new SmsStop($this->bdd);
|
||||
$is_stop = $internal_smsstop->check_for_stop($received['text']);
|
||||
if ($is_stop)
|
||||
{
|
||||
$internal_smsstop->create($id_user, $origin);
|
||||
}
|
||||
|
||||
//Link medias
|
||||
$internal_media = new Media($this->bdd);
|
||||
foreach ($media_ids as $media_id)
|
||||
|
|
|
@ -285,9 +285,7 @@ namespace controllers\internals;
|
|||
$internal_group = new \controllers\internals\Group($this->bdd);
|
||||
$internal_conditional_group = new \controllers\internals\ConditionalGroup($this->bdd);
|
||||
$internal_phone = new \controllers\internals\Phone($this->bdd);
|
||||
$internal_smsstop = new \controllers\internals\SmsStop($this->bdd);
|
||||
|
||||
$users_smsstops = [];
|
||||
$users_settings = [];
|
||||
$users_phones = [];
|
||||
$users_mms_phones = [];
|
||||
|
@ -308,17 +306,6 @@ namespace controllers\internals;
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($users_smsstops[$scheduled['id_user']]) && $users_settings[$scheduled['id_user']]['smsstop'])
|
||||
{
|
||||
$users_smsstops[$scheduled['id_user']] = [];
|
||||
|
||||
$smsstops = $internal_smsstop->gets_for_user($scheduled['id_user']);
|
||||
foreach ($smsstops as $smsstop)
|
||||
{
|
||||
$users_smsstops[$scheduled['id_user']][] = $smsstop['number'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($users_phones[$scheduled['id_user']]))
|
||||
{
|
||||
$phones = $internal_phone->gets_for_user($scheduled['id_user']);
|
||||
|
@ -480,12 +467,6 @@ namespace controllers\internals;
|
|||
continue;
|
||||
}
|
||||
|
||||
//Remove messages to smsstops numbers
|
||||
if (in_array($message['destination'], $users_smsstops[$scheduled['id_user']]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$smss_to_send[] = $message;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,15 +73,4 @@ namespace controllers\internals;
|
|||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a string to check if its a SMS stop
|
||||
*
|
||||
* @param string $str : The string to check
|
||||
* @return bool : true if sms stop, false else
|
||||
*/
|
||||
public function check_for_stop (string $str)
|
||||
{
|
||||
return trim(mb_strtolower($str)) == 'stop';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,25 +204,4 @@ namespace controllers\publics;
|
|||
|
||||
return $this->redirect(\descartes\Router::url('Connect', 'login'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow to stop impersonating a user
|
||||
* @param mixed $csrf
|
||||
*/
|
||||
public function stop_impersonate()
|
||||
{
|
||||
$old_session = $_SESSION['old_session'] ?? false;
|
||||
if (!$old_session)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Impossible de récupérer l\'identité originale, vous avez été deconnecté à la place.');
|
||||
|
||||
return $this->redirect(\descartes\Router::url('Connect', 'logout'));
|
||||
}
|
||||
|
||||
$user_email = $_SESSION['user']['email'];
|
||||
$_SESSION = $old_session;
|
||||
|
||||
\FlashMessage\FlashMessage::push('success', 'Vous n\'incarnez plus l\'utilisateur ' . $user_email . '.');
|
||||
return $this->redirect(\descartes\Router::url('Dashboard', 'show'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,5 +164,4 @@ namespace controllers\publics;
|
|||
|
||||
return $this->redirect(\descartes\Router::url('Connect', 'login'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace controllers\publics;
|
|||
*/
|
||||
public function list_json()
|
||||
{
|
||||
$entities = $this->internal_sended->list_for_user($_SESSION['user']['id'], 10000);
|
||||
$entities = $this->internal_sended->list_for_user($_SESSION['user']['id']);
|
||||
foreach ($entities as &$entity)
|
||||
{
|
||||
$entity['destination_formatted'] = \controllers\internals\Tool::phone_link($entity['destination']);
|
||||
|
|
|
@ -18,7 +18,6 @@ class User extends \descartes\Controller
|
|||
{
|
||||
private $internal_user;
|
||||
private $internal_quota;
|
||||
private $internal_setting;
|
||||
|
||||
/**
|
||||
* Cette fonction est appelée avant toute les autres :
|
||||
|
@ -31,7 +30,6 @@ class User extends \descartes\Controller
|
|||
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
|
||||
$this->internal_user = new \controllers\internals\User($bdd);
|
||||
$this->internal_quota = new \controllers\internals\Quota($bdd);
|
||||
$this->internal_setting = new \controllers\internals\Setting($bdd);
|
||||
|
||||
\controllers\internals\Tool::verifyconnect();
|
||||
|
||||
|
@ -409,68 +407,4 @@ class User extends \descartes\Controller
|
|||
|
||||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Allow an admin to impersonate a user
|
||||
* @param mixed $csrf
|
||||
* @param array int $_GET['user_ids'] : Ids of users to impersonate, the array should actually contain one id only, we keep use of array for simpler compatibility in UI
|
||||
*/
|
||||
public function impersonate ($csrf)
|
||||
{
|
||||
if (!$this->verify_csrf($csrf))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Jeton CSRF invalid !');
|
||||
|
||||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
||||
}
|
||||
|
||||
if (count($_GET['user_ids']) != 1)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Vous devez séléctionner un et un seul utilisateur à incarner !');
|
||||
|
||||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
||||
}
|
||||
|
||||
$id_user = (int) $_GET['user_ids'][0];
|
||||
|
||||
//Check if this user exists
|
||||
$user = $this->internal_user->get($id_user);
|
||||
if (!$user)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Cet utilisateur n\'existe pas !');
|
||||
|
||||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
||||
}
|
||||
|
||||
$settings = $this->internal_setting->gets_for_user($id_user);
|
||||
if (!$settings)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Impossible de charger les settings de cet utilisateur !');
|
||||
|
||||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
||||
}
|
||||
|
||||
if (\models\User::STATUS_ACTIVE !== $user['status'])
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Impossible d\'incarner cet utilisateur car il est actuellement suspendu');
|
||||
|
||||
return $this->redirect(\descartes\Router::url('User', 'list'));
|
||||
}
|
||||
|
||||
$user['settings'] = $settings;
|
||||
|
||||
//Save old session to get it back later
|
||||
$old_session = $_SESSION;
|
||||
$_SESSION = [
|
||||
'old_session' => $old_session,
|
||||
'impersonate' => true,
|
||||
'connect' => true,
|
||||
'user' => $user,
|
||||
];
|
||||
|
||||
\FlashMessage\FlashMessage::push('success', 'Vous incarnez désormais l\'utilisateur ' . $user['email'] . '.');
|
||||
return $this->redirect(\descartes\Router::url('Dashboard', 'show'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
'update_api_key' => '/account/update_api_key/{csrf}/',
|
||||
'delete' => '/account/delete/{csrf}/',
|
||||
'logout' => '/logout/',
|
||||
'stop_impersonate' => '/stop_impersonate/{csrf}/',
|
||||
],
|
||||
|
||||
'Command' => [
|
||||
|
@ -149,7 +148,6 @@
|
|||
'edit' => '/user/edit/',
|
||||
'update' => '/user/update/{csrf}/',
|
||||
'update_status' => '/user/delete/{status}/{csrf}/',
|
||||
'impersonate' => '/user/impersonate/{csrf}/',
|
||||
],
|
||||
|
||||
'Phone' => [
|
||||
|
|
|
@ -21,13 +21,7 @@
|
|||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<?php if ($_SESSION['impersonate'] ?? false) { ?>
|
||||
<li <?php echo $page == 'users' ? 'class="active"' : ''; ?>>
|
||||
<a href="<?php echo \descartes\Router::url('Account', 'stop_impersonate', ['csrf' => $_SESSION['csrf']]); ?>"><i class="fa fa-fw fa-sign-out"></i> Ne plus incarner</a>
|
||||
</li>
|
||||
<?php } else { ?>
|
||||
<a href="<?php echo \descartes\Router::url('Account', 'logout'); ?>"><i class="fa fa-fw fa-power-off"></i> Déconnexion</a>
|
||||
<?php } ?>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><i class="fa fa-upload fa-fw"></i> Liste des SMS envoyés (10 000 derniers SMS maximum)</h3>
|
||||
<h3 class="panel-title"><i class="fa fa-upload fa-fw"></i> Liste des SMS envoyés</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form method="GET">
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
<strong>Action pour la séléction :</strong>
|
||||
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('User', 'update_status', ['csrf' => $_SESSION['csrf'], 'status' => 0]); ?>"><span class="fa fa-pause"></span> Suspendre</button>
|
||||
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('User', 'update_status', ['csrf' => $_SESSION['csrf'], 'status' => 1]); ?>"><span class="fa fa-play"></span> Activer</button>
|
||||
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('User', 'impersonate', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-child"></span> Incarner</button>
|
||||
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('User', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button>
|
||||
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('User', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue