Changeset 4420
- Timestamp:
- Dec 4, 2009, 1:34:19 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/event_cats/include/evntcats_admin_funcs.inc.php
r4418 r4420 93 93 */ 94 94 function ec_create_user_OK() { 95 global $page ;95 global $page, $ec_lists; 96 96 97 97 // This function assumes that the validity of the different indexes of … … 140 140 $_POST['groupname'] != '' 141 141 ) { 142 // Checks if a group named $_POST['groupname'] already exists. 143 // If not, creates it : then, t4 is no more false. In any case, t3 gets 144 // the id of the group named $_POST['groupname']. 142 145 $t2 = 0; $t3 = false; $t4 = false; 143 while ( 146 while ( // The check is executed once at minimum 144 147 !($t3 = mysql_fetch_row(pwg_query(" 145 148 SELECT `id` … … 147 150 WHERE `name` = '".$_POST['groupname']."'; 148 151 "))) and 149 $t2++ == 0 150 ) $t4 = pwg_query(" 152 $t2++ == 0 // The check is executed twice at maximum 153 ) // Cannot be executed twice 154 $t4 = pwg_query(" 151 155 INSERT INTO `".GROUPS_TABLE."` (`name`, `is_default`) 152 156 VALUES ('".$_POST['groupname']."', 'false'); … … 166 170 ) $page['errors'][] = 167 171 sprintf(l10n('ec_group_create_pb'), $_POST['groupname']).' (2) : '. 168 'MySQL error '.mysql_errno().', "'.mysql_error().'"';172 'MySQL error '.mysql_errno().', "'.mysql_error().'"'; 169 173 else $page['infos'][] = sprintf( 170 174 l10n('ec_group_create_OK2'), … … 174 178 // If a category id has been posted, the newly created group must be 175 179 // allowed to navigate in this category 176 177 /*178 179 180 if (isset($_POST['ec_in_up_cat'])) { 180 181 if (mysql_num_rows(pwg_query(" … … 184 185 ")) == 0) return ec_end1('ec_in_up_cat', 'Category doesn\'t exist : '); 185 186 else { 186 187 $query = ' 188 SELECT id 189 FROM '.CATEGORIES_TABLE.' 190 WHERE id IN ('.implode(',', get_uppercat_ids(array($page['cat']))).') 191 AND status = \'private\' 192 ;'; 193 $private_uppercats = array_from_query($query, 'id'); 194 195 // We must not reinsert already existing lines in group_access table 196 $granteds = array(); 197 foreach ($private_uppercats as $cat_id) 198 { 199 $granteds[$cat_id] = array(); 200 } 201 202 $query = ' 203 SELECT group_id, cat_id 204 FROM '.GROUP_ACCESS_TABLE.' 205 WHERE cat_id IN ('.implode(',', $private_uppercats).') 206 AND group_id IN ('.implode(',', $_POST['grant_groups']).') 207 ;'; 208 $result = pwg_query($query); 209 while ($row = mysql_fetch_array($result)) 210 { 211 array_push($granteds[$row['cat_id']], $row['group_id']); 212 } 213 214 $inserts = array(); 215 216 foreach ($private_uppercats as $cat_id) 217 { 218 $group_ids = array_diff($_POST['grant_groups'], $granteds[$cat_id]); 219 foreach ($group_ids as $group_id) 220 { 221 array_push($inserts, array('group_id' => $group_id, 222 'cat_id' => $cat_id)); 223 } 224 } 225 226 mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $inserts); 227 228 187 $private_uppercats = array_from_query(" 188 SELECT `id` 189 FROM `".CATEGORIES_TABLE."` 190 WHERE `id` IN (". 191 implode(',', get_uppercat_ids(array($_POST['ec_in_up_cat']))). 192 ") 193 AND `status` = 'private'; 194 ", 'id'); 195 $inserts = array(); 196 foreach ($private_uppercats as $cat_id) 197 $inserts[] = array( 198 'group_id' => $t3[0], 199 'cat_id' => $cat_id 200 ); 201 mass_inserts(GROUP_ACCESS_TABLE,array('group_id','cat_id'), $inserts); 202 if (mysql_errno() == 0) 203 $page['infos'][] = sprintf( 204 l10n('ec_group_create_OK2'), 205 $_POST['groupname'],$ec_lists['categories'][$_POST['ec_in_up_cat']] 206 ); 207 else 208 $page['errors'][] = 209 sprintf(l10n('ec_group_create_pb'), $_POST['groupname']).' (3) : '. 210 'MySQL error '.mysql_errno().', "'.mysql_error().'"'; 229 211 } 230 212 } 231 213 232 */233 234 214 // If an add. p. id has been posted, the newly created group must be 235 215 // allowed to navigate in this additional page 216 217 /* 218 219 220 221 222 */ 236 223 } 237 224 else { … … 241 228 // If an add. p. id has been posted, the newly created user must be 242 229 // allowed to navigate in this additional page => not possible to 243 // allow individually => must give a warning message 230 // allow individually => must give a warning message ? 244 231 245 232 }
Note: See TracChangeset
for help on using the changeset viewer.