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

Source for file add.php

Documentation is available at add.php

  1. <?php
  2. /**
  3.  * @package linea21.core
  4.  * @subpackage user
  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. //////////// Check Inclusion de pages ////////////
  12. if (!class_exists('auth')) {
  13.   include_once("../lib/lib_common.php");
  14.   ReloadIndex('admin');
  15. }
  16. ////////////
  17.  
  18. //////////// Check Droits utilisateur ////////////
  19. if (!$l21auth->isSuperAdmin()) ReloadIndex('admin');
  20. ////////////
  21. ?>
  22.  
  23. <div id="chemin">
  24. <ul>
  25.     <li><a href="index.php" class="chemin_home"><?php echo _t('way','home')?></a></li>
  26.     <li><a href="<?php echo $rub_link?>" id="chemin_<?php echo $rub?>" class="chemin_rub"><?php echo _t('menu','user')?></a></li>
  27.     <li><span><?php echo formatNavTitle(_t('user','add'))?></span></li>
  28. </ul>
  29. </div>
  30. <!--end barre haute -->
  31. <?php
  32. $form_pseudo='';
  33. $form_email='';
  34. $form_first_name='';
  35. $form_last_name='';
  36. $layer_rights"style=\"display:none;\"";
  37. $mask_type_S='';
  38. $mask_type_P='';
  39. $mask_type_A='';
  40.  
  41. $mask_dashboard_1="checked=\"checked\"";
  42. $mask_dashboard_2='';
  43. $mask_publication_1="checked=\"checked\"";
  44. $mask_publication_2='';
  45. $mask_news_1="checked=\"checked\"";
  46. $mask_news_2='';
  47. $mask_workshop_1="checked=\"checked\"";
  48. $mask_workshop_2='';
  49.  
  50. $workgroups=$sql_object->DBSelect($q);
  51. $default_wg array();
  52.  
  53.  
  54. if(isset($_POST['enregistrer'])) {
  55.   $data_table_user=unserialize(urldecode($_POST['data_table_user']));
  56.   $data_table_right=unserialize(urldecode($_POST['data_table_right']));
  57.   $data_table_workgroups=unserialize(urldecode($_POST['data_table_workgroups']));
  58.   $user_objectnew user;
  59.   $data_table_user[5$u_password $user_object -> GetNewPassword();
  60.   
  61.   $u_login $data_table_user[0];
  62.   $u_mail $data_table_user[1];
  63.  
  64.   /** include envoi de mail */
  65.   $todo_mail='add_user';
  66.   include_once(override('../user/mail_actions.php'));
  67.   include_once(override('../mail/template.php'));
  68.   /** end mail */
  69.  
  70.   $result=$user_object->AddUser($data_table_user$data_table_right$sql_object);
  71.   $link_confirm="confirm.php?rub=".$rub."&todo=".$todo;
  72.   if(is_numeric($result)) {
  73.     $r $user_object -> AddWorkshops($result$data_table_workgroups'U' $sql_object);
  74.     header("Location: ".$link_confirm);
  75.   }
  76.   else  system_error();
  77. }
  78.  
  79.  
  80. if(isset($_POST['valider'])) {
  81.   $table_user[0$_POST['pseudo'];
  82.   $table_user[1$_POST['email'];
  83.   $table_user[2'N';
  84.   $table_user[3$_POST['first_name'];
  85.   $table_user[4$_POST['last_name'];
  86.   
  87.   $user_objectnew user;
  88.   $integrity=$user_object->CheckDataIntegrity($table_user$sql_object);
  89.  
  90.   if($_POST['user_type']=='simple_user'{
  91.     $table_right=$user_object->InitUserRight('SIMPLE_USER');
  92.     $mask_type_S="checked=\"checked\"";
  93.   }
  94.   if($_POST['user_type']=='admin_user'{
  95.     $table_right=$user_object->InitUserRight('ADMIN_USER');
  96.     $mask_type_A="checked=\"checked\"";
  97.   }
  98.   if($_POST['user_type']=='privilege_user'{
  99.     $table_right['dashboard']=$_POST['dashboard'];
  100.     $table_right['workshop']=$_POST['workshop'];
  101.     $table_right['publication']=$_POST['publication'];
  102.     $table_right['news']=$_POST['news'];
  103.     $table_right['yellowpages']='U';
  104.     $table_right['project']='U';
  105.     $table_right['theme']='U';
  106.     $table_right['scale']='U';
  107.     $table_right['level']='U';
  108.     $table_right['category_user']='U';
  109.     $layer_rights"style=\"display:block;\"";
  110.     $mask_type_P="checked=\"checked\"";
  111.   }
  112.  
  113.   if(isset($_POST['workgroups'])) {
  114.     $table_workgroups=$_POST['workgroups'];
  115.     $default_wg=$table_workgroups;
  116.   }
  117.   else $table_workgroups=array();
  118.  
  119.   $form_pseudo=$_POST['pseudo'];
  120.   $form_email=$_POST['email'];
  121.   $form_first_name=$_POST['first_name'];
  122.   $form_last_name=$_POST['last_name'];
  123.   $table_user=urlencode(serialize($table_user));
  124.   $table_right=urlencode(serialize($table_right));
  125.   $table_workgroups=urlencode(serialize($table_workgroups));
  126.  
  127.   if($_POST['dashboard']=='O'{
  128.     $mask_dashboard_1='';
  129.     $mask_dashboard_2="checked=\"checked\"";
  130.   }
  131.   if($_POST['publication']=='O'{
  132.     $mask_publication_1='';
  133.     $mask_publication_2="checked=\"checked\"";
  134.   }
  135.   if($_POST['news']=='O'{
  136.     $mask_news_1='';
  137.     $mask_news_2="checked=\"checked\"";
  138.   }
  139.   if($_POST['workshop']=='O'{
  140.     $mask_workshop_1='';
  141.     $mask_workshop_2="checked=\"checked\"";
  142.   }
  143. }
  144.  
  145. // preparation affichage detaillé
  146. $rights_display='';
  147. if(defined('MOD_SDI')) {
  148.   $rights_display.= "<div><div class=\"rights\">⇨ "._t('menu','dashboard')." : </div>\n";
  149.   $rights_display.= "<div class=\"rightpanel\">\n";
  150.   $rights_display.= "<input type=\"radio\" id=\"dashboard_1\" class=\"radio\" name=\"dashboard\" value=\"U\" ".$mask_dashboard_1." /><label for=\"dashboard_1\">"_t('user','norights')."</label>\n";
  151.   $rights_display.= "<input type=\"radio\" id=\"dashboard_2\" class=\"radio\" name=\"dashboard\" value=\"O\" ".$mask_dashboard_2."/><label for=\"dashboard_2\">"_t('user','managerrights')."</label>\n";
  152.   $rights_display.= "</div></div>\n";
  153. else $rights_display.="<input type=\"hidden\" id=\"dashboard\" name=\"dashboard\" value=\"U\" />\n";
  154. if(defined('MOD_PUBLICATION')) {
  155.   $rights_display.= "<div><div class=\"rights\">⇨ "._t('menu','publication')." : </div>\n";
  156.   $rights_display.= "<div class=\"rightpanel\">\n";
  157.   $rights_display.= "<input type=\"radio\" id=\"publication_1\" class=\"radio\" name=\"publication\" value=\"U\" ".$mask_publication_1." /><label for=\"publication_1\">"_t('user','norights')."</label>\n";
  158.   $rights_display.= "<input type=\"radio\" id=\"publication_2\" class=\"radio\" name=\"publication\" value=\"O\" ".$mask_publication_2." /><label for=\"publication_2\">"_t('user','redactorrights')."</label>\n";
  159.   $rights_display.= "</div></div>\n";
  160. else $rights_display.="<input type=\"hidden\" id=\"publication\" name=\"publication\" value=\"U\" />\n";
  161. if(defined('MOD_NEWS')) {
  162.   $rights_display.= "<div><div class=\"rights\">⇨ "._t('menu','news')." : </div>\n";
  163.   $rights_display.= "<div class=\"rightpanel\">\n";
  164.   $rights_display.= "<input type=\"radio\" id=\"news_1\" class=\"radio\" name=\"news\" value=\"U\" ".$mask_news_1." /><label for=\"news_1\">"_t('user','norights')."</label>\n";
  165.   $rights_display.= "<input type=\"radio\" id=\"news_2\" class=\"radio\" name=\"news\" value=\"O\" ".$mask_news_2."/><label for=\"news_2\">"_t('user','redactorrights')."</label>\n";
  166.   $rights_display.= "</div></div>\n";
  167. else $rights_display.="<input type=\"hidden\" id=\"news\" name=\"news\" value=\"U\" />\n";
  168. if(defined('MOD_WORKSHOP')) {
  169.   $rights_display.= "<div><div class=\"rights\">⇨ "._t('menu','workshop')." : </div>\n";
  170.   $rights_display.= "<div class=\"rightpanel\">\n";
  171.   $rights_display.= "<input type=\"radio\" id=\"workshop_1\" class=\"radio\" name=\"workshop\" value=\"U\" ".$mask_workshop_1." /><label for=\"workshop_1\">"_t('user','norights')."</label>\n";
  172.   $rights_display.= "<input type=\"radio\" id=\"workshop_2\" class=\"radio\" name=\"workshop\" value=\"O\" ".$mask_workshop_2." /><label for=\"workshop_2\">"_t('user','animatorrights')."</label>\n";
  173.   $rights_display.= "</div></div>\n";
  174. else $rights_display.="<input type=\"hidden\" id=\"wokshop\" name=\"workshop\" value=\"U\" />\n";
  175.  
  176. include_once(THEME_ADMIN_PATH."quickicons.php");
  177.  
  178. if(!isset($_POST['valider'])) $mask_type_S='checked="checked"';
  179. ?>
  180.  
  181. <?php
  182. if(!isset($integrity|| is_string($integrity)) {
  183.   ?>
  184. <div class="contentcontainer">
  185. <?php
  186. include_once(override($dir.'/menurub.php'THEME_ADMIN_PATH));
  187. ?>
  188. <div id="content">
  189. <?php
  190. if(isset($integrity&& is_string($integrity)) display_errors($integrity);
  191.  
  192. $js "$('input:radio[name=user_type]').click(function() {
  193.                     var value = $(this).val();
  194.                     if(value == 'privilege_user') {
  195.                         $('div#rights').slideDown();
  196.                     } else {
  197.                         if($('div#rights').is(':visible')) $('div#rights').slideUp();
  198.                     }
  199.                 });";
  200.  
  201. ?>
  202. <h2><?php echo formatTitleh2(_t('user','add_title'))?></h2>
  203.  
  204. <form id="adduser" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  205.     <div class="label"><?php echo ucfirst(_t('user','type'))?> : *</div>
  206.     <div class="rightpanel">
  207.         <input name="user_type" type="radio" id="simple_user" maxlength="150" value="simple_user" <?php echo $mask_type_S?> />
  208.         <label for="simple_user"><?php echo mb_ucfirst(_t('user','type_simple'))?></label>
  209.         <input name="user_type" type="radio" id="privilege_user" maxlength="150" value="privilege_user" <?php echo $mask_type_P;  ?> />
  210.         <label for="privilege_user"><?php echo mb_ucfirst(_t('user','type_privilege'))?></label>
  211.         <input name="user_type" type="radio" id="admin_user" maxlength="150" value="admin_user" <?php echo $mask_type_A;  ?> />
  212.         <label for="admin_user"><?php echo mb_ucfirst(_t('user','type_admin'))?></label>
  213.     </div>
  214.  
  215. <div id="rights" <?php echo $layer_rights?>>
  216.  
  217. <h3 class="part"><?php echo mb_ucfirst(_t('user','set_rights'))?></h3>
  218. <?php echo $rights_display?></div>
  219.  
  220. <h3 class="part"><?php echo mb_ucfirst(_t('user','profile'))?></h3>
  221. <p>
  222.     <label for="pseudo"><?php echo mb_ucfirst(_t('user','login'))?> : *</label>
  223.     <input name="pseudo" type="text" class="textfield" id="pseudo" maxlength="150" value="<?php echo $form_pseudo?>" />
  224. </p>
  225. <p>
  226. <label for="email"><?php echo mb_ucfirst(_t('user','email'))?> : *</label>
  227. <input name="email" type="text" class="textfield" id="email" maxlength="200" value="<?php echo $form_email?>" />
  228. </p>
  229. <p>
  230.     <label for="first_name"><?php echo mb_ucfirst(_t('user','first_name'))?> : </label>
  231.     <input name="first_name" type="text" class="textfield" id="first_name" maxlength="200" value="<?php echo $form_first_name?>" />
  232. </p>
  233. <p>
  234.     <label for="last_name"><?php echo mb_ucfirst(_t('user','last_name'))?> : </label>
  235.     <input name="last_name" type="text" class="textfield" id="last_name" maxlength="200" value="<?php echo $form_last_name?>" />
  236. </p>
  237. <div>
  238.     <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  239.     <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  240.     <div class="label"><?php echo ucfirst(_t('user','workgroups'))?> :</div>
  241.     <div class="rightpanel"><?php echo workgroupsCheckbox($workgroups'workgroups[]'$default_wg)?>
  242. </div>
  243. <?php
  244. if(isset($table_user&& isset($table_right&& isset($table_workgroups)) {
  245.   echo "<input name=\"data_table_user\" type=\"hidden\" value=\"".$table_user."\" id=\"data_table_user\" />\n";
  246.   echo "<input name=\"data_table_right\" type=\"hidden\" value=\"".$table_right."\" id=\"data_table_right\" />\n";
  247.   echo "<input name=\"data_table_workgroups\" type=\"hidden\" value=\"".$table_workgroups."\" id=\"data_table_workgroups\" />\n";
  248. }
  249. ?>
  250. <br />
  251. <?php echo cancel_button('javascript:history.go(-1);')?>
  252. <input name="valider" type="submit" value="<?php echo _t('btn','valid')?>" class="button" id="valider" />
  253. </div>
  254. </form>
  255. </div>
  256. <?php include_once(override($dir.'/help.php'THEME_ADMIN_PATH))?></div>
  257. <?php
  258. // Récapitulatif
  259. else    {
  260.  
  261.   $wg_display '';
  262.   if(isset($_POST['workgroups'])) {
  263.     $q=SQL_Get_WorkshopsDenomination($_POST['workgroups']);
  264.     $workgroups=$sql_object->DBSelect($q);
  265.     foreach($workgroups as $wg{
  266.       $wg_display .= '- '.$wg['workshop_denomination'].'<br />'.END_LINE;
  267.     }
  268.   else $wg_display .= _t('divers''none');
  269.  
  270.  
  271.   $reca_droits ='';
  272.   if($_POST['user_type']=='simple_user'{
  273.     $display_type=_t('user','type_simple');
  274.   }
  275.   if($_POST['user_type']=='admin_user'{
  276.     $display_type=_t('user','type_admin');
  277.   }
  278.   if($_POST['user_type']=='privilege_user')  {
  279.     $display_type=_t('user','type_privilege');
  280.  
  281.     $reca_droits.='<h3 class="part">'_t('user','set_rights').'</h3>'.END_LINE;
  282.     $reca_droits.='<dl class="summary">'.END_LINE;
  283.  
  284.     if(defined('MOD_SDI'))  {
  285.       $reca_droits.="<dt> . "._t('menu','sdi')." : </dt>";
  286.       $reca_droits.="<dd>".GetDisplayUserRight($_POST['dashboard']'dashboard')."</dd>";
  287.     }
  288.     if(defined('MOD_PUBLICATION'))  {
  289.       $reca_droits.="<dt>  . "._t('menu','publication')." : </dt>";
  290.       $reca_droits.="<dd>".GetDisplayUserRight($_POST['publication'])."</dd>";
  291.     }
  292.     if(defined('MOD_WORKSHOP'))  {
  293.       $reca_droits.="<dt>  . "._t('menu','workshop')." : </dt>";
  294.       $reca_droits.="<dd>".GetDisplayUserRight($_POST['workshop']'workshop')."</dd>";
  295.     }
  296.     if(defined('MOD_NEWS'))  {
  297.       $reca_droits.="<dt>  . "._t('menu','news')." : </dt>";
  298.       $reca_droits.="<dd>".GetDisplayUserRight($_POST['news'])."</dd>";
  299.     }
  300.     $reca_droits.='</dl>'.END_LINE;
  301.   }
  302.  
  303.   ?>
  304. <div class="contentcontainer">
  305. <?php
  306. include_once(override($dir.'/menurub.php'THEME_ADMIN_PATH));
  307. ?>
  308. <div id="content">
  309.   <h2><?php echo formatTitleh2(_t('recap','title'))?></h2>
  310.   <dl class="summary">
  311.       <dt><?php echo mb_ucfirst(_t('user','type'))?> :</dt>
  312.       <dd><?php echo $display_type?><br />
  313.       </dd>
  314.       <dt><?php echo mb_ucfirst(_t('user','login'))?> :</dt>
  315.       <dd><?php echo $form_pseudo?><br />
  316.       </dd>
  317.       <dt><?php echo mb_ucfirst(_t('user','email'))?> :</dt>
  318.       <dd><?php echo $form_email?><br />
  319.       </dd>
  320.       <dt><?php echo mb_ucfirst(_t('user','first_name'))?> :</dt>
  321.       <dd><?php echo $form_first_name?><br />
  322.       </dd>
  323.       <dt><?php echo mb_ucfirst(_t('user','last_name'))?> :</dt>
  324.       <dd><?php echo $form_last_name?><br />
  325.       </dd>
  326.       <dt><?php echo mb_ucfirst(_t('user','workgroups'))?> :</dt>
  327.       <dd><?php echo stripslashes($wg_display)?></dd>
  328.   </dl>
  329.   <?php echo $reca_droits?>
  330.   <form id="adduser" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  331.     <div>
  332.     <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  333.     <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  334.     <input name="data_table_user" type="hidden" value="<?php echo $table_user?>" id="data_table_user" />
  335.     <input name="data_table_right" type="hidden" value="<?php echo $table_right?>" id="data_table_right" />
  336.     <input name="data_table_workgroups" type="hidden" value="<?php echo $table_workgroups?>" id="data_table_workgroups" />
  337.     <?php echo cancel_button('?rub=user&amp;todo=list')?>
  338.     <input name="retour" type="button" value="<?php echo _t('btn','preview'?>" class="button" id="retour" onclick="history.go(-1);" />
  339.     <input name="enregistrer" type="submit" value="<?php echo _t('btn','save'?>" class="button" id="valider" />
  340.     </div>
  341.   </form>
  342. </div>
  343. <?php include_once(override($dir.'/help.php'THEME_ADMIN_PATH))?>
  344. </div>
  345. <?php
  346. }
  347. ?>

Documentation generated on Thu, 20 Mar 2014 16:45:44 +0100 by phpDocumentor 1.4.1