Changeset 642 for trunk/admin/update.php
- Timestamp:
- Dec 12, 2004, 10:06:39 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/update.php
r638 r642 48 48 if (is_numeric($id_uppercat)) 49 49 { 50 $query = 'SELECT name,uppercats,dir FROM '.CATEGORIES_TABLE; 51 $query.= ' WHERE id = '.$id_uppercat; 52 $query.= ';'; 53 $row = mysql_fetch_array( pwg_query( $query)); 54 $uppercats = $row['uppercats']; 55 $name = $row['name']; 56 $dir = $row['dir']; 57 58 $upper_array = explode( ',', $uppercats); 50 $query = ' 51 SELECT id,name,uppercats,dir,visible,status 52 FROM '.CATEGORIES_TABLE.' 53 WHERE id = '.$id_uppercat.' 54 ;'; 55 $row = mysql_fetch_array(pwg_query($query)); 56 $parent = array('id' => $row['id'], 57 'name' => $row['name'], 58 'dir' => $row['dir'], 59 'uppercats' => $row['uppercats'], 60 'visible' => $row['visible'], 61 'status' => $row['status']); 62 63 $upper_array = explode( ',', $parent['uppercats']); 59 64 60 65 $local_dir = ''; … … 62 67 $database_dirs = array(); 63 68 $query = ' 64 SELECT id,dir FROM '.CATEGORIES_TABLE.' 65 WHERE id IN ('.$uppercats.') 66 ;'; 67 $result = pwg_query( $query); 69 SELECT id,dir 70 FROM '.CATEGORIES_TABLE.' 71 WHERE id IN ('.$parent['uppercats'].') 72 ;'; 73 $result = pwg_query($query); 68 74 while ($row = mysql_fetch_array($result)) 69 75 { … … 79 85 // 1. display the category name to update 80 86 $output = '<ul class="menu">'; 81 $output.= '<li><strong>'.$ name.'</strong>';82 $output.= ' [ '.$ dir.' ]';87 $output.= '<li><strong>'.$parent['name'].'</strong>'; 88 $output.= ' [ '.$parent['dir'].' ]'; 83 89 $output.= '</li>'; 84 90 … … 95 101 $sub_category_dirs = array(); 96 102 $query = ' 97 SELECT id,dir FROM '.CATEGORIES_TABLE.' 103 SELECT id,dir 104 FROM '.CATEGORIES_TABLE.' 98 105 WHERE site_id = 1 99 106 '; … … 132 139 // array of new categories to insert 133 140 $inserts = array(); 141 142 // calculate default value at category creation 143 $create_values = array(); 144 if (isset($parent)) 145 { 146 // at creation, must a category be visible or not ? Warning : if 147 // the parent category is invisible, the category is automatically 148 // create invisible. (invisible = locked) 149 if ('false' == $parent['visible']) 150 { 151 $create_values{'visible'} = 'false'; 152 } 153 else 154 { 155 $create_values{'visible'} = $conf['newcat_default_visible']; 156 } 157 // at creation, must a category be public or private ? Warning : 158 // if the parent category is private, the category is 159 // automatically create private. 160 if ('private' == $parent['status']) 161 { 162 $create_values{'status'} = 'private'; 163 } 164 else 165 { 166 $create_values{'status'} = $conf['newcat_default_status']; 167 } 168 } 169 else 170 { 171 $create_values{'visible'} = $conf['newcat_default_visible']; 172 $create_values{'status'} = $conf['newcat_default_status']; 173 } 134 174 135 175 foreach ($fs_subdirs as $fs_subdir) … … 140 180 if (!is_numeric($category_id)) 141 181 { 182 $insert = array(); 183 142 184 if (preg_match('/^[a-zA-Z0-9-_.]+$/', $fs_subdir)) 143 185 { 144 186 $name = str_replace('_', ' ', $fs_subdir); 145 187 146 $value = "('".$fs_subdir."','".$name."',1"; 147 if (!is_numeric($id_uppercat)) 148 { 149 $value.= ',NULL'; 150 } 151 else 152 { 153 $value.= ','.$id_uppercat; 154 } 155 $value.= ",'undef'"; 156 $value.= ')'; 157 array_push($inserts, $value); 188 $insert{'dir'} = $fs_subdir; 189 $insert{'name'} = $name; 190 $insert{'site_id'} = 1; 191 $insert{'uppercats'} = 'undef'; 192 $insert{'commentable'} = $conf['newcat_default_commentable']; 193 $insert{'uploadable'} = $conf['newcat_default_uploadable']; 194 $insert{'status'} = $create_values{'status'}; 195 $insert{'visible'} = $create_values{'visible'}; 196 197 if (isset($parent)) 198 { 199 $insert{'id_uppercat'} = $parent['id']; 200 } 201 202 array_push($inserts, $insert); 158 203 } 159 204 else … … 168 213 if (count($inserts) > 0) 169 214 { 170 $query = ' 171 INSERT INTO '.CATEGORIES_TABLE.' 172 (dir,name,site_id,id_uppercat,uppercats) VALUES 173 '; 174 $query.= implode(',', $inserts); 175 $query.= ' 176 ;'; 177 pwg_query($query); 178 215 $dbfields = array( 216 'dir','name','site_id','id_uppercat','uppercats','commentable', 217 'uploadable','visible','status' 218 ); 219 mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts); 220 179 221 $counts['new_categories']+= count($inserts); 180 222 // updating uppercats field 181 223 $query = ' 182 UPDATE '.CATEGORIES_TABLE.' 183 SET uppercats = '; 184 if ($uppercats != '') 185 { 186 $query.= "CONCAT('".$uppercats."',',',id)"; 224 UPDATE '.CATEGORIES_TABLE; 225 if (isset($parent)) 226 { 227 $query.= " 228 SET uppercats = CONCAT('".$parent['uppercats']."',',',id) 229 WHERE id_uppercat = ".$parent['id']; 187 230 } 188 231 else 189 232 { 190 $query.= 'id'; 191 } 192 $query.= ' 193 WHERE id_uppercat '; 194 if (!is_numeric($id_uppercat)) 195 { 196 $query.= 'IS NULL'; 197 } 198 else 199 { 200 $query.= '= '.$id_uppercat; 233 $query.= ' 234 SET uppercats = id 235 WHERE id_uppercat IS NULL'; 201 236 } 202 237 $query.= '
Note: See TracChangeset
for help on using the changeset viewer.