Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
/*************************
3
  Coppermine Photo Gallery
4
  ************************
5
  Copyright (c) 2003-2005 Coppermine Dev Team
6
  v1.1 originaly written by Gregory DEMAR
7
 
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
  ********************************************
13
  Coppermine version: 1.3.3
14
  $Source: /cvsroot/coppermine/stable/groupmgr.php,v $
15
  $Revision: 1.7 $
16
  $Author: gaugau $
17
  $Date: 2005/04/19 03:17:10 $
18
**********************************************/
19
 
20
define('IN_COPPERMINE', true);
21
define('GROUPMGR_PHP', true);
22
 
23
require('include/init.inc.php');
24
 
25
if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
26
 
27
if (defined('UDB_INTEGRATION')) udb_synchronize_groups();
28
 
29
function display_group_list()
30
{
31
    global $CONFIG;
32
    global $lang_groupmgr_php, $lang_byte_units, $lang_yes, $lang_no;
33
 
34
    $result = db_query("SELECT * FROM {$CONFIG['TABLE_USERGROUPS']} WHERE 1 ORDER BY group_id");
35
    if (!mysql_num_rows($result)) {
36
        db_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']}
37
        VALUES (1, 'Administrators', 0, 1, 1, 1, 1, 1, 1, 0, 0, 3, 0, 5, 3)");
38
        db_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']}
39
        VALUES (2, 'Registered', 1024, 0, 1, 1, 1, 1, 1, 1, 0, 3, 0, 5, 3)");
40
        db_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']}
41
        VALUES (3, 'Anonymous', 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 5, 3)");
42
        db_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']}
43
        VALUES (4, 'Banned', 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 5, 3)");
44
        cpg_die(CRITICAL_ERROR, 'Group table was empty !<br /><br />Default groups created, please reload this page', __FILE__, __LINE__);
45
    }
46
 
47
    $field_list = array('can_rate_pictures', 'can_send_ecards', 'can_post_comments', 'can_upload_pictures', 'pub_upl_need_approval', 'can_create_albums', 'priv_upl_need_approval');
48
 
49
    while ($group = mysql_fetch_array($result)) {
50
        $group['group_name'] = $group['group_name'];
51
 
52
        if ($group['group_id'] > 4 && !defined('UDB_INTEGRATION')) {
53
            echo <<< EOT
54
        <tr>
55
                <td class="tableb" style="padding-left: 1px; padding-right: 1px">
56
                        <input type="checkbox" name="delete_group[]" value="{$group['group_id']}" class="checkbox">
57
                </td>
58
 
59
EOT;
60
        } else {
61
            echo <<< EOT
62
        <tr>
63
                <td class="tableb">
64
                        &nbsp;
65
                </td>
66
 
67
EOT;
68
        }
69
        echo <<< EOT
70
                <td class="tableb">
71
                        <input type="hidden" name="group_id[]" value="{$group['group_id']}">
72
                        <input type="text" name="group_name_{$group['group_id']}" value="{$group['group_name']}" class="textinput">
73
                </td>
74
                <td class="tableb" style="white-space: nowrap;">
75
                        <input type="text" name="group_quota_{$group['group_id']}" value="{$group['group_quota']}" size="10" class="textinput"> {$lang_byte_units[1]}
76
                </td>
77
 
78
EOT;
79
        foreach ($field_list as $field_name) {
80
            $value = $group[$field_name];
81
            $yes_selected = ($value == 1) ? 'selected' : '';
82
            $no_selected = ($value == 0) ? 'selected' : '';
83
            echo <<< EOT
84
                <td class="tableb" align="center">
85
                        <select name="{$field_name}_{$group['group_id']}" class="listbox">
86
                                <option value="1" $yes_selected>$lang_yes</option>
87
                                <option value="0" $no_selected>$lang_no</option>
88
                        </select>
89
                </td>
90
 
91
EOT;
92
        }
93
 
94
     echo "<td class=\"tableb\" align=\"center\">";
95
      echo "<select name=\"upload_form_config_{$group['group_id']}\" class=\"listbox\">";
96
 
97
       for ($count=0; $count<5; $count++) {
98
 
99
           if ($count == '3') {
100
 
101
               continue;
102
 
103
           }
104
 
105
           if ($count == '4') {
106
 
107
               if ($group['upload_form_config'] == 3) {
108
                   $selected = 'selected';
109
               } else {
110
                   $selected = '';
111
               }
112
 
113
               echo "<option value=\"3\" $selected >{$lang_groupmgr_php['upload_form_config_values'][4]}</option>";
114
 
115
               continue;
116
 
117
           }
118
 
119
           if ($group['upload_form_config'] == $count) {
120
               $selected = 'selected';
121
           } else {
122
               $selected = '';
123
           }
124
 
125
           echo "<option value=\"$count\" $selected >{$lang_groupmgr_php['upload_form_config_values'][$count]}</option>";
126
 
127
       }
128
 
129
        echo "</select>";
130
        echo "</td>";
131
 
132
     // Create custom form request permission box
133
     echo "<td class=\"tableb\" align=\"center\">";
134
     echo "<select name=\"custom_user_upload_{$group['group_id']}\" class=\"listbox\">";
135
 
136
     // Determine if yes or no should be the selected option in the form.
137
     $custom_upload_yes = ($group['custom_user_upload'] == 1) ? 'selected' : '';
138
     $custom_upload_no = ($group['custom_user_upload'] == 0) ? 'selected' : '';
139
 
140
     // Create select list.
141
     echo "<option value=\"1\" $custom_upload_yes>$lang_yes</option>";
142
     echo "<option value=\"0\" $custom_upload_no>$lang_no</option>";
143
     echo "</select>";
144
     echo "</td>";
145
 
146
     // Create permissible number of file upload boxes box.
147
     echo "<td class=\"tableb\" align=\"center\">";
148
     echo "<select name=\"num_file_upload_{$group['group_id']}\" class=\"listbox\">";
149
     for ($i = 1; $i <= 10; $i++) {
150
     echo "<option value=\"$i\"";
151
     if($group['num_file_upload']==$i){echo "selected=\"selected\"";}
152
     echo " >$i</option>";
153
     }
154
     echo "</select>";
155
     echo "</td>";
156
 
157
     // Create permissible number of URI upload boxes box.
158
     echo "<td class=\"tableb\" align=\"center\">";
159
     echo "<select name=\"num_URI_upload_{$group['group_id']}\" class=\"listbox\">";
160
     for ($i = 1; $i <= 10; $i++) {
161
     echo "<option value=\"$i\"";
162
     if($group['num_URI_upload']==$i){echo "selected=\"selected\"";}
163
     echo " >$i</option>";
164
     }
165
     echo "</select>";
166
     echo "</td>";
167
 
168
 
169
        echo <<< EOT
170
        </tr>
171
 
172
EOT;
173
    } // while
174
    mysql_free_result($result);
175
}
176
 
177
function get_post_var($var)
178
{
179
    global $HTTP_POST_VARS, $lang_errors;
180
 
181
    if (!isset($HTTP_POST_VARS[$var])) cpg_die(CRITICAL_ERROR, $lang_errors['param_missing'] . " ($var)", __FILE__, __LINE__);
182
    return $HTTP_POST_VARS[$var];
183
}
184
 
185
function process_post_data()
186
{
187
    global $CONFIG, $HTTP_POST_VARS;
188
 
189
    $field_list = array('group_name', 'group_quota', 'can_rate_pictures', 'can_send_ecards', 'can_post_comments', 'can_upload_pictures', 'pub_upl_need_approval', 'can_create_albums', 'priv_upl_need_approval', 'upload_form_config', 'custom_user_upload', 'num_file_upload', 'num_URI_upload');
190
 
191
    $group_id_array = get_post_var('group_id');
192
    foreach ($group_id_array as $key => $group_id) {
193
        $set_statment = '';
194
        foreach ($field_list as $field) {
195
            if (!isset($HTTP_POST_VARS[$field . '_' . $group_id])) cpg_die(CRITICAL_ERROR, $lang_errors['param_missing'] . " ({$field}_{$group_id})", __FILE__, __LINE__);
196
            if ($field == 'group_name') {
197
                $set_statment .= $field . "='" . addslashes($HTTP_POST_VARS[$field . '_' . $group_id]) . "',";
198
            } else {
199
                $set_statment .= $field . "='" . (int)$HTTP_POST_VARS[$field . '_' . $group_id] . "',";
200
            }
201
        }
202
        $set_statment = substr($set_statment, 0, -1);
203
        db_query("UPDATE {$CONFIG['TABLE_USERGROUPS']} SET $set_statment WHERE group_id = '$group_id' LIMIT 1");
204
    }
205
}
206
 
207
if (isset($HTTP_POST_VARS) && count($HTTP_POST_VARS)) {
208
    if (isset($HTTP_POST_VARS['del_sel']) && isset($HTTP_POST_VARS['delete_group']) && is_array($HTTP_POST_VARS['delete_group'])) {
209
        foreach($HTTP_POST_VARS['delete_group'] as $group_id) {
210
            db_query("DELETE FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = '" . (int)$group_id . "' LIMIT 1");
211
            db_query("UPDATE {$CONFIG['TABLE_USERS']} SET user_group = '2' WHERE user_group = '" . (int)$group_id . "'");
212
        }
213
    } elseif (isset($HTTP_POST_VARS['new_group'])) {
214
        db_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']} (group_name) VALUES ('')");
215
    } elseif (isset($HTTP_POST_VARS['apply_modifs'])) {
216
        process_post_data();
217
    }
218
}
219
 
220
pageheader($lang_groupmgr_php['title']);
221
echo <<<EOT
222
 
223
<script language="javascript">
224
function confirmDel()
225
{
226
    return confirm("{$lang_groupmgr_php['confirm_del']}");
227
}
228
</script>
229
 
230
 
231
EOT;
232
 
233
starttable('100%');
234
 
235
echo <<<EOT
236
        <tr>
237
                <td class="tableh1" colspan="2"><b><span class="statlink">{$lang_groupmgr_php['group_name']}</span></b></td>
238
                <td class="tableh1"><b><span class="statlink">{$lang_groupmgr_php['disk_quota']}</span></b></td>
239
                <td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['can_rate']}</span></b></td>
240
                <td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['can_send_ecards']}</span></b></td>
241
                <td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['can_post_com']}</span></b></td>
242
                <td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['can_upload']}</span></b></td>
243
                <td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['approval_1']}</span></b></td>
244
                <td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['can_have_gallery']}</span></b></td>
245
                <td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['approval_2']}</span></b></td>
246
                <td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['upload_form_config']}</span></b></td>
247
                <td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['custom_user_upload']}</span></b></td>
248
                <td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['num_file_upload']}</span></b></td>
249
                <td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['num_URI_upload']}</span></b></td>
250
        </tr>
251
        <form method="post" action="$PHP_SELF">
252
 
253
EOT;
254
 
255
display_group_list();
256
 
257
echo <<<EOT
258
        <tr>
259
            <td colspan="14" class="tableh2">
260
                <b>{$lang_groupmgr_php['notes']}</b>
261
                </td>
262
        </tr>
263
        <tr>
264
            <td colspan="14" class="tableb">
265
                {$lang_groupmgr_php['note1']}
266
                </td>
267
        </tr>
268
        <tr>
269
            <td colspan="14" class="tableb">
270
                {$lang_groupmgr_php['note2']}
271
                </td>
272
        </tr>
273
 
274
EOT;
275
 
276
if (defined('UDB_INTEGRATION')) {
277
    echo <<<EOT
278
        <tr>
279
            <td colspan="14" align="center" class="tablef">
280
                        <input type="submit" name="apply_modifs" value="{$lang_groupmgr_php['apply']}" class="button">&nbsp;&nbsp;&nbsp;
281
                </td>
282
        </form>
283
        </tr>
284
 
285
EOT;
286
} else {
287
    echo <<<EOT
288
        <tr>
289
            <td colspan="14" align="center" class="tablef">
290
                        <input type="submit" name="apply_modifs" value="{$lang_groupmgr_php['apply']}" class="button">&nbsp;&nbsp;&nbsp;
291
                        <input type="submit" name="new_group" value="{$lang_groupmgr_php['create_new_group']}" class="button">&nbsp;&nbsp;&nbsp;
292
                        <input type="submit" name="del_sel" value="{$lang_groupmgr_php['del_groups']}" onClick="return confirmDel()" class="button">
293
                </td>
294
        </form>
295
        </tr>
296
 
297
EOT;
298
}
299
endtable();
300
pagefooter();
301
ob_end_flush();
302
 
303
?>