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

Last change on this file since 4027 was 4027, checked in by LucMorizur, 15 years ago

[Event Cats] Modify template/autolog_new.tpl

File size: 4.2 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] <=> read_ec_conf('activated')) yes/no ;
28 _ duplication allowance ($ec_conf[1] <=> read_ec_conf('dup_allow')) :
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 _ the number of digits when creating a new code automatically
34   ($ec_conf[2] <=> read_ec_conf('auto_code_dg_nb')) ;
35 _ what to do in case an unknown code is used with "autolog" parameter
36   ($ec_conf[3] <=> read_ec_conf('unknown_code')) :
37   0 : nothing ("goto" home page, index.php (not logged in of course)) ;
38   1 : redirected to "access denied" page ;
39   2 : redirected to an Additional Page precised below.
40 _ the id of the Additional Page which must be used in case of usage of an
41   unknow code ($ec_conf[4] <=> read_ec_conf('unknown_code_ap_id')).
42*****************************************************************************/
43
44global $ec_conf;
45
46// $ec_conf initalization / check
47if ($t = mysql_fetch_row(pwg_query("
48 SELECT `value`
49 FROM `".CONFIG_TABLE."`
50 WHERE `param` = 'event_cats';
51"))) {
52  $ec_conf = explode(',' , $t[0]);
53}
54else {
55  $ec_conf = explode(',' , '0,1,10,0,0');
56  change_ec_conf('activated', 0);
57}
58
59/*
60 * change_ec_conf($c, $v)
61 * updates Event Cats configuration values in the database as well as in
62 * $ec_conf.
63 *
64 * @param
65 *   $c : conf value to update ;
66 *   $v : value to give to $ec_conf[$c].
67 * @return
68 *   true or false whether the change was OK or not
69 */
70function change_ec_conf($c, $v) {
71  global $ec_conf;
72  switch ($c) {
73    case 'activated':
74      $ec_conf[0] = $v;
75    break;
76    case 'dup_allow':
77      $ec_conf[1] = $v;
78    break;
79    case 'auto_code_dg_nb':
80      $ec_conf[2] = $v;
81    break;
82    case 'unknown_code':
83      $ec_conf[3] = $v;
84    break;
85    case 'unknown_code_ap_id':
86      $ec_conf[4] = $v;
87    break;
88    default: return false;
89  }
90  return pwg_query("
91   UPDATE `".CONFIG_TABLE."`
92   SET `value` = '".implode(',', $ec_conf)."'
93   WHERE `param` = 'event_cats';
94  ");
95}
96
97/*
98 * read_ec_conf($c)
99 * returns the value in $ec_conf using string keys.
100 *
101 * @param
102 *   $c : conf value to update ;
103 * @return
104 *   $ec_conf value
105 */
106function read_ec_conf($c) {
107  global $ec_conf;
108  switch ($c) {
109    case 'activated'         : return $ec_conf[0];
110    case 'dup_allow'         : return $ec_conf[1];
111    case 'auto_code_dg_nb'   : return $ec_conf[2];
112    case 'unknown_code'      : return $ec_conf[3];
113    case 'unknown_code_ap_id': return $ec_conf[4];
114    default                  : return false;
115  }
116}
117
118?>
Note: See TracBrowser for help on using the repository browser.