source: extensions/event_cats/event_cats/include/ec_conf.inc.php @ 3956

Last change on this file since 3956 was 3956, checked in by LucMorizur, 11 years ago

[event cats] First commit, with files this time

File size: 3.8 KB
Line 
1<?php
2
3// +-----------------------------------------------------------------------+
4// | Piwigo - a PHP based picture gallery                                  |
5// +-----------------------------------------------------------------------+
6// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
7// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
8// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
9// +-----------------------------------------------------------------------+
10// | This program is free software; you can redistribute it and/or modify  |
11// | it under the terms of the GNU General Public License as published by  |
12// | the Free Software Foundation                                          |
13// |                                                                       |
14// | This program is distributed in the hope that it will be useful, but   |
15// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
16// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
17// | General Public License for more details.                              |
18// |                                                                       |
19// | You should have received a copy of the GNU General Public License     |
20// | along with this program; if not, write to the Free Software           |
21// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
22// | USA.                                                                  |
23// +-----------------------------------------------------------------------+
24
25/*****************************************************************************
26Parameters ($ec_conf) :
27 _ plugin activated ($ec_conf[0]) yes/no ;
28 _ duplication allowance ($ec_conf[1]) :
29   0 : no account ;
30   1 : all accounts ;
31   2 : no account but those specified ;    \
32   3 : all accounts but those specified.   | could be different finally
33 _ what to do in case an unknown code is used with "autolog" parameter
34   ($ec_conf[2]) :
35   0 : nothing ("goto" home page, index.php (not logged in of course)) ;
36   1 : redirected to "access denied" page ;
37   2 : redirected to an Additional Page precised below.
38 _ the id of the Additional Page which must be used in case of usage of an
39   unknow code ($ec_conf[3]).
40*****************************************************************************/
41
42global $ec_conf;
43
44// $ec_conf initalization / check
45if ($t = mysql_fetch_row(pwg_query("
46 SELECT `value`
47 FROM `".CONFIG_TABLE."`
48 WHERE `param` = 'event_cats';
49"))) {
50  $ec_conf = explode(',' , $t[0]);
51}
52else {
53  $ec_conf = explode(',' , '0,1,0,0');
54  change_ec_conf('activated', 0);
55}
56
57/*
58 * change_ec_conf($c, $v)
59 * updates Event Cats configuration values in the database as well as in
60 * $ec_conf.
61 *
62 * @param
63 *   $c : conf value to update ;
64 *   $v : value to give to $ec_conf[$c].
65 * @return
66 *   true or false whether the change was OK or not
67 */
68function change_ec_conf($c, $v) {
69  global $ec_conf;
70  switch ($c) {
71    case 'activated':
72      $d = 0;
73    break;
74    case 'dup_allow':
75      $d = 1;
76    break;
77    case 'unknown_code':
78      $d = 2;
79    break;
80    case 'unknown_code_ap_id':
81      $d = 3;
82    break;
83    default: return false;
84  }
85  $ec_conf[$d] = $v;
86  return pwg_query("
87   UPDATE `".CONFIG_TABLE."`
88   SET `value` = '".implode(',', $ec_conf)."'
89   WHERE `param` = 'event_cats';
90  ");
91}
92
93/*
94 * read_ec_conf($c)
95 * returns the value in $ec_conf using string keys.
96 *
97 * @param
98 *   $c : conf value to update ;
99 * @return
100 *   $ec_conf value
101 */
102function read_ec_conf($c) {
103  global $ec_conf;
104  switch ($c) {
105    case 'activated':
106      return $d[0];
107    break;
108    case 'dup_allow':
109      return $d[1];
110    break;
111    case 'unknown_code':
112      return $d[2];
113    break;
114    case 'unknown_code_ap_id':
115      return $d[3];
116    break;
117    default: return false;
118  }
119}
120
121?>
Note: See TracBrowser for help on using the repository browser.