Changeset 825 for trunk/admin
- Timestamp:
- Aug 18, 2005, 7:59:00 PM (19 years ago)
- Location:
- trunk/admin
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/cat_modify.php
r809 r825 40 40 41 41 //--------------------------------------------------------- form criteria check 42 if ( isset( $_POST['submit'] ) ) 43 { 44 $query = 'UPDATE '.CATEGORIES_TABLE; 45 $query.= ' SET name = '; 46 if ( empty($_POST['name'])) 47 $query.= 'NULL'; 48 else 49 $query.= "'".htmlentities( $_POST['name'], ENT_QUOTES)."'"; 50 51 $query.= ', comment = '; 52 if ( empty($_POST['comment'])) 53 $query.= 'NULL'; 54 else 55 $query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'"; 56 57 if ( isset( $_POST['uploadable'] ) ) 58 $query.= ", uploadable = '".$_POST['uploadable']."'"; 59 60 if ( isset( $_POST['commentable'] ) ) 61 $query.= ", commentable = '".$_POST['commentable']."'"; 62 63 if ( isset( $_POST['associate'] ) ) 64 { 65 $query.= ', id_uppercat = '; 66 if ( $_POST['associate'] == -1 or $_POST['associate'] == '' ) 67 $query.= 'NULL'; 68 else 69 $query.= $_POST['associate']; 70 } 71 $query.= ' WHERE id = '.$_GET['cat_id']; 72 $query.= ';'; 73 pwg_query( $query ); 74 42 if (isset($_POST['submit'])) 43 { 44 $data = 45 array( 46 'id' => $_GET['cat_id'], 47 'name' => @$_POST['name'], 48 'commentable' => $_POST['commentable'], 49 'uploadable' => 50 isset($_POST['uploadable']) ? $_POST['uploadable'] : 'false', 51 'comment' => 52 $conf['allow_html_descriptions'] ? 53 @$_POST['comment'] : strip_tags(@$_POST['comment']) 54 ); 55 56 mass_updates( 57 CATEGORIES_TABLE, 58 array( 59 'primary' => array('id'), 60 'update' => array_diff(array_keys($data), array('id')) 61 ), 62 array($data) 63 ); 64 75 65 set_cat_visible(array($_GET['cat_id']), $_POST['visible']); 76 66 set_cat_status(array($_GET['cat_id']), $_POST['status']); -
trunk/admin/cat_perm.php
r817 r825 202 202 $template->assign_vars( 203 203 array( 204 ' TITLE' =>205 sprintf(206 l10n('Manage permissions for category "%s"'),207 get_cat_display_name_from_id($page['cat'])208 ) 204 'CATEGORIES_NAV' => 205 get_cat_display_name_from_id( 206 $page['cat'], 207 'admin.php?page=cat_modify&cat_id=' 208 ), 209 209 'F_ACTION' => 210 210 add_session_id( -
trunk/admin/include/functions.php
r809 r825 583 583 } 584 584 585 / / get_keywords returns an array with relevant keywords found in the string586 // given in argument. Keywords must be separated by comma in thisstring.587 // keywords must : 588 // - be longer or equal to 3 characters 589 // - not contain ', " or blank characters 590 // - unique in the string ("test,test" -> "test") 591 function get_keywords( $keywords_string ) 592 { 593 $keywords = array(); 594 595 $candidates = explode( ',', $keywords_string );596 foreach ( $candidates as $candidate ) {597 if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) )598 array_push( $keywords, $candidate );599 }600 601 return array_unique( $keywords);585 /** 586 * returns an array with relevant keywords found in the given string. 587 * 588 * Keywords must be separated by comma or space characters. 589 * 590 * @param string keywords_string 591 * @return array 592 */ 593 function get_keywords($keywords_string) 594 { 595 return 596 array_unique( 597 preg_split( 598 '/[\s,]+/', 599 $keywords_string 600 ) 601 ); 602 602 } 603 603 … … 743 743 UPDATE '.$tablename.' 744 744 SET '; 745 $is_first = true; 745 746 foreach ($dbfields['update'] as $num => $key) 746 747 { 747 if ( $num >= 1)748 if (!$is_first) 748 749 { 749 750 $query.= ",\n "; 750 751 } 751 752 $query.= $key.' = '; 752 if (isset($data[$key]) )753 if (isset($data[$key]) and $data[$key] != '') 753 754 { 754 755 $query.= '\''.$data[$key].'\''; … … 758 759 $query.= 'NULL'; 759 760 } 761 $is_first = false; 760 762 } 761 763 $query.= ' -
trunk/admin/include/functions_metadata.php
r738 r825 205 205 return $files; 206 206 } 207 208 // used_metadata string is displayed to inform admin which metadata will be 209 // used from files for synchronization 210 function get_used_metadata_list() 211 { 212 global $conf; 213 214 $used_metadata = array('filesize', 'width', 'height'); 215 216 if ($conf['use_exif']) 217 { 218 array_push($used_metadata, 'date_creation'); 219 } 220 221 if ($conf['use_iptc']) 222 { 223 foreach (array_keys($conf['use_iptc_mapping']) as $key) 224 { 225 array_push($used_metadata, $key); 226 } 227 } 228 229 return array_unique($used_metadata); 230 } 207 231 ?> -
trunk/admin/picture_modify.php
r817 r825 28 28 if(!defined("PHPWG_ROOT_PATH")) 29 29 { 30 die ("Hacking attempt!");30 die('Hacking attempt!'); 31 31 } 32 32 include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); 33 34 // +-----------------------------------------------------------------------+ 35 // | synchronize metadata | 36 // +-----------------------------------------------------------------------+ 37 38 if (isset($_GET['sync_metadata'])) 39 { 40 $query = ' 41 SELECT path 42 FROM '.IMAGES_TABLE.' 43 WHERE id = '.$_GET['image_id'].' 44 ;'; 45 list($path) = mysql_fetch_row(pwg_query($query)); 46 update_metadata(array($_GET['image_id'] => $path)); 47 48 array_push($page['infos'], l10n('Metadata synchronized from file')); 49 } 50 33 51 //--------------------------------------------------------- update informations 52 34 53 // first, we verify whether there is a mistake on the given creation date 35 if (isset($_POST['date_creation']) and !empty($_POST['date_creation'])) 36 { 37 if (!check_date_format($_POST['date_creation'])) 54 if (isset($_POST['date_creation_action']) 55 and 'set' == $_POST['date_creation_action']) 56 { 57 if (!checkdate( 58 $_POST['date_creation_month'], 59 $_POST['date_creation_day'], 60 $_POST['date_creation_year']) 61 ) 38 62 { 39 63 array_push($page['errors'], $lang['err_date']); 40 64 } 41 65 } 66 42 67 if (isset($_POST['submit']) and count($page['errors']) == 0) 43 68 { 44 $query = 'UPDATE '.IMAGES_TABLE.' SET name = '; 45 if ($_POST['name'] == '') 46 $query.= 'NULL'; 69 $data = array(); 70 $data{'id'} = $_GET['image_id']; 71 $data{'name'} = $_POST['name']; 72 $data{'author'} = $_POST['author']; 73 74 if ($conf['allow_html_descriptions']) 75 { 76 $data{'comment'} = @$_POST['description']; 77 } 47 78 else 48 $query.= "'".htmlentities($_POST['name'], ENT_QUOTES)."'"; 49 50 $query.= ', author = '; 51 if ($_POST['author'] == '') 52 $query.= 'NULL'; 79 { 80 $data{'comment'} = strip_tags(@$_POST['description']); 81 } 82 83 if (isset($_POST['date_creation_action'])) 84 { 85 if ('set' == $_POST['date_creation_action']) 86 { 87 $data{'date_creation'} = $_POST['date_creation_year'] 88 .'-'.$_POST['date_creation_month'] 89 .'-'.$_POST['date_creation_day']; 90 } 91 else if ('unset' == $_POST['date_creation_action']) 92 { 93 $data{'date_creation'} = ''; 94 } 95 } 96 97 $keywords = get_keywords($_POST['keywords']); 98 if (count($keywords) > 0) 99 { 100 $data{'keywords'} = implode(',', $keywords); 101 } 53 102 else 54 $query.= "'".htmlentities($_POST['author'],ENT_QUOTES)."'"; 55 56 $query.= ', comment = '; 57 if ($_POST['comment'] == '') 58 $query.= 'NULL'; 59 else 60 $query.= "'".htmlentities($_POST['comment'],ENT_QUOTES)."'"; 61 62 $query.= ', date_creation = '; 63 if (!empty($_POST['date_creation'])) 64 $query.= "'".date_convert($_POST['date_creation'])."'"; 65 else if ($_POST['date_creation'] == '') 66 $query.= 'NULL'; 67 68 $query.= ', keywords = '; 69 $keywords_array = get_keywords($_POST['keywords']); 70 if (count($keywords_array) == 0) 71 $query.= 'NULL'; 72 else 73 { 74 $query.= "'"; 75 foreach ($keywords_array as $i => $keyword) { 76 if ($i > 0) $query.= ','; 77 $query.= $keyword; 78 } 79 $query.= "'"; 80 } 81 82 $query.= ' WHERE id = '.$_GET['image_id']; 83 $query.= ';'; 84 pwg_query($query); 103 { 104 $data{'keywords'} = ''; 105 } 106 107 mass_updates( 108 IMAGES_TABLE, 109 array( 110 'primary' => array('id'), 111 'update' => array_diff(array_keys($data), array('id')) 112 ), 113 array($data) 114 ); 115 116 array_push($page['infos'], l10n('Picture informations updated')); 85 117 } 86 118 // associate the element to other categories than its storage category … … 138 170 // retrieving direct information about picture 139 171 $query = ' 140 SELECT i.*, c.uppercats 141 FROM '.IMAGES_TABLE.' AS i 142 INNER JOIN '.CATEGORIES_TABLE.' AS c ON i.storage_category_id = c.id 143 WHERE i.id = '.$_GET['image_id'].' 172 SELECT * 173 FROM '.IMAGES_TABLE.' 174 WHERE id = '.$_GET['image_id'].' 144 175 ;'; 145 176 $row = mysql_fetch_array(pwg_query($query)); … … 147 178 $storage_category_id = $row['storage_category_id']; 148 179 149 if (empty($row['name']))150 {151 $title = str_replace('_', ' ',get_filename_wo_extension($row['file']));152 }153 else154 {155 $title = $row['name'];156 }157 180 // Navigation path 158 $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']); 159 160 $url_img = PHPWG_ROOT_PATH.'picture.php?image_id='.$_GET['image_id']; 161 $url_img .= '&cat='.$row['storage_category_id']; 181 162 182 $date = isset($_POST['date_creation']) && empty($page['errors']) 163 183 ?$_POST['date_creation']:date_convert_back(@$row['date_creation']); 164 184 165 $url = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='; 166 $storage_category = get_cat_display_name_cache($row['uppercats'], 167 $url, 168 false); 169 //----------------------------------------------------- template initialization 185 // +-----------------------------------------------------------------------+ 186 // | template init | 187 // +-----------------------------------------------------------------------+ 188 170 189 $template->set_filenames( 171 190 array( … … 174 193 ); 175 194 176 $template->assign_vars(array( 177 'TITLE_IMG'=>$title, 178 'STORAGE_CATEGORY_IMG'=>$storage_category, 179 'PATH_IMG'=>$row['path'], 180 'FILE_IMG'=>$row['file'], 181 'TN_URL_IMG'=>$thumbnail_url, 182 'URL_IMG'=>add_session_id($url_img), 183 'DEFAULT_NAME_IMG'=>str_replace('_',' ',get_filename_wo_extension($row['file'])), 184 'FILE_IMG'=>$row['file'], 185 'NAME_IMG'=>isset($_POST['name'])?$_POST['name']:@$row['name'], 186 'SIZE_IMG'=>@$row['width'].' * '.@$row['height'], 187 'FILESIZE_IMG'=>@$row['filesize'].' KB', 188 'REGISTRATION_DATE_IMG' 189 => format_date($row['date_available'], 'mysql_datetime', true), 190 'AUTHOR_IMG'=>isset($_POST['author'])?$_POST['author']:@$row['author'], 191 'CREATION_DATE_IMG'=>$date, 192 'KEYWORDS_IMG'=>isset($_POST['keywords'])?$_POST['keywords']:@$row['keywords'], 193 'COMMENT_IMG'=>isset($_POST['comment'])?$_POST['comment']:@$row['comment'], 195 $template->assign_vars( 196 array( 197 'U_SYNC' => 198 add_session_id( 199 PHPWG_ROOT_PATH.'admin.php?page=picture_modify'. 200 '&image_id='.$_GET['image_id']. 201 (isset($_GET['cat_id']) ? '&cat_id='.$_GET['cat_id'] : ''). 202 '&sync_metadata=1' 203 ), 204 205 'PATH'=>$row['path'], 206 207 'TN_SRC' => get_thumbnail_src($row['path'], @$row['tn_ext']), 208 209 'NAME' => 210 isset($_POST['name']) ? 211 stripslashes($_POST['name']) : @$row['name'], 212 213 'DIMENSIONS' => @$row['width'].' * '.@$row['height'], 214 215 'FILESIZE' => @$row['filesize'].' KB', 216 217 'REGISTRATION_DATE' => 218 format_date($row['date_available'], 'mysql_datetime', false), 219 220 'AUTHOR' => isset($_POST['author']) ? $_POST['author'] : @$row['author'], 221 222 'CREATION_DATE' => $date, 223 224 'KEYWORDS' => 225 isset($_POST['keywords']) ? 226 stripslashes($_POST['keywords']) : @$row['keywords'], 227 228 'DESCRIPTION' => 229 isset($_POST['description']) ? 230 stripslashes($_POST['description']) : @$row['comment'], 194 231 195 'L_UPLOAD_NAME'=>$lang['upload_name'], 196 'L_DEFAULT'=>$lang['default'], 197 'L_FILE'=>$lang['file'], 198 'L_SIZE'=>$lang['size'], 199 'L_FILESIZE'=>$lang['filesize'], 200 'L_REGISTRATION_DATE'=>$lang['registration_date'], 201 'L_AUTHOR'=>$lang['author'], 202 'L_CREATION_DATE'=>$lang['creation_date'], 203 'L_KEYWORDS'=>$lang['keywords'], 204 'L_COMMENT'=>$lang['description'], 205 'L_CATEGORIES'=>$lang['categories'], 206 'L_DISSOCIATE'=>$lang['dissociate'], 207 'L_INFOIMAGE_ASSOCIATE'=>$lang['infoimage_associate'], 208 'L_SUBMIT'=>$lang['submit'], 209 'L_RESET'=>$lang['reset'], 210 'L_CAT_ASSOCIATED'=>$lang['infoimage_associated'], 211 'L_CAT_DISSOCIATED'=>$lang['infoimage_dissociated'], 212 'L_PATH'=>$lang['path'], 213 'L_STORAGE_CATEGORY'=>$lang['storage_category'], 214 'L_REPRESENTS'=>$lang['represents'], 215 'L_DOESNT_REPRESENT'=>$lang['doesnt_represent'], 232 'F_ACTION' => 233 add_session_id( 234 PHPWG_ROOT_PATH.'admin.php' 235 .get_query_string_diff(array('sync_metadata')) 236 ) 237 ) 238 ); 239 240 // creation date 241 unset($day, $month, $year); 242 243 if (isset($_POST['date_creation_action']) 244 and 'set' == $_POST['date_creation_action']) 245 { 246 foreach (array('day', 'month', 'year') as $varname) 247 { 248 $$varname = $_POST['date_creation_'.$varname]; 249 } 250 } 251 else if (isset($row['date_creation']) and !empty($row['date_creation'])) 252 { 253 list($year, $month, $day) = explode('-', $row['date_creation']); 254 } 255 else 256 { 257 list($year, $month, $day) = array('', 0, 0); 258 } 259 get_day_list('date_creation_day', $day); 260 get_month_list('date_creation_month', $month); 261 $template->assign_vars(array('DATE_CREATION_YEAR_VALUE' => $year)); 216 262 217 'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?'.$_SERVER['QUERY_STRING']) 218 )); 263 $query = ' 264 SELECT category_id, uppercats 265 FROM '.IMAGE_CATEGORY_TABLE.' AS ic 266 INNER JOIN '.CATEGORIES_TABLE.' AS c 267 ON c.id = ic.category_id 268 WHERE image_id = '.$_GET['image_id'].' 269 ;'; 270 $result = pwg_query($query); 271 272 if (mysql_num_rows($result) > 1) 273 { 274 $template->assign_block_vars('links', array()); 275 } 276 277 while ($row = mysql_fetch_array($result)) 278 { 279 $name = 280 get_cat_display_name_cache( 281 $row['uppercats'], 282 PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id=', 283 false 284 ); 285 286 if ($row['category_id'] == $storage_category_id) 287 { 288 $template->assign_vars(array('STORAGE_CATEGORY' => $name)); 289 } 290 else 291 { 292 $template->assign_block_vars('links.category', array('NAME' => $name)); 293 } 294 } 295 296 // jump to link 297 // 298 // 1. find all linked categories that are reachable for the current user. 299 // 2. if a category is available in the URL, use it if reachable 300 // 3. if URL category not available or reachable, use the first reachable 301 // linked category 302 // 4. if no category reachable, no jumpto link 303 $base_url_img = PHPWG_ROOT_PATH.'picture.php'; 304 $base_url_img.= '?image_id='.$_GET['image_id']; 305 $base_url_img.= '&cat='; 306 unset($url_img); 307 308 $query = ' 309 SELECT category_id 310 FROM '.IMAGE_CATEGORY_TABLE.' 311 WHERE image_id = '.$_GET['image_id'].' 312 ;'; 313 $authorizeds = array_diff( 314 array_from_query($query, 'category_id'), 315 explode(',', calculate_permissions($user['id'], $user['status'])) 316 ); 317 318 if (isset($_GET['cat_id']) 319 and in_array($_GET['cat_id'], $authorizeds)) 320 { 321 $url_img = $base_url_img.$_GET['cat_id']; 322 } 323 else 324 { 325 foreach ($authorizeds as $category) 326 { 327 $url_img = $base_url_img.$category; 328 break; 329 } 330 } 331 332 if (isset($url_img)) 333 { 334 $template->assign_block_vars( 335 'jumpto', 336 array( 337 'URL' => $url_img 338 ) 339 ); 340 } 219 341 220 342 // associate to another category ? … … 259 381 //----------------------------------------------------------- sending html code 260 382 261 262 383 $template->assign_var_from_handle('ADMIN_CONTENT', 'picture_modify'); 263 384 ?>
Note: See TracChangeset
for help on using the changeset viewer.