Changeset 9634


Ignore:
Timestamp:
03/12/11 22:56:58 (9 years ago)
Author:
mistic100
Message:

[plugins] Comments on Albums

  • corrections
  • public list available
Location:
extensions/Comments_on_Albums
Files:
13 added
3 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • extensions/Comments_on_Albums/changelog.txt

    r9624 r9634  
    1 0.1.a 
     10.2 
     2- Test version 
    23- bug corrected on coa_admin_comments.php 
     4- public listing is available 
     5- table is created in utf8 
    36 
    470.1 
  • extensions/Comments_on_Albums/include/coa_admin_comments.php

    r9624 r9634  
    127127 
    128128        // template 
    129         $template->set_filename('comments', dirname(__FILE__) .'/../template/coa_admin.tpl'); 
     129        $template->set_filename('comments', dirname(__FILE__) .'/../template/coa_admin_comments.tpl'); 
    130130        $template->assign(array( 
    131131                'F_ACTION' => get_root_url().'admin.php?page=comments&section=albums', 
  • extensions/Comments_on_Albums/include/coa_admin_intro.php

    r9624 r9634  
    1010list($nb_comments) = pwg_db_fetch_row(pwg_query($query)); 
    1111 
    12 $template->assign('NB_COMMENTS', l10n_dec('%d comment', '%d comments', $nb_comments) .' ('. l10n('Albums') .')'); 
     12$template->assign('DB_COMMENTS_ALBUMS', l10n_dec('%d comment', '%d comments', $nb_comments)); 
    1313 
    1414// unvalidated comments 
     
    2828 
    2929// template 
    30 $template->set_filename('comments_on_albums', dirname(__FILE__) .'/../template/coa_intro.tpl'); 
     30$template->set_filename('comments_on_albums', dirname(__FILE__) .'/../template/coa_admin_intro.tpl'); 
    3131$template->concat('ADMIN_CONTENT', $template->parse('comments_on_albums', true)); 
    3232 
  • extensions/Comments_on_Albums/include/coa_albums.php

    r9624 r9634  
    2727                        include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions 
    2828                        check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID); 
    29                         $author_id = get_comment_author_id($_GET['comment_to_edit']); 
     29                        $author_id = get_comment_author_id_albums($_GET['comment_to_edit']); 
    3030 
    3131                        if (can_manage_comment('edit', $author_id)) { 
    3232                                if (!empty($_POST['content'])) { 
    33                                         update_user_comment(array( 
     33                                        update_user_comment_albums(array( 
    3434                                                'comment_id' => $_GET['comment_to_edit'], 
    3535                                                'image_id' => $category['id'], 
     
    4949                        include_once(COA_PATH.'include/functions_comment.inc.php'); 
    5050                        check_input_parameter('comment_to_delete', $_GET, false, PATTERN_ID); 
    51                         $author_id = get_comment_author_id($_GET['comment_to_delete']); 
     51                        $author_id = get_comment_author_id_albums($_GET['comment_to_delete']); 
    5252 
    5353                        if (can_manage_comment('delete', $author_id)) { 
    54                                 delete_user_comment($_GET['comment_to_delete']); 
     54                                delete_user_comment_albums($_GET['comment_to_delete']); 
    5555                        } 
    5656 
     
    6262                        include_once(COA_PATH.'include/functions_comment.inc.php'); 
    6363                        check_input_parameter('comment_to_validate', $_GET, false, PATTERN_ID); 
    64                         $author_id = get_comment_author_id($_GET['comment_to_validate']); 
     64                        $author_id = get_comment_author_id_albums($_GET['comment_to_validate']); 
    6565 
    6666                        if (can_manage_comment('validate', $author_id)) { 
    67                                 validate_user_comment($_GET['comment_to_validate']); 
     67                                validate_user_comment_albums($_GET['comment_to_validate']); 
    6868                        } 
    6969 
     
    124124        } 
    125125 
    126         // number of comments for this picture 
     126        // number of comments for this category 
    127127        $query = 'SELECT COUNT(*) AS nb_comments 
    128128                FROM '.COA_TABLE.' 
  • extensions/Comments_on_Albums/include/functions_comment.inc.php

    r9624 r9634  
    33 
    44//returns string action to perform on a new comment: validate, moderate, reject 
    5 function user_comment_check($action, $comment) 
    6 { 
    7   global $conf,$user; 
    8  
    9   if ($action=='reject') 
    10     return $action; 
    11  
    12   $my_action = $conf['comment_spam_reject'] ? 'reject':'moderate'; 
    13  
    14   if ($action==$my_action) 
    15     return $action; 
    16  
    17   // we do here only BASIC spam check (plugins can do more) 
    18   if ( !is_a_guest() ) 
    19     return $action; 
    20  
    21   $link_count = preg_match_all( '/https?:\/\//', 
    22     $comment['content'], $matches); 
    23  
    24   if ( strpos($comment['author'], 'http://')!==false ) 
    25   { 
    26     $link_count++; 
    27   } 
    28  
    29   if ( $link_count>$conf['comment_spam_max_links'] ) 
    30     return $my_action; 
    31  
    32   return $action; 
     5if (!function_exists('user_comment_check')) { 
     6        function user_comment_check($action, $comment) 
     7        { 
     8          global $conf,$user; 
     9 
     10          if ($action=='reject') 
     11                return $action; 
     12 
     13          $my_action = $conf['comment_spam_reject'] ? 'reject':'moderate'; 
     14 
     15          if ($action==$my_action) 
     16                return $action; 
     17 
     18          // we do here only BASIC spam check (plugins can do more) 
     19          if ( !is_a_guest() ) 
     20                return $action; 
     21 
     22          $link_count = preg_match_all( '/https?:\/\//', 
     23                $comment['content'], $matches); 
     24 
     25          if ( strpos($comment['author'], 'http://')!==false ) 
     26          { 
     27                $link_count++; 
     28          } 
     29 
     30          if ( $link_count>$conf['comment_spam_max_links'] ) 
     31                return $my_action; 
     32 
     33          return $action; 
     34        } 
    3335} 
    3436 
     
    4446 * @param array infos out array of messages 
    4547 */ 
    46 function insert_user_comment( &$comm, $key, &$infos ) 
     48function insert_user_comment_albums( &$comm, $key, &$infos ) 
    4749{ 
    4850  global $conf, $user; 
     
    185187 * @param comment_id 
    186188 */ 
    187 function delete_user_comment($comment_id) { 
     189function delete_user_comment_albums($comment_id) { 
    188190  $user_where_clause = ''; 
    189191  if (!is_admin()) 
     
    216218 */ 
    217219 
    218 function update_user_comment($comment, $post_key) 
     220function update_user_comment_albums($comment, $post_key) 
    219221{ 
    220222  global $conf; 
     
    259261} 
    260262 
    261 function email_admin($action, $comment) 
    262 { 
    263   global $conf; 
    264  
    265   if (!in_array($action, array('edit', 'delete')) 
    266       or (($action=='edit') and !$conf['email_admin_on_comment_edition']) 
    267       or (($action=='delete') and !$conf['email_admin_on_comment_deletion'])) 
    268   { 
    269     return; 
    270   } 
    271  
    272   include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 
    273  
    274   $keyargs_content = array(); 
    275   $keyargs_content[] = get_l10n_args('Author: %s', $comment['author']); 
    276   if ($action=='delete') 
    277   { 
    278     $keyargs_content[] = get_l10n_args('This author removed the comment with id %d', 
    279                                        $comment['comment_id'] 
    280                                        ); 
    281   } 
    282   else 
    283   { 
    284     $keyargs_content[] = get_l10n_args('This author modified following comment:', ''); 
    285     $keyargs_content[] = get_l10n_args('Comment: %s', $comment['content']); 
    286   } 
    287  
    288   pwg_mail_notification_admins(get_l10n_args('Comment by %s', 
    289                                              $comment['author']), 
    290                                $keyargs_content 
    291                                ); 
    292 } 
    293  
    294 function get_comment_author_id($comment_id, $die_on_error=true) 
     263if (!function_exists('email_admin')) { 
     264        function email_admin($action, $comment) 
     265        { 
     266          global $conf; 
     267 
     268          if (!in_array($action, array('edit', 'delete')) 
     269                  or (($action=='edit') and !$conf['email_admin_on_comment_edition']) 
     270                  or (($action=='delete') and !$conf['email_admin_on_comment_deletion'])) 
     271          { 
     272                return; 
     273          } 
     274 
     275          include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 
     276 
     277          $keyargs_content = array(); 
     278          $keyargs_content[] = get_l10n_args('Author: %s', $comment['author']); 
     279          if ($action=='delete') 
     280          { 
     281                $keyargs_content[] = get_l10n_args('This author removed the comment with id %d', 
     282                                                   $comment['comment_id'] 
     283                                                   ); 
     284          } 
     285          else 
     286          { 
     287                $keyargs_content[] = get_l10n_args('This author modified following comment:', ''); 
     288                $keyargs_content[] = get_l10n_args('Comment: %s', $comment['content']); 
     289          } 
     290 
     291          pwg_mail_notification_admins(get_l10n_args('Comment by %s', 
     292                                                         $comment['author']), 
     293                                           $keyargs_content 
     294                                           ); 
     295        } 
     296} 
     297 
     298function get_comment_author_id_albums($comment_id, $die_on_error=true) 
    295299{ 
    296300  $query = ' 
     
    318322} 
    319323 
    320 function validate_user_comment($comment_id) 
     324function validate_user_comment_albums($comment_id) 
    321325{ 
    322326  $query = ' 
  • extensions/Comments_on_Albums/main.inc.php

    r9624 r9634  
    22/* 
    33Plugin Name: Comment on Albums 
    4 Version: 0.1.a 
     4Version: 0.2 
    55Description: Allows users to comment albums 
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=512 
     
    1717// +-----------------------------------------------------------------------+ 
    1818define('COA_NAME' , 'Comment on Albums'); 
    19 define('COA_VERSION', '0.1.a'); 
     19define('COA_VERSION', '0.2'); 
    2020define('COA_DIR' , basename(dirname(__FILE__))); 
    2121define('COA_PATH' , PHPWG_PLUGINS_PATH . COA_DIR . '/'); 
     
    2727// +-----------------------------------------------------------------------+ 
    2828add_event_handler('loc_end_index', 'COA_index'); 
     29add_event_handler('loc_after_page_header', 'COA_comments_page'); 
    2930add_event_handler('loc_end_admin', 'COA_admin'); 
    3031 
    3132 
    3233// +-----------------------------------------------------------------------+ 
    33 //                                      Fonctions 
     34//                                      Functions 
    3435// +-----------------------------------------------------------------------+ 
    3536 
     
    3940        if ($page['section'] == 'categories' AND isset($page['category'])) {     
    4041                include(COA_PATH . 'include/coa_albums.php'); 
     42        } 
     43} 
     44 
     45function COA_comments_page() { 
     46        global $template, $page, $conf; 
     47         
     48        if ($page['body_id'] == 'theCommentsPage') { 
     49                include(COA_PATH . 'include/coa_comments_page.php'); 
    4150        } 
    4251} 
  • extensions/Comments_on_Albums/maintain.inc.php

    r9624 r9634  
    1616                `validation_date` datetime DEFAULT NULL, 
    1717                PRIMARY KEY (`id`) 
    18         );"); 
     18        ) DEFAULT CHARSET=utf8;"); 
    1919} 
    2020 
  • extensions/Comments_on_Albums/template/coa_albums.tpl

    r9624 r9634  
    11{combine_script id="jquery"} 
    2 {combine_css path=$COA_PATH|@cat:'template/style.css'} 
     2{combine_css path=$COA_PATH|@cat:'template/style_albums.css'} 
    33 
    4 {footer_script equire="jquery"}{literal} 
     4{footer_script require="jquery"}{literal} 
    55        // cancel all color changements and set default color to comments 
    66        jQuery('.thumbnailCategory').css('color', jQuery('body').css('color')); 
Note: See TracChangeset for help on using the changeset viewer.