Ignore:
Timestamp:
Jun 23, 2009, 12:22:43 AM (15 years ago)
Author:
Criss
Message:

Deactivate anti-flood on update
Adviser can edit only its comments
Language file converted in UTF-8
Add home link in edit and message block title bar

Location:
extensions/CommentEditor
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/CommentEditor/classes/ce_plugin.class.php

    r3439 r3443  
    11<?php
    2 /* $Id: ce_plugin.class.php,v 1.7 2009/06/22 12:25:04 Criss Exp $ */
     2/* $Id: ce_plugin.class.php,v 1.8 2009/06/22 22:18:14 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
     
    1111
    1212    var $comments_ids;
    13     private static $url_prefix = null;
    14 
    15 
    16     function CE_Plugin() {
    17         if (null == self::$url_prefix) {
    18             self::$url_prefix = get_root_url() . 'index.php?' . CE_ACTION . '=';
    19         }
    20     }
    2113
    2214    /* ************************ */
     
    6860            if (isset($this->comments_ids[$key])) {
    6961                // User allowed to have edit link
    70                 $comments[$key]['U_ID'] =  $this->comments_ids[$key];
    71                 $comments[$key]['DATE'] .= ' - <a href="' . $this->getEditUrlPrefix();
    72                 $comments[$key]['DATE'] .= $comments[$key]['U_ID'] . '">';
     62                $current_id = $this->comments_ids[$key];
     63                $comments[$key]['U_ID'] =  $current_id;
     64                $comments[$key]['DATE'] .= ' - <a href="';
     65                $comments[$key]['DATE'] .= $this->getEditUrl($current_id);
     66                $comments[$key]['DATE'] .= '">';
    7367                $comments[$key]['DATE'] .= 'Edit';
    7468                $comments[$key]['DATE'] .= '</a>';
     
    8175     * Check whether a comment edit or update is requested.
    8276     */
    83     function loc_end_index() {
     77    function loc_begin_index() {
    8478        $comment_id = "";
    8579        $action = $this->isCommentEdit($_SERVER['QUERY_STRING'], $comment_id);
     
    146140            return false;
    147141        }
    148         if (is_admin()) {
     142        if (is_admin() and !is_adviser()) {
    149143            return true;
    150144        }
     
    213207            'comment_id'    => $comment->getInfo('comment_id'),
    214208        );
     209
     210        // Deactivate anti-flood system
     211        global $conf;
     212        $old_anti_flood = $conf['anti-flood_time'];
     213        $conf['anti-flood_time'] = 0;
     214
    215215        $comment_action = update_user_comment($comment_array, @$_POST['key'], $infos );
     216
     217        // Reactivate anti-flood system
     218        $conf['anti-flood_time'] = $old_anti_flood;
    216219
    217220        switch ($comment_action) {
     
    284287
    285288        global $template;
     289        if ("" == $template->get_template_vars('U_HOME')) {
     290            $template->assign('U_HOME', make_index_url());
     291        }
    286292        $template->set_filenames(array('ce_message'=>$this->getTemplate('message.tpl')));
    287293        $template->block_html_head( '',
     
    297303    function displayComment($p_comment) {
    298304        global $template;
    299 
    300305        $template->set_filenames(array('ce_edit'=>$this->getTemplate()));
    301306        $template->block_html_head( '',
     
    306311        $template->assign($begin, null);
    307312        $template->assign($end, null);
    308         $tplComment = array(
     313        $tpl_comment = array(
    309314            'CONTENT'   => $p_comment->getInfo('content'),
    310315            'KEY'       => $p_comment->getInfo('comment_id'),
     
    313318            'DISABLED'  => !is_admin(),
    314319            'USERS'     => CE_Comment::getUsers(),
    315             'F_ACTION'  => $this->getUpdateUrlPrefix(),
     320            'F_ACTION'  => $this->getUpdateUrl(),
    316321            'FREEAUTHOR'=> ($p_comment->isKnownAuthor())?'':'checked="checked"'
    317322        );
    318         $template->assign('comment', $tplComment);
     323        if ("" == $template->get_template_vars('U_HOME')) {
     324            $template->assign('U_HOME', make_index_url());
     325        }
     326        $template->assign('comment', $tpl_comment);
    319327        $template->concat($begin, $template->parse('ce_edit', true));
    320     }
    321 
    322     function getEditUrlPrefix() {
    323         return self::$url_prefix . CE_ACTION_EDIT . '&' . CE_ID . '=';
    324     }
    325 
    326     function getUpdateUrlPrefix() {
    327         return self::$url_prefix . CE_ACTION_UPDATE;
     328
     329    }
     330
     331    function getScriptName() {
     332        // By now, still in index page
     333        // return script_basename();
     334        return 'index';
     335    }
     336
     337    function getEditUrl($comment_id) {
     338        $url  = get_root_url() . $this->getScriptName() . '.php';
     339        // By now, still in index pages without params
     340        // $url .= get_query_string_diff(array(CE_ACTION, CE_ID));
     341        $url = add_url_params(  $url,
     342                                array(
     343                                    CE_ACTION => CE_ACTION_EDIT,
     344                                    CE_ID=>$comment_id
     345                                )
     346        );
     347        return $url;
     348    }
     349
     350    function getUpdateUrl() {
     351        $url  = get_root_url() . script_basename() .'.php';
     352        // By now, still in index pages without params
     353        // $url .= get_query_string_diff(array(CE_ACTION, CE_ID));
     354        $url = add_url_params(  $url,
     355                                array(
     356                                    CE_ACTION => CE_ACTION_UPDATE
     357                                )
     358        );
     359        return $url;
    328360    }
    329361
  • extensions/CommentEditor/include/ce_common.inc.php

    r3439 r3443  
    11<?php
    2 /* $Id: ce_common.inc.php,v 1.5 2009/06/18 21:02:12 Criss Exp $ */
     2/* $Id: ce_common.inc.php,v 1.8 2009/06/22 22:18:13 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
    5 define('CE_VERSION',       '1.0.f');
    65define('CE_INCLUDE_DIR',   'include/');
    76define('CE_CLASSES_DIR',   'classes/');
  • extensions/CommentEditor/language/fr_FR/plugin.lang.php

    r3428 r3443  
    11<?php
    2 /* $Id: plugin.lang.php,v 1.3 2009/06/17 19:08:24 Criss Exp $ */
     2/* $Id: plugin.lang.php,v 1.4 2009/06/22 22:18:12 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44global $lang;
     5
    56
    67$lang['comment_edit'] = 'Edition de commentaire';
     
    1112$lang[CE_TYPE_INFO] = 'Information';
    1213$lang[CE_TYPE_ERROR] = 'Erreur';
    13 $lang['comment_edit_forbidden'] = 'Vous n\'&ecirc;tes pas autoris&eacute; &agrave; &eacute;diter ce commentaire';
    14 $lang['comment_access_invalid'] = 'Acc&egrave;s invalide';
     14$lang['comment_edit_forbidden'] = 'Vous n\'êtes pas autorisé à éditer ce commentaire';
     15$lang['comment_access_invalid'] = 'Accès invalide';
    1516?>
  • extensions/CommentEditor/main.inc.php

    r3439 r3443  
    11<?php
    2 /* $Id: main.inc.php,v 1.8 2009/06/22 12:25:04 Criss Exp $ */
     2/* $Id: main.inc.php,v 1.9 2009/06/22 22:18:14 Criss Exp $ */
    33/*
    44 Plugin Name: Comment Editor
    5  Version: 1.0.f
     5 Version: 1.0.g
    66 Description: Allow to edit comment
    77 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=296
     
    1111
    1212/** History **
     13
     14    2009-06-22 1.0.g
     15                        Deactivate anti-flood on update
     16                        Adviser can edit only its comments
     17                        Language file converted in UTF-8
     18                        Add home link in edit and message block title bar
    1319
    1420    2009-06-22 1.0.f
     
    3440if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    3541
     42define('CE_VERSION',       '1.0.g');
    3643define('CE_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
    3744define('CE_ROOT', dirname(__FILE__).'/');
     
    4552                    array(&$ce_plugin, 'loc_begin_page_header'));
    4653add_event_handler(  'loc_begin_index',
    47                     array(&$ce_plugin, 'loc_end_index'), 1);
     54                    array(&$ce_plugin, 'loc_begin_index'), 1);
    4855
    4956set_plugin_data($plugin['id'], $ce_plugin);
  • extensions/CommentEditor/template/edit.tpl

    r3426 r3443  
    1 {* $Id: edit.tpl,v 1.3 2009/06/17 19:08:24 Criss Exp $ *}
     1{* $Id: edit.tpl,v 1.4 2009/06/22 22:18:13 Criss Exp $ *}
    22{if !$comment.DISABLED}
    33<script type="text/javascript">
     
    1313<div id="content" class="content">
    1414    <div class="titrePage">
     15        <ul class="categoryActions">
     16            <li><a href="{$U_HOME}" title="{'return to homepage'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'home'|@translate}"/></a></li>
     17        </ul>
    1518        <h2>{'comment_edit'|@translate}</h2>
    1619    </div>
  • extensions/CommentEditor/template/message.tpl

    r3426 r3443  
    1 {* $Id: message.tpl,v 1.3 2009/06/17 19:08:24 Criss Exp $ *}
     1{* $Id: message.tpl,v 1.4 2009/06/22 22:18:13 Criss Exp $ *}
    22<div class="content" id="message-block">
    33    <div class="titrePage">
     4        <ul class="categoryActions">
     5            <li><a href="{$U_HOME}" title="{'return to homepage'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'home'|@translate}"/></a></li>
     6        </ul>
    47        <h2 id="message-header">{'CommentEditor'|@translate} - {$message.TITLE}</h2>
    58    </div>
Note: See TracChangeset for help on using the changeset viewer.