Changeset 11934
- Timestamp:
- Aug 12, 2011, 9:13:57 AM (13 years ago)
- Location:
- extensions/Icy_Picture_Modify
- Files:
-
- 9 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Icy_Picture_Modify/CHANGELOG
r11637 r11934 1 1.0.3 2011-08-12 2 3 - Compatible with Piwigo 2.2.3, Piwigo 2.2.4 and the lastest version 4 of the plugin 'community' (*) 5 - Allow user to make links for image (image may be associated to or 6 dissociate from any uploadable album). See KNOWN PROBLEMS in the file 7 README for more details. 8 - Allow user to make represent for uploadable albums. See KNOWN PROBLEMS 9 in the file README for more details. 10 - Clean up code 11 12 (*) http://piwigo.org/ext/extension_view.php?eid=303 13 1 14 1.0.2 2011-07-04 2 15 -
extensions/Icy_Picture_Modify/README
r11637 r11934 1 Name 2 Icy Picture Modify 1 NAME 3 2 4 Description 3 icy_picture_modify -- Allow user to modify their pictures 4 5 DESCRIPTION 6 5 7 A piwigo extension that allows users to modify pictures they uploaded. 6 8 This extension just works as the 'picture_modify.php' for administrator. … … 9 11 'picture_modify.php' of the Piwigo distribution (version 2.2.3.) 10 12 11 Author 12 icy 13 14 License 15 GPL2 16 17 Homepage 18 At Github.com: https://github.com/icy/icy_picture_modify 19 At Piwigo.com: http://piwigo.org/ext/extension_view.php?eid=563 20 SVN repository: http://piwigo.org/svn/extensions/Icy_Picture_Modify/ 21 22 Usage 13 USAGE 23 14 24 15 1. Install and enable the plugin "community" which allows users to upload pictures … … 27 18 to modify that picture's information. 28 19 29 F eatures20 FEATURES 30 21 31 22 Users can modify the following information of a picture 32 1. Author 33 2. Description 34 3. Picture's date 35 4. Tags 36 5. ACL 37 6. Synchronize meta data 38 7. Delete picture 23 * Author 24 * Description 25 * Picture's date 26 * Tags 27 * ACL 28 * Synchronize meta data 29 * Delete picture 30 * Associcate/Dissociated image to/from uploadable category 31 * Use image to represent for uploadable category 39 32 40 K nown problems33 KNOWN PROBLEMS 41 34 42 1. Doesn't support all known templates 43 2. The source code isn't cleaned up for some hidden features: 44 - Link picture to some albums 45 - Use picture as some albums' thumbnail 35 * This plugin doesn't support all known templates 36 * This plugin may not work smoothly without plugin 'community' 37 * User can delete an image which is associated to some albums to which 38 the user doesn't have permission to write/access. When the plugin 39 'community' isn't installed, user can create image's link and/or 40 represents for any visible albums in the gallery. 41 42 AUTHOR 43 44 Anh K. Huỳnh (icy) 45 46 LICENSE 47 48 GPL2 49 50 HOMGEPAGE 51 52 At Github.com: https://github.com/icy/icy_picture_modify 53 At Piwigo.com: http://piwigo.org/ext/extension_view.php?eid=563 54 SVN repository: http://piwigo.org/svn/extensions/Icy_Picture_Modify/ -
extensions/Icy_Picture_Modify/icy_picture_modify.php
r11614 r11934 58 58 59 59 // Simplify redirect to administrator page if current user == admin 60 // FIXME: when a non-existent image_id is provided, the original code61 // FIXME: picture_modify doesn't work well. It should deny to modify62 // FIXME: such picture.63 60 if (is_admin()) 64 61 { … … 68 65 $url.= '&image_id='.$_GET['image_id']; 69 66 $url.= isset($_GET['cat_id']) ? '&cat_id='.$_GET['cat_id'] : ''; 67 // FIXME: What happens if a POST data were sent within admin uid? 70 68 redirect_http($url); 71 69 } … … 94 92 } 95 93 94 // <find writable categories> 95 96 // * Purpose: Find all categories that are reachable for the current user. 97 // * FIXME: This query will include all readable categories, those ones 98 // use can't write to them. 99 100 $my_categories = array(); 101 $my_permissions = null; 102 103 // <community support> 104 if (is_file(PHPWG_PLUGINS_PATH.'community/include/functions_community.inc.php')) 105 { 106 include_once(PHPWG_PLUGINS_PATH.'community/include/functions_community.inc.php'); 107 $user_permissions = community_get_user_permissions($user['id']); 108 $my_categories = $user_permissions['upload_categories']; 109 } 110 // </community support> 111 112 // FIXME: what happens if both of the following conditions are true 113 // FIXME: * true == $user_permissions['create_whole_gallery'] 114 // FIXME: * 0 < count($my_categories) 115 if (empty($user_permissions) or $user_permissions['create_whole_gallery']) 116 { 117 $query = ' 118 SELECT category_id 119 FROM '.IMAGE_CATEGORY_TABLE.' 120 ;'; 121 122 // list of categories to which the user can access 123 $my_categories = array_diff( 124 array_from_query($query, 'category_id'), 125 explode(',',calculate_permissions($user['id'], $user['status']))); 126 } 127 // </find writable categories> 96 128 97 129 // +-----------------------------------------------------------------------+ … … 128 160 ;'; 129 161 130 $authorizeds = array_diff( 131 array_from_query($query, 'category_id'), 132 explode(',', calculate_permissions($user['id'], $user['status'])) 133 ); 162 $authorizeds = array_intersect($my_categories, 163 array_from_query($query, 'category_id')); 134 164 135 165 foreach ($authorizeds as $category_id) … … 164 194 } 165 195 166 //--------------------------------------------------------- update informations 196 // +-----------------------------------------------------------------------+ 197 // | update informations | 198 // +-----------------------------------------------------------------------+ 167 199 168 200 // first, we verify whether there is a mistake on the given creation date … … 231 263 array_push($page['infos'], l10n('Photo informations updated')); 232 264 } 265 266 // +-----------------------------------------------------------------------+ 267 // | associate | 268 // +-----------------------------------------------------------------------+ 233 269 // associate the element to other categories than its storage category 270 // 234 271 if (isset($_POST['associate']) 235 272 and isset($_POST['cat_dissociated']) … … 239 276 associate_images_to_categories( 240 277 array($_GET['image_id']), 241 $_POST['cat_dissociated']278 array_intersect($_POST['cat_dissociated'], $my_categories) 242 279 ); 243 280 } 281 282 244 283 // dissociate the element from categories (but not from its storage category) 245 284 if (isset($_POST['dissociate']) … … 248 287 ) 249 288 { 289 $arr_dissociate = array_intersect($_POST['cat_associated'], $my_categories); 250 290 $query = ' 251 291 DELETE FROM '.IMAGE_CATEGORY_TABLE.' 252 292 WHERE image_id = '.$_GET['image_id'].' 253 AND category_id IN ('.implode(',', $ _POST['cat_associated']).')293 AND category_id IN ('.implode(',', $arr_dissociate).') 254 294 '; 255 295 pwg_query($query); 256 296 257 update_category($ _POST['cat_associated']);258 } 259 // elect the element to represent the given categories297 update_category($arr_dissociate); 298 } 299 // select the element to represent the given categories 260 300 if (isset($_POST['elect']) 261 301 and isset($_POST['cat_dismissed']) … … 264 304 { 265 305 $datas = array(); 266 foreach ($_POST['cat_dismissed'] as $category_id) 267 { 268 array_push($datas, 269 array('id' => $category_id, 270 'representative_picture_id' => $_GET['image_id'])); 271 } 272 $fields = array('primary' => array('id'), 273 'update' => array('representative_picture_id')); 274 mass_updates(CATEGORIES_TABLE, $fields, $datas); 306 $arr_dimissed = array_intersect($_POST['cat_dismissed'], $my_categories); 307 if (count($arr_dimissed) > 0) 308 { 309 foreach ($arr_dimissed as $category_id) 310 { 311 array_push($datas, 312 array('id' => $category_id, 313 'representative_picture_id' => $_GET['image_id'])); 314 } 315 $fields = array('primary' => array('id'), 316 'update' => array('representative_picture_id')); 317 mass_updates(CATEGORIES_TABLE, $fields, $datas); 318 } 275 319 } 276 320 // dismiss the element as representant of the given categories … … 280 324 ) 281 325 { 282 set_random_representant($_POST['cat_elected']); 326 $arr_dismiss = array_intersect($_POST['cat_elected'], $my_categories); 327 if (count($arr_dismiss) > 0) 328 { 329 set_random_representant($arr_dismiss); 330 } 283 331 } 284 332 … … 310 358 $row = pwg_db_fetch_assoc(pwg_query($query)); 311 359 360 // the physical storage directory contains the image 312 361 $storage_category_id = null; 313 362 if (!empty($row['storage_category_id'])) … … 463 512 ;'; 464 513 465 $authorizeds = array_diff( 466 array_from_query($query, 'category_id'), 467 explode( 468 ',', 469 calculate_permissions($user['id'], $user['status']) 470 ) 471 ); 472 514 // list of categories (OF THIS IMAGE) to which the user can access 515 $authorizeds = array_intersect($my_categories, 516 array_from_query($query, 'category_id')); 517 518 // if current category belongs to list of authorized categories 519 // we simply provide link to that category 473 520 if (isset($_GET['cat_id']) 474 521 and in_array($_GET['cat_id'], $authorizeds)) … … 482 529 ); 483 530 } 531 // otherwise we provide links to the *first* category in the list 484 532 else 485 533 { … … 493 541 ) 494 542 ); 543 // FIXME: why the first category is selected? 495 544 break; 496 545 } … … 507 556 FROM '.CATEGORIES_TABLE.' 508 557 INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = category_id 509 WHERE image_id = '.$_GET['image_id']; 558 WHERE image_id = '.$_GET['image_id'] . ' 559 AND id IN ('. join(",", $my_categories).')'; 560 // if the image belongs to a physical storage, 561 // we simply ignore that storage album 510 562 if (isset($storage_category_id)) 511 563 { … … 531 583 FROM '.CATEGORIES_TABLE.' 532 584 WHERE id NOT IN ('.implode(',', $associateds).') 585 AND id IN ('. join(",", $my_categories).') 533 586 ;'; 534 587 display_select_cat_wrapper($query, array(), 'dissociated_options'); … … 539 592 FROM '.CATEGORIES_TABLE.' 540 593 WHERE representative_picture_id = '.$_GET['image_id'].' 594 AND id IN ('. join(",", $my_categories).') 541 595 ;'; 542 596 display_select_cat_wrapper($query, array(), 'elected_options'); … … 545 599 SELECT id,name,uppercats,global_rank 546 600 FROM '.CATEGORIES_TABLE.' 547 WHERE representative_picture_id != '.$_GET['image_id'].' 548 OR representative_picture_id IS NULL 601 WHERE id IN ('. join(",", $my_categories).') 602 AND (representative_picture_id != '.$_GET['image_id'].' 603 OR representative_picture_id IS NULL) 549 604 ;'; 550 605 display_select_cat_wrapper($query, array(), 'dismissed_options'); -
extensions/Icy_Picture_Modify/main.inc.php
r11614 r11934 2 2 /* 3 3 Plugin Name: Icy Modify Picture 4 Version: 1.0. 24 Version: 1.0.3 5 5 Description: Allow users to modify pictures they uploaded 6 6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=563 -
extensions/Icy_Picture_Modify/template/icy_picture_modify.tpl
r11610 r11934 12 12 {combine_css path= 'themes/default/js/ui/theme/'|@cat:'jquery.ui.datepicker.css'} 13 13 {combine_css path= "$ICY_PICTURE_MODIFY_PATH/template/"|@cat:'datepicker.css'} 14 {combine_css path= "$ICY_PICTURE_MODIFY_PATH/template/"|@cat:'ui-resizable.css'} 14 15 15 16 {* Heavily copied from Piwigo distribution: picture_modify.tpl *} … … 183 184 184 185 </form> 186 187 <form id="associations" method="post" action="{$F_ACTION}#associations"> 188 <fieldset> 189 <legend>{'Linked albums'|@translate}</legend> 190 191 <table class="doubleSelect"> 192 <tr> 193 <td> 194 <h3>{'Associated'|@translate}</h3> 195 <select class="categoryList" name="cat_associated[]" multiple="multiple" size="30"> 196 {html_options options=$associated_options} 197 </select> 198 <p><input class="submit" type="submit" value="»" name="dissociate" style="font-size:15px;"></p> 199 </td> 200 201 <td> 202 <h3>{'Dissociated'|@translate}</h3> 203 <select class="categoryList" name="cat_dissociated[]" multiple="multiple" size="30"> 204 {html_options options=$dissociated_options} 205 </select> 206 <p><input class="submit" type="submit" value="«" name="associate" style="font-size:15px;"></p> 207 </td> 208 </tr> 209 </table> 210 211 </fieldset> 212 </form> 213 214 <form id="representation" method="post" action="{$F_ACTION}#representation"> 215 <fieldset> 216 <legend>{'Representation of albums'|@translate}</legend> 217 218 <table class="doubleSelect"> 219 <tr> 220 <td> 221 <h3>{'Represents'|@translate}</h3> 222 <select class="categoryList" name="cat_elected[]" multiple="multiple" size="30"> 223 {html_options options=$elected_options} 224 </select> 225 <p><input class="submit" type="submit" value="»" name="dismiss" style="font-size:15px;"></p> 226 </td> 227 228 <td> 229 <h3>{'Does not represent'|@translate}</h3> 230 <select class="categoryList" name="cat_dismissed[]" multiple="multiple" size="30"> 231 {html_options options=$dismissed_options} 232 </select> 233 <p><input class="submit" type="submit" value="«" name="elect" style="font-size:15px;"></p> 234 </td> 235 </tr> 236 </table> 237 238 </fieldset> 239 </form>
Note: See TracChangeset
for help on using the changeset viewer.