Changeset 805
- Timestamp:
- Jul 17, 2005, 5:09:24 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/user_list.php
r792 r805 74 74 case 'selection' : 75 75 { 76 $collection = $_POST['selection']; 76 if (isset($_POST['selection'])) 77 { 78 $collection = $_POST['selection']; 79 } 77 80 break; 78 81 } 79 82 } 80 83 81 if (-1 != $_POST['associate']) 82 { 83 $datas = array(); 84 85 $query = ' 84 if (count($collection) > 0) 85 { 86 if (-1 != $_POST['associate']) 87 { 88 $datas = array(); 89 90 $query = ' 86 91 SELECT user_id 87 92 FROM '.USER_GROUP_TABLE.' 88 93 WHERE group_id = '.$_POST['associate'].' 89 94 ;'; 90 $associated = array_from_query($query, 'user_id'); 91 92 // TODO : if $associable array is empty, no further actions 93 $associable = array_diff($collection, $associated); 94 95 foreach ($associable as $item) 95 $associated = array_from_query($query, 'user_id'); 96 97 $associable = array_diff($collection, $associated); 98 99 if (count($associable) > 0) 100 { 101 foreach ($associable as $item) 102 { 103 array_push($datas, 104 array('group_id'=>$_POST['associate'], 105 'user_id'=>$item)); 106 } 107 108 mass_inserts(USER_GROUP_TABLE, 109 array('group_id', 'user_id'), 110 $datas); 111 } 112 } 113 114 if (-1 != $_POST['dissociate']) 96 115 { 97 array_push($datas, 98 array('group_id'=>$_POST['associate'], 99 'user_id'=>$item)); 100 } 101 102 mass_inserts(USER_GROUP_TABLE, 103 array('group_id', 'user_id'), 104 $datas); 105 } 106 107 if (-1 != $_POST['dissociate']) 108 { 109 $query = ' 116 $query = ' 110 117 DELETE FROM '.USER_GROUP_TABLE.' 111 118 WHERE group_id = '.$_POST['dissociate'].' 112 119 AND user_id IN ('.implode(',', $collection).') 113 120 '; 114 pwg_query($query); 115 } 116 117 // properties to set for the collection (a user list) 118 $datas = array(); 119 $dbfields = array('primary' => array('id'), 'update' => array()); 120 121 $formfields = array('nb_image_line', 'nb_line_page', 'template', 'language', 122 'recent_period', 'expand', 'show_nb_comments', 123 'maxwidth', 'maxheight', 'status'); 121 pwg_query($query); 122 } 123 124 // properties to set for the collection (a user list) 125 $datas = array(); 126 $dbfields = array('primary' => array('id'), 'update' => array()); 127 128 $formfields = 129 array('nb_image_line', 'nb_line_page', 'template', 'language', 130 'recent_period', 'expand', 'show_nb_comments', 'maxwidth', 131 'maxheight', 'status'); 124 132 125 foreach ($formfields as $formfield) 126 { 127 if ($_POST[$formfield.'_action'] != 'leave') 133 foreach ($formfields as $formfield) 128 134 { 129 array_push($dbfields['update'], $formfield); 135 if ($_POST[$formfield.'_action'] != 'leave') 136 { 137 array_push($dbfields['update'], $formfield); 138 } 130 139 } 131 }132 133 // updating elements is useful only if needed...134 if (count($dbfields['update']) > 0)135 {136 $datas = array();137 140 138 foreach ($collection as $user_id) 141 // updating elements is useful only if needed... 142 if (count($dbfields['update']) > 0) 139 143 { 140 $data = array(); 141 $data['id'] = $user_id; 142 143 // TODO : verify if submited values are semanticaly correct 144 foreach ($dbfields['update'] as $dbfield) 144 $datas = array(); 145 146 foreach ($collection as $user_id) 145 147 { 146 // if the action is 'unset', the key won't be in row and 147 // mass_updates function will set this field to NULL 148 if ('set' == $_POST[$dbfield.'_action']) 148 $data = array(); 149 $data['id'] = $user_id; 150 151 // TODO : verify if submited values are semanticaly correct 152 foreach ($dbfields['update'] as $dbfield) 149 153 { 150 $data[$dbfield] = $_POST[$dbfield]; 154 // if the action is 'unset', the key won't be in row and 155 // mass_updates function will set this field to NULL 156 if ('set' == $_POST[$dbfield.'_action']) 157 { 158 $data[$dbfield] = $_POST[$dbfield]; 159 } 151 160 } 161 162 // Webmaster (user_id = 1) status must not be changed 163 if (1 == $user_id and isset($data['status'])) 164 { 165 $data['status'] = 'admin'; 166 } 167 168 array_push($datas, $data); 152 169 } 153 170 154 // Webmaster (user_id = 1) status must not be changed 155 if (1 == $user_id and isset($data['status'])) 156 { 157 $data['status'] = 'admin'; 158 } 159 160 array_push($datas, $data); 171 mass_updates(USERS_TABLE, $dbfields, $datas); 161 172 } 162 163 // echo '<pre>'; print_r($dbfields); echo '</pre>'; 164 // echo '<pre>'; print_r($datas); echo '</pre>'; 165 mass_updates(USERS_TABLE, $dbfields, $datas);173 } 174 else 175 { 176 array_push($page['errors'], l10n('Select at least one user')); 166 177 } 167 178 } -
trunk/doc/ChangeLog
r804 r805 1 2005-07-17 Pierrick LE GALL 2 3 * bug fixed : in admin/user_list, if target is "selection" and 4 that no user is selected, an error occurs 5 1 6 2005-07-17 Pierrick LE GALL 2 7
Note: See TracChangeset
for help on using the changeset viewer.