linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file add_u.php

Documentation is available at add_u.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage workshop
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10. ?>
  11.  
  12. <script type="text/javascript">
  13.     $(document).ready( function()
  14.     {
  15.         function UpdateList() {
  16.             $("#user_login").val('');
  17.             var type = $("input[name='user_statut']:checked").val(); // we get current Type O || U
  18.             $.ajax({url: '../workshop/_ajax_user_autocomplete.php?type=' + type, dataType: 'json',
  19.                 success: function(r){
  20.                     t.plugins['autocomplete'].setValues(r);
  21.                 }
  22.             });
  23.         }
  24.  
  25.         $("input[name='user_statut']").click(function(){
  26.             UpdateList();
  27.         });
  28.         
  29.         // Autocomplete initialization
  30.         var t = new $.TextboxList('#user_login', {unique: true, plugins: {autocomplete: {onlyFromValues: true}}});
  31.         $.ajax({url: '../workshop/_ajax_user_autocomplete.php?type=U', dataType: 'json', success: function(r){
  32.             t.plugins['autocomplete'].setValues(r);
  33.         }});
  34.  
  35.     });
  36. </script>
  37.  
  38. <?php
  39. if(isset($_POST['id']))    $id=$_POST['id'];
  40. if(isset($_GET['id']))    $id=$_GET['id'];
  41.  
  42. //////////// Check Inclusion de pages ////////////
  43. if (!function_exists('AuthenthificationProcess')){
  44.   include_once("../lib/lib_common.php");
  45.   ReloadIndex('admin');
  46. }
  47. ////////////
  48.  
  49. //////////// Check Droits utilisateur ////////////
  50. if (isWorkgroupOrganiser(GetSessionElement('id')$sql_object$id)<>true && !IsSuperAdmin())
  51. ReloadIndex('admin');
  52. ////////////
  53.  
  54. $form_user_login='';
  55. $mask_statut_O='';
  56. $mask_statut_U="checked=\"checked\"";
  57.  
  58. $req_det_workshopSQL_getoneCompleteWorkshop($id);
  59. $result_workshop=$sql_object->DBSelect($req_det_workshop);
  60. $workshop_denomination=formatText($result_workshop[0]['workshop_denomination']'2HTML');
  61.  
  62. $link_cancel=$rub_link."&amp;todo=det&amp;id=".$id;
  63.  
  64. $workshop_objectnew workshop;
  65.  
  66. if(isset($_POST['enregistrer'])) {
  67.   $data_login=$_POST['data_login'];
  68.   $data_statut=$_POST['data_statut'];
  69.   if (!IsSuperAdmin())$data_statut='U';
  70.   //faire l'ajout de user avec AddUserWorkshop
  71.   $result=$workshop_object->AddUserWorkshop($id$data_login$data_statut $sql_object);
  72.   echo $result;
  73.   $link_confirm="confirm.php?rub=".$rub."&todo=".$todo."&id=".$id;
  74.   if(is_numeric($result)) header("Location: ".$link_confirm);
  75.   else  system_error();
  76. }
  77.  
  78. if(isset($_POST['valider'])) {
  79.   $data_login=$_POST['user_login'];
  80.   $data_statut=$_POST['user_statut'];
  81.   if (!IsSuperAdmin())$data_statut='U';
  82.   $workshop_objectnew workshop;
  83.   $integrity=$workshop_object->CheckUsersIntegrity($data_login$id$sql_object$data_statut);
  84.   if(is_string($integrity)) {
  85.     $text_format='2FIELD';
  86.   else {
  87.     $text_format='2HTML';
  88.   }
  89.  
  90.   $form_user_login=formatText(str_replace(",",", "$_POST['user_login'])$text_format);
  91.   if($_POST['user_statut']=='U'$mask_statut_U="checked=\"checked\""else $mask_statut_U='';
  92.   if($_POST['user_statut']=='O'$mask_statut_O="checked=\"checked\""else $mask_statut_O='';
  93. }
  94. include_once(THEME_ADMIN_PATH."quickicons.php");
  95. $navtitle=_t('workshop','add_new_user')." : ".$workshop_denomination;
  96. ?>
  97. <div id="chemin">
  98. <ul>
  99.     <li><a href="index.php" class="chemin_home"><?php echo _t('way','home'?></a></li>
  100.     <li><a href="<?php echo $rub_link?>" id="chemin_<?php echo $rub?>" class="chemin_rub"><?php echo _t('menu','workshop')?></a></li>
  101.     <li><span><?php echo formatnavTitle($navtitle)?></span></li>
  102. </ul>
  103. </div>
  104. <!--end barre haute -->
  105. <?php
  106. if(!isset($integrity|| is_string($integrity)) {
  107.   ?>
  108. <div class="contentcontainer"><?php
  109. include_once($dir."/menurub.php");
  110. ?>
  111. <div id="content">
  112. <?php if(isset($integrity&& is_string($integrity)) display_errors($integrity)?>
  113. <?php afflinkbar($todo,$id$lang)?>
  114. <h2><?php echo formatTitleh2(_t('workshop','name')." : ".$workshop_denomination)?></h2>
  115. <form id="adduserworkshop" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  116. <p>
  117.   <label for="user_login"><?php echo _t('workshop','add_new_user_login')?> * : </label>
  118.   <input name="user_login" type="text" class="textfield" id="user_login" maxlength="150" value="<?php echo $form_user_login?>" />
  119. </p>
  120. <?php
  121. if (IsSuperAdmin()){
  122. ?>
  123.  
  124.   <div class="label"><?php echo _t('workshop','add_new_user_right')?> * : </div>
  125.   <div class="rightpanel">
  126.   <input name="user_statut" type="radio" id="statut_U" value="U" <?php echo $mask_statut_U?> />
  127.   <label for="statut_U"><?php echo _t('statut','U')?></label>
  128.   <input name="user_statut" type="radio" id="statut_O" value="O" <?php echo $mask_statut_O?> />
  129.   <label for="statut_O"><?php echo _t('statut','O')?></label>
  130.   </div>
  131. <?php else ?>
  132.   <input name="user_statut" type="hidden" value="U" id="todo" />
  133. <?php ?>
  134.  
  135.   <div>
  136.     <input name="id" type="hidden" value="<?php echo $id?>" id="id" />
  137.     <?php echo cancel_button($link_cancel)?>
  138.     <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  139.     <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  140.     <input name="valider" type="submit" value="<?php echo _t('btn','valid'?>" class="button" id="valider" />
  141.   </div>
  142. </form>
  143. </div>
  144. <?php include_once($dir."/help.php")?></div>
  145. <?php
  146. // Récapitulatif
  147. else    {
  148.   ?>
  149. <div class="contentcontainer"><?php
  150. include_once($dir."/menurub.php");
  151. ?>
  152. <div id="content"><?php afflinkbar($todo,$id$lang)?>
  153. <h2><?php echo _t('recap','title'?></h2>
  154. <?php
  155. echo "<dl class=\"dl3\">\n";
  156. echo "<dt>"._t('workshop','add_new_user_login')." :</dt>\n";
  157. echo "<dd>".$form_user_login."</dd>\n";
  158. echo "<dt>"._t('workshop','add_new_user_right'."</dt>\n";
  159. echo "<dd>"display_statut($_POST['user_statut'])"</dd>\n";
  160. echo "</dl>\n";
  161. ?>
  162. <form id="addworkshop" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  163.   <div>
  164.   <input name="id" type="hidden" value="<?php echo $id?>" id="id" />
  165.   <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  166.   <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  167.   <?php echo cancel_button($link_cancel)?>
  168.   <input name="data_login" type="hidden" value="<?php echo $data_login?>" id="data_login" />
  169.   <input name="data_statut" type="hidden" value="<?php echo $data_statut?>" id="data_statut" />
  170.   <input name="retour" type="button" value="<?php echo _t('btn','preview'?>" class="button" id="retour" onclick="history.go(-1);" />
  171.   <input name="enregistrer" type="submit"    value="<?php echo _t('btn','save'?>" class="button" id="valider" />
  172.   </div>
  173. </form>
  174. </div>
  175. <?php include_once($dir."/help.php")?>
  176. </div>
  177. <?php
  178. }
  179. ?>

Documentation generated on Thu, 03 May 2012 15:02:02 +0200 by phpDocumentor 1.4.1