noalyss Version-9
ajax_tag_set_group.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta 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 * PhpCompta 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 PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
21
22if (!defined('ALLOWED'))
23 die('Appel direct ne sont pas permis');
24
25
26/**
27 * @file
28 * @brief
29 */
30global $g_user;
31$g_user->can_request('CFGTAG');
32
33/*
34 * Received parameter
35 * gDossier
36 * act : action to perform
37 * tag_group : tag_group.tg_id
38 * tag=tags.t_id
39 *
40 */
41try
42{
43 $act=$http->request("act");
44}
45catch (Exception $e)
46{
47
48 record_log(__FILE__.$e->getMessage()." ".$e->getTraceAsString());
49 echo $e->getMessage()." ".$e->getTraceAsString();
50}
51$obj=new Tag_Group_SQL($cn);
53$obj_manage->set_callback("ajax_misc.php");
54$obj_manage->add_json_param("op", "tag_group");
55if ($act=="add")
56{
57 $tag_group_id=$http->request("tag_group");
58 $tag=$http->request("tag");
59 $obj_manage->set_pk($tag_group_id);
60 // add tag to group tag
61 // protect against duplicate
62 if ($cn->get_value("select count (*) from jnt_tag_group_tag where tag_id = $1 and tag_group_id = $2",
63 [$tag, $tag_group_id])==0)
64 {
65 $cn->exec_sql("insert into jnt_tag_group_tag(tag_id,tag_group_id) values ($1,$2)", [$tag, $tag_group_id]);
66 }
67}
68elseif ($act=="remove")
69{
70 $tag=$http->request("jt_tag");
71 $tag_group_id=$cn->get_value("select tag_group_id from jnt_tag_group_tag where jt_id = $1",[$tag]);
72 $obj_manage->set_pk($tag_group_id);
73 // remove tag from tag_group
74 $cn->exec_sql("delete from jnt_tag_group_tag where jt_id=$1", [$tag]);
75}
76$obj_manage->input_tag();
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
global $g_user
catch(Exception $e) $obj
manage tag_group table
if( $delta< 0) elseif( $delta==0)