diff options
-rw-r--r-- | admin/configuration.php | 6 | ||||
-rw-r--r-- | admin/waiting.php | 180 | ||||
-rw-r--r-- | doc/ChangeLog | 8 | ||||
-rw-r--r-- | include/functions.inc.php | 42 | ||||
-rw-r--r-- | install/config.sql | 1 | ||||
-rw-r--r-- | picture.php | 16 | ||||
-rw-r--r-- | template/cclear/admin/configuration.tpl | 5 | ||||
-rw-r--r-- | template/cclear/admin/update.tpl | 83 | ||||
-rw-r--r-- | template/cclear/admin/waiting.tpl | 21 | ||||
-rw-r--r-- | 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 @@ -24,11 +24,6 @@ <input type="radio" class="radio" name="log" value="false" {general.HISTORY_NO} />{L_NO}</td> </tr> <tr> - <td><strong>{general.L_CONF_NOTIFICATION} :</strong><br /><span class="small">{general.L_CONF_NOTIFICATION_INFO}</span></td> - <td class="row1"><input type="radio" class="radio" name="mail_notification" value="true" {general.NOTIFICATION_YES} />{L_YES} - <input type="radio" class="radio" name="mail_notification" value="false" {general.NOTIFICATION_NO} />{L_NO}</td> - </tr> - <tr> <td><strong>{general.L_CONF_GALLERY_LOCKED} :</strong><br /><span class="small">{general.L_CONF_GALLERY_LOCKED_INFO}</span></td> <td class="row1"><input type="radio" class="radio" name="gallery_locked" value="true" {general.GALLERY_LOCKED_YES} />{L_YES} <input type="radio" class="radio" name="gallery_locked" value="false" {general.GALLERY_LOCKED_NO} />{L_NO}</td> 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 @@ <li class="update_summary_del">{update.NB_DEL_ELEMENTS} {L_NB_DEL_ELEMENTS}</li> <li class="update_summary_err">{update.NB_ERRORS} {L_UPDATE_NB_ERRORS}</li> </ul> -<!-- BEGIN errors --> +<!-- BEGIN update_errors --> <h3>{L_UPDATE_ERROR_LIST_TITLE}</h3> <ul> - <!-- BEGIN error --> - <li>[{update.errors.error.ELEMENT}] {update.errors.error.LABEL}</li> - <!-- END error --> + <!-- BEGIN update_error --> + <li>[{update.update_errors.update_error.ELEMENT}] {update.update_errors.update_error.LABEL}</li> + <!-- END update_error --> </ul> <h3>{L_UPDATE_ERRORS_CAPTION}</h3> <ul> <li><strong>PWG-UPDATE-1</strong> : {L_UPDATE_WRONG_DIRNAME_INFO}</li> <li><strong>PWG-UPDATE-2</strong> : {L_UPDATE_MISSING_TN_INFO} {{PICTURE_EXT_LIST}}</li> </ul> -<!-- END errors --> -<!-- BEGIN infos --> +<!-- END update_errors --> +<!-- BEGIN update_infos --> <h3>{L_UPDATE_INFOS_TITLE}</h3> <ul> - <!-- BEGIN info --> - <li>[{update.infos.info.ELEMENT}] {update.infos.info.LABEL}</li> - <!-- END info --> + <!-- BEGIN update_info --> + <li>[{update.update_infos.update_info.ELEMENT}] {update.update_infos.update_info.LABEL}</li> + <!-- END update_info --> </ul> -<!-- END infos --> +<!-- END update_infos --> <!-- END update --> <!-- BEGIN metadata_result --> @@ -45,36 +45,43 @@ <!-- BEGIN introduction --> <h3>{L_UPDATE_TITLE}</h3> <form action="{F_ACTION}" method="post" id="update"> - <ul> - <li> - {L_UPDATE_SYNC_FILES} - <ul> - <li><input type="radio" name="sync" value="dirs" {SYNC_DIRS_CHECKED} /> {L_UPDATE_SYNC_DIRS}</li> - <li><input type="radio" name="sync" value="files" {SYNC_ALL_CHECKED} /> {L_UPDATE_SYNC_ALL}</li> - <li><input type="checkbox" name="display_info" value="1" {DISPLAY_INFO_CHECKED} /> {L_UPDATE_DISPLAY_INFO}</li> - <li><input type="checkbox" name="simulate" value="1" checked="checked" /> {L_UPDATE_SIMULATE}</li> - </ul> - </li> - <li> - {L_UPDATE_SYNC_METADATA}. {L_USED_METADATA} : {METADATA_LIST}. - <ul> - <li><input type="radio" name="sync" value="metadata_new" /> {L_UPDATE_SYNC_METADATA_NEW}</li> - <li><input type="radio" name="sync" value="metadata_all" /> {L_UPDATE_SYNC_METADATA_ALL}</li> - </ul> - </li> - <li> - {L_UPDATE_CATS_SUBSET}<br /> - <select style="width:500px" name="cat" size="10"> - <!-- BEGIN category_option --> - <option {introduction.category_option.SELECTED} value="{introduction.category_option.VALUE}">{introduction.category_option.OPTION}</option> - <!-- END category_option --> - </select> - <input type="checkbox" name="subcats-included" value="1" {SUBCATS_INCLUDED_CHECKED} /> {L_SEARCH_SUBCATS_INCLUDED} - </li> - </ul> - <p> + + <fieldset> + <legend>{L_UPDATE_SYNC_FILES}</legend> + + <ul> + <li><label><input type="radio" name="sync" value="dirs" {SYNC_DIRS_CHECKED} /> {L_UPDATE_SYNC_DIRS}</label></li> + <li><label><input type="radio" name="sync" value="files" {SYNC_ALL_CHECKED} /> {L_UPDATE_SYNC_ALL}</label></li> + <li><label><input type="checkbox" name="display_info" value="1" {DISPLAY_INFO_CHECKED} /> {L_UPDATE_DISPLAY_INFO}</label></li> + <li><label><input type="checkbox" name="simulate" value="1" checked="checked" /> {L_UPDATE_SIMULATE}</label></li> + </ul> + </fieldset> + + <fieldset> + <legend>{L_UPDATE_SYNC_METADATA}</legend> + <p> {L_USED_METADATA} : {METADATA_LIST}.</p> + <ul> + <li><label><input type="radio" name="sync" value="metadata_new" /> {L_UPDATE_SYNC_METADATA_NEW}</label></li> + <li><label><input type="radio" name="sync" value="metadata_all" /> {L_UPDATE_SYNC_METADATA_ALL}</label></li> + </ul> + </fieldset> + + <fieldset> + <legend>{L_UPDATE_CATS_SUBSET}</legend> + + <select style="width:500px" name="cat" size="10"> + <!-- BEGIN category_option --> + <option {introduction.category_option.SELECTED} value="{introduction.category_option.VALUE}">{introduction.category_option.OPTION}</option> + <!-- END category_option --> + </select> + + <label><input type="checkbox" name="subcats-included" value="1" {SUBCATS_INCLUDED_CHECKED} /> {L_SEARCH_SUBCATS_INCLUDED}</label> + </fieldset> + + <p class="bottomButtons"> <input type="submit" value="{L_SUBMIT}" name="submit" class="bouton" /> <input type="reset" value="{L_RESET}" name="reset" class="bouton" /> </p> + </form> <!-- END introduction --> 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 @@ <h2>{lang:title_waiting}</h2> <form action="{F_ACTION}" method="post" id="waiting"> + + <input type="hidden" name="list" value="{LIST}" /> + <table style="width:100%;" > <tr class="throw"> <th style="width:20%;">{L_CATEGORY}</th> @@ -16,25 +19,29 @@ <td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">{picture.CATEGORY_IMG}</td> <td class="{picture.WAITING_CLASS}" style="white-space:nowrap;">{picture.DATE_IMG}</td> <td class="{picture.WAITING_CLASS}" style="white-space:nowrap;"> - <a target="_blank" href="{picture.PREVIEW_URL_IMG}">{picture.FILE_IMG}</a> + <a target="_blank" href="{picture.PREVIEW_URL_IMG}" title="{picture.FILE_TITLE}">{picture.FILE_IMG}</a> </td> <td class="{picture.WAITING_CLASS}" style="white-space:nowrap;"> <!-- BEGIN thumbnail --> - <a target="_blank" href="{picture.thumbnail.PREVIEW_URL_TN_IMG}">{picture.thumbnail.FILE_TN_IMG}</a> + <a target="_blank" href="{picture.thumbnail.PREVIEW_URL_TN_IMG}" title="{picture.thumbnail.FILE_TN_TITLE}">{picture.thumbnail.FILE_TN_IMG}</a> <!-- END thumbnail --> </td> <td class="{picture.WAITING_CLASS}" style="white-space:nowrap;"> <a href="mailto:{picture.UPLOAD_EMAIL}">{picture.UPLOAD_USERNAME}</a> </td> <td class="{picture.WAITING_CLASS}" style="white-space:nowrap;"> - <input type="radio" name="validate-{picture.ID_IMG}" value="true" />{L_SUBMIT} - <input type="radio" name="validate-{picture.ID_IMG}" value="false" />{L_DELETE} + <label><input type="radio" name="action-{picture.ID_IMG}" value="validate" /> {lang:Validate}</label> + <label><input type="radio" name="action-{picture.ID_IMG}" value="reject" /> {lang:Reject}</label> </td> </tr> <!-- END picture --> </table> - <p> - <input type="submit" name="submit" value="{L_SUBMIT}" class="bouton" /> - <input type="reset" name="reset" value="{L_RESET}" class="bouton" /> + + <p class="bottomButtons"> + <input type="submit" name="submit" value="{lang:Submit}" /> + <input type="submit" name="validate-all" value="{lang:Validate All}" /> + <input type="submit" name="reject-all" value="{lang:Reject All}" /> + <input type="reset" value="{lang:Reset}" /> </p> + </form> 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']:''; |