aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include
diff options
context:
space:
mode:
Diffstat (limited to 'admin/include')
-rw-r--r--admin/include/add_core_tabs.inc.php66
-rw-r--r--admin/include/albums_tab.inc.php2
-rw-r--r--admin/include/c13y_internal.class.php2
-rw-r--r--admin/include/check_integrity.class.php30
-rw-r--r--admin/include/configuration_sizes_process.inc.php7
-rw-r--r--admin/include/configuration_watermark_process.inc.php7
-rw-r--r--admin/include/functions.php741
-rw-r--r--admin/include/functions_history.inc.php40
-rw-r--r--admin/include/functions_install.inc.php6
-rw-r--r--admin/include/functions_metadata.php16
-rw-r--r--admin/include/functions_notification_by_mail.inc.php100
-rw-r--r--admin/include/functions_permalinks.php2
-rw-r--r--admin/include/functions_plugins.inc.php4
-rw-r--r--admin/include/functions_upgrade.php22
-rw-r--r--admin/include/functions_upload.inc.php78
-rw-r--r--admin/include/image.class.php2
-rw-r--r--admin/include/index.php2
-rw-r--r--admin/include/languages.class.php77
-rw-r--r--admin/include/photos_add_direct_prepare.inc.php103
-rw-r--r--admin/include/photos_add_direct_process.inc.php80
-rw-r--r--admin/include/plugins.class.php247
-rw-r--r--admin/include/tabsheet.class.php2
-rw-r--r--admin/include/themes.class.php185
-rw-r--r--admin/include/updates.class.php103
-rw-r--r--admin/include/uploadify/uploadify.php37
25 files changed, 1035 insertions, 926 deletions
diff --git a/admin/include/add_core_tabs.inc.php b/admin/include/add_core_tabs.inc.php
index a1ac2a0ce..efc9cd0db 100644
--- a/admin/include/add_core_tabs.inc.php
+++ b/admin/include/add_core_tabs.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -29,17 +29,17 @@ function add_core_tabs($sheets, $tab_id)
{
case 'album':
global $admin_album_base_url;
- $sheets['properties'] = array('caption' => l10n('Properties'), 'url' => $admin_album_base_url.'-properties');
- $sheets['sort_order'] = array('caption' => l10n('Manage photo ranks'), 'url' => $admin_album_base_url.'-sort_order');
- $sheets['permissions'] = array('caption' => l10n('Permissions'), 'url' => $admin_album_base_url.'-permissions');
- $sheets['notification'] = array('caption' => l10n('Notification'), 'url' => $admin_album_base_url.'-notification');
+ $sheets['properties'] = array('caption' => '<span class="icon-pencil"></span>'.l10n('Properties'), 'url' => $admin_album_base_url.'-properties');
+ $sheets['sort_order'] = array('caption' => '<span class="icon-shuffle"></span>'.l10n('Manage photo ranks'), 'url' => $admin_album_base_url.'-sort_order');
+ $sheets['permissions'] = array('caption' => '<span class="icon-lock"></span>'.l10n('Permissions'), 'url' => $admin_album_base_url.'-permissions');
+ $sheets['notification'] = array('caption' => '<span class="icon-mail-alt"></span>'.l10n('Notification'), 'url' => $admin_album_base_url.'-notification');
break;
case 'albums':
global $my_base_url;
- $sheets['list'] = array('caption' => l10n('List'), 'url' => $my_base_url.'cat_list');
- $sheets['move'] = array('caption' => l10n('Move'), 'url' => $my_base_url.'cat_move');
- $sheets['permalinks'] = array('caption' => l10n('Permalinks'), 'url' => $my_base_url.'permalinks');
+ $sheets['list'] = array('caption' => '<span class="icon-menu"></span>'.l10n('List'), 'url' => $my_base_url.'cat_list');
+ $sheets['move'] = array('caption' => '<span class="icon-move"></span>'.l10n('Move'), 'url' => $my_base_url.'cat_move');
+ $sheets['permalinks'] = array('caption' => '<span class="icon-link"></span>'.l10n('Permalinks'), 'url' => $my_base_url.'permalinks');
break;
case 'batch_manager':
@@ -50,21 +50,29 @@ function add_core_tabs($sheets, $tab_id)
case 'cat_options':
global $link_start, $conf;
- $sheets['status'] = array('caption' => l10n('Public / Private'), 'url' => $link_start.'cat_options&amp;section=status');
- $sheets['visible'] = array('caption' => l10n('Lock'), 'url' => $link_start.'cat_options&amp;section=visible');
+ $sheets['status'] = array('caption' => '<span class="icon-lock"></span>'.l10n('Public / Private'), 'url' => $link_start.'cat_options&amp;section=status');
+ $sheets['visible'] = array('caption' => '<span class="icon-block"></span>'.l10n('Lock'), 'url' => $link_start.'cat_options&amp;section=visible');
if ($conf['activate_comments'])
- $sheets['comments'] = array('caption' => l10n('Comments'), 'url' => $link_start.'cat_options&amp;section=comments');
+ $sheets['comments'] = array('caption' => '<span class="icon-chat"></span>'.l10n('Comments'), 'url' => $link_start.'cat_options&amp;section=comments');
if ($conf['allow_random_representative'])
$sheets['representative'] = array('caption' => l10n('Representative'), 'url' => $link_start.'cat_options&amp;section=representative');
break;
case 'comments':
- $sheets[''] = array('caption' => l10n('User comments validation'), 'url' => '');
+ $sheets[''] = array('caption' => l10n('User comments'), 'url' => '');
break;
-
+
+ case 'users':
+ $sheets[''] = array('caption' => '<span class="icon-users"> </span>'.l10n('User list'), 'url' => '');
+ break;
+
+ case 'groups':
+ $sheets[''] = array('caption' => '<span class="icon-group"> </span>'.l10n('Groups'), 'url' => '');
+ break;
+
case 'configuration':
global $conf_link;
- $sheets['main'] = array('caption' => l10n('Main'), 'url' => $conf_link.'main');
+ $sheets['main'] = array('caption' => l10n('General'), 'url' => $conf_link.'main');
$sheets['sizes'] = array('caption' => l10n('Photo sizes'), 'url' => $conf_link.'sizes');
$sheets['watermark'] = array('caption' => l10n('Watermark'), 'url' => $conf_link.'watermark');
$sheets['display'] = array('caption' => l10n('Display'), 'url' => $conf_link.'display');
@@ -83,15 +91,15 @@ function add_core_tabs($sheets, $tab_id)
case 'history':
global $link_start;
- $sheets['stats'] = array('caption' => l10n('Statistics'), 'url' => $link_start.'stats');
- $sheets['history'] = array('caption' => l10n('Search'), 'url' => $link_start.'history');
+ $sheets['stats'] = array('caption' => '<span class="icon-signal"></span>'.l10n('Statistics'), 'url' => $link_start.'stats');
+ $sheets['history'] = array('caption' => '<span class="icon-search"></span>'.l10n('Search'), 'url' => $link_start.'history');
break;
case 'languages':
global $my_base_url;
- $sheets['installed'] = array('caption' => l10n('Installed Languages'), 'url' => $my_base_url.'&amp;tab=installed');
- $sheets['update'] = array('caption' => l10n('Check for updates'), 'url' => $my_base_url.'&amp;tab=update');
- $sheets['new'] = array('caption' => l10n('Add New Language'), 'url' => $my_base_url.'&amp;tab=new');
+ $sheets['installed'] = array('caption' => '<span class="icon-language"></span>'.l10n('Installed Languages'), 'url' => $my_base_url.'&amp;tab=installed');
+ $sheets['update'] = array('caption' => '<span class="icon-arrows-cw"></span>'.l10n('Check for updates'), 'url' => $my_base_url.'&amp;tab=update');
+ $sheets['new'] = array('caption' => '<span class="icon-plus-circled"></span>'.l10n('Add New Language'), 'url' => $my_base_url.'&amp;tab=new');
break;
case 'nbm':
@@ -104,22 +112,22 @@ function add_core_tabs($sheets, $tab_id)
case 'photo':
global $admin_photo_base_url;
$sheets['properties'] = array('caption' => l10n('Properties'), 'url' => $admin_photo_base_url.'-properties');
- $sheets['coi'] = array('caption' => l10n('Center of interest'), 'url' => $admin_photo_base_url.'-coi');
+ $sheets['coi'] = array('caption' => '<span class="icon-crop"></span>'.l10n('Center of interest'), 'url' => $admin_photo_base_url.'-coi');
break;
case 'photos_add':
global $conf;
- $sheets['direct'] = array('caption' => l10n('Web Form'), 'url' => PHOTOS_ADD_BASE_URL.'&amp;section=direct');
- $sheets['applications'] = array('caption' => l10n('Applications'), 'url' => PHOTOS_ADD_BASE_URL.'&amp;section=applications');
+ $sheets['direct'] = array('caption' => '<span class="icon-upload"></span>'.l10n('Web Form'), 'url' => PHOTOS_ADD_BASE_URL.'&amp;section=direct');
+ $sheets['applications'] = array('caption' => '<span class="icon-network"></span>'.l10n('Applications'), 'url' => PHOTOS_ADD_BASE_URL.'&amp;section=applications');
if ($conf['enable_synchronization'])
- $sheets['ftp'] = array('caption' => l10n('FTP + Synchronization'), 'url' => PHOTOS_ADD_BASE_URL.'&amp;section=ftp');
+ $sheets['ftp'] = array('caption' => '<span class="icon-exchange"></span>'.l10n('FTP + Synchronization'), 'url' => PHOTOS_ADD_BASE_URL.'&amp;section=ftp');
break;
case 'plugins':
global $my_base_url;
- $sheets['installed'] = array('caption' => l10n('Plugin list'), 'url' => $my_base_url.'&amp;tab=installed');
- $sheets['update'] = array('caption' => l10n('Check for updates'), 'url' => $my_base_url.'&amp;tab=update');
- $sheets['new'] = array('caption' => l10n('Other plugins'), 'url' => $my_base_url.'&amp;tab=new');
+ $sheets['installed'] = array('caption' => '<span class="icon-equalizer"></span>'.l10n('Plugin list'), 'url' => $my_base_url.'&amp;tab=installed');
+ $sheets['update'] = array('caption' => '<span class="icon-arrows-cw"></span>'.l10n('Check for updates'), 'url' => $my_base_url.'&amp;tab=update');
+ $sheets['new'] = array('caption' => '<span class="icon-plus-circled"></span>'.l10n('Other plugins'), 'url' => $my_base_url.'&amp;tab=new');
break;
case 'rating':
@@ -129,9 +137,9 @@ function add_core_tabs($sheets, $tab_id)
case 'themes':
global $my_base_url;
- $sheets['installed'] = array('caption' => l10n('Installed Themes'), 'url' => $my_base_url.'&amp;tab=installed');
- $sheets['update'] = array('caption' => l10n('Check for updates'), 'url' => $my_base_url.'&amp;tab=update');
- $sheets['new'] = array('caption' => l10n('Add New Theme'), 'url' => $my_base_url.'&amp;tab=new');
+ $sheets['installed'] = array('caption' => '<span class="icon-brush"></span>'.l10n('Installed Themes'), 'url' => $my_base_url.'&amp;tab=installed');
+ $sheets['update'] = array('caption' => '<span class="icon-arrows-cw"></span>'.l10n('Check for updates'), 'url' => $my_base_url.'&amp;tab=update');
+ $sheets['new'] = array('caption' => '<span class="icon-plus-circled"></span>'.l10n('Add New Theme'), 'url' => $my_base_url.'&amp;tab=new');
break;
case 'updates':
diff --git a/admin/include/albums_tab.inc.php b/admin/include/albums_tab.inc.php
index 88a0e9be5..399778d01 100644
--- a/admin/include/albums_tab.inc.php
+++ b/admin/include/albums_tab.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
diff --git a/admin/include/c13y_internal.class.php b/admin/include/c13y_internal.class.php
index 27df84246..10375095a 100644
--- a/admin/include/c13y_internal.class.php
+++ b/admin/include/c13y_internal.class.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
diff --git a/admin/include/check_integrity.class.php b/admin/include/check_integrity.class.php
index 62372e214..da549d777 100644
--- a/admin/include/check_integrity.class.php
+++ b/admin/include/check_integrity.class.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -71,9 +71,10 @@ class check_integrity
// Information
if (count($this->retrieve_list) > 0)
{
- $header_notes[] =
- l10n_dec('%d anomaly has been detected.', '%d anomalies have been detected.',
- count($this->retrieve_list));
+ $header_notes[] = l10n_dec(
+ '%d anomaly has been detected.', '%d anomalies have been detected.',
+ count($this->retrieve_list)
+ );
}
// Treatments
@@ -116,15 +117,17 @@ class check_integrity
if ($corrected_count > 0)
{
- $page['infos'][] =
- l10n_dec('%d anomaly has been corrected.', '%d anomalies have been detected corrected.',
- $corrected_count);
+ $page['infos'][] = l10n_dec(
+ '%d anomaly has been corrected.', '%d anomalies have been detected corrected.',
+ $corrected_count
+ );
}
if ($not_corrected_count > 0)
{
- $page['errors'][] =
- l10n_dec('%d anomaly has not been corrected.', '%d anomalies have not been corrected.',
- $not_corrected_count);
+ $page['errors'][] = l10n_dec(
+ '%d anomaly has not been corrected.', '%d anomalies have not been corrected.',
+ $not_corrected_count
+ );
}
}
else
@@ -145,9 +148,10 @@ class check_integrity
if ($ignored_count > 0)
{
- $page['infos'][] =
- l10n_dec('%d anomaly has been ignored.', '%d anomalies have been ignored.',
- $ignored_count);
+ $page['infos'][] = l10n_dec(
+ '%d anomaly has been ignored.', '%d anomalies have been ignored.',
+ $ignored_count
+ );
}
}
}
diff --git a/admin/include/configuration_sizes_process.inc.php b/admin/include/configuration_sizes_process.inc.php
index e6fa870d6..47cfaf388 100644
--- a/admin/include/configuration_sizes_process.inc.php
+++ b/admin/include/configuration_sizes_process.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -254,10 +254,7 @@ if (count($errors) == 0)
clear_derivative_cache($changed_types);
}
- array_push(
- $page['infos'],
- l10n('Your configuration settings are saved')
- );
+ $page['infos'][] = l10n('Your configuration settings are saved');
}
else
{
diff --git a/admin/include/configuration_watermark_process.inc.php b/admin/include/configuration_watermark_process.inc.php
index 0d28e32a8..ad23d92a2 100644
--- a/admin/include/configuration_watermark_process.inc.php
+++ b/admin/include/configuration_watermark_process.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -174,10 +174,7 @@ if (count($errors) == 0)
clear_derivative_cache($changed_types);
}
- array_push(
- $page['infos'],
- l10n('Your configuration settings are saved')
- );
+ $page['infos'][] = l10n('Your configuration settings are saved');
}
else
{
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 957ef086e..71c164822 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -21,11 +21,19 @@
// | USA. |
// +-----------------------------------------------------------------------+
-include(PHPWG_ROOT_PATH.'admin/include/functions_metadata.php');
+/**
+ * @package functions\admin\___
+ */
+
+include_once(PHPWG_ROOT_PATH.'admin/include/functions_metadata.php');
+
-// The function delete_site deletes a site and call the function
-// delete_categories for each primary category of the site
-function delete_site( $id )
+/**
+ * Deletes a site and call delete_categories for each primary category of the site
+ *
+ * @param int $id
+ */
+function delete_site($id)
{
// destruction of the categories of the site
$query = '
@@ -44,18 +52,19 @@ DELETE FROM '.SITES_TABLE.'
pwg_query($query);
}
-
-// The function delete_categories deletes the categories identified by the
-// (numeric) key of the array $ids. It also deletes (in the database) :
-// - all the elements physically linked to the category (delete_elements, see further)
-// - all the links between elements and this category
-// - all the restrictions linked to the category
-// The function works recursively.
-//
-// the $photo_deletion_mode is for photos virtually linked to the categorty
-// * no_delete : delete no photo, may create orphans
-// * delete_orphans : delete photos that are no longer linked to any category
-// * force_delete : delete photos even if they are linked to another category
+/**
+ * Recursively deletes one or more categories.
+ * It also deletes :
+ * - all the elements physically linked to the category (with delete_elements)
+ * - all the links between elements and this category
+ * - all the restrictions linked to the category
+ *
+ * @param int[] $ids
+ * @param string $photo_deletion_mode
+ * - no_delete : delete no photo, may create orphans
+ * - delete_orphans : delete photos that are no longer linked to any category
+ * - force_delete : delete photos even if they are linked to another category
+ */
function delete_categories($ids, $photo_deletion_mode='no_delete')
{
if (count($ids) == 0)
@@ -156,8 +165,12 @@ DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.'
trigger_action('delete_categories', $ids);
}
-// Deletes all files (on disk) related to given image ids
-// @return image ids where files are deleted successfully
+/**
+ * Deletes all files (on disk) related to given image ids.
+ *
+ * @param int[] $ids
+ * @return 0|int[] image ids where files were successfully deleted
+ */
function delete_element_files($ids)
{
global $conf;
@@ -219,12 +232,18 @@ SELECT
return $new_ids;
}
-// The function delete_elements deletes the elements identified by the
-// (numeric) values of the array $ids. It also deletes (in the database) :
-// - all the comments related to elements
-// - all the links between categories and elements
-// - all the favorites associated to elements
-// @return number of deleted elements
+/**
+ * Deletes elements from database.
+ * It also deletes :
+ * - all the comments related to elements
+ * - all the links between categories/tags and elements
+ * - all the favorites/rates associated to elements
+ * - removes elements from caddie
+ *
+ * @param int[] $ids
+ * @param bool $physical_deletion
+ * @return int number of deleted elements
+ */
function delete_elements($ids, $physical_deletion=false)
{
if (count($ids) == 0)
@@ -241,60 +260,55 @@ function delete_elements($ids, $physical_deletion=false)
return 0;
}
}
+
+ $ids_str = wordwrap(implode(', ', $ids), 80, "\n");
// destruction of the comments on the image
$query = '
DELETE FROM '.COMMENTS_TABLE.'
- WHERE image_id IN (
-'.wordwrap(implode(', ', $ids), 80, "\n").')
+ WHERE image_id IN ('. $ids_str .')
;';
pwg_query($query);
- // destruction of the links between images and this category
+ // destruction of the links between images and categories
$query = '
DELETE FROM '.IMAGE_CATEGORY_TABLE.'
- WHERE image_id IN (
-'.wordwrap(implode(', ', $ids), 80, "\n").')
+ WHERE image_id IN ('. $ids_str .')
;';
pwg_query($query);
// destruction of the links between images and tags
$query = '
DELETE FROM '.IMAGE_TAG_TABLE.'
- WHERE image_id IN (
-'.wordwrap(implode(', ', $ids), 80, "\n").')
+ WHERE image_id IN ('. $ids_str .')
;';
pwg_query($query);
// destruction of the favorites associated with the picture
$query = '
DELETE FROM '.FAVORITES_TABLE.'
- WHERE image_id IN (
-'.wordwrap(implode(', ', $ids), 80, "\n").')
+ WHERE image_id IN ('. $ids_str .')
;';
pwg_query($query);
// destruction of the rates associated to this element
$query = '
DELETE FROM '.RATE_TABLE.'
- WHERE element_id IN (
-'.wordwrap(implode(', ', $ids), 80, "\n").')
+ WHERE element_id IN ('. $ids_str .')
;';
pwg_query($query);
- // destruction of the rates associated to this element
+ // destruction of the caddie associated to this element
$query = '
DELETE FROM '.CADDIE_TABLE.'
- WHERE element_id IN (
-'.wordwrap(implode(', ', $ids), 80, "\n").')
+ WHERE element_id IN ('. $ids_str .')
;';
pwg_query($query);
// destruction of the image
$query = '
DELETE FROM '.IMAGES_TABLE.'
- WHERE id IN (
-'.wordwrap(implode(', ', $ids), 80, "\n").')
+ WHERE id IN ('. $ids_str .')
;';
pwg_query($query);
@@ -303,8 +317,7 @@ DELETE FROM '.IMAGES_TABLE.'
SELECT
id
FROM '.CATEGORIES_TABLE.'
- WHERE representative_picture_id IN (
-'.wordwrap(implode(', ', $ids), 80, "\n").')
+ WHERE representative_picture_id IN ('. $ids_str .')
;';
$category_ids = array_from_query($query, 'id');
if (count($category_ids) > 0)
@@ -316,13 +329,13 @@ SELECT
return count($ids);
}
-// The delete_user function delete a user identified by the $user_id
-// It also deletes :
-// - all the access linked to this user
-// - all the links to any group
-// - all the favorites linked to this user
-// - calculated permissions linked to the user
-// - all datas about notifications for the user
+/**
+ * Deletes an user.
+ * It also deletes all related data (accesses, favorites, permissions, etc.)
+ * @todo : accept array input
+ *
+ * @param int $user_id
+ */
function delete_user($user_id)
{
global $conf;
@@ -356,7 +369,7 @@ DELETE FROM '.$table.'
pwg_query($query);
}
- // destruction of the user
+ // purge of sessions
$query = '
DELETE FROM '.SESSIONS_TABLE.'
WHERE data LIKE \'pwg_uid|i:'.(int)$user_id.';%\'
@@ -415,10 +428,9 @@ SELECT
/**
* Verifies that the representative picture really exists in the db and
- * picks up a random represantive if possible and based on config.
+ * picks up a random representative if possible and based on config.
*
- * @param mixed category id
- * @returns void
+ * @param 'all'|int|int[] $ids
*/
function update_category($ids = 'all')
{
@@ -485,9 +497,8 @@ SELECT DISTINCT id
}
/**
- * check and repair images integrity
- *
- * TODO see delete_elements function to check all linked tables
+ * Checks and repairs IMAGE_CATEGORY_TABLE integrity.
+ * Removes all entries from the table which correspond to a deleted image.
*/
function images_integrity()
{
@@ -513,18 +524,18 @@ DELETE
}
/**
- * returns an array containing sub-directories which can be a category,
- * recursive by default
- *
- * directories nammed "thumbnail", "pwg_high" or "pwg_representative" are
- * omitted
+ * Returns an array containing sub-directories which are potentially
+ * a category.
+ * Directories named ".svn", "thumbnail", "pwg_high" or "pwg_representative"
+ * are omitted.
*
- * @param string $basedir
- * @return array
+ * @param string $basedir (eg: ./galleries)
+ * @return string[]
*/
function get_fs_directories($path, $recursive = true)
{
$dirs = array();
+ $path = rtrim($path, '/');
if (is_dir($path))
{
@@ -540,7 +551,7 @@ function get_fs_directories($path, $recursive = true)
and $node != 'pwg_representative'
and is_dir($path.'/'.$node))
{
- array_push($dirs, $path.'/'.$node);
+ $dirs[] = $path.'/'.$node;
if ($recursive)
{
$dirs = array_merge($dirs, get_fs_directories($path.'/'.$node));
@@ -555,9 +566,8 @@ function get_fs_directories($path, $recursive = true)
}
/**
- * order categories (update categories.rank and global_rank database fields)
- * so that rank field are consecutive integers starting at 1 for each child
- * @return void
+ * Orders categories (update categories.rank and global_rank database fields)
+ * so that rank field are consecutive integers starting at 1 for each child.
*/
function update_global_rank()
{
@@ -623,22 +633,21 @@ SELECT id, id_uppercat, uppercats, rank, global_rank
}
/**
- * change the visible property on a set of categories
+ * Change the **visible** property on a set of categories.
*
- * @param array categories
- * @param string value
- * @return void
+ * @param int[] $categories
+ * @param boolean|string $value
*/
function set_cat_visible($categories, $value)
{
- if (!in_array($value, array('true', 'false')))
+ if ( ($value = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)) === null )
{
trigger_error("set_cat_visible invalid param $value", E_USER_WARNING);
return false;
}
// unlocking a category => all its parent categories become unlocked
- if ($value == 'true')
+ if ($value)
{
$uppercats = get_uppercat_ids($categories);
$query = '
@@ -648,7 +657,7 @@ UPDATE '.CATEGORIES_TABLE.'
pwg_query($query);
}
// locking a category => all its child categories become locked
- if ($value == 'false')
+ else
{
$subcats = get_subcat_ids($categories);
$query = '
@@ -660,11 +669,10 @@ UPDATE '.CATEGORIES_TABLE.'
}
/**
- * change the status property on a set of categories : private or public
+ * Change the **status** property on a set of categories : private or public.
*
- * @param array categories
- * @param string value
- * @return void
+ * @param int[] $categories
+ * @param string $value
*/
function set_cat_status($categories, $value)
{
@@ -698,10 +706,10 @@ UPDATE '.CATEGORIES_TABLE.'
}
/**
- * returns all uppercats category ids of the given category ids
+ * Returns all uppercats category ids of the given category ids.
*
- * @param array cat_ids
- * @return array
+ * @param int[] $cat_ids
+ * @return int[]
*/
function get_uppercat_ids($cat_ids)
{
@@ -729,9 +737,9 @@ SELECT uppercats
}
/**
- * set a new random representant to the categories
+ * Set a new random representant to the categories.
*
- * @param array categories
+ * @param int[] $categories
*/
function set_random_representant($categories)
{
@@ -747,12 +755,9 @@ SELECT image_id
;';
list($representative) = pwg_db_fetch_row(pwg_query($query));
- array_push(
- $datas,
- array(
- 'id' => $category_id,
- 'representative_picture_id' => $representative,
- )
+ $datas[] = array(
+ 'id' => $category_id,
+ 'representative_picture_id' => $representative,
);
}
@@ -767,10 +772,10 @@ SELECT image_id
}
/**
- * returns the fulldir for each given category id
+ * Returns the fulldir for each given category id.
*
- * @param array cat_ids
- * @return array
+ * @param int[] intcat_ids
+ * @return string[]
*/
function get_fulldirs($cat_ids)
{
@@ -819,11 +824,10 @@ SELECT id, uppercats, site_id
}
/**
- * returns an array with all file system files according to
- * $conf['file_ext']
+ * Returns an array with all file system files according to $conf['file_ext']
*
* @param string $path
- * @param bool recursive
+ * @param bool $recursive
* @return array
*/
function get_fs($path, $recursive = true)
@@ -862,26 +866,26 @@ function get_fs($path, $recursive = true)
{
if (basename($path) == 'thumbnail')
{
- array_push($fs['thumbnails'], $path.'/'.$node);
+ $fs['thumbnails'][] = $path.'/'.$node;
}
else if (basename($path) == 'pwg_representative')
{
- array_push($fs['representatives'], $path.'/'.$node);
+ $fs['representatives'][] = $path.'/'.$node;
}
else
{
- array_push($fs['elements'], $path.'/'.$node);
+ $fs['elements'][] = $path.'/'.$node;
}
}
// else if (in_array($extension, $conf['file_ext']))
else if (isset($conf['flip_file_ext'][$extension]))
{
- array_push($fs['elements'], $path.'/'.$node);
+ $fs['elements'][] = $path.'/'.$node;
}
}
else if (is_dir($path.'/'.$node) and $node != 'pwg_high' and $recursive)
{
- array_push($subdirs, $node);
+ $subdirs[] = $node;
}
}
}
@@ -905,14 +909,12 @@ function get_fs($path, $recursive = true)
}
/**
- * synchronize base users list and related users list
+ * Synchronize base users list and related users list.
*
- * compares and synchronizes base users table (USERS_TABLE) with its child
+ * Compares and synchronizes base users table (USERS_TABLE) with its child
* tables (USER_INFOS_TABLE, USER_ACCESS, USER_CACHE, USER_GROUP) : each
* base user must be present in child tables, users in child tables not
* present in base table must be deleted.
- *
- * @return void
*/
function sync_users()
{
@@ -974,10 +976,7 @@ DELETE
}
/**
- * updates categories.uppercats field based on categories.id +
- * categories.id_uppercat
- *
- * @return void
+ * Updates categories.uppercats field based on categories.id + categories.id_uppercat
*/
function update_uppercats()
{
@@ -995,19 +994,16 @@ SELECT id, id_uppercat, uppercats
$uppercat = $id;
while ($uppercat)
{
- array_push($upper_list, $uppercat);
+ $upper_list[] = $uppercat;
$uppercat = $cat_map[$uppercat]['id_uppercat'];
}
$new_uppercats = implode(',', array_reverse($upper_list));
if ($new_uppercats != $cat['uppercats'])
{
- array_push(
- $datas,
- array(
- 'id' => $id,
- 'uppercats' => $new_uppercats
- )
+ $datas[] = array(
+ 'id' => $id,
+ 'uppercats' => $new_uppercats
);
}
}
@@ -1016,9 +1012,7 @@ SELECT id, id_uppercat, uppercats
}
/**
- * update images.path field
- *
- * @return void
+ * Update images.path field base on images.file and storage categories fulldirs.
*/
function update_path()
{
@@ -1042,12 +1036,11 @@ UPDATE '.IMAGES_TABLE.'
}
/**
- * change the parent category of the given categories. The categories are
+ * Change the parent category of the given categories. The categories are
* supposed virtual.
*
- * @param array category identifiers
- * @param int parent category identifier
- * @return void
+ * @param int[] $category_ids
+ * @param int $new_parent (-1 for root)
*/
function move_categories($category_ids, $new_parent = -1)
{
@@ -1095,20 +1088,16 @@ SELECT uppercats
// into a new parent category with uppercats 12,125,13,14,24
if (preg_match('/^'.$category['uppercats'].'(,|$)/', $new_parent_uppercats))
{
- array_push(
- $page['errors'],
- l10n('You cannot move an album in its own sub album')
- );
+ $page['errors'][] = l10n('You cannot move an album in its own sub album');
return;
}
}
}
- $tables =
- array(
- USER_ACCESS_TABLE => 'user_id',
- GROUP_ACCESS_TABLE => 'group_id'
- );
+ $tables = array(
+ USER_ACCESS_TABLE => 'user_id',
+ GROUP_ACCESS_TABLE => 'group_id'
+ );
$query = '
UPDATE '.CATEGORIES_TABLE.'
@@ -1139,66 +1128,62 @@ SELECT status
{
foreach ($categories as $cat_id => $category)
{
- switch ($category['status'])
+ if ('public' == $category['status'])
{
- case 'public' :
- {
- set_cat_status(array($cat_id), 'private');
- break;
- }
- case 'private' :
- {
- $subcats = get_subcat_ids(array($cat_id));
+ set_cat_status(array($cat_id), 'private');
+ }
+
+ $subcats = get_subcat_ids(array($cat_id));
- foreach ($tables as $table => $field)
- {
- $query = '
+ foreach ($tables as $table => $field)
+ {
+ $query = '
SELECT '.$field.'
FROM '.$table.'
WHERE cat_id = '.$cat_id.'
;';
- $category_access = array_from_query($query, $field);
+ $category_access = array_from_query($query, $field);
- $query = '
+ $query = '
SELECT '.$field.'
FROM '.$table.'
WHERE cat_id = '.$new_parent.'
;';
- $parent_access = array_from_query($query, $field);
+ $parent_access = array_from_query($query, $field);
- $to_delete = array_diff($parent_access, $category_access);
+ $to_delete = array_diff($category_access, $parent_access);
- if (count($to_delete) > 0)
- {
- $query = '
+ if (count($to_delete) > 0)
+ {
+ $query = '
DELETE FROM '.$table.'
WHERE '.$field.' IN ('.implode(',', $to_delete).')
AND cat_id IN ('.implode(',', $subcats).')
;';
- pwg_query($query);
- }
- }
- break;
+ pwg_query($query);
}
}
}
}
- array_push(
- $page['infos'],
- l10n_dec(
- '%d album moved', '%d albums moved',
- count($categories)
- )
+ $page['infos'][] = l10n_dec(
+ '%d album moved', '%d albums moved',
+ count($categories)
);
}
/**
- * create a virtual category
+ * Create a virtual category.
*
- * @param string category name
- * @param int parent category id
- * @return array with ('info' and 'id') or ('error') key
+ * @param string $category_name
+ * @param int $parent_id
+ * @param array $options
+ * - boolean commentable
+ * - boolean visible
+ * - string status
+ * - string comment
+ * - boolean inherit
+ * @return array ('info', 'id') or ('error')
*/
function create_virtual_category($category_name, $parent_id=null, $options=array())
{
@@ -1303,7 +1288,33 @@ SELECT id, uppercats, global_rank, visible, status
update_global_rank();
- if ('private' == $insert['status'])
+ if ('private' == $insert['status'] and !empty($insert['id_uppercat']) and ((isset($options['inherit']) and $options['inherit']) or $conf['inheritance_by_default']) )
+ {
+ $query = '
+ SELECT group_id
+ FROM '.GROUP_ACCESS_TABLE.'
+ WHERE cat_id = '.$insert['id_uppercat'].'
+ ;';
+ $granted_grps = array_from_query($query, 'group_id');
+ $inserts = array();
+ foreach ($granted_grps as $granted_grp)
+ {
+ $inserts[] = array(
+ 'group_id' => $granted_grp,
+ 'cat_id' => $inserted_id
+ );
+ }
+ mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $inserts);
+
+ $query = '
+ SELECT user_id
+ FROM '.USER_ACCESS_TABLE.'
+ WHERE cat_id = '.$insert['id_uppercat'].'
+ ;';
+ $granted_users = array_from_query($query, 'user_id');
+ add_permission_on_category($inserted_id, array_unique(array_merge(get_admins(), array($user['id']), $granted_users)));
+ }
+ else if ('private' == $insert['status'])
{
add_permission_on_category($inserted_id, array_unique(array_merge(get_admins(), array($user['id']))));
}
@@ -1315,12 +1326,11 @@ SELECT id, uppercats, global_rank, visible, status
}
/**
- * Set tags to an image. Warning: given tags are all tags associated to the
- * image, not additionnal tags.
+ * Set tags to an image.
+ * Warning: given tags are all tags associated to the image, not additionnal tags.
*
- * @param array tag ids
- * @param int image id
- * @return void
+ * @param int[] $tags
+ * @param int $image_id
*/
function set_tags($tags, $image_id)
{
@@ -1330,9 +1340,8 @@ function set_tags($tags, $image_id)
/**
* Add new tags to a set of images.
*
- * @param array tag ids
- * @param array image ids
- * @return void
+ * @param int[] $tags
+ * @param int[] $images
*/
function add_tags($tags, $images)
{
@@ -1367,10 +1376,13 @@ DELETE
array_keys($inserts[0]),
$inserts
);
+ invalidate_user_cache_nb_tags();
}
/**
+ * Delete tags and tags associations.
*
+ * @param int[] $tag_ids
*/
function delete_tags($tag_ids)
{
@@ -1397,9 +1409,17 @@ DELETE
WHERE id IN ('.implode(',', $tag_ids).')
;';
pwg_query($query);
+
+ invalidate_user_cache_nb_tags();
}
-function tag_id_from_tag_name($tag_name)
+/**
+ * Returns a tag id from its name. If nothing found, create a new tag.
+ *
+ * @param string $tag_name
+ * @return int
+ */
+function tag_id_from_tag_name($tag_name, $create=true)
{
global $page;
@@ -1444,6 +1464,9 @@ SELECT id
)
)
);
+
+ invalidate_user_cache_nb_tags();
+
$page['tag_id_from_tag_name_cache'][$tag_name] = pwg_db_insert_id(TAGS_TABLE);
return $page['tag_id_from_tag_name_cache'][$tag_name];
}
@@ -1454,6 +1477,11 @@ SELECT id
return $page['tag_id_from_tag_name_cache'][$tag_name];
}
+/**
+ * Set tags of images. Overwrites all existing associations.
+ *
+ * @param array $tags_of - keys are image ids, values are array of tag ids
+ */
function set_tags_of($tags_of)
{
if (count($tags_of) > 0)
@@ -1486,17 +1514,17 @@ DELETE
$inserts
);
}
+
+ invalidate_user_cache_nb_tags();
}
}
/**
* Associate a list of images to a list of categories.
+ * The function will not duplicate links and will preserve ranks.
*
- * The function will not duplicate links and will preserve ranks
- *
- * @param array images
- * @param array categories
- * @return void
+ * @param int[] $images
+ * @param int[] $categories
*/
function associate_images_to_categories($images, $categories)
{
@@ -1559,13 +1587,10 @@ SELECT
{
$rank = ++$current_rank_of[$category_id];
- array_push(
- $inserts,
- array(
- 'image_id' => $image_id,
- 'category_id' => $category_id,
- 'rank' => $rank,
- )
+ $inserts[] = array(
+ 'image_id' => $image_id,
+ 'category_id' => $category_id,
+ 'rank' => $rank,
);
}
}
@@ -1586,12 +1611,10 @@ SELECT
/**
* Dissociate images from all old categories except their storage category and
* associate to new categories.
+ * This function will preserve ranks.
*
- * This function will preserve ranks
- *
- * @param array images
- * @param array categories
- * @return void
+ * @param int[] $images
+ * @param int[] $categories
*/
function move_images_to_categories($images, $categories)
{
@@ -1630,9 +1653,8 @@ DELETE '.IMAGE_CATEGORY_TABLE.'.*
* Associate images associated to a list of source categories to a list of
* destination categories.
*
- * @param array sources
- * @param array destinations
- * @return void
+ * @param int[] $sources
+ * @param int[] $destinations
*/
function associate_categories_to_categories($sources, $destinations)
{
@@ -1654,8 +1676,7 @@ SELECT image_id
/**
* Refer main Piwigo URLs (currently PHPWG_DOMAIN domain)
*
- * @param void
- * @return array like $conf['links']
+ * @return string[]
*/
function pwg_URL()
{
@@ -1671,7 +1692,7 @@ function pwg_URL()
}
/**
- * Invalidates cahed data (permissions and category counts) for all users.
+ * Invalidates cached data (permissions and category counts) for all users.
*/
function invalidate_user_cache($full = true)
{
@@ -1695,9 +1716,25 @@ UPDATE '.USER_CACHE_TABLE.'
}
/**
- * adds the caracter set to a create table sql query.
- * all CREATE TABLE queries must call this function
- * @param string query - the sql query
+ * Invalidates cached tags counter for all users.
+ */
+function invalidate_user_cache_nb_tags()
+{
+ global $user;
+ unset($user['nb_available_tags']);
+
+ $query = '
+UPDATE '.USER_CACHE_TABLE.'
+ SET nb_available_tags = NULL';
+ pwg_query($query);
+}
+
+/**
+ * Adds the caracter set to a create table sql query.
+ * All CREATE TABLE queries must call this function
+ *
+ * @param string $query
+ * @return string
*/
function create_table_add_character_set($query)
{
@@ -1742,9 +1779,11 @@ function create_table_add_character_set($query)
}
/**
- * Returns array use on template with html_options method
- * @param Min and Max access to use
- * @return array of user access level
+ * Returns access levels as array used on template with html_options functions.
+ *
+ * @param int $MinLevelAccess
+ * @param int $MaxLevelAccess
+ * @return array
*/
function get_user_access_level_html_options($MinLevelAccess = ACCESS_FREE, $MaxLevelAccess = ACCESS_CLOSED)
{
@@ -1757,9 +1796,11 @@ function get_user_access_level_html_options($MinLevelAccess = ACCESS_FREE, $MaxL
}
/**
- * returns a list of templates currently available in template-extension
+ * returns a list of templates currently available in template-extension.
* Each .tpl file is extracted from template-extension.
- * @return array
+ *
+ * @param string $start (internal use)
+ * @return string[]
*/
function get_extents($start='')
{
@@ -1784,6 +1825,12 @@ function get_extents($start='')
return $extents;
}
+/**
+ * Create a new tag.
+ *
+ * @param string $tag_name
+ * @return array ('id', info') or ('error')
+ */
function create_tag($tag_name)
{
// does the tag already exists?
@@ -1796,45 +1843,35 @@ SELECT id
if (count($existing_tags) == 0)
{
- mass_inserts(
+ single_insert(
TAGS_TABLE,
- array('name', 'url_name'),
array(
- array(
- 'name' => $tag_name,
- 'url_name' => trigger_event('render_tag_url', $tag_name),
- )
+ 'name' => $tag_name,
+ 'url_name' => trigger_event('render_tag_url', $tag_name),
)
);
$inserted_id = pwg_db_insert_id(TAGS_TABLE);
return array(
- 'info' => sprintf(
- l10n('Tag "%s" was added'),
- stripslashes($tag_name)
- ),
+ 'info' => l10n('Tag "%s" was added', stripslashes($tag_name)),
'id' => $inserted_id,
);
}
else
{
return array(
- 'error' => sprintf(
- l10n('Tag "%s" already exists'),
- stripslashes($tag_name)
- )
+ 'error' => l10n('Tag "%s" already exists', stripslashes($tag_name))
);
}
}
/**
* Is the category accessible to the (Admin) user ?
- *
* Note : if the user is not authorized to see this category, category jump
* will be replaced by admin cat_modify page
*
- * @param int category id to verify
+ * @param int $category_id
* @return bool
*/
function cat_admin_access($category_id)
@@ -1851,10 +1888,14 @@ function cat_admin_access($category_id)
}
/**
- * Retrieve data from external URL
+ * Retrieve data from external URL.
*
- * @param string $src: URL
- * @param global $dest: can be a file ressource or string
+ * @param string $src
+ * @param string|Ressource $dest - can be a file ressource or string
+ * @param array $get_data - data added to request url
+ * @param array $post_data - data transmitted with POST
+ * @param string $user_agent
+ * @param int $step (internal use)
* @return bool
*/
function fetchRemote($src, &$dest, $get_data=array(), $post_data=array(), $user_agent='Piwigo', $step=0)
@@ -2008,13 +2049,11 @@ function fetchRemote($src, &$dest, $get_data=array(), $post_data=array(), $user_
return true;
}
-
/**
- * returns the groupname corresponding to the given group identifier if
- * exists
+ * Returns the groupname corresponding to the given group identifier if exists.
*
- * @param int group_id
- * @return mixed
+ * @param int $group_id
+ * @return string|false
*/
function get_groupname($group_id)
{
@@ -2037,10 +2076,10 @@ SELECT name
}
/**
- * returns the username corresponding to the given user identifier if exists
+ * Returns the username corresponding to the given user identifier if exists.
*
- * @param int user_id
- * @return mixed
+ * @param int $user_id
+ * @return string|false
*/
function get_username($user_id)
{
@@ -2064,13 +2103,22 @@ SELECT '.$conf['user_fields']['username'].'
return stripslashes($username);
}
-function get_newsletter_subscribe_base_url($language) {
+/**
+ * Get url on piwigo.org for newsletter subscription
+ *
+ * @param string $language (unused)
+ * @return string
+ */
+function get_newsletter_subscribe_base_url($language='en_UK')
+{
return PHPWG_URL.'/announcement/subscribe/';
}
/**
- * Accordion menus need to know which section to open by default when
- * loading the page
+ * Return admin menu id for accordion.
+ *
+ * @param string $menu_page
+ * @return int
*/
function get_active_menu($menu_page)
{
@@ -2125,14 +2173,19 @@ function get_active_menu($menu_page)
case 'theme':
case 'languages':
return 5;
+
+ default:
+ return 0;
}
- return 0;
}
-/*
- * get tags list from SQL query (ids are surrounded by ~~, for get_tag_ids())
- * @param string: query
- * @param boolean: only_user_language, if true, only local name is returned for multilingual tags
+/**
+ * Get tags list from SQL query (ids are surrounded by ~~, for get_tag_ids()).
+ *
+ * @param string $query
+ * @param boolean $only_user_language - if true, only local name is returned for
+ * multilingual tags (if ExtendedDescription plugin is active)
+ * @return array[] ('id', 'name')
*/
function get_taglist($query, $only_user_language=true)
{
@@ -2143,7 +2196,7 @@ function get_taglist($query, $only_user_language=true)
while ($row = pwg_db_fetch_assoc($result))
{
$raw_name = $row['name'];
- $name = trigger_event('render_tag_name', $raw_name);
+ $name = trigger_event('render_tag_name', $raw_name, $row);
$taglist[] = array(
'name' => $name,
@@ -2174,18 +2227,20 @@ function get_taglist($query, $only_user_language=true)
return $taglist;
}
-/*
- * get tags ids from a list of raw tags (existing tags or new tags)
- * @param mixed: raw_tags, array or comma separated string
- * @param boolean: allow_create
+/**
+ * Get tags ids from a list of raw tags (existing tags or new tags).
+ *
+ * In $raw_tags we receive something like array('~~6~~', '~~59~~', 'New
+ * tag', 'Another new tag') The ~~34~~ means that it is an existing
+ * tag. We added the surrounding ~~ to permit creation of tags like "10"
+ * or "1234" (numeric characters only)
+ *
+ * @param string|string[] $raw_tags - array or comma separated string
+ * @param boolean $allow_create
+ * @return int[]
*/
function get_tag_ids($raw_tags, $allow_create=true)
{
- // In $raw_tags we receive something like array('~~6~~', '~~59~~', 'New
- // tag', 'Another new tag') The ~~34~~ means that it is an existing
- // tag. I've added the surrounding ~~ to permit creation of tags like "10"
- // or "1234" (numeric characters only)
-
$tag_ids = array();
if (!is_array($raw_tags))
{
@@ -2208,11 +2263,16 @@ function get_tag_ids($raw_tags, $allow_create=true)
return $tag_ids;
}
-/** returns the argument_ids array with new sequenced keys based on related
+/**
+ * Returns the argument_ids array with new sequenced keys based on related
* names. Sequence is not case sensitive.
- * Warning: By definition, this function breaks original keys
+ * Warning: By definition, this function breaks original keys.
+ *
+ * @param int[] $elements_ids
+ * @param string[] $name - names of elements, indexed by ids
+ * @return int[]
*/
-function order_by_name($element_ids,$name)
+function order_by_name($element_ids, $name)
{
$ordered_element_ids = array();
foreach ($element_ids as $k_id => $element_id)
@@ -2224,14 +2284,18 @@ function order_by_name($element_ids,$name)
return $ordered_element_ids;
}
+/**
+ * Grant access to a list of categories for a list of users.
+ *
+ * @param int[] $category_ids
+ * @param int[] $user_ids
+ */
function add_permission_on_category($category_ids, $user_ids)
{
- // array-ify categories and users
if (!is_array($category_ids))
{
$category_ids = array($category_ids);
}
-
if (!is_array($user_ids))
{
$user_ids = array($user_ids);
@@ -2244,12 +2308,16 @@ function add_permission_on_category($category_ids, $user_ids)
}
// make sure categories are private and select uppercats or subcats
- $cat_ids = (isset($_POST['apply_on_sub'])) ? implode(',', get_subcat_ids($category_ids)).",".implode(',', get_uppercat_ids($category_ids)) : implode(',', get_uppercat_ids($category_ids));
+ $cat_ids = get_uppercat_ids($category_ids);
+ if (isset($_POST['apply_on_sub']))
+ {
+ $cat_ids = array_merge($cat_ids, get_subcat_ids($category_ids));
+ }
+
$query = '
-SELECT
- id
+SELECT id
FROM '.CATEGORIES_TABLE.'
- WHERE id IN ('.$cat_ids.')
+ WHERE id IN ('.implode(',', $cat_ids).')
AND status = \'private\'
;';
$private_cats = array_from_query($query, 'id');
@@ -2258,53 +2326,33 @@ SELECT
{
return;
}
-
- // We must not reinsert already existing lines in user_access table
- $granteds = array();
- foreach ($private_cats as $cat_id)
- {
- $granteds[$cat_id] = array();
- }
-
- $query = '
-SELECT
- user_id,
- cat_id
- FROM '.USER_ACCESS_TABLE.'
- WHERE cat_id IN ('.implode(',', $private_cats).')
- AND user_id IN ('.implode(',', $user_ids).')
-;';
- $result = pwg_query($query);
- while ($row = pwg_db_fetch_assoc($result))
- {
- array_push($granteds[$row['cat_id']], $row['user_id']);
- }
-
+
$inserts = array();
-
foreach ($private_cats as $cat_id)
{
- $grant_to_users = array_diff($user_ids, $granteds[$cat_id]);
-
- foreach ($grant_to_users as $user_id)
+ foreach ($user_ids as $user_id)
{
- array_push(
- $inserts,
- array(
- 'user_id' => $user_id,
- 'cat_id' => $cat_id
- )
+ $inserts[] = array(
+ 'user_id' => $user_id,
+ 'cat_id' => $cat_id
);
}
}
-
- if (count($inserts) > 0)
- {
- mass_inserts(USER_ACCESS_TABLE, array_keys($inserts[0]), $inserts);
- }
+
+ mass_inserts(
+ USER_ACCESS_TABLE,
+ array('user_id','cat_id'),
+ $inserts,
+ array('ignore'=>true)
+ );
}
-
+/**
+ * Returns the list of admin users.
+ *
+ * @param boolean $include_webmaster
+ * @return int[]
+ */
function get_admins($include_webmaster=true)
{
$status_list = array('admin');
@@ -2324,7 +2372,11 @@ SELECT
return array_from_query($query, 'user_id');
}
-/** delete all derivative files for one or several types */
+/**
+ * Delete all derivative files for one or several types
+ *
+ * @param 'all'|int[] $types
+ */
function clear_derivative_cache($types='all')
{
if ($types === 'all')
@@ -2381,6 +2433,10 @@ function clear_derivative_cache($types='all')
}
}
+/**
+ * Used by clear_derivative_cache()
+ * @ignore
+ */
function clear_derivative_cache_rec($path, $pattern)
{
$rmdir = true;
@@ -2427,6 +2483,12 @@ function clear_derivative_cache_rec($path, $pattern)
}
}
+/**
+ * Deletes derivatives of a particular element
+ *
+ * @param array $infos ('path'[, 'representative_ext'])
+ * @param 'all'|int $type
+ */
function delete_element_derivatives($infos, $type='all')
{
$path = $infos['path'];
@@ -2456,4 +2518,85 @@ function delete_element_derivatives($infos, $type='all')
}
}
}
+
+/**
+ * Returns an array containing sub-directories, excluding ".svn"
+ *
+ * @param string $directory
+ * @return string[]
+ */
+function get_dirs($directory)
+{
+ $sub_dirs = array();
+ if ($opendir = opendir($directory))
+ {
+ while ($file = readdir($opendir))
+ {
+ if ($file != '.'
+ and $file != '..'
+ and is_dir($directory.'/'.$file)
+ and $file != '.svn')
+ {
+ $sub_dirs[] = $file;
+ }
+ }
+ closedir($opendir);
+ }
+ return $sub_dirs;
+}
+
+/**
+ * Recursively delete a directory.
+ *
+ * @param string $path
+ * @param string $trash_path, try to move the directory to this path if it cannot be delete
+ */
+function deltree($path, $trash_path=null)
+{
+ if (is_dir($path))
+ {
+ $fh = opendir($path);
+ while ($file = readdir($fh))
+ {
+ if ($file != '.' and $file != '..')
+ {
+ $pathfile = $path . '/' . $file;
+ if (is_dir($pathfile))
+ {
+ deltree($pathfile, $trash_path);
+ }
+ else
+ {
+ @unlink($pathfile);
+ }
+ }
+ }
+ closedir($fh);
+
+ if (@rmdir($path))
+ {
+ return true;
+ }
+ elseif (!empty($trash_path))
+ {
+ if (!is_dir($trash_path))
+ {
+ @mkgetdir($trash_path, MKGETDIR_RECURSIVE|MKGETDIR_DIE_ON_ERROR|MKGETDIR_PROTECT_HTACCESS);
+ }
+ while ($r = $trash_path . '/' . md5(uniqid(rand(), true)))
+ {
+ if (!is_dir($r))
+ {
+ @rename($path, $r);
+ break;
+ }
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
+
?> \ No newline at end of file
diff --git a/admin/include/functions_history.inc.php b/admin/include/functions_history.inc.php
index 2b18547dc..61d676503 100644
--- a/admin/include/functions_history.inc.php
+++ b/admin/include/functions_history.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -58,18 +58,12 @@ SELECT
if (isset($search['fields']['date-after']))
{
- array_push(
- $clauses,
- "date >= '".$search['fields']['date-after']."'"
- );
+ $clauses[] = "date >= '".$search['fields']['date-after']."'";
}
if (isset($search['fields']['date-before']))
{
- array_push(
- $clauses,
- "date <= '".$search['fields']['date-before']."'"
- );
+ $clauses[] = "date <= '".$search['fields']['date-before']."'";
}
if (isset($search['fields']['types']))
@@ -88,34 +82,25 @@ SELECT
$clause.= "= '".$type."'";
}
- array_push($local_clauses, $clause);
+ $local_clauses[] = $clause;
}
}
if (count($local_clauses) > 0)
{
- array_push(
- $clauses,
- implode(' OR ', $local_clauses)
- );
+ $clauses[] = implode(' OR ', $local_clauses);
}
}
if (isset($search['fields']['user'])
and $search['fields']['user'] != -1)
{
- array_push(
- $clauses,
- 'user_id = '.$search['fields']['user']
- );
+ $clauses[] = 'user_id = '.$search['fields']['user'];
}
if (isset($search['fields']['image_id']))
{
- array_push(
- $clauses,
- 'image_id = '.$search['fields']['image_id']
- );
+ $clauses[] = 'image_id = '.$search['fields']['image_id'];
}
if (isset($search['fields']['filename']))
@@ -123,14 +108,11 @@ SELECT
if (count($search['image_ids']) == 0)
{
// a clause that is always false
- array_push($clauses, '1 = 2 ');
+ $clauses[] = '1 = 2 ';
}
else
{
- array_push(
- $clauses,
- 'image_id IN ('.implode(', ', $search['image_ids']).')'
- );
+ $clauses[] = 'image_id IN ('.implode(', ', $search['image_ids']).')';
}
}
@@ -168,7 +150,7 @@ SELECT
while ($row = pwg_db_fetch_assoc($result))
{
- array_push($data, $row);
+ $data[] = $row;
}
return $data;
@@ -177,4 +159,4 @@ SELECT
add_event_handler('get_history', 'get_history', EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
trigger_action('functions_history_included');
-?>
+?> \ No newline at end of file
diff --git a/admin/include/functions_install.inc.php b/admin/include/functions_install.inc.php
index d9643e721..9e479f54b 100644
--- a/admin/include/functions_install.inc.php
+++ b/admin/include/functions_install.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -79,7 +79,7 @@ function activate_core_themes()
$themes = new themes();
foreach ($themes->fs_themes as $theme_id => $fs_theme)
{
- if (in_array($theme_id, array('elegant', 'Sylvia', 'clear', 'dark', 'smartpocket')))
+ if (in_array($theme_id, array('elegant', 'smartpocket')))
{
$themes->perform_action('activate', $theme_id);
}
@@ -96,7 +96,7 @@ function install_db_connect(&$infos, &$errors)
}
catch (Exception $e)
{
- array_push( $errors, l10n($e->getMessage()));
+ $errors[] = l10n($e->getMessage());
}
}
?> \ No newline at end of file
diff --git a/admin/include/functions_metadata.php b/admin/include/functions_metadata.php
index e3fc84d96..5bcbb12bf 100644
--- a/admin/include/functions_metadata.php
+++ b/admin/include/functions_metadata.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -122,7 +122,8 @@ function get_sync_metadata_attributes()
$update_fields =
array_merge(
$update_fields,
- array_keys($conf['use_exif_mapping'])
+ array_keys($conf['use_exif_mapping']),
+ array('latitude', 'longitude')
);
}
@@ -219,23 +220,20 @@ SELECT id, path, representative_ext
foreach (explode(',', $data[$key]) as $tag_name)
{
- array_push(
- $tags_of[$id],
- tag_id_from_tag_name($tag_name)
- );
+ $tags_of[$id][] = tag_id_from_tag_name($tag_name);
}
}
}
$data['date_metadata_update'] = CURRENT_DATE;
- array_push($datas, $data);
+ $datas[] = $data;
}
if (count($datas) > 0)
{
$update_fields = get_sync_metadata_attributes();
- array_push($update_fields, 'date_metadata_update');
+ $update_fields[] = 'date_metadata_update';
$update_fields = array_diff(
$update_fields,
@@ -297,7 +295,7 @@ SELECT id
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
- array_push($cat_ids, $row['id']);
+ $cat_ids[] = $row['id'];
}
if (count($cat_ids) == 0)
diff --git a/admin/include/functions_notification_by_mail.inc.php b/admin/include/functions_notification_by_mail.inc.php
index e727e9e6f..8d0fe2621 100644
--- a/admin/include/functions_notification_by_mail.inc.php
+++ b/admin/include/functions_notification_by_mail.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -169,7 +169,7 @@ order by';
{
while ($nbm_user = pwg_db_fetch_assoc($result))
{
- array_push($data_users, $nbm_user);
+ $data_users[] = $nbm_user;
}
}
}
@@ -256,8 +256,7 @@ function set_user_on_env_nbm(&$nbm_user, $is_action_send)
if ($is_action_send)
{
- $nbm_user['theme'] = $user['theme'];
- $env_nbm['mail_template'] = get_mail_template($env_nbm['email_format'], $nbm_user['theme']);
+ $env_nbm['mail_template'] = get_mail_template($env_nbm['email_format']);
$env_nbm['mail_template']->set_filename('notification_by_mail', 'notification_by_mail.tpl');
}
}
@@ -285,7 +284,7 @@ function inc_mail_sent_success($nbm_user)
global $page, $env_nbm;
$env_nbm['sent_mail_count'] += 1;
- array_push($page['infos'], sprintf($env_nbm['msg_info'], stripslashes($nbm_user['username']), $nbm_user['mail_address']));
+ $page['infos'][] = sprintf($env_nbm['msg_info'], stripslashes($nbm_user['username']), $nbm_user['mail_address']);
}
/*
@@ -298,7 +297,7 @@ function inc_mail_sent_failed($nbm_user)
global $page, $env_nbm;
$env_nbm['error_on_mail_count'] += 1;
- array_push($page['errors'], sprintf($env_nbm['msg_error'], stripslashes($nbm_user['username']), $nbm_user['mail_address']));
+ $page['errors'][] = sprintf($env_nbm['msg_error'], stripslashes($nbm_user['username']), $nbm_user['mail_address']);
}
/*
@@ -312,16 +311,32 @@ function display_counter_info()
if ($env_nbm['error_on_mail_count'] != 0)
{
- array_push($page['errors'], l10n_dec('%d mail was not sent.', '%d mails were not sent.', $env_nbm['error_on_mail_count']));
+ $page['errors'][] = l10n_dec(
+ '%d mail was not sent.', '%d mails were not sent.',
+ $env_nbm['error_on_mail_count']
+ );
+
if ($env_nbm['sent_mail_count'] != 0)
- array_push($page['infos'], l10n_dec('%d mail was sent.', '%d mails were sent.', $env_nbm['sent_mail_count']));
+ {
+ $page['infos'][] = l10n_dec(
+ '%d mail was sent.', '%d mails were sent.',
+ $env_nbm['sent_mail_count']
+ );
+ }
}
else
{
if ($env_nbm['sent_mail_count'] == 0)
- array_push($page['infos'], l10n('No mail to send.'));
+ {
+ $page['infos'][] = l10n('No mail to send.');
+ }
else
- array_push($page['infos'], l10n_dec('%d mail was sent.', '%d mails were sent.', $env_nbm['sent_mail_count']));
+ {
+ $page['infos'][] = l10n_dec(
+ '%d mail was sent.', '%d mails were sent.',
+ $env_nbm['sent_mail_count']
+ );
+ }
}
}
@@ -394,12 +409,12 @@ function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_su
if (check_sendmail_timeout())
{
// Stop fill list on 'send', if the quota is override
- array_push($page['errors'], $msg_break_timeout);
+ $page['errors'][] = $msg_break_timeout;
break;
}
// Fill return list
- array_push($check_key_treated, $nbm_user['check_key']);
+ $check_key_treated[] = $nbm_user['check_key'];
$do_update = true;
if ($nbm_user['mail_address'] != '')
@@ -407,7 +422,7 @@ function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_su
// set env nbm user
set_user_on_env_nbm($nbm_user, true);
- $subject = '['.$conf['gallery_title'].']: '.($is_subscribe ? l10n('Subscribe to notification by mail'): l10n('Unsubscribe from notification by mail'));
+ $subject = '['.$conf['gallery_title'].'] '.($is_subscribe ? l10n('Subscribe to notification by mail'): l10n('Unsubscribe from notification by mail'));
// Assign current var for nbm mail
assign_vars_nbm_mail_content($nbm_user);
@@ -423,20 +438,22 @@ function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_su
'GOTO_GALLERY_URL' => get_gallery_home_url(),
)
);
+
+ $ret = pwg_mail(
+ array(
+ 'name' => stripslashes($nbm_user['username']),
+ 'email' => $nbm_user['mail_address'],
+ ),
+ array(
+ 'from' => $env_nbm['send_as_mail_formated'],
+ 'subject' => $subject,
+ 'email_format' => $env_nbm['email_format'],
+ 'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
+ 'content_format' => $env_nbm['email_format'],
+ )
+ );
- if (pwg_mail
- (
- format_email(stripslashes($nbm_user['username']), $nbm_user['mail_address']),
- array
- (
- 'from' => $env_nbm['send_as_mail_formated'],
- 'subject' => $subject,
- 'email_format' => $env_nbm['email_format'],
- 'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
- 'content_format' => $env_nbm['email_format'],
- 'theme' => $nbm_user['theme']
- )
- ))
+ if ($ret)
{
inc_mail_sent_success($nbm_user);
}
@@ -453,22 +470,17 @@ function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_su
if ($do_update)
{
- array_push
- (
- $updates,
- array
- (
- 'check_key' => $nbm_user['check_key'],
- 'enabled' => $enabled_value
- )
- );
+ $updates[] = array(
+ 'check_key' => $nbm_user['check_key'],
+ 'enabled' => $enabled_value
+ );
$updated_data_count += 1;
- array_push($page['infos'], sprintf($msg_info, stripslashes($nbm_user['username']), $nbm_user['mail_address']));
+ $page['infos'][] = sprintf($msg_info, stripslashes($nbm_user['username']), $nbm_user['mail_address']);
}
else
{
$error_on_updated_data_count += 1;
- array_push($page['errors'], sprintf($msg_error, stripslashes($nbm_user['username']), $nbm_user['mail_address']));
+ $page['errors'][] = sprintf($msg_error, stripslashes($nbm_user['username']), $nbm_user['mail_address']);
}
}
@@ -489,13 +501,17 @@ function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_su
}
- array_push($page['infos'], l10n_dec('%d user was updated.', '%d users were updated.', $updated_data_count));
+ $page['infos'][] = l10n_dec(
+ '%d user was updated.', '%d users were updated.',
+ $updated_data_count
+ );
+
if ($error_on_updated_data_count != 0)
{
- array_push($page['errors'],
- l10n_dec('%d user was not updated.',
- '%d users were not updated.',
- $error_on_updated_data_count));
+ $page['errors'][] = l10n_dec(
+ '%d user was not updated.', '%d users were not updated.',
+ $error_on_updated_data_count
+ );
}
unset_make_full_url();
diff --git a/admin/include/functions_permalinks.php b/admin/include/functions_permalinks.php
index 5c5541af8..6c8ae4aac 100644
--- a/admin/include/functions_permalinks.php
+++ b/admin/include/functions_permalinks.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
diff --git a/admin/include/functions_plugins.inc.php b/admin/include/functions_plugins.inc.php
index 682e05d06..fb98c799c 100644
--- a/admin/include/functions_plugins.inc.php
+++ b/admin/include/functions_plugins.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -39,7 +39,7 @@ function get_admin_plugin_menu_link($file)
}
else if (isset($page['errors']))
{
- array_push($page['errors'], 'PLUGIN ERROR: "'.$file.'" is not a valid file');
+ $page['errors'][] = 'PLUGIN ERROR: "'.$file.'" is not a valid file';
}
return $url;
}
diff --git a/admin/include/functions_upgrade.php b/admin/include/functions_upgrade.php
index ed4b0f410..4bd639f85 100644
--- a/admin/include/functions_upgrade.php
+++ b/admin/include/functions_upgrade.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -93,7 +93,7 @@ AND id NOT IN (\'' . implode('\',\'', $standard_plugins) . '\')
$plugins = array();
while ($row = pwg_db_fetch_assoc($result))
{
- array_push($plugins, $row['id']);
+ $plugins[] = $row['id'];
}
if (!empty($plugins))
@@ -105,8 +105,8 @@ WHERE id IN (\'' . implode('\',\'', $plugins) . '\')
;';
pwg_query($query);
- array_push($page['infos'],
- l10n('As a precaution, following plugins have been deactivated. You must check for plugins upgrade before reactiving them:').'<p><i>'.implode(', ', $plugins).'</i></p>');
+ $page['infos'][] = l10n('As a precaution, following plugins have been deactivated. You must check for plugins upgrade before reactiving them:')
+ .'<p><i>'.implode(', ', $plugins).'</i></p>';
}
}
@@ -135,8 +135,8 @@ SELECT
$theme_names = array();
while ($row = pwg_db_fetch_assoc($result))
{
- array_push($theme_ids, $row['id']);
- array_push($theme_names, $row['name']);
+ $theme_ids[] = $row['id'];
+ $theme_names[] = $row['name'];
}
if (!empty($theme_ids))
@@ -148,8 +148,8 @@ DELETE
;';
pwg_query($query);
- array_push($page['infos'],
- l10n('As a precaution, following themes have been deactivated. You must check for themes upgrade before reactiving them:').'<p><i>'.implode(', ', $theme_names).'</i></p>');
+ $page['infos'][] = l10n('As a precaution, following themes have been deactivated. You must check for themes upgrade before reactiving them:')
+ .'<p><i>'.implode(', ', $theme_names).'</i></p>';
// what is the default theme?
$query = '
@@ -249,11 +249,11 @@ WHERE '.$conf['user_fields']['username'].'=\''.$username.'\'
if (!$conf['password_verify']($password, $row['password']))
{
- array_push($page['errors'], l10n('Invalid password!'));
+ $page['errors'][] = l10n('Invalid password!');
}
elseif ($row['status'] != 'admin' and $row['status'] != 'webmaster')
{
- array_push($page['errors'], l10n('You do not have access rights to run upgrade'));
+ $page['errors'][] = l10n('You do not have access rights to run upgrade');
}
else
{
@@ -279,7 +279,7 @@ function get_available_upgrade_ids()
if (is_file($upgrades_path.'/'.$node)
and preg_match('/^(.*?)-database\.php$/', $node, $match))
{
- array_push($available_upgrade_ids, $match[1]);
+ $available_upgrade_ids[] = $match[1];
}
}
}
diff --git a/admin/include/functions_upload.inc.php b/admin/include/functions_upload.inc.php
index a23977910..40a53adf9 100644
--- a/admin/include/functions_upload.inc.php
+++ b/admin/include/functions_upload.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -122,13 +122,9 @@ function save_upload_form_config($data, &$errors=array(), &$form_errors=array())
}
else
{
- array_push(
- $errors,
- sprintf(
- $upload_form_config[$field]['error_message'],
- $min,
- $max
- )
+ $errors[] = sprintf(
+ $upload_form_config[$field]['error_message'],
+ $min, $max
);
$form_errors[$field] = '['.$min.' .. '.$max.']';
@@ -175,6 +171,7 @@ function add_uploaded_file($source_filepath, $original_filename=null, $categorie
}
$file_path = null;
+ $is_tiff = false;
if (isset($image_id))
{
@@ -230,6 +227,11 @@ SELECT
{
$file_path.= 'gif';
}
+ elseif (IMAGETYPE_TIFF_MM == $type or IMAGETYPE_TIFF_II == $type)
+ {
+ $is_tiff = true;
+ $file_path.= 'tif';
+ }
else
{
$file_path.= 'jpg';
@@ -248,6 +250,50 @@ SELECT
}
@chmod($file_path, 0644);
+ if ($is_tiff and pwg_image::get_library() == 'ext_imagick')
+ {
+ // move the uploaded file to pwg_representative sub-directory
+ $representative_file_path = dirname($file_path).'/pwg_representative/';
+ $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.';
+
+ $representative_ext = $conf['tiff_representative_ext'];
+ $representative_file_path.= $representative_ext;
+
+ prepare_directory(dirname($representative_file_path));
+
+ $exec = $conf['ext_imagick_dir'].'convert';
+
+ if ('jpg' == $conf['tiff_representative_ext'])
+ {
+ $exec .= ' -quality 98';
+ }
+
+ $exec .= ' "'.realpath($file_path).'"';
+
+ $dest = pathinfo($representative_file_path);
+ $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"';
+
+ $exec .= ' 2>&1';
+ @exec($exec, $returnarray);
+
+ // sometimes ImageMagick creates file-0.jpg (full size) + file-1.jpg
+ // (thumbnail). I don't know how to avoid it.
+ $representative_file_abspath = realpath($dest['dirname']).'/'.$dest['basename'];
+ if (!file_exists($representative_file_abspath))
+ {
+ $first_file_abspath = preg_replace(
+ '/\.'.$representative_ext.'$/',
+ '-0.'.$representative_ext,
+ $representative_file_abspath
+ );
+
+ if (file_exists($first_file_abspath))
+ {
+ rename($first_file_abspath, $representative_file_abspath);
+ }
+ }
+ }
+
if (pwg_image::get_library() != 'gd')
{
if ($conf['original_resize'])
@@ -324,6 +370,11 @@ SELECT
$insert['level'] = $level;
}
+ if (isset($representative_ext))
+ {
+ $insert['representative_ext'] = $representative_ext;
+ }
+
single_insert(IMAGES_TABLE, $insert);
$image_id = pwg_db_insert_id(IMAGES_TABLE);
@@ -494,16 +545,7 @@ function convert_shorthand_notation_to_bytes($value)
function add_upload_error($upload_id, $error_message)
{
- if (!isset($_SESSION['uploads_error']))
- {
- $_SESSION['uploads_error'] = array();
- }
- if (!isset($_SESSION['uploads_error'][$upload_id]))
- {
- $_SESSION['uploads_error'][$upload_id] = array();
- }
-
- array_push($_SESSION['uploads_error'][$upload_id], $error_message);
+ $_SESSION['uploads_error'][$upload_id][] = $error_message;
}
function ready_for_upload_message()
diff --git a/admin/include/image.class.php b/admin/include/image.class.php
index 02e45a209..101309911 100644
--- a/admin/include/image.class.php
+++ b/admin/include/image.class.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
diff --git a/admin/include/index.php b/admin/include/index.php
index 41732f2fd..c8de97f60 100644
--- a/admin/include/index.php
+++ b/admin/include/index.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
diff --git a/admin/include/languages.class.php b/admin/include/languages.class.php
index 6a7262bb0..bb9487bec 100644
--- a/admin/include/languages.class.php
+++ b/admin/include/languages.class.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -57,7 +57,7 @@ class languages
case 'activate':
if (isset($crt_db_language))
{
- array_push($errors, 'CANNOT ACTIVATE - LANGUAGE IS ALREADY ACTIVATED');
+ $errors[] = 'CANNOT ACTIVATE - LANGUAGE IS ALREADY ACTIVATED';
break;
}
@@ -74,13 +74,13 @@ INSERT INTO '.LANGUAGES_TABLE.'
case 'deactivate':
if (!isset($crt_db_language))
{
- array_push($errors, 'CANNOT DEACTIVATE - LANGUAGE IS ALREADY DEACTIVATED');
+ $errors[] = 'CANNOT DEACTIVATE - LANGUAGE IS ALREADY DEACTIVATED';
break;
}
if ($language_id == get_default_language())
{
- array_push($errors, 'CANNOT DEACTIVATE - LANGUAGE IS DEFAULT LANGUAGE');
+ $errors[] = 'CANNOT DEACTIVATE - LANGUAGE IS DEFAULT LANGUAGE';
break;
}
@@ -95,12 +95,12 @@ DELETE
case 'delete':
if (!empty($crt_db_language))
{
- array_push($errors, 'CANNOT DELETE - LANGUAGE IS ACTIVATED');
+ $errors[] = 'CANNOT DELETE - LANGUAGE IS ACTIVATED';
break;
}
if (!isset($this->fs_languages[$language_id]))
{
- array_push($errors, 'CANNOT DELETE - LANGUAGE DOES NOT EXIST');
+ $errors[] = 'CANNOT DELETE - LANGUAGE DOES NOT EXIST';
break;
}
@@ -112,10 +112,7 @@ UPDATE '.USER_INFOS_TABLE.'
;';
pwg_query($query);
- if (!$this->deltree(PHPWG_ROOT_PATH.'language/'.$language_id))
- {
- $this->send_to_trash(PHPWG_ROOT_PATH.'language/'.$language_id);
- }
+ deltree(PHPWG_ROOT_PATH.'language/'.$language_id, PHPWG_ROOT_PATH.'language/trash');
break;
case 'set_default':
@@ -371,7 +368,7 @@ UPDATE '.USER_INFOS_TABLE.'
and $old_files = file($extract_path.'/obsolete.list', FILE_IGNORE_NEW_LINES)
and !empty($old_files))
{
- array_push($old_files, 'obsolete.list');
+ $old_files[] = 'obsolete.list';
foreach($old_files as $old_file)
{
$path = $extract_path.'/'.$old_file;
@@ -381,10 +378,7 @@ UPDATE '.USER_INFOS_TABLE.'
}
elseif (is_dir($path))
{
- if (!$this->deltree($path))
- {
- $this->send_to_trash($path);
- }
+ deltree($path, PHPWG_ROOT_PATH.'language/trash');
}
}
}
@@ -406,59 +400,6 @@ UPDATE '.USER_INFOS_TABLE.'
}
/**
- * delete $path directory
- * @param string - path
- */
- function deltree($path)
- {
- if (is_dir($path))
- {
- $fh = opendir($path);
- while ($file = readdir($fh))
- {
- if ($file != '.' and $file != '..')
- {
- $pathfile = $path . '/' . $file;
- if (is_dir($pathfile))
- {
- $this->deltree($pathfile);
- }
- else
- {
- @unlink($pathfile);
- }
- }
- }
- closedir($fh);
- return @rmdir($path);
- }
- }
-
- /**
- * send $path to trash directory
- * @param string - path
- */
- function send_to_trash($path)
- {
- $trash_path = PHPWG_ROOT_PATH . 'language/trash';
- if (!is_dir($trash_path))
- {
- @mkdir($trash_path);
- $file = @fopen($trash_path . '/.htaccess', 'w');
- @fwrite($file, 'deny from all');
- @fclose($file);
- }
- while ($r = $trash_path . '/' . md5(uniqid(rand(), true)))
- {
- if (!is_dir($r))
- {
- @rename($path, $r);
- break;
- }
- }
- }
-
- /**
* Sort functions
*/
function language_version_compare($a, $b)
diff --git a/admin/include/photos_add_direct_prepare.inc.php b/admin/include/photos_add_direct_prepare.inc.php
index f9443553d..117abb802 100644
--- a/admin/include/photos_add_direct_prepare.inc.php
+++ b/admin/include/photos_add_direct_prepare.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -105,6 +105,18 @@ if (pwg_image::get_library() == 'gd')
}
}
+//warn the user if the picture will be resized after upload
+if ($conf['original_resize'])
+{
+ $template->assign(
+ array(
+ 'original_resize_maxwidth' => $conf['original_resize_maxwidth'],
+ 'original_resize_maxheight' => $conf['original_resize_maxheight'],
+ )
+ );
+}
+
+
$upload_modes = array('html', 'multiple');
$upload_mode = isset($conf['upload_mode']) ? $conf['upload_mode'] : 'multiple';
@@ -132,6 +144,13 @@ $template->assign(
);
$upload_file_types = 'jpeg, png, gif';
+
+if (pwg_image::get_library() == 'ext_imagick')
+{
+ $upload_file_types.= ', tiff';
+ $template->assign('tif_enabled', true);
+}
+
if ('html' == $upload_mode)
{
$upload_file_types.= ', zip';
@@ -148,28 +167,52 @@ $template->assign(
// we need to know the category in which the last photo was added
$selected_category = array();
-$selected_parent = array();
-$query = '
-SELECT
- category_id,
- id_uppercat
+if (isset($_GET['album']))
+{
+ // set the category from get url or ...
+ check_input_parameter('album', $_GET, false, PATTERN_ID);
+
+ // test if album really exists
+ $query = '
+SELECT id
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id = '.$_GET['album'].'
+;';
+ $result = pwg_query($query);
+ if (pwg_db_num_rows($result) == 1)
+ {
+ $selected_category = array($_GET['album']);
+
+ // lets put in the session to persist in case of upload method switch
+ $_SESSION['selected_category'] = $selected_category;
+ }
+ else
+ {
+ fatal_error('[Hacking attempt] the album id = "'.$_GET['album'].'" is not valid');
+ }
+}
+else if (isset($_SESSION['selected_category']))
+{
+ $selected_category = $_SESSION['selected_category'];
+}
+else
+{
+ // we need to know the category in which the last photo was added
+ $query = '
+SELECT category_id
FROM '.IMAGES_TABLE.' AS i
JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = i.id
JOIN '.CATEGORIES_TABLE.' AS c ON category_id = c.id
ORDER BY i.id DESC
LIMIT 1
-;';
-$result = pwg_query($query);
-if (pwg_db_num_rows($result) > 0)
-{
- $row = pwg_db_fetch_assoc($result);
-
- $selected_category = array($row['category_id']);
-
- if (!empty($row['id_uppercat']))
+;
+';
+ $result = pwg_query($query);
+ if (pwg_db_num_rows($result) > 0)
{
- $selected_parent = array($row['id_uppercat']);
+ $row = pwg_db_fetch_assoc($result);
+ $selected_category = array($row['category_id']);
}
}
@@ -185,13 +228,6 @@ display_select_cat_wrapper(
'category_options'
);
-// new category
-display_select_cat_wrapper(
- $query,
- $selected_parent,
- 'category_parent_options'
- );
-
// image level options
$selected_level = isset($_POST['level']) ? $_POST['level'] : 0;
@@ -212,12 +248,12 @@ $setup_errors = array();
$error_message = ready_for_upload_message();
if (!empty($error_message))
{
- array_push($setup_errors, $error_message);
+ $setup_errors[] = $error_message;
}
if (!function_exists('gd_info'))
{
- array_push($setup_errors, l10n('GD library is missing'));
+ $setup_errors[] = l10n('GD library is missing');
}
$template->assign(
@@ -238,24 +274,17 @@ if (!isset($_SESSION['upload_hide_warnings']))
if ($conf['use_exif'] and !function_exists('read_exif_data'))
{
- array_push(
- $setup_warnings,
- l10n('Exif extension not available, admin should disable exif use')
- );
+ $setup_warnings[] = l10n('Exif extension not available, admin should disable exif use');
}
if (get_ini_size('upload_max_filesize') > get_ini_size('post_max_size'))
{
- array_push(
- $setup_warnings,
- sprintf(
- l10n('In your php.ini file, the upload_max_filesize (%sB) is bigger than post_max_size (%sB), you should change this setting'),
- get_ini_size('upload_max_filesize', false),
- get_ini_size('post_max_size', false)
- )
+ $setup_warnings[] = l10n(
+ 'In your php.ini file, the upload_max_filesize (%sB) is bigger than post_max_size (%sB), you should change this setting',
+ get_ini_size('upload_max_filesize', false),
+ get_ini_size('post_max_size', false)
);
}
-
$template->assign(
array(
'setup_warnings' => $setup_warnings,
diff --git a/admin/include/photos_add_direct_process.inc.php b/admin/include/photos_add_direct_process.inc.php
index eb5536342..e0a6cba22 100644
--- a/admin/include/photos_add_direct_process.inc.php
+++ b/admin/include/photos_add_direct_process.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -34,12 +34,9 @@ if (isset($_GET['processed']))
// exceeded the post_max_size (but not the upload_max_size)
if (!isset($_POST['submit_upload']))
{
- array_push(
- $page['errors'],
- sprintf(
- l10n('The uploaded files exceed the post_max_size directive in php.ini: %sB'),
- ini_get('post_max_size')
- )
+ $page['errors'][] = l10n(
+ 'The uploaded files exceed the post_max_size directive in php.ini: %sB',
+ ini_get('post_max_size')
);
}
else
@@ -51,7 +48,7 @@ if (isset($_GET['processed']))
{
foreach ($_POST['onUploadError'] as $error)
{
- array_push($page['errors'], $error);
+ $page['errors'][] = $error;
}
}
@@ -97,14 +94,11 @@ if (isset($_GET['processed']))
if (is_valid_image_extension(pathinfo($node['filename'], PATHINFO_EXTENSION)))
{
- array_push($indexes_to_extract, $node['index']);
+ $indexes_to_extract[] = $node['index'];
- array_push(
- $images_to_add,
- array(
- 'source_filepath' => $upload_dir.'/'.$temporary_archive_name.'/'.$node['filename'],
- 'original_filename' => basename($node['filename']),
- )
+ $images_to_add[] = array(
+ 'source_filepath' => $upload_dir.'/'.$temporary_archive_name.'/'.$node['filename'],
+ 'original_filename' => basename($node['filename']),
);
}
}
@@ -121,12 +115,9 @@ if (isset($_GET['processed']))
}
elseif (is_valid_image_extension($extension))
{
- array_push(
- $images_to_add,
- array(
- 'source_filepath' => $_FILES['image_upload']['tmp_name'][$idx],
- 'original_filename' => $_FILES['image_upload']['name'][$idx],
- )
+ $images_to_add[] = array(
+ 'source_filepath' => $_FILES['image_upload']['tmp_name'][$idx],
+ 'original_filename' => $_FILES['image_upload']['name'][$idx],
);
}
@@ -139,7 +130,7 @@ if (isset($_GET['processed']))
$_POST['level']
);
- array_push($image_ids, $image_id);
+ $image_ids[] = $image_id;
// TODO: if $image_id is not an integer, something went wrong
}
@@ -148,13 +139,10 @@ if (isset($_GET['processed']))
{
$error_message = file_upload_error_message($error);
- array_push(
- $page['errors'],
- sprintf(
- l10n('Error on file "%s" : %s'),
- $_FILES['image_upload']['name'][$idx],
- $error_message
- )
+ $page['errors'][] = l10n(
+ 'Error on file "%s" : %s',
+ $_FILES['image_upload']['name'][$idx],
+ $error_message
);
}
}
@@ -172,7 +160,7 @@ if (isset($_GET['processed']))
{
foreach ($_SESSION['uploads_error'][ $_POST['upload_id'] ] as $error)
{
- array_push($page['errors'], $error);
+ $page['errors'][] = $error;
}
}
@@ -216,29 +204,18 @@ SELECT
$thumbnail['link'] = get_root_url().'admin.php?page=photo-'.$image_id.'&amp;cat_id='.$category_id;
- array_push($page['thumbnails'], $thumbnail);
+ $page['thumbnails'][] = $thumbnail;
}
if (!empty($page['thumbnails']))
{
- array_push(
- $page['infos'],
- sprintf(
- l10n('%d photos uploaded'),
- count($page['thumbnails'])
- )
- );
+ $page['infos'][] = l10n('%d photos uploaded', count($page['thumbnails']));
if (0 != $_POST['level'])
{
- array_push(
- $page['infos'],
- sprintf(
- l10n('Privacy level set to "%s"'),
- l10n(
- sprintf('Level %d', $_POST['level'])
- )
- )
+ $page['infos'][] = l10n(
+ 'Privacy level set to "%s"',
+ l10n(sprintf('Level %d', $_POST['level']))
);
}
@@ -252,13 +229,10 @@ SELECT
$category_name = get_cat_display_name_from_id($category_id, 'admin.php?page=album-');
// information
- array_push(
- $page['infos'],
- sprintf(
- l10n('Album "%s" now contains %d photos'),
- '<em>'.$category_name.'</em>',
- $count
- )
+ $page['infos'][] = l10n(
+ 'Album "%s" now contains %d photos',
+ '<em>'.$category_name.'</em>',
+ $count
);
$page['batch_link'] = PHOTOS_ADD_BASE_URL.'&batch='.implode(',', $image_ids);
diff --git a/admin/include/plugins.class.php b/admin/include/plugins.class.php
index 3c0cb6ffa..0ddc85b50 100644
--- a/admin/include/plugins.class.php
+++ b/admin/include/plugins.class.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -21,6 +21,43 @@
// | USA. |
// +-----------------------------------------------------------------------+
+/**
+ * class DummyPlugin_maintain
+ * used when a plugin uses the old procedural declaration of maintenance methods
+ */
+class DummyPlugin_maintain extends PluginMaintain
+{
+ function install($plugin_version, &$errors=array())
+ {
+ if (is_callable('plugin_install'))
+ {
+ return plugin_install($this->plugin_id, $plugin_version, $errors);
+ }
+ }
+ function activate($plugin_version, &$errors=array())
+ {
+ if (is_callable('plugin_activate'))
+ {
+ return plugin_activate($this->plugin_id, $plugin_version, $errors);
+ }
+ }
+ function deactivate()
+ {
+ if (is_callable('plugin_deactivate'))
+ {
+ return plugin_deactivate($this->plugin_id);
+ }
+ }
+ function uninstall()
+ {
+ if (is_callable('plugin_uninstall'))
+ {
+ return plugin_uninstall($this->plugin_id);
+ }
+ }
+}
+
+
class plugins
{
var $fs_plugins = array();
@@ -30,7 +67,7 @@ class plugins
/**
* Initialize $fs_plugins and $db_plugins_by_id
- */
+ */
function plugins()
{
$this->get_fs_plugins();
@@ -41,19 +78,51 @@ class plugins
}
}
- /**
+ /**
+ * Returns the maintain class of a plugin
+ * or build a new class with the procedural methods
+ * @param string $plugin_id
+ */
+ private static function build_maintain_class($plugin_id)
+ {
+ $file_to_include = PHPWG_PLUGINS_PATH . $plugin_id . '/maintain.inc.php';
+ $classname = $plugin_id.'_maintain';
+
+ if (file_exists($file_to_include))
+ {
+ include_once($file_to_include);
+
+ if (class_exists($classname))
+ {
+ $plugin_maintain = new $classname($plugin_id);
+ }
+ else
+ {
+ $plugin_maintain = new DummyPlugin_maintain($plugin_id);
+ }
+ }
+ else
+ {
+ $plugin_maintain = new DummyPlugin_maintain($plugin_id);
+ }
+
+ return $plugin_maintain;
+ }
+
+ /**
* Perform requested actions
- * @param string - action
- * @param string - plugin id
- * @param array - errors
- */
+ * @param string - action
+ * @param string - plugin id
+ * @param array - errors
+ */
function perform_action($action, $plugin_id)
{
if (isset($this->db_plugins_by_id[$plugin_id]))
{
$crt_db_plugin = $this->db_plugins_by_id[$plugin_id];
}
- $file_to_include = PHPWG_PLUGINS_PATH . $plugin_id . '/maintain.inc.php';
+
+ $plugin_maintain = self::build_maintain_class($plugin_id);
$errors = array();
@@ -64,20 +133,15 @@ class plugins
{
break;
}
- if (file_exists($file_to_include))
- {
- include_once($file_to_include);
- if (function_exists('plugin_install'))
- {
- plugin_install($plugin_id, $this->fs_plugins[$plugin_id]['version'], $errors);
- }
- }
+
+ $plugin_maintain->install($this->fs_plugins[$plugin_id]['version'], $errors);
+
if (empty($errors))
{
$query = '
-INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES (\''
-. $plugin_id . '\',\'' . $this->fs_plugins[$plugin_id]['version'] . '\'
-)';
+INSERT INTO '. PLUGINS_TABLE .' (id,version)
+ VALUES (\''. $plugin_id .'\', \''. $this->fs_plugins[$plugin_id]['version'] .'\')
+;';
pwg_query($query);
}
break;
@@ -93,20 +157,20 @@ INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES (\''
{
break;
}
- if (empty($errors) and file_exists($file_to_include))
+
+ if (empty($errors))
{
- include_once($file_to_include);
- if (function_exists('plugin_activate'))
- {
- plugin_activate($plugin_id, $crt_db_plugin['version'], $errors);
- }
+ $plugin_maintain->activate($crt_db_plugin['version'], $errors);
}
+
if (empty($errors))
{
$query = '
-UPDATE ' . PLUGINS_TABLE . '
-SET state=\'active\', version=\''.$this->fs_plugins[$plugin_id]['version'].'\'
-WHERE id=\'' . $plugin_id . '\'';
+UPDATE '. PLUGINS_TABLE .'
+ SET state=\'active\',
+ version=\''. $this->fs_plugins[$plugin_id]['version'] .'\'
+ WHERE id=\''. $plugin_id .'\'
+;';
pwg_query($query);
}
break;
@@ -116,17 +180,15 @@ WHERE id=\'' . $plugin_id . '\'';
{
break;
}
+
$query = '
-UPDATE ' . PLUGINS_TABLE . ' SET state=\'inactive\' WHERE id=\'' . $plugin_id . '\'';
+UPDATE '. PLUGINS_TABLE .'
+ SET state=\'inactive\'
+ WHERE id=\''. $plugin_id .'\'
+;';
pwg_query($query);
- if (file_exists($file_to_include))
- {
- include_once($file_to_include);
- if (function_exists('plugin_deactivate'))
- {
- plugin_deactivate($plugin_id);
- }
- }
+
+ $plugin_maintain->deactivate();
break;
case 'uninstall':
@@ -138,17 +200,14 @@ UPDATE ' . PLUGINS_TABLE . ' SET state=\'inactive\' WHERE id=\'' . $plugin_id .
{
$this->perform_action('deactivate', $plugin_id);
}
+
$query = '
-DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
+DELETE FROM '. PLUGINS_TABLE .'
+ WHERE id=\''. $plugin_id .'\'
+;';
pwg_query($query);
- if (file_exists($file_to_include))
- {
- include_once($file_to_include);
- if (function_exists('plugin_uninstall'))
- {
- plugin_uninstall($plugin_id);
- }
- }
+
+ $plugin_maintain->uninstall();
break;
case 'restore':
@@ -166,18 +225,17 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
{
break;
}
- if (!$this->deltree(PHPWG_PLUGINS_PATH . $plugin_id))
- {
- $this->send_to_trash(PHPWG_PLUGINS_PATH . $plugin_id);
- }
+
+ deltree(PHPWG_PLUGINS_PATH . $plugin_id, PHPWG_PLUGINS_PATH . 'trash');
break;
}
+
return $errors;
}
/**
- * Get plugins defined in the plugin directory
- */
+ * Get plugins defined in the plugin directory
+ */
function get_fs_plugins()
{
$dir = opendir(PHPWG_PLUGINS_PATH);
@@ -267,8 +325,10 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
// Retrieve PEM versions
function get_versions_to_check($version=PHPWG_VERSION)
{
+ global $conf;
+
$versions_to_check = array();
- $url = PEM_URL . '/api/get_version_list.php?category=12&format=php';
+ $url = PEM_URL . '/api/get_version_list.php?category_id='. $conf['pem_plugins_category'] .'&format=php';
if (fetchRemote($url, $result) and $pem_versions = @unserialize($result))
{
if (!preg_match('/^\d+\.\d+\.\d+$/', $version))
@@ -400,7 +460,7 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
{
$server_plugins[$plugin['extension_id']] = array();
}
- array_push($server_plugins[$plugin['extension_id']], $plugin['revision_name']);
+ $server_plugins[$plugin['extension_id']][] = $plugin['revision_name'];
}
foreach ($this->fs_plugins as $plugin_id => $fs_plugin)
@@ -504,7 +564,7 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
and $old_files = file($extract_path.'/obsolete.list', FILE_IGNORE_NEW_LINES)
and !empty($old_files))
{
- array_push($old_files, 'obsolete.list');
+ $old_files[] = 'obsolete.list';
foreach($old_files as $old_file)
{
$path = $extract_path.'/'.$old_file;
@@ -514,10 +574,7 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
}
elseif (is_dir($path))
{
- if (!$this->deltree($path))
- {
- $this->send_to_trash($path);
- }
+ deltree($path, PHPWG_PLUGINS_PATH . 'trash');
}
}
}
@@ -553,59 +610,6 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
}
return $merged_extensions;
}
-
- /**
- * delete $path directory
- * @param string - path
- */
- function deltree($path)
- {
- if (is_dir($path))
- {
- $fh = opendir($path);
- while ($file = readdir($fh))
- {
- if ($file != '.' and $file != '..')
- {
- $pathfile = $path . '/' . $file;
- if (is_dir($pathfile))
- {
- $this->deltree($pathfile);
- }
- else
- {
- @unlink($pathfile);
- }
- }
- }
- closedir($fh);
- return @rmdir($path);
- }
- }
-
- /**
- * send $path to trash directory
- * @param string - path
- */
- function send_to_trash($path)
- {
- $trash_path = PHPWG_PLUGINS_PATH . 'trash';
- if (!is_dir($trash_path))
- {
- @mkdir($trash_path);
- $file = @fopen($trash_path . '/.htaccess', 'w');
- @fwrite($file, 'deny from all');
- @fclose($file);
- }
- while ($r = $trash_path . '/' . md5(uniqid(rand(), true)))
- {
- if (!is_dir($r))
- {
- @rename($path, $r);
- break;
- }
- }
- }
/**
* Sort functions
@@ -613,12 +617,19 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
function plugin_version_compare($a, $b)
{
if (strtolower($a) == 'auto') return false;
-
- $pattern = array('/([a-z])/ei', '/\.+/', '/\.\Z|\A\./');
- $replacement = array( "'.'.intval('\\1', 36).'.'", '.', '');
-
- $array = preg_replace($pattern, $replacement, array($a, $b));
-
+
+ $array = preg_replace(
+ array('/\.+/', '/\.\Z|\A\./'),
+ array('.', ''),
+ array($a, $b)
+ );
+
+ $array = preg_replace_callback(
+ '/([a-z])/i',
+ create_function('$m', 'return intval($m[1], 36);'),
+ $array
+ );
+
return version_compare($array[0], $array[1], '>=');
}
diff --git a/admin/include/tabsheet.class.php b/admin/include/tabsheet.class.php
index 693d87f82..9dc441a7e 100644
--- a/admin/include/tabsheet.class.php
+++ b/admin/include/tabsheet.class.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
diff --git a/admin/include/themes.class.php b/admin/include/themes.class.php
index 654d220ef..7832c42e0 100644
--- a/admin/include/themes.class.php
+++ b/admin/include/themes.class.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -21,6 +21,36 @@
// | USA. |
// +-----------------------------------------------------------------------+
+/**
+ * class DummyTheme_maintain
+ * used when a theme uses the old procedural declaration of maintenance methods
+ */
+class DummyTheme_maintain extends ThemeMaintain
+{
+ function activate($theme_version, &$errors=array())
+ {
+ if (is_callable('theme_activate'))
+ {
+ return theme_activate($this->theme_id, $theme_version, $errors);
+ }
+ }
+ function deactivate()
+ {
+ if (is_callable('theme_deactivate'))
+ {
+ return theme_deactivate($this->theme_id);
+ }
+ }
+ function delete()
+ {
+ if (is_callable('theme_delete'))
+ {
+ return theme_delete($this->theme_id);
+ }
+ }
+}
+
+
class themes
{
var $fs_themes = array();
@@ -41,6 +71,37 @@ class themes
}
/**
+ * Returns the maintain class of a theme
+ * or build a new class with the procedural methods
+ * @param string $theme_id
+ */
+ private static function build_maintain_class($theme_id)
+ {
+ $file_to_include = PHPWG_THEMES_PATH.'/'.$theme_id.'/admin/maintain.inc.php';
+ $classname = $theme_id.'_maintain';
+
+ if (file_exists($file_to_include))
+ {
+ include_once($file_to_include);
+
+ if (class_exists($classname))
+ {
+ $theme_maintain = new $classname($theme_id);
+ }
+ else
+ {
+ $theme_maintain = new DummyTheme_maintain($theme_id);
+ }
+ }
+ else
+ {
+ $theme_maintain = new DummyTheme_maintain($theme_id);
+ }
+
+ return $theme_maintain;
+ }
+
+ /**
* Perform requested actions
* @param string - action
* @param string - theme id
@@ -55,7 +116,7 @@ class themes
$crt_db_theme = $this->db_themes_by_id[$theme_id];
}
- $file_to_include = PHPWG_THEMES_PATH.'/'.$theme_id.'/admin/maintain.inc.php';
+ $theme_maintain = self::build_maintain_class($theme_id);
$errors = array();
@@ -77,34 +138,23 @@ class themes
$missing_parent = $this->missing_parent_theme($theme_id);
if (isset($missing_parent))
{
- array_push(
- $errors,
- sprintf(
- l10n('Impossible to activate this theme, the parent theme is missing: %s'),
- $missing_parent
- )
+ $errors[] = l10n(
+ 'Impossible to activate this theme, the parent theme is missing: %s',
+ $missing_parent
);
break;
}
-
if ($this->fs_themes[$theme_id]['mobile']
and !empty($conf['mobile_theme'])
and $conf['mobile_theme'] != $theme_id)
{
- array_push($errors, l10n('You can activate only one mobile theme.'));
+ $errors[] = l10n('You can activate only one mobile theme.');
break;
}
- if (file_exists($file_to_include))
- {
- include($file_to_include);
- if (function_exists('theme_activate'))
- {
- theme_activate($theme_id, $this->fs_themes[$theme_id]['version'], $errors);
- }
- }
+ $theme_maintain->activate($this->fs_themes[$theme_id]['version'], $errors);
if (empty($errors))
{
@@ -134,10 +184,7 @@ INSERT INTO '.THEMES_TABLE.'
// you can't deactivate the last theme
if (count($this->db_themes_by_id) <= 1)
{
- array_push(
- $errors,
- l10n('Impossible to deactivate this theme, you need at least one theme.')
- );
+ $errors[] = l10n('Impossible to deactivate this theme, you need at least one theme.');
break;
}
@@ -147,8 +194,7 @@ INSERT INTO '.THEMES_TABLE.'
$new_theme = null;
$query = '
-SELECT
- id
+SELECT id
FROM '.THEMES_TABLE.'
WHERE id != \''.$theme_id.'\'
;';
@@ -165,14 +211,7 @@ SELECT
$this->set_default_theme($new_theme);
}
- if (file_exists($file_to_include))
- {
- include($file_to_include);
- if (function_exists('theme_deactivate'))
- {
- theme_deactivate($theme_id);
- }
- }
+ $theme_maintain->deactivate();
$query = '
DELETE
@@ -190,7 +229,7 @@ DELETE
case 'delete':
if (!empty($crt_db_theme))
{
- array_push($errors, 'CANNOT DELETE - THEME IS INSTALLED');
+ $errors[] = 'CANNOT DELETE - THEME IS INSTALLED';
break;
}
if (!isset($this->fs_themes[$theme_id]))
@@ -202,20 +241,16 @@ DELETE
$children = $this->get_children_themes($theme_id);
if (count($children) > 0)
{
- array_push(
- $errors,
- sprintf(
- l10n('Impossible to delete this theme. Other themes depends on it: %s'),
- implode(', ', $children)
- )
+ $errors[] = l10n(
+ 'Impossible to delete this theme. Other themes depends on it: %s',
+ implode(', ', $children)
);
break;
}
- if (!$this->deltree(PHPWG_THEMES_PATH.$theme_id))
- {
- $this->send_to_trash(PHPWG_THEMES_PATH.$theme_id);
- }
+ $theme_maintain->delete();
+
+ deltree(PHPWG_THEMES_PATH.$theme_id, PHPWG_THEMES_PATH . 'trash');
break;
case 'set_default':
@@ -256,7 +291,7 @@ DELETE
{
if (isset($test_child['parent']) and $test_child['parent'] == $theme_id)
{
- array_push($children, $test_child['name']);
+ $children[] = $test_child['name'];
}
}
@@ -316,7 +351,7 @@ SELECT
$themes = array();
while ($row = pwg_db_fetch_assoc($result))
{
- array_push($themes, $row);
+ $themes[] = $row;
}
return $themes;
}
@@ -622,7 +657,7 @@ SELECT
and $old_files = file($extract_path.'/obsolete.list', FILE_IGNORE_NEW_LINES)
and !empty($old_files))
{
- array_push($old_files, 'obsolete.list');
+ $old_files[] = 'obsolete.list';
foreach($old_files as $old_file)
{
$path = $extract_path.'/'.$old_file;
@@ -632,10 +667,7 @@ SELECT
}
elseif (is_dir($path))
{
- if (!$this->deltree($path))
- {
- $this->send_to_trash($path);
- }
+ deltree($path, PHPWG_THEMES_PATH . 'trash');
}
}
}
@@ -655,59 +687,6 @@ SELECT
}
/**
- * delete $path directory
- * @param string - path
- */
- function deltree($path)
- {
- if (is_dir($path))
- {
- $fh = opendir($path);
- while ($file = readdir($fh))
- {
- if ($file != '.' and $file != '..')
- {
- $pathfile = $path . '/' . $file;
- if (is_dir($pathfile))
- {
- $this->deltree($pathfile);
- }
- else
- {
- @unlink($pathfile);
- }
- }
- }
- closedir($fh);
- return @rmdir($path);
- }
- }
-
- /**
- * send $path to trash directory
- * @param string - path
- */
- function send_to_trash($path)
- {
- $trash_path = PHPWG_THEMES_PATH . 'trash';
- if (!is_dir($trash_path))
- {
- @mkdir($trash_path);
- $file = @fopen($trash_path . '/.htaccess', 'w');
- @fwrite($file, 'deny from all');
- @fclose($file);
- }
- while ($r = $trash_path . '/' . md5(uniqid(rand(), true)))
- {
- if (!is_dir($r))
- {
- @rename($path, $r);
- break;
- }
- }
- }
-
- /**
* Sort functions
*/
function theme_version_compare($a, $b)
diff --git a/admin/include/updates.class.php b/admin/include/updates.class.php
index 0ec0e0c40..2ab70d2be 100644
--- a/admin/include/updates.class.php
+++ b/admin/include/updates.class.php
@@ -1,4 +1,25 @@
<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based photo gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
@@ -33,7 +54,7 @@ class updates
}
}
- function check_piwigo_upgrade()
+ static function check_piwigo_upgrade()
{
$_SESSION['need_update'] = null;
@@ -161,7 +182,7 @@ class updates
{
if (in_array($ext_id, $conf['updates_ignored'][$type]))
{
- array_push($ignore_list, $ext_id);
+ $ignore_list[] = $ext_id;
}
else
{
@@ -242,54 +263,13 @@ class updates
return $this->$type->$version_compare($a, $b);
}
- function deltree($path, $move_to_trash=false)
- {
- if (is_dir($path))
- {
- $fh = opendir($path);
- while ($file = readdir($fh))
- {
- if ($file != '.' and $file != '..')
- {
- $pathfile = $path . '/' . $file;
- if (is_dir($pathfile))
- {
- self::deltree($pathfile, $move_to_trash);
- }
- else
- {
- @unlink($pathfile);
- }
- }
- }
- closedir($fh);
- if (@rmdir($path))
- {
- return true;
- }
- elseif ($move_to_trash)
- {
- $trash = PHPWG_ROOT_PATH.'_trash';
- if (!is_dir($trash))
- {
- @mkgetdir($trash);
- }
- return @rename($path, $trash . '/'.md5(uniqid(rand(), true)));
- }
- else
- {
- return false;
- }
- }
- }
-
- function process_obsolete_list($file)
+ static function process_obsolete_list($file)
{
if (file_exists(PHPWG_ROOT_PATH.$file)
and $old_files = file(PHPWG_ROOT_PATH.$file, FILE_IGNORE_NEW_LINES)
and !empty($old_files))
{
- array_push($old_files, $file);
+ $old_files[] = $file;
foreach($old_files as $old_file)
{
$path = PHPWG_ROOT_PATH.$old_file;
@@ -299,13 +279,13 @@ class updates
}
elseif (is_dir($path))
{
- self::deltree($path, true);
+ deltree($path, PHPWG_ROOT_PATH.'_trash');
}
}
}
}
- function dump_database($include_history=false)
+ static function dump_database($include_history=false)
{
global $page, $conf, $cfgBase;
@@ -350,16 +330,16 @@ class updates
}
@readfile($backupFile);
- self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
+ deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
exit();
}
else
{
- array_push($page['errors'], l10n('Unable to dump database.'));
+ $page['errors'][] = l10n('Unable to dump database.');
}
}
- function upgrade_to($upgrade_to, &$step, $check_current_version=true)
+ static function upgrade_to($upgrade_to, &$step, $check_current_version=true)
{
global $page, $conf, $template;
@@ -449,13 +429,14 @@ class updates
if (empty($error))
{
self::process_obsolete_list($obsolete_list);
- self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
+ deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
invalidate_user_cache(true);
$template->delete_compiled_templates();
unset($_SESSION['need_update']);
if ($step == 2)
{
- array_push($page['infos'], l10n('Update Complete'), $upgrade_to);
+ $page['infos'][] = l10n('Update Complete');
+ $page['infos'][] = $upgrade_to;
$step = -1;
}
else
@@ -466,24 +447,22 @@ class updates
else
{
file_put_contents(PHPWG_ROOT_PATH.$conf['data_location'].'update/log_error.txt', $error);
- array_push(
- $page['errors'],
- sprintf(
- l10n('An error has occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.'),
- get_root_url().$conf['data_location'].'update/log_error.txt'
- )
- );
+
+ $page['errors'][] = l10n(
+ 'An error has occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.',
+ get_root_url().$conf['data_location'].'update/log_error.txt'
+ );
}
}
else
{
- self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
- array_push($page['errors'], l10n('An error has occured during upgrade.'));
+ deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
+ $page['errors'][] = l10n('An error has occured during upgrade.');
}
}
else
{
- array_push($page['errors'], l10n('Piwigo cannot retrieve upgrade file from server'));
+ $page['errors'][] = l10n('Piwigo cannot retrieve upgrade file from server');
}
}
}
diff --git a/admin/include/uploadify/uploadify.php b/admin/include/uploadify/uploadify.php
index 1e36f3268..a4ba4db36 100644
--- a/admin/include/uploadify/uploadify.php
+++ b/admin/include/uploadify/uploadify.php
@@ -1,4 +1,26 @@
<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based photo gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
define('PHPWG_ROOT_PATH','../../../');
define('IN_ADMIN', true);
@@ -47,20 +69,7 @@ $image_id = add_uploaded_file(
$_POST['level']
);
-if (!isset($_SESSION['uploads']))
-{
- $_SESSION['uploads'] = array();
-}
-
-if (!isset($_SESSION['uploads'][ $_POST['upload_id'] ]))
-{
- $_SESSION['uploads'][ $_POST['upload_id'] ] = array();
-}
-
-array_push(
- $_SESSION['uploads'][ $_POST['upload_id'] ],
- $image_id
- );
+$_SESSION['uploads'][ $_POST['upload_id'] ][] = $image_id;
$query = '
SELECT