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

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

[Event Cats] PNG, JS, TPL and CSS normally finished now. Remains "only" PHP and SQL...

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