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

Source for file tpl_wg-subscription.php

Documentation is available at tpl_wg-subscription.php

  1. <?php
  2. /**
  3.  * @package linea21.core
  4.  * @subpackage public
  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('../class/system/class.form.php');
  12.  
  13. isset($_COOKIE['linea21']['login']?  $isAuthentified true $isAuthentified false;
  14.  
  15. if(isset($_REQUEST['id'])) {
  16.   $_POST['workgroup_'.$_REQUEST['id']] true;
  17.   $link_back HrefMaker(array('rub'=>$GLOBALS['links'][U_L]['workgroup']['linkvalue']'id'=> $_REQUEST['id']));
  18. }
  19. $link_registration array('rub'=> $GLOBALS['links'][U_L]['user-registration']['linkvalue']);
  20. $link_account array('rub'=> $GLOBALS['links'][U_L]['user-prefs']['linkvalue']);
  21.  
  22. function ischecked($id{
  23.   if(isset($_POST['workgroup_'.$id]))  return true;
  24.   else return false;
  25. }
  26.  
  27. function isWgselected($workgroups{
  28.   for($i=0$i<count($workgroups)$i++{
  29.     $var 'workgroup_'.$workgroups[$i]->workshop_id;
  30.     if(isset($_POST[$var])) return true;
  31.   }
  32.   return false;
  33. }
  34.  
  35. function getSelectedwg($workgroups{
  36.   $a array();
  37.   for($i=0$i<count($workgroups)$i++{
  38.     $var 'workgroup_'.$workgroups[$i]->workshop_id;
  39.     if(isset($_POST[$var])) array_push($a$workgroups[$i]->workshop_id);
  40.   }
  41.  
  42.   return $a;
  43. }
  44. ?>
  45.  
  46. <?php
  47. // set HTML Title
  48. SetHTMLTitle(_t('workshop','get_involve_long'));
  49. setBreadcrumb(array(_t('workshop','get_involve'=> false));
  50.  
  51. // workshops
  52. $workgroups $GLOBALS['sql_object']->DBSelect(SQL_Get_WorkshopsNames()'OBJECT');
  53. // we init an array to see if user has already subscribed all groups
  54. $subscribed array();
  55. for($i=0$i<count($workgroups)$i++{
  56.   if(isWorkgroupUser($workgroups[$i]->workshop_id)) {
  57.     array_push($subscribedtrue);
  58.   else {
  59.     array_push($subscribedfalse);
  60.   }
  61. }
  62. ?>
  63. <h1>
  64.  
  65. <?php echo _t('workshop','get_involve_long')?></h1>
  66. <div>
  67.  
  68.  
  69. <?php
  70. $comment='';
  71.  
  72. if(isset($_POST['comment'])) {
  73.  
  74.   $msg='';
  75.  
  76.   // sélection d'au moins un groupe
  77.   if (!isWgselected($workgroups)) $msg.=_t('workshop','nogroup_selected').'<br />';
  78.   else {
  79.     $groups='';
  80.     $data=$GLOBALS['sql_object']->DBSelect(SQL_Get_WorkshopsNames(getSelectedwg($workgroups))'OBJECT');
  81.  
  82.     foreach($data as $el{
  83.       $groups.= " - ".$el->workshop_denomination" <i>(id: ".$el->workshop_id.")</i><br />\n";
  84.     }
  85.   }
  86.  
  87.   if(empty($msg)) {
  88.     $passed true;
  89.     $class='confirm';
  90.     $msg .= _t('workshop''confirm_request');
  91.     if(isset($link_back)) $msg .= ' <a href="'.$link_back.'" title="'._t('workshop','workshop_back').'" >'._t('workshop','workshop_back').'</a>.'.END_LINE;
  92.     $linkuser 'index.php?rub=user&todo=mod&id='.$_COOKIE['linea21']['id'].'#groups';
  93.  
  94.     /** include email template */
  95.     $a['action']='workgroup_request';
  96.     include_once(themePath('../workshop/mail_actions.php'));
  97.     include_once(themePath('../mail/template.php'));
  98.  
  99.   else {
  100.     $passed false;
  101.     $class='error';
  102.   }
  103. }
  104.  
  105. if(isset($passed)) echo '<div class="'.$class.'">'.$msg.'</div>';
  106.  
  107. if(!$isAuthentified{
  108.  
  109.   echo '<p class="warning">'._t('workshop','note_account').' ' '<a href="'.HrefMaker($link_account).'" title="'.formatText(_t('divers','auth')'2ATT').'" >'._t('divers','auth').'</a>.<br />'.END_LINE;
  110.   echo '<a href="'.HrefMaker($link_registration).'">'._t('user','info_inscription2').' </a></p>';
  111.  
  112. else {
  113.   // affichage s'il manque un champs
  114.   if(!isset($passed|| $passed== false{
  115.  
  116.     // the user has not subscribed all groups, we display the form
  117.     if(in_array(false$subscribed)) {
  118.  
  119.       $form new genForm;
  120.       $form->startForm('index.php''#wg-subscription');
  121.       $form->insertHTML('<div id="choosegdt">'._t('workshop','subscribe_to').' : </div>');
  122.       $form->insertHTML('<div class="label-leftmargin">');
  123.       for($i=0$i<count($workgroups)$i++{
  124.         if(!isWorkgroupUser($workgroups[$i]->workshop_id)) {
  125.           // we remove the workgroups user already belongs to
  126.           $form->checkboxInput('checkbox','workgroup_'.$workgroups[$i]->workshop_id$workgroups[$i]->workshop_id$workgroups[$i]->workshop_denominationischecked($workgroups[$i]->workshop_id)'after''cb''labelised autowidth');
  127.         }
  128.       }
  129.       $form->insertHTML('</div>');
  130.       $form->textareaInput('comment',ucfirst(_t('divers''comment')).' ('._t('divers''optional').') : ',false,'labelised'false$comment6010);
  131.       $form->insertBR();
  132.       $form->submitButton(false_t('btn''valid')true'submitbut');
  133.       $form->hiddenInput('rub'$_REQUEST['rub']);
  134.       if(isset($_REQUEST['id'])) $form->hiddenInput('id'$_REQUEST['id']);
  135.       $form->closeForm();
  136.       if(!$output $form->getForm()) {
  137.         die("error: " $form->error);
  138.       }
  139.       else 
  140.         echo $output;
  141.       }
  142.       // the user already subscribed all groups, we display a warning
  143.     else {
  144.       echo '<p class="warning">'._t('workshop''allgroups_subscribed').'</p>'.END_LINE;
  145.     }
  146.   }
  147. }
  148.  
  149. ?></div>

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