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 (!function_exists('AuthenthificationProcess')) {
  13.   include_once("../lib/lib_common.php");
  14.   ReloadIndex('admin');
  15. }
  16. ////////////
  17.  
  18. //////////// Check Droits utilisateur ////////////
  19. if (!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(themePath('../user/mail_actions.php'));
  67.   include_once('../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($dir."/menurub.php");
  187. ?>
  188. <div id="content">
  189. <?php
  190. if(isset($integrity&& is_string($integrity)) display_errors($integrity);
  191. ?>
  192. <h2><?php echo formatTitleh2(_t('user','add_title'))?></h2>
  193.  
  194. <form id="adduser" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  195.     <div class="label"><?php echo ucfirst(_t('user','type'))?> : *</div>
  196.     <div class="rightpanel">
  197.         <input name="user_type" type="radio" id="simple_user" maxlength="150" value="simple_user" onclick="ShowthemeTableRights('')" <?php echo $mask_type_S?> />
  198.         <label for="simple_user"><?php echo _t('user','type_simple')?></label>
  199.         <input name="user_type" type="radio" id="privilege_user" maxlength="150" value="privilege_user" onclick="ShowthemeTableRights('rights')" <?php echo $mask_type_P;  ?> />
  200.         <label for="privilege_user"><?php echo _t('user','type_privilege')?></label>
  201.         <input name="user_type" type="radio" id="admin_user" maxlength="150" value="admin_user" onclick="ShowthemeTableRights('')" <?php echo $mask_type_A;  ?> />
  202.         <label for="admin_user"><?php echo _t('user','type_admin')?></label>
  203.     </div>
  204.  
  205. <div id="rights" <?php echo $layer_rights?>>
  206.  
  207. <h3 class="part"><?php echo _t('user','set_rights')?></h3>
  208. <?php echo $rights_display?></div>
  209.  
  210. <h3 class="part"><?php echo _t('user','profile')?></h3>
  211. <p>
  212.     <label for="pseudo"><?php echo ucfirst(_t('user','pseudo'))?> : *</label>
  213.     <input name="pseudo" type="text" class="textfield" id="pseudo" maxlength="150" value="<?php echo $form_pseudo?>" />
  214. </p>
  215. <p>
  216. <label for="email"><?php echo ucfirst(_t('user','email'))?> : *</label>
  217. <input name="email" type="text" class="textfield" id="email" maxlength="200" value="<?php echo $form_email?>" />
  218. </p>
  219. <p>
  220.     <label for="first_name"><?php echo ucfirst(_t('user','first_name'))?> : </label>
  221.     <input name="first_name" type="text" class="textfield" id="first_name" maxlength="200" value="<?php echo $form_first_name?>" />
  222. </p>
  223. <p>
  224.     <label for="last_name"><?php echo ucfirst(_t('user','last_name'))?> : </label>
  225.     <input name="last_name" type="text" class="textfield" id="last_name" maxlength="200" value="<?php echo $form_last_name?>" />
  226. </p>
  227. <div>
  228.     <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  229.     <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  230.     <div class="label"><?php echo ucfirst(_t('user','workgroups'))?> :</div>
  231.     <div class="rightpanel"><?php echo workgroupsCheckbox($workgroups'workgroups[]'$default_wg)?>
  232. </div>
  233. <?php
  234. if(isset($table_user&& isset($table_right&& isset($table_workgroups)) {
  235.   echo "<input name=\"data_table_user\" type=\"hidden\" value=\"".$table_user."\" id=\"data_table_user\" />\n";
  236.   echo "<input name=\"data_table_right\" type=\"hidden\" value=\"".$table_right."\" id=\"data_table_right\" />\n";
  237.   echo "<input name=\"data_table_workgroups\" type=\"hidden\" value=\"".$table_workgroups."\" id=\"data_table_workgroups\" />\n";
  238. }
  239. ?>
  240. <br />
  241. <?php echo cancel_button('javascript:history.go(-1);')?>
  242. <input name="valider" type="submit" value="<?php echo _t('btn','valid')?>" class="button" id="valider" />
  243. </div>
  244. </form>
  245. </div>
  246. <?php include_once($dir."/help.php")?></div>
  247. <?php
  248. // Récapitulatif
  249. else    {
  250.  
  251.   $wg_display '';
  252.   if(isset($_POST['workgroups'])) {
  253.     $q=SQL_Get_WorkshopsDenomination($_POST['workgroups']);
  254.     $workgroups=$sql_object->DBSelect($q);
  255.     foreach($workgroups as $wg{
  256.       $wg_display .= '- '.$wg['workshop_denomination'].'<br />'.END_LINE;
  257.     }
  258.   else $wg_display .= _t('divers''none');
  259.  
  260.  
  261.   $reca_droits ='';
  262.   if($_POST['user_type']=='simple_user'{
  263.     $display_type=_t('user','type_simple');
  264.   }
  265.   if($_POST['user_type']=='admin_user'{
  266.     $display_type=_t('user','type_admin');
  267.   }
  268.   if($_POST['user_type']=='privilege_user')  {
  269.     $display_type=_t('user','type_privilege');
  270.  
  271.     $reca_droits.='<h3 class="part">'_t('user','set_rights').'</h3>'.END_LINE;
  272.     $reca_droits.='<dl class="dl3">'.END_LINE;
  273.  
  274.     if(defined('MOD_SDI'))  {
  275.       $reca_droits.="<dt> . "._t('menu','sdi')." : </dt>";
  276.       $reca_droits.="<dd>".GetDisplayUserRight($_POST['dashboard']'dashboard')."</dd>";
  277.     }
  278.     if(defined('MOD_PUBLICATION'))  {
  279.       $reca_droits.="<dt>  . "._t('menu','publication')." : </dt>";
  280.       $reca_droits.="<dd>".GetDisplayUserRight($_POST['publication'])."</dd>";
  281.     }
  282.     if(defined('MOD_WORKSHOP'))  {
  283.       $reca_droits.="<dt>  . "._t('menu','workshop')." : </dt>";
  284.       $reca_droits.="<dd>".GetDisplayUserRight($_POST['workshop']'workshop')."</dd>";
  285.     }
  286.     if(defined('MOD_NEWS'))  {
  287.       $reca_droits.="<dt>  . "._t('menu','news')." : </dt>";
  288.       $reca_droits.="<dd>".GetDisplayUserRight($_POST['news'])."</dd>";
  289.     }
  290.     $reca_droits.='</dl>'.END_LINE;
  291.   }
  292.  
  293.   ?>
  294. <div class="contentcontainer">
  295. <?php
  296. include_once($dir."/menurub.php");
  297. ?>
  298. <div id="content">
  299.   <h2><?php echo formatTitleh2(_t('recap','title'))?></h2>
  300.   <dl class="dl3">
  301.       <dt><?php echo _t('user','type'?> :</dt>
  302.       <dd><?php echo $display_type?><br />
  303.       </dd>
  304.       <dt><?php echo ucfirst(_t('user','pseudo')) ?> :</dt>
  305.       <dd><?php echo $form_pseudo?><br />
  306.       </dd>
  307.       <dt><?php echo ucfirst(_t('user','email')) ?> :</dt>
  308.       <dd><?php echo $form_email?><br />
  309.       </dd>
  310.       <dt><?php echo ucfirst(_t('user','first_name')) ?> :</dt>
  311.       <dd><?php echo $form_first_name?><br />
  312.       </dd>
  313.       <dt><?php echo ucfirst(_t('user','last_name')) ?> :</dt>
  314.       <dd><?php echo $form_last_name?><br />
  315.       </dd>
  316.       <dt><?php echo ucfirst(_t('user','workgroups')) ?> :</dt>
  317.       <dd><?php echo stripslashes($wg_display)?></dd>
  318.   </dl>
  319.   <?php echo $reca_droits?>
  320.   <form id="adduser" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  321.     <div>
  322.     <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  323.     <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  324.     <input name="data_table_user" type="hidden" value="<?php echo $table_user?>" id="data_table_user" />
  325.     <input name="data_table_right" type="hidden" value="<?php echo $table_right?>" id="data_table_right" />
  326.     <input name="data_table_workgroups" type="hidden" value="<?php echo $table_workgroups?>" id="data_table_workgroups" />
  327.     <?php echo cancel_button('?rub=user&amp;todo=list')?>
  328.     <input name="retour" type="button" value="<?php echo _t('btn','preview'?>" class="button" id="retour" onclick="history.go(-1);" />
  329.     <input name="enregistrer" type="submit" value="<?php echo _t('btn','save'?>" class="button" id="valider" />
  330.     </div>
  331.   </form>
  332. </div>
  333. <?php include_once($dir."/help.php")?>
  334. </div>
  335. <?php
  336. }
  337. ?>

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