Remove unused files (removed view:groups/permission_choice)

This commit is contained in:
xdrm-brackets 2017-02-18 16:10:59 +01:00
parent 7a224990d4
commit 32cc74166b
3 changed files with 2 additions and 204 deletions

View File

@ -1,159 +0,0 @@
<?php
namespace viewer\view\group;
use \viewer\core\Viewer;
use \api\core\Request;
use \error\core\Err;
use \error\core\Error;
use \api\core\Authentification;
class permission_choice{
public static function render($params){
/* [1] On vérifie les param + fetch données du groupe
=========================================================*/
/* (1) On vérifie les paramètres */
if( !isset($params['id_target']) || !is_numeric($params['id_target']) || !isset($params['id_action']) || !is_numeric($params['id_action']) )
return Viewer::$htmlError;
/* (2) On récupère le groupe cible */
$checktypeRequest = new Request('clusterDefault/getById', [
'id_cluster' => $params['id_target'],
'class' => 1
]);
$checktypeResponse = $checktypeRequest->dispatch();
/* (3) Si on ne le trouve pas, on retourne une erreur */
if( $checktypeResponse->error->get() != Err::Success )
return Viewer::$htmlError;
/* (4) On récupère les données du groupe */
$currentCluster = $checktypeResponse->get('cluster');
/* [2] On récupère les données de l'action
=========================================================*/
/* (1) Rédige la requête */
$permlistRequest = new Request('clusterDefault/getPermissions', []);
$permlistResponse = $permlistRequest->dispatch();
/* (2) Manage error */
if( $permlistResponse->error->get() != Err::Success )
return Viewer::$htmlError;
/* (3) Get action name (non-translated) */
$action_name = null;
foreach($permlistResponse->get('permissions') as $perm)
if( $perm['id_permission'] == $params['id_action'] )
$action_name = $perm['name'];
/* (4) Manage error (not found) */
if( is_null($action_name) )
return Viewer::$htmlError;
/* [2] Init Twig
=========================================================*/
$loader = new \Twig_Loader_Filesystem(__BUILD__.'/viewer/view');
$twig = new \Twig_Environment($loader, []);
/* [3] Store variables
=========================================================*/
$variables = [
'p_permname' => $action_name,
'p_id_target' => $params['id_target'],
'p_id_permission' => $params['id_action'],
'p_name' => $currentCluster['name'],
'p_theme' => $_SESSION['WAREHOUSE']['theme']
];
/* [4] Store functions
=========================================================*/
$twig->addFunction(new \Twig_Function('f_userclusters', function($id_target, $id_action){
/* [1] On récupère les groupes utilisateurs
=========================================================*/
/* (1) On exécute la requête */
$getmembersRequest = new Request('clusterDefault/getAuthenticatedClusters', [
'id_target' => $id_target,
'id_action' => $id_action
]);
$getmembersResponse = $getmembersRequest->dispatch();
/* (2) Si erreur, on retourne rien par défaut */
if( $getmembersResponse->error->get() != Err::Success )
return [];
/* (3) On récupère la liste des UID uniquement */
$members_ids = [];
foreach($getmembersResponse->get('clusters') as $member)
$members_ids[] = $member['id_user_cluster'];
/* [2] On récupère les utilisateurs non membres
=========================================================*/
/* (2) On exécute la requête */
$getuclusterRequest = new Request('clusterDefault/getAll', [
'class' => 0
]);
$getuclustersResponse = $getuclusterRequest->dispatch();
/* (3) si erreur, on affiche l'explicitation */
if( $getuclustersResponse->error->get() != Err::Success )
return [];
/* (4) On récupère la liste des utilisateurs */
$uclusters = $getuclustersResponse->get('clusters');
/* (5) On ajoute s'ils sont dans le groupe ou non */
foreach($uclusters as $u=>$ucluster)
$uclusters[$u]['already'] = in_array($ucluster['id_user_cluster'], $members_ids);
return $uclusters;
}));
$twig->addFilter(new \Twig_Filter('translate', function($word, $lang){
$word = strtolower($word);
if( $lang === 'fr' ){
switch($word){
case 'start': return 'démarrer'; break;
case 'stop': return 'arrêter'; break;
case 'signal': return 'signaler'; break;
case 'lock': return 'bloquer'; break;
case 'unlock': return 'débloquer'; break;
default: return $word; break;
}
}else
return $word;
}));
/* [5] Build the whole stuff
=========================================================*/
return $twig->render('group/permission_choice.twig', [
'p_permname' => $variables['p_permname'],
'p_id_permission' => $variables['p_id_permission'],
'p_name' => $variables['p_name'],
'p_id_target' => $variables['p_id_target'],
'p_theme' => $variables['p_theme']
]);
}
}
?>

View File

@ -1,29 +0,0 @@
<span style='text-align:center; color: #666; text-decoration: underline; cursor: pointer;' id='permissions-change-group'>Modifier d'autres permissions</span>
<p></p>
<span data-member-view></span>
<article class='check-table'>
<input type='hidden' id='permission-choice-idtarget' value='{{ p_id_target }}'>
<input type='hidden' id='permission-choice-idaction' value='{{ p_id_permission }}'>
<div>
<span><strong>Nom du groupe</strong></span>
<span><strong>permission <u>{{ p_permname | translate('fr') }}</u> sur <u>{{ p_name }}</u></strong></span>
</div>
{% for ucluster in f_userclusters(p_id_target, p_id_permission) %}
<div>
<span>{{ ucluster.name }}</span>
<span>
<input type='checkbox' value='{{ ucluster.id_user_cluster }}' data-name='member' id='checkbox_{{ ucluster.id_user_cluster }}' {% if ucluster.already %}checked{% endif %}>
<label for='checkbox_{{ ucluster.id_user_cluster }}'></label>
</span>
</div>
{% endfor %}
</article>

View File

@ -202,21 +202,7 @@
=========================================================*/ =========================================================*/
echo "<section data-sublink='permissions'>"; echo "<section data-sublink='permissions'>";
/* (1) Si on a un ID_CLUSTER, on affiche la composition
---------------------------------------------------------*/
if( count($post) > 2 && preg_match('/^m\d+$/', $post[1]) && preg_match('/^a\d+$/', $post[2])){
$membersChoice = new Viewer('group.permission_choice', [
'id_target' => (int) substr($post[1], 1),
'id_action' => (int) substr($post[2], 1)
]);
$membersChoice->view();
}else{
$groupChoice = new Viewer('group.permission', []); $groupChoice = new Viewer('group.permission', []);
$groupChoice->view(); $groupChoice->view();
}
echo '</section>'; echo '</section>';