noalyss Version-9
ajax_bookmark.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright Author Dany De Bontridder danydb@aevalys.eu
22
23/**
24 * @file
25 * @brief user's bookmark
26 */
27if ( ! defined ('ALLOWED')) die('Appel direct ne sont pas permis');
28echo HtmlInput::title_box(_("Favoris"), "bookmark_div");
29if (! isset($_GET['ac'])) {
30 /*
31 * find default module
32 */
34}
35// Add bookmark
36if (isset($_GET['bookmark_add'])){
37 $count=$cn->get_value("select count(*) from bookmark"
38 . " where b_action=$1 and login=$2",
39 array($_GET['ac'],$g_user->login)
40 );
41 // Add bookmark only if absent
42 if ( $count == 0 ){
43 $cn->exec_sql("insert into bookmark(b_action,login) values($1,$2)",
44 array($_GET['ac'],$g_user->login));
45 } else {
46 $js="error_message('"._("Ce favori a déjà été ajouté")."');";
47 echo create_script($js);
48 }
49}
50// remove bookmark
51if (isset($_GET['bookmark_delete']) && isset ($_GET['book'])){
52 $a_book=$_GET['book'];
53 for ($e=0;$e<count($a_book);$e++)
54 {
55 $cn->exec_sql("delete from bookmark where b_id=$1 and login=$2",
56 array($a_book[$e],$g_user->login));
57 }
58}
59
60$bookmark_sql="select distinct b_id,b_action,b_order,me_code,me_description, javascript"
61 . " from bookmark "
62 . "join v_menu_description_favori on (code=b_action or b_action=me_code)"
63 . "where "
64 . "login=$1 order by me_code";
65$a_bookmark=$cn->get_array($bookmark_sql,array($g_user->login));
66$url="do.php?gDossier=".Dossier::id()."&ac=";
67?>
68<div class="content">
69<form id="bookmark_del_frm" method="get" onsubmit="remove_bookmark();return false">
70<?php echo HtmlInput::array_to_hidden(array("gDossier",'ac'), $_REQUEST); ?>
71
72 <table class="result">
73 <?php for ($i=0;$i<count($a_bookmark);$i++): ?>
74 <?php
75 /*
76 * Display only the last ac
77 */
78 $a_code= explode('/',$a_bookmark[$i]['b_action']);
79 $idx=count($a_code);
80 $code=$a_code[$idx-1];
81 ?>
82 <tr class="<?php echo (($i%2)==0?'odd':'even')?>">
83 <td>
84 <?php
85 $ch=new ICheckBox('book[]');
86 $ch->value=$a_bookmark[$i]['b_id'];
87 echo $ch->input();
88 ?>
89 </td>
90 <td>
91 <a class='mtitle' style='text-decoration: underline' href="<?php echo $url."&ac=".$a_bookmark[$i]['b_action']; ?>">
92 <?php echo $code ?>
93 </a>
94 </td>
95 <td>
96 <?php echo $a_bookmark[$i]['me_description'] ?>
97 </td>
98 </tr>
99 <?php endfor; ?>
100 </table>
101<?php
102if ( count($a_bookmark) > 0) :
103 echo HtmlInput::submit("bookmark_delete",_("Supprimez favoris sélectionnés"),"","smallbutton");
105 ?>
106</form>
107<form id="bookmark_frm" method="get" onsubmit="save_bookmark();return false">
108<?php
109echo _("Menu actuel")." : ".hb($_GET['ac']);
110echo HtmlInput::array_to_hidden(array("gDossier","ac"), $_REQUEST);
111?>
112<p>
113<?php echo HtmlInput::submit("bookmark_add", _("Ajoutez le menu actuel à vos favoris"),"","smallbutton"); ?>
114</form>
115
116
117</div>
hb($p_string)
Definition: ac_common.php:53
find_default_module()
Definition: ac_common.php:991
tr($p_string, $p_extra='')
Definition: ac_common.php:88
p($p_string)
Definition: ac_common.php:39
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
global $g_user
if no group available , then stop
$idx
if(! isset($_GET['ac'])) if(isset( $_GET[ 'bookmark_add'])) if(isset($_GET['bookmark_delete']) &&isset($_GET['book'])) $bookmark_sql
$code
$a_bookmark
$url
$opd_description style
$_REQUEST['ac']
$_GET['qcode']
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
static array_to_hidden($array, $global_array)
transform request data to hidden
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Html Input.
$all table
$count
create_script($p_string)
create the HTML for adding the script tags around of the script
endfor