Changeset 133 for trunk/admin/picture_modify.php
- Timestamp:
- Sep 19, 2003, 11:40:52 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/picture_modify.php
r61 r133 74 74 $query.= ';'; 75 75 mysql_query( $query ); 76 // make the picture representative of a category ? 77 $query = 'SELECT DISTINCT(category_id) as category_id'; 78 $query.= ',representative_picture_id'; 79 $query.= ' FROM '.PREFIX_TABLE.'image_category AS ic'; 80 $query.= ', '.PREFIX_TABLE.'categories AS c'; 81 $query.= ' WHERE c.id = ic.category_id'; 82 $query.= ' AND image_id = '.$_GET['image_id']; 83 $query.= ';'; 84 $result = mysql_query( $query ); 85 while ( $row = mysql_fetch_array( $result ) ) 86 { 87 // if the user ask the picture to be the representative picture of its 88 // category, the category is updated in the database (without wondering 89 // if this picture was already the representative one) 90 if ( $_POST['representative-'.$row['category_id']] == 1 ) 91 { 92 $query = 'UPDATE '.PREFIX_TABLE.'categories'; 93 $query.= ' SET representative_picture_id = '.$_GET['image_id']; 94 $query.= ' WHERE id = '.$row['category_id']; 95 $query.= ';'; 96 mysql_query( $query ); 97 } 98 // if the user ask this picture to be not any more the representative, 99 // we have to set the representative_picture_id of this category to NULL 100 else if ( $row['representative_picture_id'] == $_GET['image_id'] ) 101 { 102 $query = 'UPDATE '.PREFIX_TABLE.'categories'; 103 $query.= ' SET representative_picture_id = NULL'; 104 $query.= ' WHERE id = '.$row['category_id']; 105 $query.= ';'; 106 mysql_query( $query ); 107 } 108 } 76 109 // associate with a new category ? 77 110 if ( $_POST['associate'] != '-1' ) … … 112 145 'author','creation_date','keywords','comment', 'upload_name', 113 146 'dissociate','categories','infoimage_associate', 114 'cat_image_info' );147 'cat_image_info','category_representative' ); 115 148 templatize_array( $tpl, 'lang', $sub ); 116 149 $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); … … 206 239 $vtp->setVar( $sub, 'linked_category.invisible', $invisible_string ); 207 240 } 241 $vtp->setVar( $sub, 'linked_category.id', $row['storage_category_id'] ); 242 if ( $result['representative_picture_id'] == $_GET['image_id'] ) 243 { 244 $vtp->setVar( $sub, 'linked_category.representative_checked', 245 ' checked="checked"' ); 246 } 208 247 $vtp->closeSession( $sub, 'linked_category' ); 209 248 // retrieving all the linked categories 210 249 $query = 'SELECT DISTINCT(category_id) as category_id,status,visible'; 250 $query.= ',representative_picture_id'; 211 251 $query.= ' FROM '.PREFIX_TABLE.'image_category'; 212 252 $query.= ','.PREFIX_TABLE.'categories'; … … 219 259 { 220 260 $vtp->addSession( $sub, 'linked_category' ); 261 $vtp->setVar( $sub, 'linked_category.id', $row['category_id'] ); 221 262 222 263 $vtp->addSession( $sub, 'checkbox' ); … … 250 291 } 251 292 293 if ( $row['representative_picture_id'] == $_GET['image_id'] ) 294 { 295 $vtp->setVar( $sub, 'linked_category.representative_checked', 296 ' checked="checked"' ); 297 } 298 252 299 $vtp->closeSession( $sub, 'linked_category' ); 253 300 }
Note: See TracChangeset
for help on using the changeset viewer.