From 429dd2ff626119727103297cd33b3c9a3b921d89 Mon Sep 17 00:00:00 2001 From: plegall Date: Wed, 24 Aug 2005 22:22:29 +0000 Subject: - deletion : no mail notification anymore. Feature replaced by RSS feed notification. - improvement : on waiting pictures management. Ability to validate all or reject all in one clic. - regrouped fields in admin/update git-svn-id: http://piwigo.org/svn/trunk@849 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/configuration.php | 6 -- admin/waiting.php | 180 +++++++++++++++++++++++--------- doc/ChangeLog | 8 ++ include/functions.inc.php | 42 -------- install/config.sql | 1 - picture.php | 16 --- template/cclear/admin/configuration.tpl | 5 - template/cclear/admin/update.tpl | 83 ++++++++------- template/cclear/admin/waiting.tpl | 21 ++-- upload.php | 7 +- 10 files changed, 200 insertions(+), 169 deletions(-) diff --git a/admin/configuration.php b/admin/configuration.php index 5d3864937..8829c0822 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -164,8 +164,6 @@ switch ($page['section']) { $history_yes = ($conf['log']=='true')?'checked="checked"':''; $history_no = ($conf['log']=='false')?'checked="checked"':''; - $notif_yes = ($conf['mail_notification']=='true')?'checked="checked"':''; - $notif_no = ($conf['mail_notification']=='false')?'checked="checked"':''; $lock_yes = ($conf['gallery_locked']=='true')?'checked="checked"':''; $lock_no = ($conf['gallery_locked']=='false')?'checked="checked"':''; @@ -179,8 +177,6 @@ switch ($page['section']) 'L_CONF_TN_PREFIX_INFO'=>$lang['conf_prefix_info'], 'L_CONF_HISTORY'=>$lang['history'], 'L_CONF_HISTORY_INFO'=>$lang['conf_log_info'], - 'L_CONF_NOTIFICATION'=>$lang['conf_notification'], - 'L_CONF_NOTIFICATION_INFO'=>$lang['conf_notification_info'], 'L_CONF_GALLERY_LOCKED'=>$lang['conf_gallery_locked'], 'L_CONF_GALLERY_LOCKED_INFO'=>$lang['conf_gallery_locked_info'], @@ -188,8 +184,6 @@ switch ($page['section']) 'THUMBNAIL_PREFIX'=>$conf['prefix_thumbnail'], 'HISTORY_YES'=>$history_yes, 'HISTORY_NO'=>$history_no, - 'NOTIFICATION_YES'=>$notif_yes, - 'NOTIFICATION_NO'=>$notif_no, 'GALLERY_LOCKED_YES'=>$lock_yes, 'GALLERY_LOCKED_NO'=>$lock_no, )); diff --git a/admin/waiting.php b/admin/waiting.php index 3be00dd5c..7c8e05b51 100644 --- a/admin/waiting.php +++ b/admin/waiting.php @@ -30,49 +30,110 @@ if( !defined("PHPWG_ROOT_PATH") ) } include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); //--------------------------------------------------------------------- updates -if ( isset( $_POST['submit'] ) ) + +if (isset($_POST)) { - $query = 'SELECT * FROM '.WAITING_TABLE; - $query.= " WHERE validated = 'false';"; - $result = pwg_query( $query ); - while ( $row = mysql_fetch_array( $result ) ) + $to_validate = array(); + $to_reject = array(); + + if (isset($_POST['submit'])) + { + foreach (explode(',', $_POST['list']) as $waiting_id) + { + if (isset($_POST['action-'.$waiting_id])) + { + switch ($_POST['action-'.$waiting_id]) + { + case 'reject' : + { + array_push($to_reject, $waiting_id); + break; + } + case 'validate' : + { + array_push($to_validate, $waiting_id); + break; + } + } + } + } + } + else if (isset($_POST['validate-all'])) + { + $to_validate = explode(',', $_POST['list']); + } + else if (isset($_POST['reject-all'])) { - $key = 'validate-'.$row['id']; - if ( isset( $_POST[$key] ) ) + $to_reject = explode(',', $_POST['list']); + } + + if (count($to_validate) > 0) + { + $query = ' +UPDATE '.WAITING_TABLE.' + SET validated = \'true\' + WHERE id IN ('.implode(',', $to_validate).') +;'; + pwg_query($query); + + array_push( + $page['infos'], + sprintf( + l10n('%d waiting pictures validated'), + count($to_validate) + ) + ); + } + + if (count($to_reject) > 0) + { + // The uploaded element was refused, we have to delete its reference in + // the database and to delete the element as well. + $query = ' +SELECT id, storage_category_id, file, tn_ext + FROM '.WAITING_TABLE.' + WHERE id IN ('.implode(',', $to_reject).') +;'; + $result = pwg_query($query); + while($row = mysql_fetch_array($result)) { - if ( $_POST[$key] == 'true' ) + $dir = get_complete_dir($row['storage_category_id']); + unlink($dir.$row['file']); + if (isset($row['tn_ext']) and $row['tn_ext'] != '') { - // The uploaded element was validated, we have to set the - // "validated" field to "true" - $query = 'UPDATE '.WAITING_TABLE; - $query.= " SET validated = 'true'"; - $query.= ' WHERE id = '.$row['id']; - $query.= ';'; - pwg_query( $query ); + unlink( + get_thumbnail_src( + $dir.$row['file'], + $row['tn_ext'] + ) + ); } - else + else if (@is_file(get_thumbnail_src($dir.$row['file'], 'jpg'))) { - // The uploaded element was refused, we have to delete its reference - // in the database and to delete the element as well. - $query = 'DELETE FROM '.WAITING_TABLE; - $query.= ' WHERE id = '.$row['id']; - $query.= ';'; - pwg_query( $query ); - // deletion of the associated files - $dir = get_complete_dir( $row['storage_category_id'] ); - unlink( $dir.$row['file'] ); - if (isset($row['tn_ext']) and $row['tn_ext'] != '' ) - { - $thumbnail = $conf['prefix_thumbnail']; - $thumbnail.= get_filename_wo_extension( $row['file'] ); - $thumbnail.= '.'.$row['tn_ext']; - $url = $dir.'thumbnail/'.$thumbnail; - unlink( $url ); - } + unlink( + get_thumbnail_src( + $dir.$row['file'], + 'jpg' + ) + ); } } + + $query = ' +DELETE + FROM '.WAITING_TABLE.' + WHERE id IN ('.implode(',', $to_reject).') +;'; + pwg_query($query); + + array_push( + $page['infos'], + sprintf( + l10n('%d waiting pictures rejected'), + count($to_reject) + ) + ); } - array_push($infos, $lang['waiting_update']); } //----------------------------------------------------- template initialization @@ -92,6 +153,8 @@ $template->assign_vars(array( //---------------------------------------------------------------- form display $cat_names = array(); +$list = array(); + $query = 'SELECT * FROM '.WAITING_TABLE; $query.= " WHERE validated = 'false'"; $query.= ' ORDER BY storage_category_id'; @@ -113,16 +176,22 @@ while ( $row = mysql_fetch_array( $result ) ) $class='row1'; if ( $i++ % 2== 0 ) $class='row2'; - $template->assign_block_vars('picture' ,array( - 'WAITING_CLASS'=>$class, - 'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'], - 'ID_IMG'=>$row['id'], - 'DATE_IMG'=>format_date( $row['date'], 'unix', true ), - 'FILE_IMG'=>$row['file'], - 'PREVIEW_URL_IMG'=>$preview_url, - 'UPLOAD_EMAIL'=>$row['mail_address'], - 'UPLOAD_USERNAME'=>$row['username'] - )); + $template->assign_block_vars( + 'picture', + array( + 'WAITING_CLASS'=>$class, + 'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'], + 'ID_IMG'=>$row['id'], + 'DATE_IMG' => date('Y-m-d H:i:s', $row['date']), + 'FILE_TITLE'=>$row['file'], + 'FILE_IMG' => + (strlen($row['file']) > 10) ? + (substr($row['file'], 0, 10)).'...' : $row['file'], + 'PREVIEW_URL_IMG'=>$preview_url, + 'UPLOAD_EMAIL'=>$row['mail_address'], + 'UPLOAD_USERNAME'=>$row['username'] + ) + ); // is there an existing associated thumnail ? if ( !empty( $row['tn_ext'] )) @@ -133,12 +202,27 @@ while ( $row = mysql_fetch_array( $result ) ) $url = $cat_names[$row['storage_category_id']]['dir']; $url.= 'thumbnail/'.$thumbnail; - $template->assign_block_vars('picture.thumbnail' ,array( - 'PREVIEW_URL_TN_IMG'=>$url, - 'FILE_TN_IMG'=>$thumbnail - )); + $template->assign_block_vars( + 'picture.thumbnail', + array( + 'PREVIEW_URL_TN_IMG' => $url, + 'FILE_TN_IMG' => + (strlen($thumbnail) > 10) ? + (substr($thumbnail, 0, 10)).'...' : $thumbnail, + 'FILE_TN_TITLE' => $thumbnail + ) + ); } + + array_push($list, $row['id']); } + +$template->assign_vars( + array( + 'LIST' => implode(',', $list) + ) + ); + //----------------------------------------------------------- sending html code $template->assign_var_from_handle('ADMIN_CONTENT', 'waiting'); ?> diff --git a/doc/ChangeLog b/doc/ChangeLog index a2fba5ef3..7d325c215 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,11 @@ +2005-08-25 Pierrick LE GALL + + * deletion : no mail notification anymore. Feature replaced by RSS + feed notification. + + * improvement : on waiting pictures management. Ability to + validate all or reject all in one clic. + 2005-08-21 Pierrick LE GALL * modification : adaptation of template variables and blocks in diff --git a/include/functions.inc.php b/include/functions.inc.php index 8a3a1f116..a37623ca2 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -433,48 +433,6 @@ function format_date($date, $type = 'us', $show_time = false) return $formated_date; } -// notify sends a email to every admin of the gallery -function notify( $type, $infos = '' ) -{ - global $conf; - - $headers = 'From: <'.$conf['mail_webmaster'].'>'."\n"; - $headers.= 'Reply-To: '.$conf['mail_webmaster']."\n"; - $headers.= 'X-Mailer: PhpWebGallery, PHP '.phpversion(); - - $options = '-f '.$conf['mail_webmaster']; - // retrieving all administrators - $query = 'SELECT username,mail_address,language'; - $query.= ' FROM '.USERS_TABLE; - $query.= " WHERE status = 'admin'"; - $query.= ' AND mail_address IS NOT NULL'; - $query.= ';'; - $result = pwg_query( $query ); - while ( $row = mysql_fetch_array( $result ) ) - { - $to = $row['mail_address']; - include( PHPWG_ROOT_PATH.'language/'.$row['language'].'/common.lang.php' ); - $content = $lang['mail_hello']."\n\n"; - switch ( $type ) - { - case 'upload' : - $subject = $lang['mail_new_upload_subject']; - $content.= $lang['mail_new_upload_content']; - break; - case 'comment' : - $subject = $lang['mail_new_comment_subject']; - $content.= $lang['mail_new_comment_content']; - break; - } - $infos = str_replace( ' ', ' ', $infos ); - $infos = str_replace( '−', '-', $infos ); - $content.= "\n\n".$infos; - $content.= "\n\n-- \nPhpWebGallery ".PHPWG_VERSION; - $content = wordwrap( $content, 72 ); - @mail( $to, $subject, $content, $headers, $options ); - } -} - function pwg_write_debug() { global $debug; diff --git a/install/config.sql b/install/config.sql index 910e51388..ba7e8875d 100644 --- a/install/config.sql +++ b/install/config.sql @@ -15,7 +15,6 @@ INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('upload_maxheight INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('log','false','keep an history of visits on your website'); INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('comments_validation','false','administrators validate users comments before becoming visible'); INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('comments_forall','false','even guest not registered can post comments'); -INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('mail_notification','false','automated mail notification for adminsitrators'); INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nb_image_line','5','Number of images displayed per row'); INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nb_line_page','3','Number of rows displayed per page'); INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('recent_period','7','Period within which pictures are displayed as new (in days)'); diff --git a/picture.php b/picture.php index ce69fb3a7..94a981d26 100644 --- a/picture.php +++ b/picture.php @@ -387,22 +387,6 @@ if ( isset( $_POST['content'] ) && !empty($_POST['content']) ) } $template->assign_block_vars('information', array('INFORMATION'=>$message)); - // notification to the administrators - if ( $conf['mail_notification'] ) - { - // find any related category (can be unreachable to this admin) - $category = $related_categories[0]; - // locally, we change the $conf['level_separator'] - $conf_separator = $conf['level_separator']; - $conf['level_separator'] = ' > '; - $cat_name = get_cat_display_name_cache($category['uppercats'], - '', - false); - $conf['level_separator'] = $conf_separator; - - $cat_name = strip_tags( $cat_name ); - notify( 'comment', $cat_name.' > '.$picture['current']['name']); - } } else { diff --git a/template/cclear/admin/configuration.tpl b/template/cclear/admin/configuration.tpl index 1277de25a..a806b2af9 100644 --- a/template/cclear/admin/configuration.tpl +++ b/template/cclear/admin/configuration.tpl @@ -23,11 +23,6 @@ {L_YES}   {L_NO} - - {general.L_CONF_NOTIFICATION} :
{general.L_CONF_NOTIFICATION_INFO} - {L_YES}   - {L_NO} - {general.L_CONF_GALLERY_LOCKED} :
{general.L_CONF_GALLERY_LOCKED_INFO} {L_YES}   diff --git a/template/cclear/admin/update.tpl b/template/cclear/admin/update.tpl index af8c53654..182a9a868 100644 --- a/template/cclear/admin/update.tpl +++ b/template/cclear/admin/update.tpl @@ -11,27 +11,27 @@
  • {update.NB_DEL_ELEMENTS} {L_NB_DEL_ELEMENTS}
  • {update.NB_ERRORS} {L_UPDATE_NB_ERRORS}
  • - +

    {L_UPDATE_ERROR_LIST_TITLE}

    {L_UPDATE_ERRORS_CAPTION}

    - - + +

    {L_UPDATE_INFOS_TITLE}

    - + @@ -45,36 +45,43 @@

    {L_UPDATE_TITLE}

    - -

    + +

    + {L_UPDATE_SYNC_FILES} + +
      +
    • +
    • +
    • +
    • +
    +
    + +
    + {L_UPDATE_SYNC_METADATA} +

    {L_USED_METADATA} : {METADATA_LIST}.

    +
      +
    • +
    • +
    +
    + +
    + {L_UPDATE_CATS_SUBSET} + + + + +
    + +

    +
    diff --git a/template/cclear/admin/waiting.tpl b/template/cclear/admin/waiting.tpl index 8da061a2e..d011e9984 100644 --- a/template/cclear/admin/waiting.tpl +++ b/template/cclear/admin/waiting.tpl @@ -2,6 +2,9 @@

    {lang:title_waiting}

    + + + @@ -16,25 +19,29 @@
    {L_CATEGORY}{picture.CATEGORY_IMG} {picture.DATE_IMG} - {picture.FILE_IMG} + {picture.FILE_IMG} - {picture.thumbnail.FILE_TN_IMG} + {picture.thumbnail.FILE_TN_IMG} {picture.UPLOAD_USERNAME} - {L_SUBMIT} - {L_DELETE} + +
    -

    - - + +

    + + + +

    +
    diff --git a/upload.php b/upload.php index 82bcffd2b..39f0db5d2 100644 --- a/upload.php +++ b/upload.php @@ -212,11 +212,6 @@ if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) ) $query.= ';'; pwg_query( $query ); $page['waiting_id'] = mysql_insert_id(); - // mail notification for administrators - if ( $conf['mail_notification'] ) - { - notify( 'upload' ); - } } } @@ -276,7 +271,7 @@ else } $username = !empty($_POST['username'])?$_POST['username']:$user['username']; -$mail_address = !empty($_POST['mail_address'])?$_POST['mail_address']:$user['mail_address']; +$mail_address = !empty($_POST['mail_address'])?$_POST['mail_address']:@$user['mail_address']; $name = !empty($_POST['name'])?$_POST['name']:''; $author = !empty($_POST['author'])?$_POST['author']:''; $date_creation = !empty($_POST['date_creation'])?$_POST['date_creation']:''; -- cgit v1.2.3