<?php 
defined( '_JEXEC' ) or die( 'Restricted access' ); 

class HTML_gmaccess 
{ 
	function editGroup( $option, &$row, $membresList, $utilisateursList, $gimbriquesList, $groupesList ) 
	{ 
	
	
		JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'nom_groupe' );
		JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'description_groupe' );
		//$pane =& JPane::getInstance(tabs);
	
        ?>
		  <script>
			function submitbutton(pressbutton) {
		
			  var form = document.adminForm;
		
			  if (pressbutton == 'canceled') {
				submitform( pressbutton );
				return;
			  }
		
			  // do field validation
		
			  if (form.nom_groupe.value == ""){
				alert( "<?php echo 'nom groupe';?>" );
			  } else {
				allSelected(document.adminForm['users_selected[]']);
				allSelected(document.adminForm['groupes_selected[]']);
				submitform( pressbutton );
			  }
			}
		  </script>
		
		  <script>
			// moves elements from one select box to another one
			function moveOptions(from,to) {
			  // Move them over
			  for (var i=0; i<from.options.length; i++) {
				var o = from.options[i];
				if (o.selected) {
				  to.options[to.options.length] = new Option( o.text, o.value, false, false);
				}
			  }
			  // Delete them from original
			  for (var i=(from.options.length-1); i>=0; i--) {
				var o = from.options[i];
				if (o.selected) {
				  from.options[i] = null;
				}
			  }
			  from.selectedIndex = -1;
			  to.selectedIndex = -1;
			}
		
			function allSelected(element) {
		
			   for (var i=0; i<element.options.length; i++) {
					var o = element.options[i];
					o.selected = true;
		
				}
			 }
		  </script>
		  <script>
			// moves elements from one select box to another one
			function moveOptions2(from,to) {
			  // Move them over
			  for (var i=0; i<from.options.length; i++) {
				var o = from.options[i];
				//if (o.selected) {
				  to.options[to.options.length] = new Option( o.text, o.value, false, false);
				//}
			  }
			  // Delete them from original
			  for (var i=(from.options.length-1); i>=0; i--) {
				var o = from.options[i];
				//if (o.selected) {
				  from.options[i] = null;
				//}
			  }
			  from.selectedIndex = -1;
			  to.selectedIndex = -1;
			}
			
			function allSelected(element) {
		
			   for (var i=0; i<element.options.length; i++) {
					var o = element.options[i];
					o.selected = true;
		
				}
			 }
		  </script>
	
		
<div class="col width-40">
			
				<fieldset class="adminform">
				<legend><?php echo JText::_( 'GMA_GROUPE' )." ". $row->nom_groupe; ?></legend>

				
			   
	
		<?php
		// Put the tooltip script in the header
		JHTML::_( 'behavior.tooltip');

		// Get the pane object to create the tabs
		jimport('joomla.html.pane');
		$pane =& JPane::getInstance('sliders');

        ?>
	
			<table class="admintable">
				<form action="index.php" method="post" name="adminForm" id="adminForm">
					<tr>
						<td class="key">
                            <label for="nom_groupe">
                                <?php echo JText::_( 'GMA_NOM' ); ?>:
                            </label>
                        </td>
                        <td>
							<input class="inputbox" type="text" name="nom_groupe" size="50" maxlength="100" value="<?php echo $row->nom_groupe;?>" />
							
						</td>
					</tr>
					<tr>
						<td class="key" valign="top">
                        	 <label for="description_groupe">
                                <?php echo JText::_( 'GMA_DESCRIPTION' ); ?>:
                            </label>
                        </td>
						<td>
							<textarea name="description_groupe" cols="45" rows="10"><?php echo $row->description_groupe;?></textarea>
						</td>
					</tr>
		   </table>
	</fieldset>
</div>
<div class="col width-60">
			<fieldset class="adminform">
				<legend><?php echo JText::_( 'GMA_DEF_MEMBRE' ); ?></legend>	
		<?php
       echo $pane->startPane("content-pane");
       echo $pane->startPanel(JText::_( 'GMA_UMEMBRES' ), "Panel1");
        ?>
		  <table class="admintable" width="100%">
				<tr>
					<td align="center"  width="50%"><?php echo JText::_( 'GMA_UDISP' );?></td>
					<td width="150px" align="center">&nbsp;</td>
					<td align="center"  width="50%"><?php echo JText::_( 'GMA_MEMBRESG' );?></td>
				</tr>
				<tr>
					<td align="center"  width="50%"><?php echo $utilisateursList;?></td>
					<td width="150px" align="center">
						<p>
						  <input style="width: 50px" type="button" name="Button" value="&gt;" onClick="moveOptions(document.adminForm.users_not_selected, document.adminForm['users_selected[]'])" />
						  <br>
						  <input style="width: 50px" type="button" name="Button2" value="<?php echo JText::_( 'GMA_TOUS' );?>" onClick="moveOptions2(document.adminForm.users_not_selected, document.adminForm['users_selected[]'])" />
						  <br />
					  </p>
						<p>&nbsp;</p>
						<p><br />
				          <input style="width: 50px" type="button" name="Button" value="&lt;" onClick="moveOptions(document.adminForm['users_selected[]'],document.adminForm.users_not_selected)" />
				          <br>
				          <input style="width: 50px" type="button" name="Button3" value="<?php echo JText::_( 'GMA_AUCUN' );?>" onClick="moveOptions2(document.adminForm['users_selected[]'],document.adminForm.users_not_selected)" />
				          <br />
				          <br />
	                  </p></td>
					<td align="center"  width="50%"><?php echo $membresList;?></td>
				</tr>
				<tr>
					<td colspan=3 align="center"><?php echo JText::_( 'GMA_CTRL' );?></td>
				</tr>
</table>

		<?php
       echo $pane->endPanel();
       echo $pane->startPanel(JText::_( 'GMA_GIMBRIQUE' ), "Panel2");
        ?>
			  <table class="admintable" width="100%">
				<tr>
					<td align="center"  width="50%"><?php echo JText::_( 'GMA_GDISP' );?></td>
					<td width="150px" align="center">&nbsp;</td>
					<td align="center"  width="50%"><?php echo JText::_( 'GMA_IMBRIQUEG' );?></td>
				</tr>
				<tr>
					<td align="center"  width="50%"><?php echo $groupesList;?></td>
					<td width="150px" align="center">
						<p>
						  <input style="width: 50px" type="button" name="Button" value="&gt;" onClick="moveOptions(document.adminForm.groupes_not_selected, document.adminForm['groupes_selected[]'])" />
						  <br>
						  <input style="width: 50px" type="button" name="Button2" value="<?php echo JText::_( 'GMA_TOUS' );?>" onClick="moveOptions2(document.adminForm.groupes_not_selected, document.adminForm['groupes_selected[]'])" />
						  <br />
					  </p>
						<p>&nbsp;</p>
						<p><br />
				          <input style="width: 50px" type="button" name="Button" value="&lt;" onClick="moveOptions(document.adminForm['groupes_selected[]'],document.adminForm.groupes_not_selected)" />
				          <br>
				          <input style="width: 50px" type="button" name="Button3" value="<?php echo JText::_( 'GMA_AUCUN' );?>" onClick="moveOptions2(document.adminForm['groupes_selected[]'],document.adminForm.groupes_not_selected)" />
				          <br />
				          <br />
	                  </p></td>
					<td align="center" width="50%"><?php echo $gimbriquesList;?></td>
				</tr>
				<tr>
					<td colspan=3 align="center"><?php echo JText::_( 'GMA_CTRL' );?></td>
				</tr>
</table>
<?php
 echo $pane->endPanel();
       echo $pane->endPane();
?>
</fieldset>
		</div>				
			<input type="hidden" name="id_groupe" value="<?php echo $row->id_groupe;?>" />
			<input type="hidden" name="option" value="com_gmaccess" />
      		<input type="hidden" name="section" value="groups" />
			<input type="hidden" name="task" value="" />
			<input type="hidden" name="access_groupe" value="1" />
		</form>
	
		<?php
     
		
		
		
		
	}
	function editAccess ($option, &$row) {
		
		global $mainframe;
		$lang		= & JFactory::getLanguage();
		$document    = &JFactory::getDocument(); 
		$livesite = JURI::base();  
		$db=& JFactory::getDBO();

	?>
    <script language="javascript" type="text/javascript">
		onload = ouverture;
		
		function ouverture() {
			if(document.adminForm.source.value == 2) {
				document.getElementById('listecomposants').style.display = 'block';
				document.getElementById('textoption').style.display = 'block';
				document.getElementById('textacosection').style.display = 'none';
				document.getElementById('textvariable1').style.display = '';
				document.getElementById('textvaleur1').style.display = 'block';
				document.getElementById('textaco').style.display = 'none';
				document.getElementById('textvariable2').style.display = 'block';
				document.getElementById('textaxosection').style.display = 'none';
				document.getElementById('textvaleur2').style.display = 'block';
				document.getElementById('textaxo').style.display = 'none';
				document.getElementById('acosection').style.display = 'none';
			} else {
				document.getElementById('listecomposants').style.display = 'none';
				document.getElementById('textacosection').style.display = 'block';
				document.getElementById('textoption').style.display = 'none'; 
				document.getElementById('textvariable1').style.display = 'none';
				document.getElementById('textvaleur1').style.display = 'none';
				document.getElementById('textaco').style.display = 'block';
				document.getElementById('textvariable2').style.display = 'none';
				document.getElementById('textaxosection').style.display = 'block';
				document.getElementById('textvaleur2').style.display = 'none';
				document.getElementById('textaxo').style.display = 'block';
				document.getElementById('acosection').style.display = 'block';
			}
		}
		
		function testsource() {
			if(document.adminForm.source.value == 2) {
				document.getElementById('listecomposants').style.display = 'block'; 
				document.getElementById('textoption').style.display = 'block';
				document.getElementById('textacosection').style.display = 'none';
				document.getElementById('textvariable1').style.display = '';
				document.getElementById('textvaleur1').style.display = 'block';
				document.getElementById('textaco').style.display = 'none';
				document.getElementById('textvariable2').style.display = 'block';
				document.getElementById('textaxosection').style.display = 'none';
				document.getElementById('textvaleur2').style.display = 'block';
				document.getElementById('textaxo').style.display = 'none';
				document.getElementById('acosection').style.display = 'none';
			} else {
				document.getElementById('listecomposants').style.display = 'none';
				document.getElementById('textacosection').style.display = 'block';
				document.getElementById('textoption').style.display = 'none'; 
				document.getElementById('textvariable1').style.display = 'none';
				document.getElementById('textvaleur1').style.display = 'none';
				document.getElementById('textaco').style.display = 'block';
				document.getElementById('textvariable2').style.display = 'none';
				document.getElementById('textaxosection').style.display = 'block';
				document.getElementById('textvaleur2').style.display = 'none';
				document.getElementById('textaxo').style.display = 'block'; 
				document.getElementById('acosection').style.display = 'block';
			}
		}		
		function envoie() {
			document.adminForm.acosection.value = document.adminForm.listecomposants.value;

		}
		
		function submitbutton(pressbutton) {
		
			  var form = document.adminForm;
		
			 if (pressbutton == 'cancela') {
				submitform( pressbutton );
				return;
			  }
			  // do field validation
		
			  if (form.acosection.value == "" && form.source.value == 2){
				alert( "<?php echo JText::_( 'GMA_CHOIXOPTION' );?>" );
			  } else {
				submitform( pressbutton );
			  }
			}

	</script>
    <fieldset class="adminform">
				<legend><?php echo JText::_( 'GMA_DROITS' )." : " .$row->etiquette; ?></legend>
		<table class="admintable">
				<form action="index.php" method="post" name="adminForm" id="adminForm">
                	<tr>
						<td class="key">
                            <label for="source">
                                <?php echo JText::_( 'GMA_TDROITS' ); ?> :
                            </label>
                        </td>
                        <td>
                        <?php
							$droits = array();
		$droits[] = JHTML::_( 'select.option', '0', JText::_( 'GMA_JOOMLA') );
		$droits[] = JHTML::_( 'select.option', '1', JText::_( 'GMA_SPECIF') );
		$droits[] = JHTML::_( 'select.option', '2', JText::_( 'GMA_URLCOMP') );
		
	
		$type_droits = JHTML::_( 'select.genericlist', $droits, 'source', 'size="1" class="inputbox"  onChange="testsource()"', 'value', 'text', $row->source);
		echo $type_droits;
		
		$query = 'SELECT *' .
				' FROM #__components' .
				' WHERE '.$db->NameQuote( 'option' ).' <> "com_frontpage"' .
				' AND '.$db->NameQuote( 'option' ).' <> "com_media"' .
				' AND enabled = 1' .
				' ORDER BY ordering, name';
			$db->setQuery($query);
			$comps = $db->loadObjectList(); // component list
			$subs = array(); // sub menus
			$langs = array(); // additional language files to load
			// first pass to collect sub-menu items
			foreach ($comps as $comp)
			{
				if ($comp->parent)
				{
					if (!array_key_exists($comp->parent, $subs)) {
						$subs[$comp->parent] = array ();
					}
					$subs[$comp->parent][] = $comp;
					$langs[$comp->option.'.menu'] = true;
				} elseif (trim($comp->admin_menu_link)) {
					$langs[$comp->option.'.menu'] = true;
				}
			}

			// Load additional language files
			if (array_key_exists('.menu', $langs)) {
				unset($langs['.menu']);
			}
			foreach ($langs as $lang_name => $nothing) {
				$lang->load($lang_name);
			}
				$composants = array();
				$composants[] = JHTML::_( 'select.option', '', JText::_( 'GMA_CHOIXVALOPTION' ) );
				foreach ($comps as $comp) {
					if ($comp->parent == 0 && (trim($comp->admin_menu_link) || array_key_exists($comp->id, $subs))) {
							$text = $lang->hasKey($comp->option) ? JText::_($comp->option) : $comp->name;
							$composants[] = JHTML::_( 'select.option', $comp->option, $comp->option );
					}
				}
						
		$composant = JHTML::_('select.genericlist',   $composants, 'listecomposants', 'class="inputbox" onChange="envoie()"  size="1"', 'value', 'text', $row->acosection );
		
		
						?>
							
							
						</td>
					</tr>
                    <tr>
						<td class="key">
                            <label for="etiquette">
                                <?php echo JText::_( 'GMA_ETIQUETTE' ); ?> :
                            </label>
                        </td>
                        <td>
							<textarea name="etiquette" cols="45" rows="5"><?php echo $row->etiquette;?></textarea>
							
						</td>
					</tr>
					<tr>
						<td class="key">
                            <label for="acosection">
                            <div id="textacosection"><?php echo JText::_( 'GMA_ACOS' ); ?> :</div><div id="textoption"><?php echo JText::_( 'GMA_VAROPTION' ); ?> :</div>                
                            </label>
                        </td>
                        <td>
							<?php echo $composant; ?><input class="inputbox" type="text" name="acosection" id="acosection" size="50" maxlength="100" value="<?php echo $row->acosection;?>" />
							
						</td>
					</tr>
                    <tr id="textvariable1">
						<td class="key">
                            <label for="variable">
                                <div><?php echo JText::_( 'GMA_VARURLUN' ); ?> :</div>
                            </label>
                        </td>
                        <td>
							<input class="inputbox" type="text" name="variable" size="50" maxlength="100" value="<?php echo $row->variable;?>" />
							
						</td>
					</tr>
                    <tr>
						<td class="key">
                            <label for="aco">
                            	<div id="textaco"><?php echo JText::_( 'GMA_ACO' ); ?> :</div><div id="textvaleur1"><?php echo JText::_( 'GMA_VALURLUN' ); ?> :</div>
                            </label>
                        </td>
                        <td>
							<input class="inputbox" type="text" name="aco" size="50" maxlength="100" value="<?php echo $row->aco;?>" />
							
						</td>
					</tr>
                    <tr>
						<td class="key">
                            <label for="axosection">
                            	<div id="textaxosection"><?php echo JText::_( 'GMA_AXOS' ); ?> :</div><div id="textvariable2"><?php echo JText::_( 'GMA_VARURLDEUX' ); ?> :</div>
                            </label>
                        </td>
                        <td>
							<input class="inputbox" type="text" name="axosection" size="50" maxlength="100" value="<?php echo $row->axosection;?>" />
							
						</td>
					</tr>
                    <tr>
						<td class="key">
                            <label for="axo">
                            	<div id="textaxo"><?php echo JText::_( 'GMA_AXO' ); ?> :</div><div id="textvaleur2"><?php echo JText::_( 'GMA_VALURLDEUX' ); ?> :</div>
                            </label>
                        </td>
                        <td>
							<input class="inputbox" type="text" name="axo" size="50" maxlength="100" value="<?php echo $row->axo;?>" />
							
						</td>
					</tr>
                    
                 	<input type="hidden" name="id" value="<?php echo $row->id;?>" />
                    <input type="hidden" name="option" value="com_gmaccess" />
                    
                    <input type="hidden" name="task" value="" />
                   
                </form>
             </table>
             </fieldset>
 <?php            
	}
	function showGroups( $option, &$rows, $pageNav ) 
	{ 
	  ?> 
      <style type="text/css">
	  .icon-32-adduser {	BACKGROUND-IMAGE: url(../administrator/templates/khepri/images/toolbar/icon-32-adduser.png)}
	  </style>
	  <form action="index.php" method="post" name="adminForm"> 
	  <table class="adminlist"> 
	    <thead> 
	      <tr> 
          <th width="5%"> # </th>
	        <th width="5%"> 
	          <input type="checkbox" name="toggle" 
	               value="" onclick="checkAll(<?php echo 
	               count( $rows ); ?>);" /> 
	        </th> 
	        <th class="title" width="25%"><?php echo JText::_( 'GMA_LGROUPE' ); ?></th> 
	        <th width="10%"><?php echo JText::_( 'GMA_LTYPE' ); ?></th> 
	        <th width="55%"><?php echo JText::_( 'GMA_LDESCRIPTION' ); ?></th> 
	      </tr> 
	    </thead> 
                <tfoot>
				<tr>
					<td colspan="5">
						<?php echo $pageNav->getListFooter(); ?>
					</td>
				</tr>
			</tfoot>
			<tbody>
	    <?php
		jimport('joomla.filter.output');
	    $k = 0;
	    for ($i=0, $n=count( $rows ); $i < $n; $i++) 
	    {
			$row = &$rows[$i]; 
			$checked = JHTML::_('grid.id', $i, $row->id_groupe );
			//$published = JHTML::_('grid.published', $row, $i );
			$link = JFilterOutput::ampReplace( 'index.php?option=' . $option . '&task=edit&cid[]='. $row->id_groupe );
	      ?> 
	      <tr class="<?php echo "row$k"; ?>"> 
          	<td align="center"> 
				<?php echo $pageNav->getRowOffset( $i ); ?>
			</td>
	        <td align="center"> 
	          <?php echo $checked; ?> 
	        </td> 
	        <td>
			<a href="<?php echo $link; ?>"> 
	          <?php echo $row->nom_groupe; ?></a>
	        </td> 
	        <?php
			if ($row->access_groupe == 1){ ?>
				<td align="center"><?php echo JText::_( 'GMA_LCOLL' ); ?></td>
			<?php
			}else{ ?>
				<td align="center"><?php echo JText::_( 'GMA_LINDIV' ); ?></td>
			<?php } ?>
	        <td> 
	          <?php echo $row->description_groupe; ?> 
	        </td>
	      </tr> 
	      <?php 
	      $k = 1 - $k; 
	    } 
	    ?> 
	  </table> 
	  <input type="hidden" name="option" value="<?php echo $option;?>" /> 
	  <input type="hidden" name="task" value="groupe" /> 
	  <input type="hidden" name="boxchecked" value="0" /> 
	  </form> 
	  <?php 
	}
	
	function showAccess( $option, &$rows, $pageNav, $filtre_source ) 
	{ 
	  ?> 
      <style type="text/css">
	  .icon-32-adduser {	BACKGROUND-IMAGE: url(../administrator/templates/khepri/images/toolbar/icon-32-adduser.png)}
	  </style>
	  <form action="index.php" method="post" name="adminForm"> 
      <table width="100%"><tr align="right"><td align="right">
				<?php
				echo JText::_( 'GMA_LTDROITS' )." : " . $filtre_source;
				?>
			</td></tr></table>
	  <table class="adminlist"> 
	    <thead> 
	      <tr> 
          <th width="5%"> # </th>
	        <th width="5%"> 
	          <input type="checkbox" name="toggle" 
	               value="" onclick="checkAll(<?php echo 
	               count( $rows ); ?>);" /> 
	        </th> 
	        <th class="title" width="70%"><?php echo JText::_( 'GMA_LETIQUETTE' ); ?></th> 
	        <th width="20%" align="center"><?php echo JText::_( 'GMA_LDROITS' ); ?></th> 
	       
	      </tr> 
	    </thead> 
                <tfoot>
				<tr>
					<td colspan="5">
						<?php echo $pageNav->getListFooter(); ?>
					</td>
				</tr>
			</tfoot>
			<tbody>
	    <?php
		jimport('joomla.filter.output');
	    $k = 0;
	    for ($i=0, $n=count( $rows ); $i < $n; $i++) 
	    {
			$row = &$rows[$i]; 
			$checked = JHTML::_('grid.id', $i, $row->id );
			//$published = JHTML::_('grid.published', $row, $i );
			$link = JFilterOutput::ampReplace( 'index.php?option=' . $option . '&task=editaccess&cid[]='. $row->id );
	      ?> 
	      <tr class="<?php echo "row$k"; ?>"> 
          	<td align="center"> 
				<?php echo $pageNav->getRowOffset( $i ); ?>
			</td>
	        <td align="center"> 
	          <?php echo $checked; ?> 
	        </td> 
	        <td>
			<a href="<?php echo $link; ?>"> 
	          <?php echo $row->etiquette; ?></a>
	        </td> 
	         <?php
			if ($row->source == 1){ ?>
				<td align="center"><?php echo JText::_( 'GMA_LSPECIF' ); ?></td>
             <?php
			}elseif ($row->source == 2) { ?>
            	<td align="center"><?php echo JText::_( 'GMA_LURLCOMP' ); ?></td>
            <?php
			}else{ ?>
				<td align="center"><?php echo JText::_( 'GMA_LJOOMLA' ); ?></td>
			<?php } ?>
	       
	      </tr> 
	      <?php 
	      $k = 1 - $k; 
	    } 
	    ?> 
	  </table> 
	  <input type="hidden" name="option" value="<?php echo $option;?>" /> 
	  <input type="hidden" name="task" value="gmaccess" /> 
	  <input type="hidden" name="boxchecked" value="0" /> 
	  </form> 
	  <?php 
	}
	
	function showUser( &$rows, $pageNav, $search, $option ) {
		?>
		<form action="index.php" method="post" name="adminForm">


        
		<table>
		<tr>
			<td align="left" width="100%">
				<?php echo JText::_( 'Filter' ); ?>:
				<input type="text" name="search" id="search" value="<?php echo $search;?>" class="text_area" onchange="document.adminForm.submit();" />
				<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
				<button onclick="document.getElementById('search').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
			</td>
		</tr>
		</table>
        
		<table class="adminlist">
        <thead> 
	      <tr> 
          	<th width="5%"> # </th>
	        <th width="5%"> 
	          <input type="checkbox" name="toggle" 
	               value="" onclick="checkAll(<?php echo 
	               count( $rows ); ?>);" /> 
	        </th> 
	        <th class="title" width="40%"><?php echo JText::_( 'GMA_INOM' ); ?></th> 
	        <th width="25%"><?php echo JText::_( 'GMA_IIDENTIF' ); ?></th> 
	        <th width="25%"><?php echo JText::_( 'GMA_IGROUPE' ); ?></th> 
	      </tr> 
	    </thead> 
        <tfoot>
				<tr>
					<td colspan="5">
						<?php echo $pageNav->getListFooter(); ?>
					</td>
				</tr>
		  </tfoot>
			<tbody>
        <?php
		
	    $k = 0;
	    for ($i=0, $n=count( $rows ); $i < $n; $i++) 
	    {
			$row = &$rows[$i]; 
			$checked = JHTML::_('grid.id', $i, $row->id );
			//$published = JHTML::_('grid.published', $row, $i );
			
	      ?> 
	      <tr class="<?php echo "row$k"; ?>"> 
          	 <td align="center"> 
				<?php echo $pageNav->getRowOffset( $i ); ?>
			</td>
	        <td align="center"> 
	          <?php echo $checked; ?> 
	        </td> 
	        <td>
			
	          <?php echo $row->name; ?>
	        </td> 
	      
				<td align="center">
					<?php echo $row->username; ?>
            </td>
			
	        <td> 
	          <?php echo $row->groupname; ?> 
	        </td>
	      </tr> 
	      <?php 
	      $k = 1 - $k; 
	    } 
	    ?> 
        </tbody>
	  </table> 
	


		<input type="hidden" name="option" value="<?php echo $option;?>" />
		<input type="hidden" name="task" value="individuel" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="hidemainmenu" value="0" />
		<input type="hidden" name="access_groupe" value="2" />
		</form>
		<?php
	}
	function AccessMenuGM( $option ) {
		?>
      
       <div align="center">
        <table   align="center" border="0" cellspacing="0" cellpadding="10px">
          <tr>
            <td align="center"><p>              
              <div align="left"><img src="images/cpanel.png" width="22" height="22" align="absmiddle"> <span class="contentheading"><strong><?php echo JText::_( 'GMA_MGESTION' ); ?></strong></span>&nbsp;</div>
              <table class ="adminform" >
                <tr>
                  <td align="center"><div id="cpanel">
                      <div style="float:left;">
                        <div class="icon">
                          <a href="index2.php?option=com_gmaccess&task=groupe&scope=content"> <img src="images/user.png" alt="Gestion des Groupes" align="middle" border="0" /> <span><?php echo JText::_( 'GMA_MGROUPE' ); ?></span></a>
                        </div>
                      </div>
					  <div style="float:left;">
                        <div class="icon"> <a href="index2.php?option=com_gmaccess&task=gmaccess"> <img src="images/cpanel.png" alt="Support" align="middle" border="0" /> <span><?php echo JText::_( 'GMA_MREGLES' ); ?></span> </a> </div>
                      </div>
                  </div></td>
                </tr>
              </table>
              <br>
              <div align="left">
              <img src="images/cpanel.png" width="22" height="22" align="absmiddle"> <span class="contentheading"><strong><?php echo JText::_( 'GMA_MATTRIB' ); ?> <br>
              </strong></span>
<table class="adminform">
                <tr>
                  <td align="center"><div id="cpanel">
				  	 <div style="float:left;">
                        <div class="icon"> <a href="index2.php?option=com_gmaccess&task=backend"> <img src="components/com_gmaccess/images/install.gif" alt="G&eacute;rer les acc&egrave;s globaux et administratifs" align="middle" name="" border="0" /> <span><?php echo JText::_( 'GMA_MBACK' ); ?></span> </a> </div>
                    </div>
                      <div style="float:left;">
                        <div class="icon"> <a href="index2.php?option=com_gmaccess&task=front"> <img src="components/com_gmaccess/images/html_f2.gif" alt="G&eacute;rer les acc&egrave;s et droits aux &eacute;l&eacute;ments du site" align="middle" border="0" /> <span><?php echo JText::_( 'GMA_MFRONT' ); ?></span> </a> </div>
                      </div>
					 
					  
	
                  </div></td>
                </tr>
              </table></td>
          </tr>
        </table>
		</div>
		<?php
	}

	
	function showback($option='com_gmaccess', $aro=999999) {
	
	global $mainframe;
	
	$lang		= & JFactory::getLanguage();
	$document    = &JFactory::getDocument(); 
	$livesite = JURI::base();  
    $db=& JFactory::getDBO();
	//test utilisateur gmid
	$user		= & JFactory::getUser();
	$aro = JRequest::getVar('aro', 999999);
	$row =& JTable::getInstance('gmaccess', 'table');
	if ($aro <> '999999'){
    	$row->load( $aro );
	}
	
	//echo $aro.'aro '.$row->id_groupe.'livesite = '.$livesite.'<br>'.$user->gmid;
	$document->addScript($livesite.'components/com_gmaccess/dtree/dtree.js');
	$document->addStyleSheet( $livesite.'components/com_gmaccess/dtree/dtree.css', 'text/css', null, array( 'id' => 'StyleSheet' ) );
		?>

		<script language="JavaScript" type="text/JavaScript">
		<!--

		function savescript2(aro2) {
  			
  			
			document.getElementById('aro2').value=aro2;
			//alert(document.getElementById('axosection2').value);
			//alert(document.getElementById('axo2').value);
			document.adminForm.submit();
		}


		//-->
		</script>
		<table width="98%"><tr>
		  <td><span class="contentheading"><img src="images/cpanel.png" width="22" height="22" align="absmiddle"><strong><?php echo JText::_( 'GMA_BTITRE' ); ?> </span></td>
		</tr></table>
<table width="98%" border="1" cellspacing="10px" cellpadding="10px">
  		<tr>
   		 <td width="300px" valign="top" >
		<div class="dtree">
		<p><a href="javascript: backe.openAll();"><?php echo JText::_( 'GMA_BOUVRE' ); ?></a> | <a href="javascript: backe.closeAll();"><?php echo JText::_( 'GMA_BFERME' ); ?></a></p>

			<script type="text/javascript">
		<!--

		backe = new dTree('backe');
		
		//front.config.useCookies=true;

		backe.config.closeSameLevel=false;
		

		backe.add(0,-1,'Backend','','',true);
		backe.add('groupe',0,'<?php echo JText::_( 'GMA_BGROUPES' ); ?>','','<?php echo JText::_( 'GMA_BGROUPES' ); ?>','','images/user.png','images/user.png');
		<?php 
		$db->setQuery("SELECT * FROM #__gm_groupe where id_groupe<>0 order by access_groupe,nom_groupe asc" );
   		$groupes = $db->loadObjectList();
		foreach ( $groupes as $groupe) {
			if ( $groupe->access_groupe == 1) {
				echo "backe.add('groupe".$groupe->id_groupe."','groupe',' ".addslashes($groupe->nom_groupe)."','javascript:savescript2(".$groupe->id_groupe.")','".JText::_( 'GMA_BGROUPE' )."','','images/users.png','images/users.png');";
			}else{
				echo "backe.add('groupe".$groupe->id_groupe."','groupe',' ".addslashes($groupe->nom_groupe)."','javascript:savescript2(".$groupe->id_groupe.")','".JText::_( 'GMA_BGROUPE' )."','','images/guser.gif','images/guser.gif');";			
			}
		}
		?>

		document.write(backe);
		//<?php //echo "backe.openTo('groupe".$nom."', true);"; ?>
		//front.openTo(6, true);  		$case1 	= mosCommonHTML::gmprocessback ( $acosection, $aco, $aro, $axosection, $axo, $name);

		//-->
	</script>
	
</div>

	</td>
	<td valign="top">

	<div id="accessback">
	
    <fieldset class="adminform">
	<?php
		$nom = ($row->id_groupe) ? $row->nom_groupe : JText::_( 'GMA_BCHOIX' );
		echo '<legend>'.JText::_( 'GMA_BGESTION' ).' : '.$nom.'</legend>';
	
	?>
	
	
	<form action="index2.php" method="post" name="adminForm">
	
<?php
if ($row->id_groupe) {

	// Put the tooltip script in the header
		JHTML::_( 'behavior.tooltip');

		// Get the pane object to create the tabs
		jimport('joomla.html.pane');
		$pane =& JPane::getInstance('sliders');
?>
	<?php 
		
       echo $pane->startPane("content-pane");
 
			$query4 = 'SELECT *' .
				' FROM #__gmaccess' .
				' WHERE source = 0' .
				' ORDER BY id';
			$db->setQuery($query4);
			$droits = $db->loadObjectList(); // component list
		


		if ( is_array( $droits ) && count( $droits ) > 0 ){
			//echo $pane->endPanel();
       		echo $pane->startPanel(JText::_( 'GMA_BJOOMLA' ), "Panel1");
		?>
		<table class="admintable" width="100%">
		<?php
			$htm = 0;
			foreach ($droits as $droit) {
			
							
							if ($htm) {
								$casejoom 	= fonctionGmaccess::gmprocessback ( $droit->acosection, $droit->aco, $aro, $droit->axosection, $droit->axo, 'joom'.$droit->id);?>
								<td width="40%"><?php  echo $droit->etiquette;?> :</td><td align="center" width="10%"><?php  echo $casejoom;?></td></tr>
						<?php
								$htm = 0;
							} else {
								$casejoom 	= fonctionGmaccess::gmprocessback ( $droit->acosection, $droit->aco, $aro, $droit->axosection, $droit->axo, 'joom'.$droit->id);?>
								<tr><td width="40%"><?php  echo $droit->etiquette;?> :</td><td align="center" width="10%"><?php  echo $casejoom;?></td>
						<?php 
								$htm = 1;
							}
						
					}
						if ($htm) {?>
							<td></td><td></td></tr></table>
						<?php
						} else {?>
							</table>
						<?php
						}
				
		}
	
		// Gestion des Menus Types
		require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'helper.php' );
		$menuTypes 	= MenusHelper::getMenuTypelist();
		
		if (count($menuTypes)) {
			echo $pane->endPanel();
			echo $pane->startPanel(JText::_( 'GMA_BMENUS' ), "Panel1");
			?>
		<table class="admintable" width="100%">
		<?php
			$htm = 0;
			foreach ($menuTypes as $menuType) {
				if ($htm) {
								$casemenu 	= fonctionGmaccess::gmprocessback ( 'com_menus', 'edit', $aro, 'menu', $menuType->menutype, 'menu'.$menuType->id);?>
								<td width="40%"><?php  echo $menuType->title;?> :</td><td align="center" width="10%"><?php  echo $casemenu;?></td></tr>
						<?php
								$htm = 0;
							} else {
								$casemenu 	= fonctionGmaccess::gmprocessback ( 'com_menus', 'edit', $aro, 'menu', $menuType->menutype, 'menu'.$menuType->id);?>
								<tr><td width="40%"><?php  echo $menuType->title;?> :</td><td align="center" width="10%"><?php  echo $casemenu;?></td>
						<?php 
								$htm = 1;
							}
				//$menu->addChild(new JMenuNode($menuType->title.($menuType->home ? ' *' : ''), 'index.php?option=com_menus&task=view&menutype='.$menuType->menutype, 'class:menu'));
			}
			if ($htm) {?>
							<td></td><td></td></tr></table>
						<?php
						} else {?>
							</table>
						<?php
						}
		}

		
		
		//gestion des composants
		$query = 'SELECT *' .
				' FROM #__components' .
				' WHERE '.$db->NameQuote( 'option' ).' <> "com_frontpage"' .
				' AND '.$db->NameQuote( 'option' ).' <> "com_media"' .
				' AND enabled = 1' .
				' ORDER BY ordering, name';
			$db->setQuery($query);
			$comps = $db->loadObjectList(); // component list
			$subs = array(); // sub menus
			$langs = array(); // additional language files to load
			// first pass to collect sub-menu items
			foreach ($comps as $comp)
			{
				if ($comp->parent)
				{
					if (!array_key_exists($comp->parent, $subs)) {
						$subs[$comp->parent] = array ();
					}
					$subs[$comp->parent][] = $comp;
					$langs[$comp->option.'.menu'] = true;
				} elseif (trim($comp->admin_menu_link)) {
					$langs[$comp->option.'.menu'] = true;
				}
			}

			// Load additional language files
			if (array_key_exists('.menu', $langs)) {
				unset($langs['.menu']);
			}
			foreach ($langs as $lang_name => $nothing) {
				$lang->load($lang_name);
			}


		if ( is_array( $comps ) && count( $comps ) > 0 ){
			echo $pane->endPanel();
       		echo $pane->startPanel(JText::_( 'GMA_BCOMPOSANTS' ), "Panel1");
		?>
		<table class="admintable" width="100%">
		<?php
			$htm = 0;
			foreach ($comps as $comp) {
				if ($comp->parent == 0 && (trim($comp->admin_menu_link) || array_key_exists($comp->id, $subs))) {
							$compo = str_replace("com_", "", $comp->option); 
							$text = $lang->hasKey($comp->option) ? JText::_($comp->option) : $comp->name;
							if ($htm) {
								$casecom 	= fonctionGmaccess::gmprocessback ( $comp->option, 'manage', $aro,'' ,'' , 'manage'.$compo);?>
								<td width="40%"><?php  echo $text;?> :</td><td align="center" width="10%"><?php  echo $casecom;?></td></tr>
						<?php
								$htm = 0;
							} else {
								$casecom 	= fonctionGmaccess::gmprocessback ( $comp->option, 'manage', $aro,'' ,'' , 'manage'.$compo);?>
								<tr><td width="40%"><?php  echo $text;?> :</td><td align="center" width="10%"><?php  echo $casecom;?></td>
						<?php 
								$htm = 1;
							}
						}
					}
						if ($htm) {?>
							<td></td><td></td></tr></table>
						<?php
						} else {?>
							</table>
						<?php
						}
				
		}
	

		
		
		$query3 = 'SELECT *' .
				' FROM #__gmaccess' .
				' WHERE source = 1' .
				' ORDER BY id';
			$db->setQuery($query3);
			$droits = $db->loadObjectList(); // component list
		


		if ( is_array( $droits ) && count( $droits ) > 0 ){
			echo $pane->endPanel();
       		echo $pane->startPanel(JText::_( 'GMA_BSPECIF' ), "Panel1");
		?>
		<table class="admintable" width="100%">
		<?php
			$htm = 0;
			foreach ($droits as $droit) {
			
							
							if ($htm) {
								$casespec 	= fonctionGmaccess::gmprocessback ( $droit->acosection, $droit->aco, $aro, $droit->axosection, $droit->axo, 'spec'.$droit->id);?>
								<td width="40%"><?php  echo $droit->etiquette;?> :</td><td align="center" width="10%"><?php  echo $casespec;?></td></tr>
						<?php
								$htm = 0;
							} else {
								$casespec 	= fonctionGmaccess::gmprocessback ( $droit->acosection, $droit->aco, $aro, $droit->axosection, $droit->axo, 'spec'.$droit->id);?>
								<tr><td width="40%"><?php  echo $droit->etiquette;?> :</td><td align="center" width="10%"><?php  echo $casespec;?></td>
						<?php 
								$htm = 1;
							}
						
					}
						if ($htm) {?>
							<td></td><td></td></tr></table>
						<?php
						} else {?>
							</table>
						<?php
						}
				
		}
	
 		echo $pane->endPanel();
       echo $pane->endPane();	
}else{
?>

<table class="admintable" width="100%">
<tr><td><?php echo JText::_( 'GMA_BAIDE' ); ?></td><td></td><td></td><td></td></tr></table>
<?php


}
?>
		<input type="checkbox" name="change" id="change" style="display:none;" class="inputbox" value="1" />
		
	
	  <input type="hidden" name="option" value="com_gmaccess" />
	  <input type="hidden" name="task" value="saveback" />
	  <input type="hidden" name="aro" value="<?php echo $row->id_groupe;?>" />
	  <input type="hidden" name="aro2" id="aro2" value="<?php echo $row->id_groupe;?>" />
	</form>
	</fieldset>
	</div>
	</td>
  </tr>
</table>
	<?php 
	}
// affichage accès frontend

	function showfront($option='com_gmaccess', $axosection='item', $axo=1, $redirection=0, $sectiontype='content') {
	
	global $mainframe;
	
	$lang		= & JFactory::getLanguage();
	$document    = &JFactory::getDocument(); 
	$livesite = JURI::base();  
    $db=& JFactory::getDBO();
	//test utilisateur gmid
	$user		= & JFactory::getUser();
	//$aro = JRequest::getVar('aro', 999999);
	//$row =& JTable::getInstance('gmaccess', 'table');
	
	
	$axosection = JRequest::getVar('axosection', '');
	$axo = JRequest::getVar('axo', 0);
	$sectiontype = JRequest::getVar('sectiontype', 0);
	$redirection = JRequest::getVar('redirection', 0);

	$red = ($redirection) ? 'style="display:none;"' : '';
	$red2 = ($redirection) ? '' : 'style="display:none;"';
	$db->setQuery("SELECT *" . "\nFROM #__sections"  
        	
       	 	);
   	$sections = $db->loadObjectList();

	switch ( $axosection ) {
		case 'item':
			if ($axo) {
				$row =& JTable::getInstance('content');
				$row->load( $axo );
				/*$accessgm1 = checkgmaccess( 'action', 'right', 'users', $my->gmid, 'item', $row->id);
				$accessgm2 = checkgmaccess( 'action', 'right', 'users', $my->gmid, 'category', $row->catid);
				$accessgm3 = checkgmaccess( 'action', 'right', 'users', $my->gmid, 'section', $row->sectionid);
				if (!($acl->acl_check( 'action', 'right', 'users', $my->usertype, 'content', 'all' ) || $acl->gmacl_check( 'action', 'right', 'users', $my->gmid, 'section', 'all' ) || $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'com_gmaccess' ) | $accessgm1 | $accessgm2 | $accessgm3 )) {
					mosRedirect( 'index2.php', _NOT_AUTH );
				}*/
				$access = fonctionGmaccess::TabGmaccess( $row, $axosection, 1, 0, 0, 1, 0, 1, 0, 1, 1 );
				
				}
			break;

		case 'category':
			if ($axo) {
				$row =& JTable::getInstance('category');
				$row->load( $axo );
				
				if ($sectiontype == 'content') {
					/*if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'category', 'all' ) )) {	
								mosRedirect( 'index2.php', _NOT_AUTH );
					}*/
					$access = fonctionGmaccess::TabGmaccess( $row, $axosection, 1, 1, 1, 1, 1, 1, 1, 1, 1 );
					
				}else{
					$access = fonctionGmaccess::TabGmaccess( $row, $axosection, 1, 0, 0, 0, 0, 0, 0, 0, 0, 99999, 1, 1 );
					
				}
				}
			break;
		case 'section':
			if ($axo) {
				$row =& JTable::getInstance('section');
				$row->load( $axo );
				/*if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'section', 'all' ) )) {	
								mosRedirect( 'index2.php', _NOT_AUTH );
				}*/
				$access = fonctionGmaccess::TabGmaccess( $row, $axosection, 1, 1, 1, 1, 1, 1, 1, 1, 1 );
				
				}
			break;
		case 'content':
			if ($axo) {
				$row =& JTable::getInstance('section');
				$row->load( $axo );
				/*if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'section', 'all' ) )) {	
								mosRedirect( 'index2.php', _NOT_AUTH );
				}*/
				$access = fonctionGmaccess::TabGmaccess( $row, $axosection, 0, 1, 1, 1, 1, 1, 1, 1, 1 );
				
				}
			break;
		case 'module':
			if ($axo) {
				$row =& JTable::getInstance('module');
				$row->load( $axo );
				/*if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'modules', 'all' ) )) {	
								mosRedirect( 'index2.php', _NOT_AUTH );
				}*/
				$access = fonctionGmaccess::TabGmaccess( $row, $axosection, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
				
				}
			break;
		case 'menu':
			if ($axo) {
				$row =& JTable::getInstance('menu');
				$row->load( $axo );
				/*if (!($acl->acl_check( 'administration', 'manage', 'users', $my->usertype, 'components', 'com_menu' ) )) {	
								mosRedirect( 'index2.php', _NOT_AUTH );
				}*/
				$access = fonctionGmaccess::TabGmaccess( $row, $axosection, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
			
				}
			break;
		case 'plugin':
			if ($axo) {
				$row =& JTable::getInstance('plugin');
				$row->load( $axo );
				/*if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'mambots', 'all' ) )) {	
								mosRedirect( 'index2.php', _NOT_AUTH );
				}*/
				$access = fonctionGmaccess::TabGmaccess( $row, $axosection, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
				
				}
			break;
		case 'component':
			if ($axo) {
				$row =& JTable::getInstance('component');
				$row->load( $axo );
				/*if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'mambots', 'all' ) )) {	
								mosRedirect( 'index2.php', _NOT_AUTH );
				}*/
				$access = fonctionGmaccess::TabGmaccess( $row, $axosection, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
				
				}
			break;
		case 'componenturl':
			if ($axo) {
				$query = "SELECT * FROM #__gmaccess WHERE id = ".$axo; 
				$db->setQuery( $query);
	
				$row = $db->loadObject(); 
				$access = fonctionGmaccess::TabGmaccess( $row, $axosection, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
				
				}
			break;
		case 'contact':
			if ($axo) {
				$query = "SELECT * FROM #__contact_details WHERE id = ".$axo; 
				$db->setQuery( $query);
	
				$row = $db->loadObject(); 
				/*if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'mambots', 'all' ) )) {	
								mosRedirect( 'index2.php', _NOT_AUTH );
				}*/
				$access = fonctionGmaccess::TabGmaccess( $row, $axosection, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
				
				}
			break;
		default:
			$access=JText::_( 'GMA_FCHOIX' );
			break;
	}
	
	$document->addScript($livesite.'components/com_gmaccess/dtree/dtree.js');
	//$document->addScript($livesite.'components/com_gmaccess/js/gmaccess.javascript.js');
	$document->addStyleSheet( $livesite.'components/com_gmaccess/dtree/dtree.css', 'text/css', null, array( 'id' => 'StyleSheet' ) );
	?>
	
	
		<script language="JavaScript" type="text/JavaScript">
		<!--

		function savescript(axosection2,axo2) {
  			
  			document.getElementById('axosection2').value=axosection2;
			document.getElementById('axo2').value=axo2;
			//alert(document.getElementById('axosection2').value);
			//alert(document.getElementById('axo2').value);
			document.adminForm.submit();
		}


		//-->
		</script>
		<table width="98%"><tr><td><span class="contentheading"><img src="images/cpanel.png" width="22" height="22" align="absmiddle"><strong><?php echo JText::_( 'GMA_FTITRE' ); ?> </span></td><td <?php echo $red2;?> align="right"><BUTTON onclick="javascript: document.adminForm.submit();"><?php echo JText::_( 'GMA_FSAUVE' ); ?></BUTTON></td></tr></table>
<table width="98%" border="1" cellspacing="10px" cellpadding="10px">
  		<tr>
   		 <td width="300px" valign="top" <?php echo $red;?>>
		<div class="dtree">
		<p><a href="javascript: front.openAll();"><?php echo JText::_( 'GMA_FOUVRE' ); ?></a> | <a href="javascript: front.closeAll();"><?php echo JText::_( 'GMA_FFERME' ); ?></a></p>

			<script type="text/javascript">
		<!--

		front = new dTree('front');
		
		//front.config.useCookies=true;

		front.config.closeSameLevel=false;
		

		front.add(0,-1,'Frontend','','',true);
		
		<?php 
		//front.add('section',0,'Articles');
		echo "front.add('contentall',0,'".JText::_( 'GMA_FARTICLES' )."','javascript:savescript(\'content\',\'all\')','".JText::_( 'GMA_FTARTICLES' )."','','images/folder.gif','images/folderopen.gif');";
		foreach ( $sections as $section) {
			echo "front.add('section".$section->id."','contentall','".addslashes($section->title)." (".addslashes($section->alias).")','javascript:savescript(\'section\',".$section->id.")','".JText::_( 'GMA_FSECTION' )."','','images/folderblue.gif','images/folderopenblue.gif');";
			
			$db->setQuery("SELECT * FROM #__categories where section=$section->id" );
   			$categories = $db->loadObjectList();
			foreach ( $categories as $category) {
				echo "front.add('category".$category->id."','section".$category->section."','".addslashes($category->title)." (".addslashes($category->alias).")','javascript:savescript(\'category\',".$category->id.")','".JText::_( 'GMA_FCATEGORIE' )."','','images/folderred.gif','images/folderopenred.gif');";
				
				$db->setQuery("SELECT * FROM #__content where catid=$category->id" );
   				$contents = $db->loadObjectList();
				foreach ( $contents as $content) {
					echo "front.add('item".$content->id."','category".$content->catid."','".addslashes($content->title)."','javascript:savescript(\'item\',".$content->id.")','".JText::_( 'GMA_FARTICLE' )."');";
					
				}
			}
			
		} 
		$db->setQuery("SELECT * FROM #__content where catid=0 and sectionid=0" );
   				$contents = $db->loadObjectList();
				foreach ( $contents as $content ) {
					echo "front.add('item".$content->id."','contentall','".addslashes($content->title)."','javascript:savescript(\'item\',".$content->id.")','".JText::_( 'GMA_FSTATIQUE' )."');";
				}
		?>
		front.add('module',0,'<?php echo JText::_( 'GMA_FMODULES' ); ?>');
		<?php 
		$db->setQuery("SELECT * FROM #__modules where access<99 and client_id=0 order by module asc " );
   				$modules = $db->loadObjectList();
		foreach ($modules as $module) {
			$test = urlencode( $module->title );
			$test = str_replace('+',' ', $test);
			$mod_params = new JParameter( $module->params );
			$typemenu = $mod_params->get('menutype', 0);
			
			if ($module->module =='mod_mainmenu') {
				echo "front.add('module".$module->id."','module','".addslashes(urldecode($test))."','javascript:savescript(\'module\',".$module->id.")','".JText::_( 'GMA_FMODMENU' )."','','images/folderred.gif','images/folderopenred.gif');";
				$db->setQuery("SELECT * FROM #__menu where menutype='$typemenu' order by ordering asc " );
   				$menus = $db->loadObjectList();
				foreach ($menus as $menu) {
					echo "front.add('menu".$menu->id."','module".$module->id."','".addslashes($menu->name)."','javascript:savescript(\'menu\',".$menu->id.")','".JText::_( 'GMA_FMENU' )."');";		
				}
			}else{
				echo "front.add('module".$module->id."','module','".addslashes(urldecode($test))."','javascript:savescript(\'module\',".$module->id.")','".JText::_( 'GMA_FMODULE' )."');";		
			}
		}  
		?>
		
				front.add('plugin',0,'<?php echo JText::_( 'GMA_FPLUGINS' ); ?>');
		<?php
		$db->setQuery("SELECT * FROM #__plugins order by folder asc" );
   				$plugins = $db->loadObjectList();
				foreach ( $plugins as $plugin ) {
					echo "front.add('plugin".$plugin->id."','plugin','".addslashes($plugin->name)."','javascript:savescript(\'plugin\',".$plugin->id.")','".JText::_( 'GMA_FPLUGIN' )."');";
				}
				
		?>
		front.add('component',0,'<?php echo JText::_( 'GMA_FCOMPS' ); ?>');
		<?php
		$query = 'SELECT *' .
				' FROM #__components' .
				' WHERE '.$db->NameQuote( 'option' ).' <> "com_frontpage"' .
				' AND '.$db->NameQuote( 'option' ).' <> "com_media"' .
				' AND enabled = 1' .
				' ORDER BY ordering, name';
			$db->setQuery($query);
			$comps = $db->loadObjectList(); // component list
			$subs = array(); // sub menus
			$langs = array(); // additional language files to load
			// first pass to collect sub-menu items
			foreach ($comps as $comp)
			{
				if ($comp->parent)
				{
					if (!array_key_exists($comp->parent, $subs)) {
						$subs[$comp->parent] = array ();
					}
					$subs[$comp->parent][] = $comp;
					$langs[$comp->option.'.menu'] = true;
				} elseif (trim($comp->admin_menu_link)) {
					$langs[$comp->option.'.menu'] = true;
				}
			}

			// Load additional language files
			if (array_key_exists('.menu', $langs)) {
				unset($langs['.menu']);
			}
			foreach ($langs as $lang_name => $nothing) {
				$lang->load($lang_name);
			}

				foreach ($comps as $comp) {
					if ($comp->parent == 0 && (trim($comp->admin_menu_link) || array_key_exists($comp->id, $subs))) {
							//$compo = str_replace("com_", "", $comp->option); 
							$text = $lang->hasKey($comp->option) ? JText::_($comp->option) : $comp->name;
							echo "front.add('component".$comp->id."','component','".addslashes($text)."','javascript:savescript(\'component\',".$comp->id.")','".JText::_( 'GMA_FCOMP' )."','','images/folderred.gif','images/folderopenred.gif');";
							
							//ajout sous-menu composants
							$db->setQuery("SELECT count(*) FROM #__gmaccess where acosection='".$comp->option."' and source=2 order by id asc " );
							$total = $db->loadResult();
							if ($total) {
								$db->setQuery("SELECT * FROM #__gmaccess where acosection='$comp->option' order by id asc " );
   								$compsurl = $db->loadObjectList();
								foreach ($compsurl as $compurl) {
									echo "front.add('componenturl".$compurl->id."','component".$comp->id."','".addslashes($compurl->etiquette)."','javascript:savescript(\'componenturl\',".$compurl->id.")','".JText::_( 'GMA_FURLCOMP' )."');";
								}
							}
					}
				}

		?>
		
		document.write(front);
		<?php echo "front.openTo('".$axosection."".$axo."', true);"; ?>
		//front.openTo(6, true);

		//-->
	</script>

</div>

	</td>
	<td valign="top">
	<div id="access">
	
    <fieldset class="adminform">
	<?php
	if ($axosection=='section'){
		echo '<legend>'.JText::_( 'GMA_FSECTION' ).' : '.$row->title.' ('.$row->alias.')</legend>';
	}elseif ($axosection=='category'){
		 echo '<legend>'.JText::_( 'GMA_FCATEGORIE' ).' : '.$row->title.' ('.$row->alias.')</legend>';
	}elseif ($axosection=='item'){
		echo '<legend>'.JText::_( 'GMA_FARTICLE' ).' : '.$row->title.'</legend>';
	}elseif ($axosection=='content'){
		echo '<legend>'.JText::_( 'GMA_FTARTICLES' ).'</legend>';
	}elseif ($axosection=='module'){
		echo '<legend>'.JText::_( 'GMA_FMODULE' ).' : '.$row->title.'</legend>';
	}elseif ($axosection=='menu'){
		echo '<legend>'.JText::_( 'GMA_FMENU' ).' : '.$row->name.'</legend>';
	}elseif ($axosection=='plugin'){
		echo '<legend>'.JText::_( 'GMA_FPLUGIN' ).' : '.$row->name.'</legend>';
	}elseif ($axosection=='component'){
		echo '<legend>'.JText::_( 'GMA_FCOMP' ).' : '.$row->name.'</legend>';
	}elseif ($axosection=='contact'){
		echo '<legend>'.JText::_( 'GMA_FCONTACT' ).' : '.$row->name.'</legend>';
	}elseif ($axosection=='componenturl'){
		echo '<legend>'.JText::_( 'GMA_FURLCOMP' ).' : '.$row->etiquette.'</legend>';
	}else{
		echo '<legend>'.JText::_( 'GMA_FAIDE' ).'</legend>';
	}
	?>
	
	
	<form action="index2.php" method="post" name="adminForm">
		<?php echo $access;?>
	  <input type="hidden" name="option" value="com_gmaccess" />
	  <input type="hidden" name="task" value="savefront" />
	  <input type="hidden" name="redirection" value="<?php echo $redirection;?>" />
	   <input type="hidden" name="sectiontype" value="<?php echo $sectiontype;?>" />
	  <input type="hidden" name="axosection" value="<?php echo $axosection;?>" />
	  <input type="hidden" name="axo" value="<?php echo $row->id;?>" />
	  <input type="hidden" name="axosection2" id="axosection2" value="<?php echo $axosection;?>" />
	  <input type="hidden" name="axo2" id="axo2" value="<?php echo $row->id;?>" />
	</form>
    </fieldset>
	</div>
	</td>
  </tr>
</table>
	<?php 
	}
	
//fin de class	
}
?>