Changeset 4345 for branches/2.0/include/ws_functions.inc.php
- Timestamp:
- Nov 23, 2009, 12:38:57 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0/include/ws_functions.inc.php
r4344 r4345 943 943 ws_logfile('[merge_chunks] input parameter $output_filepath : '.$output_filepath); 944 944 945 if (is_file($output_filepath)) 946 { 947 unlink($output_filepath); 948 949 if (is_file($output_filepath)) 950 { 951 new PwgError(500, '[merge_chunks] error while trying to remove existing '.$output_filepath); 952 exit(); 953 } 954 } 955 945 956 $upload_dir = PHPWG_ROOT_PATH.'upload/buffer'; 946 957 $pattern = '/'.$original_sum.'-'.$type.'/'; … … 1037 1048 'filesize' => $filesize, 1038 1049 ); 1050 } 1051 1052 function ws_images_addFile($params, &$service) 1053 { 1054 // image_id 1055 // type {thumb, file, high} 1056 // sum 1057 1058 global $conf; 1059 if (!is_admin() || is_adviser() ) 1060 { 1061 return new PwgError(401, 'Access denied'); 1062 } 1063 1064 $params['image_id'] = (int)$params['image_id']; 1065 if ($params['image_id'] <= 0) 1066 { 1067 return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id"); 1068 } 1069 1070 // 1071 // what is the path? 1072 // 1073 $query = ' 1074 SELECT 1075 path, 1076 md5sum 1077 FROM '.IMAGES_TABLE.' 1078 WHERE id = '.$params['image_id'].' 1079 ;'; 1080 list($file_path, $original_sum) = mysql_fetch_row(pwg_query($query)); 1081 1082 // TODO only files added with web API can be updated with web API 1083 1084 // 1085 // makes sure directories are there and call the merge_chunks 1086 // 1087 $infos = add_file($file_path, $params['type'], $original_sum, $params['sum']); 1088 1089 // 1090 // update basic metadata from file 1091 // 1092 $update = array(); 1093 1094 if ('high' == $params['type']) 1095 { 1096 $update['high_filesize'] = $infos['filesize']; 1097 $update['has_high'] = 'true'; 1098 } 1099 1100 if ('file' == $params['type']) 1101 { 1102 $update['filesize'] = $infos['filesize']; 1103 $update['width'] = $infos['width']; 1104 $update['height'] = $infos['height']; 1105 } 1106 1107 // we may have nothing to update at database level, for example with a 1108 // thumbnail update 1109 if (count($update) > 0) 1110 { 1111 $update['id'] = $params['image_id']; 1112 1113 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 1114 mass_updates( 1115 IMAGES_TABLE, 1116 array( 1117 'primary' => array('id'), 1118 'update' => array_diff(array_keys($update), array('id')) 1119 ), 1120 array($update) 1121 ); 1122 } 1039 1123 } 1040 1124
Note: See TracChangeset
for help on using the changeset viewer.