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

Source for file add_com.php

Documentation is available at add_com.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. include_once("../lib/input_helpers.php");
  12. if(isset($_POST['id']))    $id=$_POST['id'];
  13. if(isset($_GET['id']))    $id=$_GET['id'];
  14.  
  15. if(isset($_POST['com_id']))    $com_id=$_POST['com_id'];
  16. if(isset($_GET['com_id']))    $com_id=$_GET['com_id'];
  17.  
  18. //////////// Check Inclusion de pages ////////////
  19. if (!class_exists('auth')){
  20.   include_once("../lib/lib_common.php");
  21.   ReloadIndex('admin');
  22. }
  23. ////////////
  24.  
  25. //////////// Check Droits utilisateur ////////////
  26. if (!$l21auth->isWorkgroupOrganiser($l21auth->GetSessionElement('id')$sql_object$id&& !$l21auth->isSuperAdmin())
  27. ReloadIndex('admin');
  28. ////////////
  29.  
  30. // TextboxList CSS/JS inclusion
  31. addDynamicCSS(THEME_ADMIN_PATH.'css/TextboxList.css');
  32. addDynamicCSS(THEME_ADMIN_PATH.'css/TextboxList.Autocomplete.css');
  33. footerAddJS('../lib/js/jquery.textboxList/GrowingInput.js');
  34. footerAddJS('../lib/js/jquery.textboxList/TextboxList.js');
  35. footerAddJS('../lib/js/jquery.textboxList/TextboxList.Autocomplete.js');
  36.  
  37.  
  38. $user_id=$l21auth->GetSessionElement('id');
  39.  
  40. $form_subject='';
  41. $form_owner='';
  42. $form_body='';
  43. $mask_owner='';
  44. $mask_notify='';
  45. $link_det=$rub_link."&amp;todo=det&amp;id=";
  46. $link_add_com=$rub_link."&amp;todo=add_com&amp;id=".$id."&amp;com_id=";
  47. if($com_id <> 0$link_cancel=$rub_link."&amp;todo=det_com&amp;id=".$id."&amp;com_id=".$com_id;
  48. else $link_cancel=$rub_link."&amp;todo=list_com&amp;id=".$id;
  49.  
  50.  
  51.  
  52. $req_det_workshopSQL_getoneCompleteWorkshop($id);
  53. $result_workshop=$sql_object->DBSelect($req_det_workshop);
  54. $workshop_denomination=formatText($result_workshop[0]['workshop_denomination']'2HTML');
  55.  
  56. $req_com_root SQL_getOnetopicWorkcom($id$com_id$com_id);
  57. $result_com_root $sql_object -> DBSelect($req_com_root);
  58. $com_root_subject=formatText($result_com_root[0]['workcom_subject']'2HTML');
  59. $workshop_com_objectnew workshop_com;
  60. if(!empty($com_root_subject)) $form_subject=$com_root_subject;
  61.  
  62. if(isset($_POST['enregistrer'])) {
  63.   $data_table=unserialize(urldecode($_POST['data_table']));
  64. //   print_r($data_table);
  65. //   $b = array('id' => $result,'user' => $_SESSION['userlogin'],'owner' => $data_table[6], 'action' => 'topic_alert', 'topic_subject' => $data_table[0], 'topic_body' => $data_table[1]);
  66. //   echo "<br /><br /><br /><br />";
  67. //   print_r($data_table);
  68. //   echo "<br /><br /><br /><br />";
  69. //   print_r($b);
  70. //   exit;
  71.   //faire l'ajout de user avec AddUserWorkshop
  72.   $result=$workshop_com_object->AddCom($data_table $sql_object);
  73.   if($com_id == 0$com_id=$result;
  74.   $link_confirm="confirm.php?rub=".$rub."&todo=".$todo."&id=".$id."&com_id=".$com_id."&mes_id=".$result;
  75.   if(is_numeric($result)) {
  76.       // we notify users if needed
  77.       if($data_table[5]===true{
  78.           // new topic
  79.           if($data_table[2== 0{
  80.               notifyUsersMsg(array('id' => $id,'user' => $_SESSION['userlogin'],'owner' => $data_table[6]'action' => 'topic_alert''topic_subject' => $data_table[0]'topic_body' => $data_table[1]));
  81.           // new post in existing topic
  82.           else {
  83.               notifyUsersMsg(array('id' => $result,'user' => $_SESSION['userlogin'],'owner' => $data_table[6]'action' => 'post_alert''topic_subject' => $data_table[0]'topic_body' => $data_table[1]'tid' => $data_table[2]'parentid' => $id));
  84.           }
  85.       }
  86.       header("Location: ".$link_confirm);
  87.   }
  88.   else  system_error();
  89. }
  90.  
  91. if(isset($_POST['valider'])) {
  92.  
  93.   $table[0$_POST['subject'];
  94.   $table[1$_POST['body'];
  95.   $table[2$_POST['com_id'];
  96.   if(isset($_POST['change-owner'])) {
  97.       $r=$sql_object -> DBSelect(SQL_get_UserInfo($_POST['owner']));
  98.       $table[3$r[0]['user_id'];
  99.       $mask_owner =' checked="checked"';
  100.       $table[6$_POST['owner'];
  101.   else {
  102.          $table[3$user_id;
  103.          $mask_owner '';
  104.          $table[6$_SESSION['userlogin'];
  105.   }
  106.   $table[4$_POST['id'];
  107.   
  108.   if(isset($_POST['notify-users'])) {
  109.       $mask_notify=' checked="checked"';
  110.       $table[5true;
  111.       $notifyusers_display _t('divers''yes');
  112.   else {
  113.       $mask_notify='';
  114.       $table[5false;
  115.       $notifyusers_display _t('divers''no');
  116.   }
  117.  
  118.   $integrity=$workshop_com_object->CheckDataIntegrity($table$sql_object);
  119.  
  120.   if(is_string($integrity)) {
  121.     $text_format='2FIELD';
  122.   else {
  123.     $text_format='2HTML';
  124.   }
  125.  
  126.   $form_subject=formatText($_POST['subject']$text_format);
  127.   if(isset($_POST['change-owner'])) {
  128.       $form_owner=formatText($_POST['owner']$text_format);
  129.   else {
  130.       $form_owner=formatText($_SESSION['userlogin']);
  131.   }
  132.   $form_body=formatText($_POST['body']$text_format);
  133.   $table=urlencode(serialize($table));
  134. }
  135. include_once(THEME_ADMIN_PATH."quickicons.php");
  136. if ($com_id==0{
  137.   $navtitle=_t('workshop','add_com')." : ".$workshop_denomination;
  138.   $titleh2=_t('workshop','name')." : ".$workshop_denomination;
  139. }
  140. else {
  141.   $navtitle=_t('workshop','add_com_mes')." : ".$com_root_subject." (".$workshop_denomination.")";
  142.   $titleh2=_t('workshop','com_name')." : ".$com_root_subject." ("._t('workshop','name')." :".$workshop_denomination.")";
  143. }?>
  144. <script type="text/javascript">
  145.     $(document).ready( function()
  146.     {
  147.       if(!$("#change-owner").is(':checked')) $("#owner-container").hide();
  148.         
  149.         $("#change-owner").click(
  150.                 function( objEvent ){
  151.                     var todo = this.checked;
  152.                     if(todo == true ) {
  153.                         $("#owner-container").fadeIn("slow");
  154.                         
  155.                     } else {
  156.                         $("#owner-container").fadeOut("slow");
  157.                     }
  158.                 }
  159.                 );
  160.         
  161.         // Autocomplete initialization
  162.         var t = new $.TextboxList('#owner', {unique: true, max:1, plugins: {autocomplete: {onlyFromValues: true, placeholder:"<?php echo _t('textbox_js''placeholder')?>"}}});
  163.                     
  164.         $.ajax({url: '../workshop/_ajax_user_autocomplete.php?groupmembers=<?php echo $id?>', dataType: 'json', success: function(r){
  165.             t.plugins['autocomplete'].setValues(r);
  166.         }});
  167.     });
  168. </script>
  169. <div id="chemin">
  170. <ul>
  171.     <li><a href="index.php" class="chemin_home"><?php echo _t('way','home'?></a></li>
  172.     <li><a href="<?php echo $rub_link?>" id="chemin_<?php echo $rub?>" class="chemin_rub"><?php echo _t('menu','workshop')?></a></li>
  173.     <li><span><?php  echo formatnavTitle($navtitle);?></span></li>
  174. </ul>
  175. </div>
  176. <!--end barre haute -->
  177. <?php
  178. if(!isset($integrity|| is_string($integrity)) {
  179.     ?>
  180. <div class="contentcontainer">
  181. <?php
  182. include_once(override($dir.'/menurub.php'THEME_ADMIN_PATH));
  183. ?>
  184. <div id="content">
  185. <?php
  186. if(isset($integrity&& is_string($integrity)) display_errors($integrity);
  187. ?> 
  188. <?php afflinkbar($todo,$id$lang)?>
  189. <h2><?php echo formatTitleh2($titleh2)?></h2>
  190. <form id="addcom" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  191. <p>
  192.     <label for="change-owner"><?php echo mb_ucfirst(_t('workshop','com_change_owner'))?> : </label>
  193.     <input type="checkbox" name="change-owner" id="change-owner" value=""<?php echo $mask_owner?> />
  194. </p>
  195. <p id="owner-container">
  196.     <label for="owner"><?php echo mb_ucfirst(_t('workshop','com_owner'))?> : * </label>
  197.     <input name="owner" type="text" class="textfield" id="owner" maxlength="150" value="<?php echo $form_owner?>" />
  198. </p>
  199. <p>
  200.     <label for="subject"><?php echo mb_ucfirst(_t('workshop','com_subject'))?> : *</label>
  201.     <input name="subject" type="text" class="textfield" id="subject" maxlength="150" value="<?php echo $form_subject?>" />
  202. </p>
  203. <p>
  204.     <label for="body"><?php echo mb_ucfirst(_t('workshop','com_body'))?> : *</label>
  205.     <textarea id="body" name="body" <?php echo AREA_SETTINGS?> class="largetextfield"><?php echo $form_body?></textarea>
  206. </p>
  207. <p>
  208.     <label for="notify-users"><?php echo mb_ucfirst(_t('workshop','com_notify'))?> : </label>
  209.     <input type="checkbox" name="notify-users" id="notify-users" value=""<?php echo $mask_notify?> />
  210. </p>
  211. <div>
  212.     <input name="id" type="hidden" value="<?php echo $id?>" id="id" />
  213.     <input name="com_id" type="hidden" value="<?php echo $com_id?>" id="com_id" /> <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" /> <?php echo cancel_button($link_cancel)?>
  214.     <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  215.     <input name="valider" type="submit" value="<?php echo _t('btn','valid'?>" class="button" id="valider" />
  216. </div>
  217. </form>
  218. </div>
  219. <?php include_once(override($dir.'/help.php'THEME_ADMIN_PATH))?></div>
  220. <?php
  221. // Récapitulatif
  222. else    {
  223. ?>
  224. <div class="contentcontainer">
  225. <?php
  226. include_once(override($dir.'/menurub.php'THEME_ADMIN_PATH));
  227. ?>
  228. <div id="content">
  229. <?php afflinkbar($todo,$id$lang)?>
  230. <h2><?php echo _t('recap','title'?></h2>
  231.  
  232. <?php
  233. echo "<dl class=\"summary\">\n";
  234. // we display user login only if we change it
  235. if(isset($_POST['change-owner'])) {
  236.     echo "<dt>".mb_ucfirst(_t('workshop','com_owner'))." : </dt>\n";
  237.     echo "<dd>".$form_owner."</dd>\n";
  238. }
  239. echo "<dt>".mb_ucfirst(_t('workshop','com_subject'))." : </dt>\n";
  240. echo "<dd>".$form_subject."</dd>\n";
  241. echo "<dt>".mb_ucfirst(_t('workshop','com_body')) ." : </dt>\n";
  242. echo "<dd>".$form_body."</dd>\n";
  243. echo "<dt>".mb_ucfirst(_t('workshop','com_notify')) ." : </dt>\n";
  244. echo "<dd>".$notifyusers_display."</dd>\n";
  245. echo "</dl>\n";
  246. ?>
  247. <form id="addworkshop" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  248. <div>
  249.     <input name="id" type="hidden" value="<?php echo $id?>" id="id" />
  250.     <input name="com_id" type="hidden" value="<?php echo $com_id?>"id="com_id" />
  251.     <input name="data_table" type="hidden" value="<?php echo $table?>" id="data_table" />
  252.     <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  253.     <?php echo cancel_button($link_cancel)?>
  254.     <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  255.     <input name="retour" type="button" value="<?php echo _t('btn','preview'?>" class="button" id="retour" onclick="history.go(-1);" />
  256.     <input name="enregistrer" type="submit" value="<?php echo _t('btn','save'?>" class="button" id="valider" />
  257. </div>
  258. </form>
  259. </div>
  260. <?php include_once(override($dir.'/help.php'THEME_ADMIN_PATH))?></div>
  261. <?php
  262.     }
  263.     ?>

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