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