noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
ajax_bookmark.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  *   This file is part of NOALYSS.
00005  *
00006  *   NOALYSS is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   NOALYSS is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with NOALYSS; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00022 
00023 /**
00024  * @file
00025  * @brief user's bookmark
00026  */
00027 if ( ! defined ('ALLOWED')) die('Appel direct ne sont pas permis');
00028 echo HtmlInput::title_box(_("Favoris"), "bookmark_div");
00029 if (! isset($_GET['ac'])) {
00030     /*
00031      * find default module
00032      */
00033     $_GET['ac']= find_default_module();
00034 }
00035 // Add bookmark
00036 if (isset($_GET['bookmark_add'])){
00037     $count=$cn->get_value("select count(*) from bookmark"
00038             . " where b_action=$1 and login=$2",
00039             array($_GET['ac'],$g_user->login)
00040             );
00041     // Add bookmark only if absent
00042     if ( $count == 0 ){
00043         $cn->exec_sql("insert into bookmark(b_action,login) values($1,$2)",
00044             array($_GET['ac'],$g_user->login));
00045     } else {
00046         $js="error_message('"._("Ce favori a déjà été ajouté")."');";
00047         echo create_script($js);
00048     }     
00049 }
00050 // remove bookmark
00051 if (isset($_GET['bookmark_delete']) && isset ($_GET['book'])){
00052     $a_book=$_GET['book'];
00053     for ($e=0;$e<count($a_book);$e++)
00054     {
00055         $cn->exec_sql("delete from bookmark where b_id=$1 and login=$2",
00056             array($a_book[$e],$g_user->login));
00057     }
00058 }
00059 
00060 $bookmark_sql="select distinct b_id,b_action,b_order,me_description, javascript"
00061         . " from bookmark "
00062         . "join v_menu_description_favori on (code=b_action)"
00063         . "where "
00064         . "login=$1 order by b_order,b_action";
00065 $a_bookmark=$cn->get_array($bookmark_sql,array($g_user->login));
00066 $url="do.php?gDossier=".Dossier::id()."&ac=";
00067 ?>
00068 <div class="content">
00069 <form id="bookmark_del_frm" method="get" onsubmit="remove_bookmark();return false">
00070 <?php    echo HtmlInput::array_to_hidden(array("gDossier",'ac'), $_REQUEST); ?>
00071 
00072     <table class="result">
00073         <?php for ($i=0;$i<count($a_bookmark);$i++): ?>
00074         <?php
00075         /*
00076          * Display only the last ac
00077          */
00078         $a_code=  explode('/',$a_bookmark[$i]['b_action']);
00079         $idx=count($a_code);
00080         $code=$a_code[$idx-1];
00081         ?>
00082         <tr class="<?php echo (($i%2)==0?'odd':'even')?>">
00083             <td>
00084                 <?php
00085                     $ch=new ICheckBox('book[]');
00086                     $ch->value=$a_bookmark[$i]['b_id'];
00087                     echo $ch->input();
00088                 ?>
00089             </td>
00090             <td>
00091                 <a class='mtitle' style='text-decoration: underline' href="<?php echo $url."&ac=".$a_bookmark[$i]['b_action']; ?>">
00092                 <?php echo $code  ?>
00093                 </a>
00094             </td>
00095             <td>
00096                 <?php echo $a_bookmark[$i]['me_description'] ?>
00097             </td>
00098         </tr>
00099         <?php endfor; ?>
00100     </table>
00101 <?php
00102 if ( count($a_bookmark) > 0) :
00103     echo HtmlInput::submit("bookmark_delete",_("Supprimez favoris sélectionnés"),"","smallbutton"); 
00104 endif;
00105     ?>
00106 </form>
00107 <form id="bookmark_frm" method="get" onsubmit="save_bookmark();return false">
00108 <?php
00109 echo _("Menu actuel")." : ".hb($_GET['ac']);
00110 echo HtmlInput::array_to_hidden(array("gDossier","ac"), $_REQUEST); 
00111 ?>
00112 <p>
00113 <?php echo HtmlInput::submit("bookmark_add", _("Ajoutez le menu  actuel à vos favoris"),"","smallbutton"); ?>
00114 </form>
00115 
00116 
00117 </div>
 All Data Structures Namespaces Files Functions Variables Enumerations