Changeset 642 for trunk/admin
- Timestamp:
- Dec 12, 2004, 10:06:39 PM (19 years ago)
- Location:
- trunk/admin
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/cat_list.php
r635 r642 60 60 if (!count($errors)) 61 61 { 62 $parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL'; 63 // As we don't create a virtual category every day, let's do (far) too 64 // much queries 62 $parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL'; 63 64 if ($parent_id != 'NULL') 65 { 66 $query = ' 67 SELECT id,uppercats,global_rank,visible,status 68 FROM '.CATEGORIES_TABLE.' 69 WHERE id = '.$parent_id.' 70 ;'; 71 $row = mysql_fetch_array(pwg_query($query)); 72 $parent = array('id' => $row['id'], 73 'uppercats' => $row['uppercats'], 74 'visible' => $row['visible'], 75 'status' => $row['status'], 76 'global_rank' => $row['global_rank']); 77 } 78 79 $insert = array(); 80 $insert{'name'} = $_POST['virtual_name']; 81 $insert{'rank'} = $_POST['rank']; 82 $insert{'commentable'} = $conf['newcat_default_commentable']; 83 $insert{'uploadable'} = $conf['newcat_default_uploadable']; 84 85 if (isset($parent)) 86 { 87 $insert{'id_uppercat'} = $parent{'id'}; 88 // at creation, must a category be visible or not ? Warning : if 89 // the parent category is invisible, the category is automatically 90 // create invisible. (invisible = locked) 91 if ('false' == $parent['visible']) 92 { 93 $insert{'visible'} = 'false'; 94 } 95 else 96 { 97 $insert{'visible'} = $conf['newcat_default_visible']; 98 } 99 // at creation, must a category be public or private ? Warning : 100 // if the parent category is private, the category is 101 // automatically create private. 102 if ('private' == $parent['status']) 103 { 104 $insert{'status'} = 'private'; 105 } 106 else 107 { 108 $insert{'status'} = $conf['newcat_default_status']; 109 } 110 } 111 else 112 { 113 $insert{'visible'} = $conf['newcat_default_visible']; 114 $insert{'status'} = $conf['newcat_default_status']; 115 } 116 117 $inserts = array($insert); 65 118 66 119 // we have then to add the virtual category 67 $query = ' 68 INSERT INTO '.CATEGORIES_TABLE.' 69 (name,id_uppercat,rank,site_id) 70 VALUES 71 (\''.$_POST['virtual_name'].'\','.$parent_id.','.$_POST['rank'].',NULL) 72 ;'; 73 pwg_query($query); 74 120 $dbfields = array('site_id','name','id_uppercat','rank','commentable', 121 'uploadable','visible','status'); 122 mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts); 123 75 124 // And last we update the uppercats 76 125 $query = ' … … 79 128 ;'; 80 129 $my_id = array_pop(mysql_fetch_array(pwg_query($query))); 81 82 if ($parent_id != 'NULL') 83 { 84 $query = ' 85 SELECT uppercats, global_rank 86 FROM '.CATEGORIES_TABLE.' 87 WHERE id = '.$parent_id.' 88 ;'; 89 $result = pwg_query($query); 90 $row = mysql_fetch_array($result); 91 92 $parent_uppercats = $row['uppercats']; 93 $parent_global_rank = $row['global_rank']; 94 } 95 96 $query = ' 97 UPDATE '.CATEGORIES_TABLE.' 98 '; 99 if (!empty($parent_uppercats)) 100 { 101 $query.= " SET uppercats = CONCAT('".$parent_uppercats."',',',id)"; 130 131 $query = ' 132 UPDATE '.CATEGORIES_TABLE; 133 if (isset($parent)) 134 { 135 $query.= " 136 SET uppercats = CONCAT('".$parent['uppercats']."',',',id) 137 , global_rank = CONCAT('".$parent['global_rank']."','.',rank)"; 102 138 } 103 139 else 104 140 { 105 $query.= ' SET uppercats = id'; 106 } 107 if (!empty($parent_global_rank)) 108 { 109 $query.= " , global_rank = CONCAT('".$parent_global_rank."','.',rank)"; 110 } 111 else 112 { 113 $query.= ' , uppercats = id'; 141 $query.= ' 142 SET uppercats = id 143 , global_rank = id'; 114 144 } 115 145 $query.= ' … … 143 173 { 144 174 $categories[$row['rank']] = $row; 175 $categories[$row['rank']]['nb_subcats'] = 0; 145 176 } 146 177 // +-----------------------------------------------------------------------+ … … 149 180 if (isset($_GET['parent_id'])) 150 181 { 151 $separator = ' <span style="font-size:15px">→</span> ';152 182 $base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list'; 153 183 … … 155 185 $navigation.= $lang['home']; 156 186 $navigation.= '</a>'; 157 $navigation.= $ separator;187 $navigation.= $conf['level_separator']; 158 188 159 189 $current_category = get_cat_info($_GET['parent_id']); 160 190 $navigation.= get_cat_display_name($current_category['name'], 161 $separator,162 191 $base_url.'&parent_id=', 163 192 false); … … 338 367 // | Categories display | 339 368 // +-----------------------------------------------------------------------+ 340 while (list($id,$category) = each($categories)) 369 $ranks = array(); 370 foreach ($categories as $category) 371 { 372 $ranks[$category['id']] = $category['rank']; 373 } 374 375 $query = ' 376 SELECT id_uppercat, COUNT(*) AS nb_subcats 377 FROM '. CATEGORIES_TABLE.' 378 WHERE id_uppercat IN ('.implode(',', array_keys($ranks)).') 379 GROUP BY id_uppercat 380 ;'; 381 $result = pwg_query($query); 382 while ($row = mysql_fetch_array($result)) 383 { 384 $categories[$ranks[$row['id_uppercat']]]['nb_subcats'] = $row['nb_subcats']; 385 } 386 387 foreach ($categories as $category) 341 388 { 342 389 $images_folder = PHPWG_ROOT_PATH.'template/'; … … 357 404 else 358 405 { 359 // (Gweltas) May be should we have to introduce a computed field in the 360 // table to avoid this query -> (z0rglub) no because the number of 361 // sub-categories depends on permissions 362 $query = ' 363 SELECT COUNT(id) AS nb_sub_cats 364 FROM '. CATEGORIES_TABLE.' 365 WHERE id_uppercat = '.$category['id'].' 366 ;'; 367 $row = mysql_fetch_array(pwg_query($query)); 368 369 if ($row['nb_sub_cats'] > 0) 406 if ($category['nb_subcats'] > 0) 370 407 { 371 408 $image_src = $images_folder.'/icon_subfolder.gif'; -
trunk/admin/cat_modify.php
r635 r642 104 104 $url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&parent_id='; 105 105 $navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">'; 106 $navigation.= $lang['home'].'</a> <span style="font-size:15px">→</span>';106 $navigation.= $lang['home'].'</a>'.$conf['level_separator']; 107 107 108 108 $navigation.= get_cat_display_name_cache( 109 109 $category['uppercats'], 110 ' <span style="font-size:15px">→</span>',111 110 $url); 112 111 -
trunk/admin/group_perm.php
r593 r642 105 105 // category name 106 106 $cat_infos = get_cat_info( $row['id'] ); 107 $name = get_cat_display_name( $cat_infos['name'],' > ', 108 'font-weight:bold;' ); 107 $name = get_cat_display_name($cat_infos['name']); 109 108 $vtp->setVar( $sub, 'category.name', $name ); 110 109 // any subcat forbidden for this group ? -
trunk/admin/include/functions.php
r638 r642 789 789 { 790 790 $sub_dirs = array(); 791 791 792 792 if ( $opendir = opendir( $basedir ) ) 793 793 { -
trunk/admin/infos_images.php
r606 r642 249 249 $current_category = get_cat_info($_GET['cat_id']); 250 250 $url = PHPWG_ROOT_PATH.'admin.php?page=infos_images&cat_id='; 251 $category_path = get_cat_display_name($current_category['name'], 252 '->', 253 $url); 251 $category_path = get_cat_display_name($current_category['name'], $url); 254 252 255 253 $form_action = PHPWG_ROOT_PATH.'admin.php'; -
trunk/admin/picture_modify.php
r640 r642 163 163 $date = isset($_POST['date_creation']) && empty($errors) 164 164 ?$_POST['date_creation']:date_convert_back(@$row['date_creation']); 165 165 166 $url = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='; 166 167 $storage_category = get_cat_display_name_cache($row['uppercats'], 167 ' → ', 168 '', 168 $url, 169 169 false); 170 170 //----------------------------------------------------- template initialization -
trunk/admin/remote_site.php
r638 r642 177 177 function insert_remote_category($xml_content, $site_id, $id_uppercat, $level) 178 178 { 179 global $counts, $removes ;179 global $counts, $removes, $conf; 180 180 181 181 $uppercats = ''; … … 185 185 { 186 186 $query = ' 187 SELECT name,uppercats,dir187 SELECT id,name,uppercats,dir,status,visible 188 188 FROM '.CATEGORIES_TABLE.' 189 189 WHERE id = '.$id_uppercat.' 190 190 ;'; 191 191 $row = mysql_fetch_array(pwg_query($query)); 192 $parent = array('id' => $row['id'], 193 'name' => $row['name'], 194 'dir' => $row['dir'], 195 'uppercats' => $row['uppercats'], 196 'visible' => $row['visible'], 197 'status' => $row['status']); 192 198 193 $uppercats = $row['uppercats'];194 $name = $row['name'];195 196 199 insert_remote_element($xml_content, $id_uppercat); 197 200 } … … 225 228 $inserts = array(); 226 229 230 // calculate default value at category creation 231 $create_values = array(); 232 if (isset($parent)) 233 { 234 // at creation, must a category be visible or not ? Warning : if 235 // the parent category is invisible, the category is automatically 236 // create invisible. (invisible = locked) 237 if ('false' == $parent['visible']) 238 { 239 $create_values{'visible'} = 'false'; 240 } 241 else 242 { 243 $create_values{'visible'} = $conf['newcat_default_visible']; 244 } 245 // at creation, must a category be public or private ? Warning : 246 // if the parent category is private, the category is 247 // automatically create private. 248 if ('private' == $parent['status']) 249 { 250 $create_values{'status'} = 'private'; 251 } 252 else 253 { 254 $create_values{'status'} = $conf['newcat_default_status']; 255 } 256 } 257 else 258 { 259 $create_values{'visible'} = $conf['newcat_default_visible']; 260 $create_values{'status'} = $conf['newcat_default_status']; 261 } 262 227 263 foreach ($xml_dirs as $xml_dir) 228 264 { … … 240 276 $insert{'site_id'} = $site_id; 241 277 $insert{'uppercats'} = 'undef'; 242 if (is_numeric($id_uppercat)) 278 $insert{'commentable'} = $conf['newcat_default_commentable']; 279 $insert{'uploadable'} = 'false'; 280 $insert{'status'} = $create_values{'status'}; 281 $insert{'visible'} = $create_values{'visible'}; 282 if (isset($parent)) 243 283 { 244 $insert{'id_uppercat'} = $ id_uppercat;284 $insert{'id_uppercat'} = $parent['id']; 245 285 } 246 286 array_push($inserts, $insert); … … 252 292 { 253 293 // inserts all found categories 254 $dbfields = array('dir','name','site_id','uppercats','id_uppercat'); 294 $dbfields = array('dir','name','site_id','uppercats','id_uppercat', 295 'commentable','uploadable','status','visible'); 255 296 mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts); 256 297 $counts{'new_categories'}+= count($inserts); … … 258 299 // updating uppercats field 259 300 $query = ' 260 UPDATE '.CATEGORIES_TABLE.' 261 SET uppercats = '; 262 if ($uppercats != '') 263 { 264 $query.= "CONCAT('".$uppercats."',',',id)"; 301 UPDATE '.CATEGORIES_TABLE; 302 if (isset($parent)) 303 { 304 $query.= " 305 SET uppercats = CONCAT('".$parent['uppercats']."',',',id) 306 WHERE id_uppercat = ".$id_uppercat; 265 307 } 266 308 else 267 309 { 268 $query.= 'id'; 269 } 270 $query.= ' 271 WHERE id_uppercat '; 272 if (!is_numeric($id_uppercat)) 273 { 274 $query.= 'IS NULL'; 275 } 276 else 277 { 278 $query.= '= '.$id_uppercat; 310 $query.= ' 311 SET uppercats = id 312 WHERE id_uppercat IS NULL'; 279 313 } 280 314 $query.= ' -
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.= ' -
trunk/admin/user_perm.php
r629 r642 221 221 // category name 222 222 $cat_infos = get_cat_info( $row['id'] ); 223 $name = get_cat_display_name( $cat_infos['name'],' > ', 224 'font-weight:bold;' ); 223 $name = get_cat_display_name($cat_infos['name']); 225 224 $vtp->setVar( $sub, 'category.name', $name ); 226 225 // usergroups -
trunk/admin/user_search.php
r631 r642 103 103 $url = PHPWG_ROOT_PATH.'admin.php?page=cat_perm&cat_id='.$row['id']; 104 104 $cat_infos = get_cat_info( $row['id'] ); 105 $template->assign_block_vars('permission.category',array( 106 'CAT_NAME'=> get_cat_display_name($cat_infos['name'],' > ', 'font-weight:bold;' ), 107 'CAT_ID'=>$row['id'], 108 'AUTH_YES'=>!$is_user_allowed?'checked="checked"':'', 109 'AUTH_NO' =>$is_user_allowed?'checked="checked"':'', 110 'CAT_URL'=>add_session_id($url) 111 )); 112 105 $template->assign_block_vars( 106 'permission.category', 107 array( 108 'CAT_NAME'=> get_cat_display_name($cat_infos['name']), 109 'CAT_ID'=>$row['id'], 110 'AUTH_YES'=>!$is_user_allowed?'checked="checked"':'', 111 'AUTH_NO' =>$is_user_allowed?'checked="checked"':'', 112 'CAT_URL'=>add_session_id($url) 113 )); 114 113 115 // any subcat forbidden for this user ? 114 116 if ( $is_user_allowed == 2 ) -
trunk/admin/waiting.php
r593 r642 114 114 PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] ); 115 115 $cat_names[$row['storage_category_id']]['display_name'] = 116 get_cat_display_name( $cat['name'], ' > ', 'font-weight:bold;');116 get_cat_display_name($cat['name']); 117 117 } 118 118 $preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file'];
Note: See TracChangeset
for help on using the changeset viewer.