Changeset 345 for trunk/admin/picture_modify.php
- Timestamp:
- Feb 2, 2004, 1:55:18 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/picture_modify.php
r226 r345 19 19 20 20 include_once( './admin/include/isadmin.inc.php' ); 21 //----------------------------------------- categories structure initialization22 $page['plain_structure'] = get_plain_structure();23 21 //--------------------------------------------------------- update informations 24 22 $errors = array(); … … 88 86 // category, the category is updated in the database (without wondering 89 87 // if this picture was already the representative one) 90 if ( $_POST['representative-'.$row['category_id']] == 1)88 if ( isset($_POST['representative-'.$row['category_id']]) ) 91 89 { 92 90 $query = 'UPDATE '.PREFIX_TABLE.'categories'; … … 98 96 // if the user ask this picture to be not any more the representative, 99 97 // we have to set the representative_picture_id of this category to NULL 100 else if ( $row['representative_picture_id'] == $_GET['image_id'] ) 98 else if ( isset( $row['representative_picture_id'] ) 99 and $row['representative_picture_id'] == $_GET['image_id'] ) 101 100 { 102 101 $query = 'UPDATE '.PREFIX_TABLE.'categories'; … … 107 106 } 108 107 } 108 $associate_or_dissociate = false; 109 109 // associate with a new category ? 110 if ( $_POST['associate'] != '-1' ) 110 if ( $_POST['associate'] != '-1' and $_POST['associate'] != '' ) 111 { 112 // does the uppercat id exists in the database ? 113 if ( !is_numeric( $_POST['associate'] ) ) 114 { 115 array_push( $errors, $lang['cat_unknown_id'] ); 116 } 117 else 118 { 119 $query = 'SELECT id'; 120 $query.= ' FROM '.PREFIX_TABLE.'categories'; 121 $query.= ' WHERE id = '.$_POST['associate']; 122 $query.= ';'; 123 if ( mysql_num_rows( mysql_query( $query ) ) == 0 ) 124 array_push( $errors, $lang['cat_unknown_id'] ); 125 } 126 } 127 if ( $_POST['associate'] != '-1' 128 and $_POST['associate'] != '' 129 and count( $errors ) == 0 ) 111 130 { 112 131 $query = 'INSERT INTO '.PREFIX_TABLE.'image_category'; … … 115 134 $query.= ';'; 116 135 mysql_query( $query); 136 $associate_or_dissociate = true; 117 137 update_category( $_POST['associate'] ); 118 138 } … … 126 146 while ( $row = mysql_fetch_array( $result ) ) 127 147 { 128 if ( $_POST['dissociate-'.$row['category_id']] == 1)148 if ( isset($_POST['dissociate-'.$row['category_id']]) ) 129 149 { 130 150 $query = 'DELETE FROM '.PREFIX_TABLE.'image_category'; … … 133 153 $query.= ';'; 134 154 mysql_query( $query ); 155 $associate_or_dissociate = true; 135 156 update_category( $row['category_id'] ); 136 157 } 158 } 159 if ( $associate_or_dissociate ) 160 { 161 synchronize_all_users(); 137 162 } 138 163 } … … 163 188 $vtp->setVar( $sub, 'form_action', $action ); 164 189 // retrieving direct information about picture 165 $query = 'SELECT file,date_available,date_creation,tn_ext,name,filesize'; 166 $query.= ',width,height,author,comment,keywords,storage_category_id'; 190 $infos = array( 'file','date_available','date_creation','tn_ext','name' 191 ,'filesize','width','height','author','comment','keywords' 192 ,'storage_category_id' ); 193 $query = 'SELECT '. implode( ',', $infos ); 167 194 $query.= ' FROM '.PREFIX_TABLE.'images'; 168 195 $query.= ' WHERE id = '.$_GET['image_id']; 169 196 $query.= ';'; 170 197 $row = mysql_fetch_array( mysql_query( $query ) ); 198 199 foreach ( $infos as $info ) { 200 if ( !isset( $row[$info] ) ) $row[$info] = ''; 201 } 202 171 203 // picture title 172 204 if ( $row['name'] == '' ) … … 291 323 } 292 324 293 if ( $row['representative_picture_id'] == $_GET['image_id'] ) 325 if ( isset( $row['representative_picture_id'] ) 326 and $row['representative_picture_id'] == $_GET['image_id'] ) 294 327 { 295 328 $vtp->setVar( $sub, 'linked_category.representative_checked', … … 307 340 } 308 341 // associate to another category ? 309 $vtp->addSession( $sub, 'associate_cat' ); 310 $vtp->setVar( $sub, 'associate_cat.value', '-1' ); 311 $vtp->setVar( $sub, 'associate_cat.content', '' ); 312 $vtp->closeSession( $sub, 'associate_cat' ); 313 $structure = create_structure( '', array() ); 314 display_categories( $structure, ' ' ); 342 // 343 // We only show a List Of Values if the number of categories is less than 344 // $conf['max_LOV_categories'] 345 $query = 'SELECT COUNT(id) AS nb_total_categories'; 346 $query.= ' FROM '.PREFIX_TABLE.'categories'; 347 $query.= ';'; 348 $row = mysql_fetch_array( mysql_query( $query ) ); 349 if ( $row['nb_total_categories'] < $conf['max_LOV_categories'] ) 350 { 351 $vtp->addSession( $sub, 'associate_LOV' ); 352 $vtp->addSession( $sub, 'associate_cat' ); 353 $vtp->setVar( $sub, 'associate_cat.value', '-1' ); 354 $vtp->setVar( $sub, 'associate_cat.content', '' ); 355 $vtp->closeSession( $sub, 'associate_cat' ); 356 $page['plain_structure'] = get_plain_structure( true ); 357 $structure = create_structure( '', array() ); 358 display_categories( $structure, ' ' ); 359 $vtp->closeSession( $sub, 'associate_LOV' ); 360 } 361 // else, we only display a small text field, we suppose the administrator 362 // knows the id of its category 363 else 364 { 365 $vtp->addSession( $sub, 'associate_text' ); 366 $vtp->closeSession( $sub, 'associate_text' ); 367 } 315 368 //----------------------------------------------------------- sending html code 316 369 $vtp->Parse( $handle , 'sub', $sub );
Note: See TracChangeset
for help on using the changeset viewer.