aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to 'admin')
-rw-r--r--admin/album_notification.php204
-rw-r--r--admin/include/c13y_internal.class.php2
-rw-r--r--admin/include/check_integrity.class.php2
-rw-r--r--admin/include/functions.php35
-rw-r--r--admin/include/functions_notification_by_mail.inc.php14
-rw-r--r--admin/include/functions_upgrade.php7
-rw-r--r--admin/include/languages.class.php4
-rw-r--r--admin/include/mysqldump.php4
-rw-r--r--admin/include/pclzip.lib.php2
-rw-r--r--admin/include/plugins.class.php4
-rw-r--r--admin/include/tabsheet.class.php2
-rw-r--r--admin/include/themes.class.php4
-rw-r--r--admin/include/updates.class.php22
-rw-r--r--admin/notification_by_mail.php18
-rw-r--r--admin/picture_modify.php19
-rw-r--r--admin/site_reader_local.php31
-rw-r--r--admin/site_update.php144
-rw-r--r--admin/themes/default/template/album_notification.tpl103
-rw-r--r--admin/themes/default/template/picture_modify.tpl1
-rw-r--r--admin/themes/default/template/user_list.tpl58
-rw-r--r--admin/themes/default/theme.css15
21 files changed, 572 insertions, 123 deletions
diff --git a/admin/album_notification.php b/admin/album_notification.php
index cafaad170..977c7b43a 100644
--- a/admin/album_notification.php
+++ b/admin/album_notification.php
@@ -46,7 +46,7 @@ $page['cat'] = $category['id'];
// +-----------------------------------------------------------------------+
// info by email to an access granted group of category informations
-if (isset($_POST['submitEmail']) and !empty($_POST['group']))
+if (isset($_POST['submitEmail']))
{
set_make_full_url();
@@ -54,6 +54,8 @@ if (isset($_POST['submitEmail']) and !empty($_POST['group']))
is empty find child representative_picture_id */
if (!empty($category['representative_picture_id']))
{
+ $img = array();
+
$query = '
SELECT id, file, path, representative_ext
FROM '.IMAGES_TABLE.'
@@ -65,56 +67,124 @@ SELECT id, file, path, representative_ext
{
$element = pwg_db_fetch_assoc($result);
- $img_url = '<a href="'.
- make_picture_url(array(
- 'image_id' => $element['id'],
- 'image_file' => $element['file'],
- 'category' => $category
- ))
- .'" class="thumblnk"><img src="'.DerivativeImage::url(IMG_THUMB, $element).'"></a>';
+ $img = array(
+ 'link' => make_picture_url(
+ array(
+ 'image_id' => $element['id'],
+ 'image_file' => $element['file'],
+ 'category' => $category
+ )
+ ),
+ 'src' => DerivativeImage::url(IMG_THUMB, $element),
+ );
}
}
- if (!isset($img_url))
- {
- $img_url = '';
- }
-
- pwg_mail_group(
- $_POST['group'],
- array(
- 'subject' => l10n('[%s] Visit album %s', $conf['gallery_title'], trigger_change('render_category_name', $category['name'], 'admin_cat_list')),
- // TODO : change this language variable to 'Visit album %s'
- // TODO : 'language_selected' => ....
- ),
- array(
- 'filename' => 'cat_group_info',
- 'assign' => array(
- 'IMG_URL' => $img_url,
- 'CAT_NAME' => trigger_change('render_category_name', $category['name'], 'admin_cat_list'),
- 'LINK' => make_index_url(array(
- 'category' => array(
- 'id' => $category['id'],
- 'name' => trigger_change('render_category_name', $category['name'], 'admin_cat_list'),
- 'permalink' => $category['permalink']
- )
- )),
- 'CPL_CONTENT' => empty($_POST['mail_content']) ? '' : stripslashes($_POST['mail_content']),
- )
+ $args = array(
+ 'subject' => l10n('[%s] Visit album %s', $conf['gallery_title'], trigger_change('render_category_name', $category['name'], 'admin_cat_list')),
+ // TODO : change this language variable to 'Visit album %s'
+ // TODO : 'language_selected' => ....
+ );
+
+ $tpl = array(
+ 'filename' => 'cat_group_info',
+ 'assign' => array(
+ 'IMG' => $img,
+ 'CAT_NAME' => trigger_change('render_category_name', $category['name'], 'admin_cat_list'),
+ 'LINK' => make_index_url(
+ array(
+ 'category' => array(
+ 'id' => $category['id'],
+ 'name' => trigger_change('render_category_name', $category['name'], 'admin_cat_list'),
+ 'permalink' => $category['permalink']
+ )
+ )
+ ),
+ 'CPL_CONTENT' => empty($_POST['mail_content']) ? '' : stripslashes($_POST['mail_content']),
)
);
- unset_make_full_url();
+ if ('users' == $_POST['who'] and isset($_POST['users']) and count($_POST['users']) > 0)
+ {
+ check_input_parameter('users', $_POST, true, PATTERN_ID);
- $query = '
+ // TODO code very similar to function pwg_mail_group. We'd better create
+ // a function pwg_mail_users that could be called from here and from
+ // pwg_mail_group
+
+ // TODO to make checks even better, we should check that theses users
+ // have access to this album. No real privacy issue here, even if we
+ // send the email to a user without permission.
+
+ $query = '
+SELECT
+ ui.user_id,
+ ui.status,
+ ui.language,
+ u.'.$conf['user_fields']['email'].' AS email,
+ u.'.$conf['user_fields']['username'].' AS username
+ FROM '.USER_INFOS_TABLE.' AS ui
+ JOIN '.USERS_TABLE.' AS u ON u.'.$conf['user_fields']['id'].' = ui.user_id
+ WHERE ui.user_id IN ('.implode(',', $_POST['users']).')
+;';
+ $users = query2array($query);
+ $usernames = array();
+
+ foreach ($users as $u)
+ {
+ $usernames[] = $u['username'];
+
+ $authkey = create_user_auth_key($u['user_id'], $u['status']);
+
+ $user_tpl = $tpl;
+
+ if ($authkey !== false)
+ {
+ $user_tpl['assign']['LINK'] = add_url_params($tpl['assign']['LINK'], array('auth' => $authkey['auth_key']));
+
+ if (isset($user_tpl['assign']['IMG']['link']))
+ {
+ $user_tpl['assign']['IMG']['link'] = add_url_params(
+ $user_tpl['assign']['IMG']['link'],
+ array('auth' => $authkey['auth_key'])
+ );
+ }
+ }
+
+ $user_args = $args;
+ if (isset($authkey))
+ {
+ $user_args['auth_key'] = $authkey['auth_key'];
+ }
+
+ switch_lang_to($u['language']);
+ pwg_mail($u['email'], $user_args, $user_tpl);
+ switch_lang_back();
+ }
+
+ $message = l10n_dec('%d mail was sent.', '%d mails were sent.', count($users));
+ $message.= ' ('.implode(', ', $usernames).')';
+
+ $page['infos'][] = $message;
+ }
+ elseif ('group' == $_POST['who'] and !empty($_POST['group']))
+ {
+ check_input_parameter('group', $_POST, false, PATTERN_ID);
+
+ pwg_mail_group($_POST['group'], $args, $tpl);
+
+ $query = '
SELECT
name
FROM '.GROUPS_TABLE.'
WHERE id = '.$_POST['group'].'
;';
- list($group_name) = pwg_db_fetch_row(pwg_query($query));
+ list($group_name) = pwg_db_fetch_row(pwg_query($query));
- $page['infos'][] = l10n('An information email was sent to group "%s"', $group_name);
+ $page['infos'][] = l10n('An information email was sent to group "%s"', $group_name);
+ }
+
+ unset_make_full_url();
}
// +-----------------------------------------------------------------------+
@@ -189,6 +259,64 @@ SELECT
}
}
+// all users with status != guest and permitted to this this album (for a
+// perfect search, we should also check that album is not only filled with
+// private photos)
+$query = '
+SELECT
+ user_id
+ FROM '.USER_INFOS_TABLE.'
+ WHERE status != \'guest\'
+;';
+$all_user_ids = query2array($query, null, 'user_id');
+
+if ('private' == $category['status'])
+{
+ $user_ids_access_indirect = array();
+
+ if (isset($group_ids) and count($group_ids) > 0)
+ {
+ $query = '
+SELECT
+ user_id
+ FROM '.USER_GROUP_TABLE.'
+ WHERE group_id IN ('.implode(',', $group_ids).')
+';
+ $user_ids_access_indirect = query2array($query, null, 'user_id');
+ }
+
+ $query = '
+SELECT
+ user_id
+ FROM '.USER_ACCESS_TABLE.'
+ WHERE cat_id = '.$category['id'].'
+;';
+ $user_ids_access_direct = query2array($query, null, 'user_id');
+
+ $user_ids_access = array_unique(array_merge($user_ids_access_direct, $user_ids_access_indirect));
+
+ $user_ids = array_intersect($user_ids_access, $all_user_ids);
+}
+else
+{
+ $user_ids = $all_user_ids;
+}
+
+if (count($user_ids) > 0)
+{
+ $query = '
+SELECT
+ '.$conf['user_fields']['id'].' AS id,
+ '.$conf['user_fields']['username'].' AS username
+ FROM '.USERS_TABLE.'
+ WHERE id IN ('.implode(',', $user_ids).')
+;';
+
+ $users = query2array($query, 'id', 'username');
+
+ $template->assign('user_options', $users);
+}
+
// +-----------------------------------------------------------------------+
// | sending html code |
// +-----------------------------------------------------------------------+
diff --git a/admin/include/c13y_internal.class.php b/admin/include/c13y_internal.class.php
index 10375095a..e0911f7e6 100644
--- a/admin/include/c13y_internal.class.php
+++ b/admin/include/c13y_internal.class.php
@@ -23,7 +23,7 @@
class c13y_internal
{
- function c13y_internal()
+ function __construct()
{
add_event_handler('list_check_integrity', array(&$this, 'c13y_version'));
add_event_handler('list_check_integrity', array(&$this, 'c13y_exif'));
diff --git a/admin/include/check_integrity.class.php b/admin/include/check_integrity.class.php
index 66ff1db8f..58893a284 100644
--- a/admin/include/check_integrity.class.php
+++ b/admin/include/check_integrity.class.php
@@ -27,7 +27,7 @@ class check_integrity
var $retrieve_list;
var $build_ignore_list;
- function check_integrity()
+ function __construct()
{
$this->ignore_list = array();
$this->retrieve_list = array();
diff --git a/admin/include/functions.php b/admin/include/functions.php
index fbbcd8c55..5ad436b71 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -180,6 +180,25 @@ function delete_element_files($ids)
}
$new_ids = array();
+ $formats_of = array();
+
+ $query = '
+SELECT
+ image_id,
+ ext
+ FROM '.IMAGE_FORMAT_TABLE.'
+ WHERE image_id IN ('.implode(',', $ids).')
+;';
+ $result = pwg_query($query);
+ while ($row = pwg_db_fetch_assoc($result))
+ {
+ if (!isset($formats_of[ $row['image_id'] ]))
+ {
+ $formats_of[ $row['image_id'] ] = array();
+ }
+
+ $formats_of[ $row['image_id'] ][] = $row['ext'];
+ }
$query = '
SELECT
@@ -205,6 +224,14 @@ SELECT
$files[] = original_to_representative( $files[0], $row['representative_ext']);
}
+ if (isset($formats_of[ $row['id'] ]))
+ {
+ foreach ($formats_of[ $row['id'] ] as $format_ext)
+ {
+ $files[] = original_to_format($files[0], $format_ext);
+ }
+ }
+
$ok = true;
if (!isset($conf['never_delete_originals']))
{
@@ -277,6 +304,13 @@ DELETE FROM '.IMAGE_CATEGORY_TABLE.'
;';
pwg_query($query);
+ // destruction of the formats
+ $query = '
+DELETE FROM '.IMAGE_FORMAT_TABLE.'
+ WHERE image_id IN ('. $ids_str .')
+;';
+ pwg_query($query);
+
// destruction of the links between images and tags
$query = '
DELETE FROM '.IMAGE_TAG_TABLE.'
@@ -540,6 +574,7 @@ function get_fs_directories($path, $recursive = true)
'.', '..', '.svn',
'thumbnail', 'pwg_high',
'pwg_representative',
+ 'pwg_format',
)
);
$exclude_folders = array_flip($exclude_folders);
diff --git a/admin/include/functions_notification_by_mail.inc.php b/admin/include/functions_notification_by_mail.inc.php
index 8d0fe2621..7dc113b0f 100644
--- a/admin/include/functions_notification_by_mail.inc.php
+++ b/admin/include/functions_notification_by_mail.inc.php
@@ -125,12 +125,12 @@ select
U.'.$conf['user_fields']['username'].' as username,
U.'.$conf['user_fields']['email'].' as mail_address,
N.enabled,
- N.last_send
-from
- '.USER_MAIL_NOTIFICATION_TABLE.' as N,
- '.USERS_TABLE.' as U
-where
- N.user_id = U.'.$conf['user_fields']['id'];
+ N.last_send,
+ UI.status
+from '.USER_MAIL_NOTIFICATION_TABLE.' as N
+ JOIN '.USERS_TABLE.' as U on N.user_id = U.'.$conf['user_fields']['id'].'
+ JOIN '.USER_INFOS_TABLE.' as UI on UI.user_id = N.user_id
+where 1=1';
if ($action == 'send')
{
@@ -159,7 +159,7 @@ order by';
else
{
$query .= '
- username;';
+ username';
}
$query .= ';';
diff --git a/admin/include/functions_upgrade.php b/admin/include/functions_upgrade.php
index b7a8763c5..eb0832879 100644
--- a/admin/include/functions_upgrade.php
+++ b/admin/include/functions_upgrade.php
@@ -174,10 +174,7 @@ UPDATE '.PREFIX_TABLE.'user_infos
// Deactivate all templates
function deactivate_templates()
{
- $query = '
- UPDATE '.PREFIX_TABLE.'config
- SET value = \''. array() .'\'
- WHERE param = \'extents_for_templates\';';
+ conf_update_param('extents_for_templates', array());
}
// Check access rights
@@ -322,4 +319,4 @@ function upgrade_db_connect()
my_error(l10n($e->getMessage()), true);
}
}
-?> \ No newline at end of file
+?>
diff --git a/admin/include/languages.class.php b/admin/include/languages.class.php
index 351e36d53..0f3e98eec 100644
--- a/admin/include/languages.class.php
+++ b/admin/include/languages.class.php
@@ -30,7 +30,7 @@ class languages
/**
* Initialize $fs_languages and $db_languages
*/
- function languages($target_charset = null)
+ function __construct($target_charset = null)
{
$this->get_fs_languages($target_charset);
}
@@ -408,4 +408,4 @@ UPDATE '.USER_INFOS_TABLE.'
return strcmp(strtolower($a['extension_name']), strtolower($b['extension_name']));
}
}
-?> \ No newline at end of file
+?>
diff --git a/admin/include/mysqldump.php b/admin/include/mysqldump.php
index 515d86ae9..1432675c8 100644
--- a/admin/include/mysqldump.php
+++ b/admin/include/mysqldump.php
@@ -59,7 +59,7 @@ class MySQLDump {
* @param boolean $compress It defines if the output file is compress (gzip) or not
* @param boolean $hexValue It defines if the outup values are base-16 or not
*/
- function MYSQLDump($db = null, $filepath = 'dump.sql', $compress = false, $hexValue = false){
+ function __construct($db = null, $filepath = 'dump.sql', $compress = false, $hexValue = false){
$this->compress = $compress;
if ( !$this->setOutputFile($filepath) )
return false;
@@ -418,4 +418,4 @@ class MySQLDump {
@fclose($file);
}
}
-?> \ No newline at end of file
+?>
diff --git a/admin/include/pclzip.lib.php b/admin/include/pclzip.lib.php
index e7facc1ea..c2d09a50c 100644
--- a/admin/include/pclzip.lib.php
+++ b/admin/include/pclzip.lib.php
@@ -212,7 +212,7 @@
// Note that no real action is taken, if the archive does not exist it is not
// created. Use create() for that.
// --------------------------------------------------------------------------------
- function PclZip($p_zipname)
+ function __construct($p_zipname)
{
// ----- Tests the zlib
diff --git a/admin/include/plugins.class.php b/admin/include/plugins.class.php
index 71093a6c1..5f258f836 100644
--- a/admin/include/plugins.class.php
+++ b/admin/include/plugins.class.php
@@ -69,7 +69,7 @@ class plugins
/**
* Initialize $fs_plugins and $db_plugins_by_id
*/
- function plugins()
+ function __construct()
{
$this->get_fs_plugins();
@@ -716,4 +716,4 @@ DELETE FROM '. PLUGINS_TABLE .'
$this->fs_plugins = $active_plugins + $inactive_plugins + $not_installed;
}
}
-?> \ No newline at end of file
+?>
diff --git a/admin/include/tabsheet.class.php b/admin/include/tabsheet.class.php
index c7681b611..959444a21 100644
--- a/admin/include/tabsheet.class.php
+++ b/admin/include/tabsheet.class.php
@@ -33,7 +33,7 @@ class tabsheet
$name is the tabsheet's name inside the template .tpl file
$titlename in the template is affected by $titlename value
*/
- function tabsheet($name = 'TABSHEET', $titlename = 'TABSHEET_TITLE')
+ function __construct($name = 'TABSHEET', $titlename = 'TABSHEET_TITLE')
{
$this->sheets = array();
$this->uniqid = null;
diff --git a/admin/include/themes.class.php b/admin/include/themes.class.php
index df0e29e66..dd6b6b1b0 100644
--- a/admin/include/themes.class.php
+++ b/admin/include/themes.class.php
@@ -60,7 +60,7 @@ class themes
/**
* Initialize $fs_themes and $db_themes_by_id
*/
- function themes()
+ function __construct()
{
$this->get_fs_themes();
@@ -736,4 +736,4 @@ SELECT
}
}
-?> \ No newline at end of file
+?>
diff --git a/admin/include/updates.class.php b/admin/include/updates.class.php
index 17a3b2578..29cefdfdb 100644
--- a/admin/include/updates.class.php
+++ b/admin/include/updates.class.php
@@ -135,15 +135,33 @@ class updates
{
return false;
}
+
+ $servers = array();
+
foreach ($pem_exts as $ext)
{
if (isset($ext_to_check[$ext['extension_id']]))
{
- $server = 'server_'.$ext_to_check[$ext['extension_id']];
- $this->$ext_to_check[$ext['extension_id']]->$server += array($ext['extension_id'] => $ext);
+ $type = $ext_to_check[$ext['extension_id']];
+
+ if (!isset($servers[$type]))
+ {
+ $servers[$type] = array();
+ }
+
+ $servers[$type][ $ext['extension_id'] ] = $ext;
+
unset($ext_to_check[$ext['extension_id']]);
}
}
+
+ foreach ($servers as $server_type => $extension_list)
+ {
+ $server_string = 'server_'.$server_type;
+
+ $this->$server_type->$server_string = $extension_list;
+ }
+
$this->check_missing_extensions($ext_to_check);
return true;
}
diff --git a/admin/notification_by_mail.php b/admin/notification_by_mail.php
index 38cadff6c..f146ba30f 100644
--- a/admin/notification_by_mail.php
+++ b/admin/notification_by_mail.php
@@ -289,13 +289,24 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l
if ($is_action_send)
{
+ $auth = null;
+ $add_url_params = array();
+
+ $auth_key = create_user_auth_key($nbm_user['user_id'], $nbm_user['status']);
+
+ if ($auth_key !== false)
+ {
+ $auth = $auth_key['auth_key'];
+ $add_url_params['auth'] = $auth;
+ }
+
set_make_full_url();
// Fill return list of "treated" check_key for 'send'
$return_list[] = $nbm_user['check_key'];
if ($conf['nbm_send_detailed_content'])
{
- $news = news($nbm_user['last_send'], $dbnow, false, $conf['nbm_send_html_mail']);
+ $news = news($nbm_user['last_send'], $dbnow, false, $conf['nbm_send_html_mail'], $auth);
$exist_data = count($news) > 0;
}
else
@@ -362,7 +373,7 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l
array
(
'TITLE' => get_title_recent_post_date($date_detail),
- 'HTML_DATA' => get_html_description_recent_post_date($date_detail)
+ 'HTML_DATA' => get_html_description_recent_post_date($date_detail, $auth)
)
);
}
@@ -373,7 +384,7 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l
array
(
'GOTO_GALLERY_TITLE' => $conf['gallery_title'],
- 'GOTO_GALLERY_URL' => get_gallery_home_url(),
+ 'GOTO_GALLERY_URL' => add_url_params(get_gallery_home_url(), $add_url_params),
'SEND_AS_NAME' => $env_nbm['send_as_name'],
)
);
@@ -389,6 +400,7 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l
'email_format' => $env_nbm['email_format'],
'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
'content_format' => $env_nbm['email_format'],
+ 'auth_key' => $auth,
)
);
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
index bf0e458e6..cdb7ccbbe 100644
--- a/admin/picture_modify.php
+++ b/admin/picture_modify.php
@@ -306,6 +306,25 @@ SELECT
$intro_vars['stats'].= ', '.sprintf(l10n('Rated %d times, score : %.2f'), $row['nb_rates'], $row['rating_score']);
}
+$query = '
+SELECT *
+ FROM '.IMAGE_FORMAT_TABLE.'
+ WHERE image_id = '.$row['id'].'
+;';
+$formats = query2array($query);
+
+if (!empty($formats))
+{
+ $format_strings = array();
+
+ foreach ($formats as $format)
+ {
+ $format_strings[] = sprintf('%s (%.2fMB)', $format['ext'], $format['filesize']/1024);
+ }
+
+ $intro_vars['formats'] = l10n('Formats: %s', implode(', ', $format_strings));
+}
+
$template->assign('INTRO', $intro_vars);
diff --git a/admin/site_reader_local.php b/admin/site_reader_local.php
index 7e618ca17..69f644467 100644
--- a/admin/site_reader_local.php
+++ b/admin/site_reader_local.php
@@ -100,14 +100,19 @@ function get_elements($path)
{
$representative_ext = $this->get_representative_ext($path, $filename_wo_ext);
}
- $fs[ $path.'/'.$node ] = array(
- 'representative_ext' => $representative_ext,
- );
+
+ $fs[ $path.'/'.$node ] = array('representative_ext' => $representative_ext);
+
+ if ($conf['enable_formats'])
+ {
+ $fs[ $path.'/'.$node ]['formats'] = $this->get_formats($path, $filename_wo_ext);
+ }
}
}
else if (is_dir($path.'/'.$node)
and $node != 'pwg_high'
and $node != 'pwg_representative'
+ and $node != 'pwg_format'
and $node != 'thumbnail' )
{
$subdirs[] = $node;
@@ -182,6 +187,26 @@ function get_representative_ext($path, $filename_wo_ext)
return null;
}
+function get_formats($path, $filename_wo_ext)
+{
+ global $conf;
+
+ $formats = array();
+
+ $base_test = $path.'/pwg_format/'.$filename_wo_ext.'.';
+
+ foreach ($conf['format_ext'] as $ext)
+ {
+ $test = $base_test.$ext;
+
+ if (is_file($test))
+ {
+ $formats[$ext] = floor(filesize($test) / 1024);
+ }
+ }
+
+ return $formats;
+}
}
?> \ No newline at end of file
diff --git a/admin/site_update.php b/admin/site_update.php
index 5bcaea12a..2a70ae5d9 100644
--- a/admin/site_update.php
+++ b/admin/site_update.php
@@ -457,6 +457,7 @@ if (isset($_POST['submit']) and $_POST['sync'] == 'files'
$start= $start_files;
$fs = $site_reader->get_elements($basedir);
+
$template->append('footer_elements', '<!-- get_elements: '
. get_elapsed_time($start, get_moment())
. ' -->' );
@@ -486,6 +487,7 @@ SELECT id, path
$inserts = array();
$insert_links = array();
+ $insert_formats = array();
foreach (array_diff(array_keys($fs), $db_elements) as $path)
{
@@ -535,36 +537,158 @@ SELECT id, path
'info' => l10n('added')
);
+ if ($conf['enable_formats'])
+ {
+ foreach ($fs[$path]['formats'] as $ext => $filesize)
+ {
+ $insert_formats[] = array(
+ 'image_id' => $insert['id'],
+ 'ext' => $ext,
+ 'filesize' => $filesize,
+ );
+
+ $infos[] = array(
+ 'path' => $insert['path'],
+ 'info' => l10n('format %s added', $ext)
+ );
+ }
+ }
+
$caddiables[] = $insert['id'];
}
- if (count($inserts) > 0)
+ // search new/removed formats on photos already registered in database
+ if ($conf['enable_formats'])
{
- if (!$simulate)
+ $db_elements_flip = array_flip($db_elements);
+
+ $existing_ids = array();
+
+ foreach (array_intersect_key($fs, $db_elements_flip) as $path => $existing)
+ {
+ $existing_ids[] = $db_elements_flip[$path];
+ }
+
+ $logger->debug('existing_ids', 'sync', $existing_ids);
+
+ if (count($existing_ids) > 0)
+ {
+ $db_formats = array();
+
+ // find formats for existing photos (already in database)
+ $query = '
+SELECT *
+ FROM '.IMAGE_FORMAT_TABLE.'
+ WHERE image_id IN ('.implode(',', $existing_ids).')
+;';
+ $result = pwg_query($query);
+ while ($row = pwg_db_fetch_assoc($result))
+ {
+ if (!isset($db_formats[$row['image_id']]))
+ {
+ $db_formats[$row['image_id']] = array();
+ }
+
+ $db_formats[$row['image_id']][$row['ext']] = $row['format_id'];
+ }
+
+ // first we search the formats that were removed
+ $formats_to_delete = array();
+
+ foreach ($db_formats as $image_id => $formats)
+ {
+ $image_formats_to_delete = array_diff_key($formats, $fs[ $db_elements[$image_id] ]['formats']);
+ $logger->debug('image_formats_to_delete', 'sync', $image_formats_to_delete);
+ foreach ($image_formats_to_delete as $ext => $format_id)
+ {
+ $formats_to_delete[] = $format_id;
+
+ $infos[] = array(
+ 'path' => $db_elements[$image_id],
+ 'info' => l10n('format %s removed', $ext)
+ );
+ }
+ }
+
+ // then we search for new formats on existing photos
+ foreach ($existing_ids as $image_id)
+ {
+ $path = $db_elements[$image_id];
+
+ $formats = array();
+ if (isset($db_formats[$image_id]))
+ {
+ $formats = $db_formats[$image_id];
+ }
+
+ $image_formats_to_insert = array_diff_key($fs[$path]['formats'], $formats);
+ $logger->debug('image_formats_to_insert', 'sync', $image_formats_to_insert);
+ foreach ($image_formats_to_insert as $ext => $filesize)
+ {
+ $insert_formats[] = array(
+ 'image_id' => $image_id,
+ 'ext' => $ext,
+ 'filesize' => $filesize,
+ );
+
+ $infos[] = array(
+ 'path' => $db_elements[$image_id],
+ 'info' => l10n('format %s added', $ext)
+ );
+ }
+ }
+ }
+ }
+
+
+ if (!$simulate)
+ {
+ // inserts all new elements
+ if (count($inserts) > 0)
{
- // inserts all new elements
mass_inserts(
IMAGES_TABLE,
array_keys($inserts[0]),
$inserts
);
-
+
// inserts all links between new elements and their storage category
mass_inserts(
IMAGE_CATEGORY_TABLE,
array_keys($insert_links[0]),
$insert_links
);
+ }
+
+ // inserts all formats
+ if (count($insert_formats) > 0)
+ {
+ mass_inserts(
+ IMAGE_FORMAT_TABLE,
+ array_keys($insert_formats[0]),
+ $insert_formats
+ );
+ }
- // add new photos to caddie
- if (isset($_POST['add_to_caddie']) and $_POST['add_to_caddie'] == 1)
- {
- fill_caddie($caddiables);
- }
+ if (count($formats_to_delete) > 0)
+ {
+ $query = '
+DELETE
+ FROM '.IMAGE_FORMAT_TABLE.'
+ WHERE format_id IN ('.implode(',', $formats_to_delete).')
+;';
+ pwg_query($query);
+ }
+
+ // add new photos to caddie
+ if (isset($_POST['add_to_caddie']) and $_POST['add_to_caddie'] == 1)
+ {
+ fill_caddie($caddiables);
}
- $counts['new_elements'] = count($inserts);
}
+ $counts['new_elements'] = count($inserts);
+
// delete elements that are in database but not in the filesystem
$to_delete_elements = array();
foreach (array_diff($db_elements, array_keys($fs)) as $path)
diff --git a/admin/themes/default/template/album_notification.tpl b/admin/themes/default/template/album_notification.tpl
index 32aa8e414..8573cf16e 100644
--- a/admin/themes/default/template/album_notification.tpl
+++ b/admin/themes/default/template/album_notification.tpl
@@ -1,3 +1,59 @@
+{combine_script id='jquery.selectize' load='footer' path='themes/default/js/plugins/selectize.min.js'}
+{combine_css id='jquery.selectize' path="themes/default/js/plugins/selectize.{$themeconf.colorscheme}.css"}
+
+{footer_script}
+jQuery(document).ready(function() {
+ jQuery("select[name=who]").change(function () {
+ checkWhoOptions();
+ });
+
+ checkWhoOptions();
+
+ function checkWhoOptions() {
+ var option = jQuery("select[name=who] option:selected").val();
+ jQuery(".who_option").hide();
+ jQuery(".who_" + option).show();
+ }
+
+ jQuery(".who_option select").selectize({
+ plugins: ['remove_button']
+ });
+
+ jQuery("form#categoryNotify").submit(function(e) {
+ var who_selected = false;
+ var who_option = jQuery("select[name=who] option:selected").val();
+
+ if (jQuery(".who_" + who_option + " select").length > 0) {
+ if (jQuery(".who_" + who_option + " select option:selected").length > 0) {
+ who_selected = true;
+ }
+ }
+
+ if (!who_selected) {
+ jQuery(".actionButtons .errors").show();
+ e.preventDefault();
+ }
+ else {
+ jQuery(".actionButtons .errors").hide();
+ console.log("form can be submited");
+ }
+ });
+});
+{/footer_script}
+
+{html_style}
+.who_option {
+ margin-top:5px;
+}
+
+span.errors {
+ background-image:none;
+ padding:2px 5px;
+ margin:0;
+ border-radius:5px;
+}
+{/html_style}
+
<div class="titrePage">
<h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> &#8250; {'Edit album'|@translate} {$TABSHEET_TITLE}</h2>
</div>
@@ -5,36 +61,51 @@
<form action="{$F_ACTION}" method="post" id="categoryNotify">
<fieldset id="emailCatInfo">
- <legend>{'Send an information email to group members'|@translate}</legend>
-
-{if isset($group_mail_options)}
+ <legend>{'Send mail to users'|@translate}</legend>
<p>
- <strong>{'Group'|@translate}</strong>
- <br>
- <select name="group">
- {html_options options=$group_mail_options}
+ <strong>{'Recipients'|@translate}</strong>
+ <select name="who">
+ <option value="group">{'Group'|translate}</option>
+ <option value="users">{'Users'|translate}</option>
</select>
</p>
+ <p class="who_option who_group">
+{if isset($group_mail_options)}
+ <select name="group" placeholder="{'Type in a search term'|translate}" style="width:524px;">
+ {html_options options=$group_mail_options}
+ </select>
+{elseif isset($no_group_in_gallery) and $no_group_in_gallery}
+ {'There is no group in this gallery.'|@translate} <a href="admin.php?page=group_list" class="externalLink">{'Group management'|@translate}</a>
+{else}
+ {'No group is permitted to see this private album'|@translate}.
+ <a href="{$permission_url}" class="externalLink">{'Permission management'|@translate}</a>
+{/if}
+ </p>
+
+ <p class="who_option who_users">
+{if isset($user_options)}
+ <select name="users[]" multiple placeholder="{'Type in a search term'|translate}" style="width:524px;">
+ {html_options options=$user_options selected=$user_options_selected}
+ </select>
+{else}
+ {'No user is permitted to see this private album'|@translate}.
+ <a href="{$permission_url}" class="externalLink">{'Permission management'|@translate}</a>
+{/if}
+ </p>
+
<p>
<strong>{'Complementary mail content'|@translate}</strong>
<br>
<textarea cols="50" rows="5" name="mail_content" id="mail_content" class="description">{$MAIL_CONTENT}</textarea>
</p>
- <p>
+ <p class="actionButtons">
<input class="submit" type="submit" value="{'Send'|@translate}" name="submitEmail">
+ <span class="errors" style="display:none">&#x2718; {'No recipient selected'|translate}</span>
</p>
-{elseif isset($no_group_in_gallery) and $no_group_in_gallery}
- <p>{'There is no group in this gallery.'|@translate} <a href="admin.php?page=group_list" class="externalLink">{'Group management'|@translate}</a></p>
-{else}
- <p>
- {'No group is permitted to see this private album'|@translate}.
- <a href="{$permission_url}" class="externalLink">{'Permission management'|@translate}</a>
- </p>
-{/if}
</fieldset>
</form>
diff --git a/admin/themes/default/template/picture_modify.tpl b/admin/themes/default/template/picture_modify.tpl
index aeba2dd6f..71b3d2ba4 100644
--- a/admin/themes/default/template/picture_modify.tpl
+++ b/admin/themes/default/template/picture_modify.tpl
@@ -63,6 +63,7 @@ jQuery("a.preview-box").colorbox({
<li>{$INTRO.add_date}</li>
<li>{$INTRO.added_by}</li>
<li>{$INTRO.size}</li>
+ <li>{$INTRO.formats}</li>
<li>{$INTRO.stats}</li>
<li>{$INTRO.id}</li>
</ul>
diff --git a/admin/themes/default/template/user_list.tpl b/admin/themes/default/template/user_list.tpl
index 39e3318b9..6744f6f69 100644
--- a/admin/themes/default/template/user_list.tpl
+++ b/admin/themes/default/template/user_list.tpl
@@ -1,3 +1,4 @@
+{include file='include/colorbox.inc.tpl'}
{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}
{combine_script id='jquery.dataTables' load='footer' path='themes/default/js/plugins/jquery.dataTables.js'}
@@ -274,7 +275,7 @@ jQuery(document).ready(function() {
jQuery("script.userDetails").html()
);
- jQuery("#user"+userId).append(template(user));
+ jQuery("#user"+userId).html(template(user));
/* groups select */
jQuery('[data-selectize=groups]').selectize({
@@ -339,10 +340,19 @@ jQuery(document).ready(function() {
console.log('technical error loading user details');
}
});
-
- return '<div id="user'+userId+'" class="userProperties"><img class="loading" src="themes/default/images/ajax-loader-small.gif"></div>';
+
+ jQuery(".user_form_popin")
+ .attr("id", "user"+userId)
+ .html('<div class="popinWait"><span><img class="loading" src="themes/default/images/ajax-loader-small.gif"> {/literal}{'Loading...'|translate|escape:'javascript'}{literal}</span></div>')
+ ;
}
+jQuery(document).on('click', '.close-user-details', function(e) {
+ jQuery('.user_form_popin').colorbox.close();
+ e.preventDefault();
+});
+
+
/* change password */
jQuery(document).on('click', '.changePasswordOpen', function() {
var userId = jQuery(this).parentsUntil('form').parent().find('input[name=user_id]').val();
@@ -474,7 +484,7 @@ jQuery(document).ready(function() {
jQuery('#user'+userId+' .userDelete .loading').show();
},
success:function(data) {
- oTable.fnDraw();
+ jQuery('.user_form_popin').colorbox.close();
jQuery('#showAddUser .infos').html('&#x2714; User '+username+' deleted').show();
},
error:function(XMLHttpRequest, textStatus, errorThrows) {
@@ -537,28 +547,17 @@ jQuery(document).ready(function() {
*/
jQuery(document).on('click', '#userList tbody td .openUserDetails', function() {
var nTr = this.parentNode.parentNode;
- if (jQuery(this).hasClass('icon-cancel-circled')) {
- /* This row is already open - close it */
- jQuery(this)
- .removeClass('icon-cancel-circled')
- .addClass('icon-pencil')
- .attr('title', "{/literal}{'Open user details'|translate|escape:'javascript'}{literal}")
- .html("{/literal}{'edit'|translate|escape:'javascript'}{literal}")
- ;
-
- oTable.fnClose( nTr );
- }
- else {
- /* Open this row */
- jQuery(this)
- .removeClass('icon-pencil')
- .addClass('icon-cancel-circled')
- .attr('title', "{/literal}{'Close user details'|translate|escape:'javascript'}{literal}")
- .html("{/literal}{'close'|translate|escape:'javascript'}{literal}")
- ;
-
- oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
- }
+
+ jQuery.colorbox({
+ inline:true,
+ title:"{/literal}{'Edit user'|translate}{literal}",
+ href:".user_form_popin",
+ onClosed: function() {
+ oTable.fnDraw();
+ }
+ });
+
+ fnFormatDetails(oTable, nTr);
});
@@ -1153,7 +1152,12 @@ span.infos, span.errors {background-image:none; padding:2px 5px; margin:0;border
<span class="infos propertiesUpdateDone" style="display:none">&#x2714; <%- user.updateString %></span>
- <input type="submit" value="{'Update user'|translate|escape:html}" style="display:none;" data-user_id="<%- user.id %>">
+ <input type="submit" value="{'Update user'|translate|escape:html}" data-user_id="<%- user.id %>">
<img class="submitWait" src="themes/default/images/ajax-loader-small.gif" style="display:none">
+ <a href="#close" class="icon-cancel-circled close-user-details" title="{'Close user details'|translate}">{'close'|translate}</a>
</form>
</script>
+
+<div style="display:none">
+ <div class="user_form_popin userProperties"></div>
+</div> \ No newline at end of file
diff --git a/admin/themes/default/theme.css b/admin/themes/default/theme.css
index 509aff377..0aa0dba1a 100644
--- a/admin/themes/default/theme.css
+++ b/admin/themes/default/theme.css
@@ -1228,6 +1228,21 @@ a.group_perm {
.userProperty {width:340px;float:left;margin-bottom:15px;}
.userActions {float:right;text-align:right;}
+.user_form_popin {
+ width:750px;
+ height:430px;
+ padding:20px;
+}
+
+.userProperties form {
+ text-align:left;
+}
+
+.popinWait {
+ padding-top:200px;
+}
+
+
.preview-box.icon-zoom-in {
display:block;
position:relative;