Changeset 11934


Ignore:
Timestamp:
Aug 12, 2011, 9:13:57 AM (9 years ago)
Author:
icy
Message:

Merge branch 'master' into svn

Location:
extensions/Icy_Picture_Modify
Files:
9 added
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/Icy_Picture_Modify/CHANGELOG

    r11637 r11934  
     11.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
    1141.0.2 2011-07-04
    215
  • extensions/Icy_Picture_Modify/README

    r11637 r11934  
    1 Name
    2   Icy Picture Modify
     1NAME
    32
    4 Description
     3  icy_picture_modify -- Allow user to modify their pictures
     4
     5DESCRIPTION
     6
    57  A piwigo extension that allows users to modify pictures they uploaded.
    68  This extension just works as the 'picture_modify.php' for administrator.
     
    911  'picture_modify.php' of the Piwigo distribution (version 2.2.3.)
    1012
    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
     13USAGE
    2314
    2415  1. Install and enable the plugin "community" which allows users to upload pictures
     
    2718     to modify that picture's information.
    2819
    29 Features
     20FEATURES
    3021
    3122  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
    3932
    40 Known problems
     33KNOWN PROBLEMS
    4134
    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
     42AUTHOR
     43
     44  Anh K. Huỳnh (icy)
     45
     46LICENSE
     47
     48  GPL2
     49
     50HOMGEPAGE
     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  
    5858
    5959// Simplify redirect to administrator page if current user == admin
    60 // FIXME: when a non-existent image_id is provided, the original code
    61 // FIXME: picture_modify doesn't work well. It should deny to modify
    62 // FIXME: such picture.
    6360if (is_admin())
    6461{
     
    6865    $url.= '&image_id='.$_GET['image_id'];
    6966    $url.= isset($_GET['cat_id']) ? '&cat_id='.$_GET['cat_id'] : '';
     67    // FIXME: What happens if a POST data were sent within admin uid?
    7068    redirect_http($url);
    7169  }
     
    9492}
    9593
     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>
     104if (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)
     115if (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>
    96128
    97129// +-----------------------------------------------------------------------+
     
    128160;';
    129161
    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'));
    134164
    135165  foreach ($authorizeds as $category_id)
     
    164194}
    165195
    166 //--------------------------------------------------------- update informations
     196// +-----------------------------------------------------------------------+
     197// |                          update informations                          |
     198// +-----------------------------------------------------------------------+
    167199
    168200// first, we verify whether there is a mistake on the given creation date
     
    231263  array_push($page['infos'], l10n('Photo informations updated'));
    232264}
     265
     266// +-----------------------------------------------------------------------+
     267// |                              associate                                |
     268// +-----------------------------------------------------------------------+
    233269// associate the element to other categories than its storage category
     270//
    234271if (isset($_POST['associate'])
    235272    and isset($_POST['cat_dissociated'])
     
    239276  associate_images_to_categories(
    240277    array($_GET['image_id']),
    241     $_POST['cat_dissociated']
     278    array_intersect($_POST['cat_dissociated'], $my_categories)
    242279    );
    243280}
     281
     282
    244283// dissociate the element from categories (but not from its storage category)
    245284if (isset($_POST['dissociate'])
     
    248287  )
    249288{
     289  $arr_dissociate = array_intersect($_POST['cat_associated'], $my_categories);
    250290  $query = '
    251291DELETE FROM '.IMAGE_CATEGORY_TABLE.'
    252292  WHERE image_id = '.$_GET['image_id'].'
    253     AND category_id IN ('.implode(',', $_POST['cat_associated']).')
     293    AND category_id IN ('.implode(',', $arr_dissociate).')
    254294';
    255295  pwg_query($query);
    256296
    257   update_category($_POST['cat_associated']);
    258 }
    259 // elect the element to represent the given categories
     297  update_category($arr_dissociate);
     298}
     299// select the element to represent the given categories
    260300if (isset($_POST['elect'])
    261301    and isset($_POST['cat_dismissed'])
     
    264304{
    265305  $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  }
    275319}
    276320// dismiss the element as representant of the given categories
     
    280324  )
    281325{
    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  }
    283331}
    284332
     
    310358$row = pwg_db_fetch_assoc(pwg_query($query));
    311359
     360// the physical storage directory contains the image
    312361$storage_category_id = null;
    313362if (!empty($row['storage_category_id']))
     
    463512;';
    464513
    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
    473520if (isset($_GET['cat_id'])
    474521    and in_array($_GET['cat_id'], $authorizeds))
     
    482529    );
    483530}
     531// otherwise we provide links to the *first* category in the list
    484532else
    485533{
     
    493541        )
    494542      );
     543    // FIXME: why the first category is selected?
    495544    break;
    496545  }
     
    507556  FROM '.CATEGORIES_TABLE.'
    508557    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
    510562if (isset($storage_category_id))
    511563{
     
    531583  FROM '.CATEGORIES_TABLE.'
    532584  WHERE id NOT IN ('.implode(',', $associateds).')
     585  AND id IN ('. join(",", $my_categories).')
    533586;';
    534587display_select_cat_wrapper($query, array(), 'dissociated_options');
     
    539592  FROM '.CATEGORIES_TABLE.'
    540593  WHERE representative_picture_id = '.$_GET['image_id'].'
     594    AND id IN ('. join(",", $my_categories).')
    541595;';
    542596display_select_cat_wrapper($query, array(), 'elected_options');
     
    545599SELECT id,name,uppercats,global_rank
    546600  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)
    549604;';
    550605display_select_cat_wrapper($query, array(), 'dismissed_options');
  • extensions/Icy_Picture_Modify/main.inc.php

    r11614 r11934  
    22/*
    33Plugin Name: Icy Modify Picture
    4 Version: 1.0.2
     4Version: 1.0.3
    55Description: Allow users to modify pictures they uploaded
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=563
  • extensions/Icy_Picture_Modify/template/icy_picture_modify.tpl

    r11610 r11934  
    1212{combine_css path= 'themes/default/js/ui/theme/'|@cat:'jquery.ui.datepicker.css'}
    1313{combine_css path= "$ICY_PICTURE_MODIFY_PATH/template/"|@cat:'datepicker.css'}
     14{combine_css path= "$ICY_PICTURE_MODIFY_PATH/template/"|@cat:'ui-resizable.css'}
    1415
    1516{* Heavily copied from Piwigo distribution: picture_modify.tpl *}
     
    183184
    184185</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="&raquo;" 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="&laquo;" 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="&raquo;" 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="&laquo;" 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.