Changeset 9510 for extensions/community/admin_permissions.php
- Timestamp:
- Mar 4, 2011, 9:18:39 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/community/admin_permissions.php
r9501 r9510 32 32 $admin_base_url = get_root_url().'admin.php?page=plugin-community-permissions'; 33 33 34 $who_options = array( 35 'any_visitor' => l10n('any visitor'), 36 'any_registered_user' => l10n('any registered user'), 37 'user' => l10n('a specific user'), 38 'group' => l10n('a group'), 39 ); 40 34 41 // +-----------------------------------------------------------------------+ 35 42 // | Check Access and exit when user status is not ok | … … 44 51 if (isset($_POST['submit_add'])) 45 52 { 46 $who_options = array('any_visitor', 'any_registered_user', 'user', 'group'); 47 48 if (!in_array($_POST['who'], $who_options)) 53 if (!in_array($_POST['who'], array_keys($who_options))) 49 54 { 50 55 die('hacking attempt: invalid "who" option'); … … 66 71 } 67 72 68 check_input_parameter('moderate ', $_POST, false, '/^(true|false)$/');73 check_input_parameter('moderated', $_POST, false, '/^(true|false)$/'); 69 74 70 75 // creating the permission … … 76 81 'recursive' => isset($_POST['recursive']) ? 'true' : 'false', 77 82 'create_subcategories' => isset($_POST['create_subcategories']) ? 'true' : 'false', 78 'moderated' => $_POST['moderate '],83 'moderated' => $_POST['moderated'], 79 84 ); 80 81 mass_inserts( 82 COMMUNITY_PERMISSIONS_TABLE, 83 array_keys($insert), 84 array($insert) 85 ); 86 87 array_push( 88 $page['infos'], 89 l10n('Permission added') 90 ); 85 86 if (isset($_POST['edit'])) 87 { 88 check_input_parameter('edit', $_POST, false, PATTERN_ID); 89 90 $insert['id'] = $_POST['edit']; 91 92 mass_updates( 93 COMMUNITY_PERMISSIONS_TABLE, 94 array( 95 'primary' => array('id'), 96 'update' => array_keys($insert), 97 ), 98 array($insert) 99 ); 100 101 $page['highlight'] = $insert['id']; 102 103 array_push( 104 $page['infos'], 105 l10n('Permission updated') 106 ); 107 } 108 else 109 { 110 mass_inserts( 111 COMMUNITY_PERMISSIONS_TABLE, 112 array_keys($insert), 113 array($insert) 114 ); 115 116 $page['highlight'] = pwg_db_insert_id(COMMUNITY_PERMISSIONS_TABLE); 117 118 array_push( 119 $page['infos'], 120 l10n('Permission added') 121 ); 122 } 91 123 92 124 conf_update_param('community_update', time()); … … 128 160 // +-----------------------------------------------------------------------+ 129 161 162 // edit mode? 163 if (isset($_GET['edit'])) 164 { 165 check_input_parameter('edit', $_GET, false, PATTERN_ID); 166 167 $query = ' 168 SELECT 169 * 170 FROM '.COMMUNITY_PERMISSIONS_TABLE.' 171 WHERE id = '.$_GET['edit'].' 172 ;'; 173 $result = pwg_query($query); 174 $row = pwg_db_fetch_assoc($result); 175 176 if (isset($row['id'])) 177 { 178 $template->assign( 179 array( 180 'edit' => $row['id'], 181 'who_options_selected' => $row['type'], 182 'user_options_selected' => $row['user_id'], 183 'group_options_selected' => $row['group_id'], 184 'category_options_selected' => $row['category_id'], 185 'recursive' => get_boolean($row['recursive']), 186 'create_subcategories' => get_boolean($row['create_subcategories']), 187 'moderated' => get_boolean($row['moderated']), 188 ) 189 ); 190 } 191 } 192 else 193 { 194 $template->assign( 195 array( 196 'moderated' => true, 197 ) 198 ); 199 } 200 201 // who options 202 $template->assign( 203 array( 204 'who_options' => $who_options, 205 ) 206 ); 130 207 131 208 // list of users … … 322 399 $trust_tooltip = l10n('uploaded photos are directly displayed in the gallery'); 323 400 } 401 402 $highlight = false; 403 if (isset($_GET['edit']) and $permission['id'] == $_GET['edit']) 404 { 405 $highlight = true; 406 } 407 if (isset($page['highlight']) and $permission['id'] == $page['highlight']) 408 { 409 $highlight = true; 410 } 411 324 412 325 413 $template->append( … … 333 421 'RECURSIVE_TOOLTIP' => l10n('Apply to sub-albums'), 334 422 'CREATE_SUBCATEGORIES' => get_boolean($permission['create_subcategories']), 335 'U_DELETE' => $admin_base_url.'&delete='.$permission['id'] 423 'U_DELETE' => $admin_base_url.'&delete='.$permission['id'], 424 'U_EDIT' => $admin_base_url.'&edit='.$permission['id'], 425 'HIGHLIGHT' => $highlight, 336 426 ) 337 427 );
Note: See TracChangeset
for help on using the changeset viewer.