Plugin Directory

Changeset 148263


Ignore:
Timestamp:
08/23/2009 12:58:41 AM (17 years ago)
Author:
Regen
Message:

Add role limit option.

Location:
comment-form-quicktags/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • comment-form-quicktags/trunk/admin.js

    r97876 r148263  
    8585    });
    8686   
     87    $('cap_check').observe('change', function(){
     88        $$('#roles input[type=checkbox]').invoke(this.checked ? 'enable' : 'disable');
     89    });
     90   
    8791    $('rform').observe('submit', function(event){
    8892        if (!confirm(cfqadminL10n['removeConfirm'])) {
  • comment-form-quicktags/trunk/comment-form-quicktags.php

    r121920 r148263  
    6565
    6666    /**
     67     * Capability name.
     68     * @var string
     69     */
     70    var $cap;
     71
     72    /**
    6773     * Initialize CommentFormQuicktags.
    6874     */
     
    7379        $this->option_name = $this->plugin_name . '-option';
    7480        $this->option_hook = 'cfq_option_page';
     81        $this->cap = 'comment_form_quicktags';
    7582        if (defined('WP_PLUGIN_URL')) {
    7683            $this->plugin_url = WP_PLUGIN_URL . '/' . $this->plugin_name;
     
    136143                )
    137144            ),
    138             'modified' => filemtime(__FILE__)
     145            'modified' => filemtime(__FILE__),
     146            'cap_check' => false
    139147        );
    140148        if (!isset($this->options['sort'])) $this->options['sort'] = array_keys($this->options['tags']);
     
    162170    function set_hooks() {
    163171        add_action('wp_head', array(&$this, 'add_head'));
     172        add_action('admin_menu', array(&$this, 'set_admin_hooks'));
    164173        add_filter('comments_template', array(&$this, 'detect_start'));
    165         add_action('admin_menu', array(&$this, 'set_admin_hooks'));
    166174    }
    167175
     
    245253     */
    246254    function detect_start($file) {
    247         ob_start(array(&$this, 'add_tags'));
    248         $this->ended = false;
    249         add_action('comment_form', array(&$this, 'detect_end'));
    250         add_action('wp_footer', array(&$this, 'detect_end'));
     255        if (!$this->options['cap_check'] || ($this->options['cap_check'] && current_user_can($this->cap))) {
     256            ob_start(array(&$this, 'add_tags'));
     257            $this->ended = false;
     258            add_action('comment_form', array(&$this, 'detect_end'));
     259            add_action('wp_footer', array(&$this, 'detect_end'));
     260        }
    251261       
    252262        return $file;
     
    301311     */
    302312    function options_page() {
     313        global $wp_roles;
    303314        include 'json.php';
     315       
    304316        if (isset($_POST['action'])) {
    305317            switch ($_POST['action']) {
     
    312324                    echo '<div class="updated fade"><p><strong>' . __('Options saved.', $this->domain) . '</strong></p></div>';
    313325                    break;
     326                case 'rolelimit':
     327                    $this->options['cap_check'] = isset($_POST['cap_check']);
     328                    $this->update_option();
     329                    if ($this->options['cap_check']) {
     330                        foreach ($wp_roles->get_names() as $role => $name) {
     331                            $wp_roles->add_cap($role, $this->cap, in_array($role, $_POST['role']));
     332                        }
     333                    }
     334                    echo '<div class="updated fade"><p><strong>' . __('Options saved.', $this->domain) . '</strong></p></div>';
     335                    break;
    314336                case 'remove':
    315337                    $this->delete_option();
    316338                    $this->get_option();
     339                    foreach ($wp_roles->get_names() as $role => $name) {
     340                        $wp_roles->remove_cap($role, $this->cap);
     341                    }
    317342                    echo '<div class="updated fade"><p><strong>' . __('Options removed.', $this->domain) . '</strong></p></div>';
    318343                    break;
     
    380405        <input type="hidden" name="sort" id="sort" value="" />
    381406        <input type="hidden" name="tags" id="tags" value="" />
    382         <input type="submit" class="button-primary" value="<?php _e('Update Tags', $this->domain) ?>" name="submit"/>
     407        <input type="submit" class="button-primary" value="<?php _e('Update Tags', $this->domain) ?>" />
    383408    </p>
    384409</form>
    385410
     411<h3><?php _e('Role limitation', $this->domain) ?></h3>
     412<form id="rolelimit" method="post" action="?page=<?php echo $this->option_hook ?>">
     413    <p>
     414        <label><input type="checkbox" id="cap_check" name="cap_check" <?php echo $this->options['cap_check'] ? 'checked="checked"' : '' ?> /> <?php _e('Use role limitation', $this->domain) ?></label>
     415    </p>
     416    <p id="roles">
     417        <?php _e('Select the roles that can use quicktags.', $this->domain) ?><br />
     418        <?php
     419            foreach ($wp_roles->roles as $role => $data) {
     420                $checked = isset($data['capabilities'][$this->cap]) && $data['capabilities'][$this->cap] ? 'checked="checked"' : '';
     421                $disabled = $this->options['cap_check'] ? '' : 'disabled="disabled"';
     422                printf('<label><input type="checkbox" name="role[]" value="%s" %s %s /> %s</label><br />', $role, $checked, $disabled, _c($data['name']));
     423            }
     424        ?>
     425    </p>
     426   
     427    <p class="submit">
     428        <input type="hidden" name="action" value="rolelimit" />
     429        <input type="submit" class="button-primary" value="<?php _e('Update roles', $this->domain) ?>" />
     430    </p>
     431</form>
    386432
    387433<h3><?php _e('Remove options', $this->domain) ?></h3>
     
    390436<p>
    391437<input type="hidden" name="action" value="remove" />
    392 <input type="submit" class="button" value="<?php _e('Remove options', $this->domain) ?>" name="submit" />
     438<input type="submit" class="button" value="<?php _e('Remove options', $this->domain) ?>" />
    393439</p>
    394440</form>
  • comment-form-quicktags/trunk/languages/comment-form-quicktags-ja.po

    r85872 r148263  
    33"Project-Id-Version: Comment Form Quicktags\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2009-01-11 23:49+0900\n"
     5"POT-Creation-Date: 2009-08-23 01:57+0100\n"
    66"PO-Revision-Date: \n"
    77"Last-Translator: Regen <g(DOT)regen100(AT)gmail(DOT)com>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
     12"Plural-Forms: nplurals=1; plural=0;\n"
    1213"X-Poedit-Language: Japanese\n"
    13 "X-Poedit-KeywordsList: __;_e\n"
    14 "X-Poedit-Basepath: .\n"
    15 "X-Poedit-SearchPath-0: C:\\repository\\comment-form-quicktags\n"
    1614
    17 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:109
    18 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:224
     15#: comment-form-quicktags.php:180
     16#: comment-form-quicktags.php:349
    1917msgid "Comment Form Quicktags Options"
    2018msgstr "Comment Form Quicktags オプション"
    2119
    22 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:109
     20#: comment-form-quicktags.php:180
    2321msgid "Comment Form Quicktags"
    2422msgstr "Comment Form Quicktags"
    2523
    26 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:120
     24#: comment-form-quicktags.php:193
    2725msgid "Are you sure?"
    2826msgstr "よろしいですか?"
    2927
    30 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:155
     28#: comment-form-quicktags.php:237
    3129msgid "Settings"
    3230msgstr "設定"
    3331
    34 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:212
     32#: comment-form-quicktags.php:324
     33#: comment-form-quicktags.php:334
    3534msgid "Options saved."
    3635msgstr "設定が保存されました。"
    3736
    38 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:217
     37#: comment-form-quicktags.php:342
    3938msgid "Options removed."
    4039msgstr "設定が削除されました。"
    4140
    42 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:225
     41#: comment-form-quicktags.php:350
    4342msgid "Javascript is needed! "
    4443msgstr "Javascriptが必要です"
    4544
    46 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:227
     45#: comment-form-quicktags.php:352
    4746msgid "Tag Options"
    4847msgstr "タグ設定"
    4948
    50 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:229
     49#: comment-form-quicktags.php:354
    5150msgid "Click a tag which you want to edit or input ID which you want to add."
    5251msgstr "編集したいタグをクリックするか追加したいIDを入力してください。"
    5352
    54 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:230
     53#: comment-form-quicktags.php:355
    5554msgid "Edit other field."
    5655msgstr "他の項目を編集してください。"
    5756
    58 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:231
     57#: comment-form-quicktags.php:356
    5958msgid "Click Edit/Add button."
    6059msgstr "編集/追加ボタンをクリックしてください。"
    6160
    62 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:232
     61#: comment-form-quicktags.php:357
    6362msgid "Sort tags by dragging."
    6463msgstr "タグをドラッグして順序を変えてください。"
    6564
    66 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:233
     65#: comment-form-quicktags.php:358
    6766msgid "After that, click Update Tags button to save."
    6867msgstr "そのあと、タグを更新ボタンを押して保存してください。"
    6968
    70 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:235
     69#: comment-form-quicktags.php:360
    7170#, php-format
    7271msgid "<strong>[Info]</strong> Allowed tags in comments: <code class=\"tags\">%s</code>."
    7372msgstr "<strong>[Info]</strong> コメントで使えるタグ: <code class=\"tags\">%s</code>"
    7473
    75 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:236
     74#: comment-form-quicktags.php:361
    7675msgid "<strong>[Note]</strong> There are special IDs: ed_link, ed_img and ed_close."
    7776msgstr "<strong>[Note]</strong> 特別なIDがあります: ed_link, ed_img, ed_close"
    7877
    79 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:252
     78#: comment-form-quicktags.php:379
    8079msgid "ID<span>*</span>"
    8180msgstr "ID<span>*</span>"
    8281
    83 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:255
     82#: comment-form-quicktags.php:382
    8483msgid "Display<span>*</span>"
    8584msgstr "表示名<span>*</span>"
    8685
    87 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:258
     86#: comment-form-quicktags.php:385
    8887msgid "Start tag"
    8988msgstr "開始タグ"
    9089
    91 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:261
     90#: comment-form-quicktags.php:388
    9291msgid "End tag"
    9392msgstr "終了タグ"
    9493
    95 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:264
     94#: comment-form-quicktags.php:391
    9695msgid "Access key"
    9796msgstr "アクセスキー"
    9897
    99 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:269
     98#: comment-form-quicktags.php:396
    10099msgid "Edit/Add"
    101100msgstr "編集/追加"
    102101
    103 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:270
     102#: comment-form-quicktags.php:397
    104103msgid "Delete"
    105104msgstr "削除"
    106105
    107 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:271
     106#: comment-form-quicktags.php:398
    108107msgid "Clear fields"
    109108msgstr "項目をクリア"
    110109
    111 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:280
     110#: comment-form-quicktags.php:407
    112111msgid "Update Tags"
    113112msgstr "タグを更新"
    114113
    115 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:285
    116 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:290
     114#: comment-form-quicktags.php:411
     115msgid "Role limitation"
     116msgstr "権限での制限"
     117
     118#: comment-form-quicktags.php:414
     119msgid "Use role limitation"
     120msgstr "権限でクイックタグの使用を制限する"
     121
     122#: comment-form-quicktags.php:417
     123msgid "Select the roles that can use quicktags."
     124msgstr "クイックタグを使用できる権限を選んでください。"
     125
     126#: comment-form-quicktags.php:429
     127msgid "Update roles"
     128msgstr "権限を更新"
     129
     130#: comment-form-quicktags.php:433
     131#: comment-form-quicktags.php:438
    117132msgid "Remove options"
    118133msgstr "オプションを削除"
    119134
    120 #: C:\repository\comment-form-quicktags/comment-form-quicktags.php:286
     135#: comment-form-quicktags.php:434
    121136msgid "You can remove the above options from the database. All the settings return to default."
    122137msgstr "上のオプションをデータベースから削除できます。全ての設定はデフォルトに戻ります。"
  • comment-form-quicktags/trunk/languages/comment-form-quicktags.pot

    r85872 r148263  
     1# SOME DESCRIPTIVE TITLE.
     2# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
     3# This file is distributed under the same license as the PACKAGE package.
     4# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
     5#
     6#, fuzzy
    17msgid ""
    28msgstr ""
    3 "Project-Id-Version: Comment Form Quicktags\n"
     9"Project-Id-Version: PACKAGE VERSION\n"
    410"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2009-01-11 23:49+0900\n"
    6 "PO-Revision-Date: \n"
    7 "Last-Translator: \n"
    8 "Language-Team: \n"
     11"POT-Creation-Date: 2009-08-23 01:57+0100\n"
     12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     14"Language-Team: LANGUAGE <LL@li.org>\n"
    915"MIME-Version: 1.0\n"
    10 "Content-Type: text/plain; charset=UTF-8\n"
     16"Content-Type: text/plain; charset=CHARSET\n"
    1117"Content-Transfer-Encoding: 8bit\n"
    12 "X-Poedit-Language: \n"
    13 "X-Poedit-KeywordsList: __;_e\n"
    14 "X-Poedit-Basepath: .\n"
    15 "X-Poedit-SearchPath-0: \n"
    1618
    17 #: /comment-form-quicktags.php:109
    18 #: /comment-form-quicktags.php:224
     19#: comment-form-quicktags.php:180 comment-form-quicktags.php:349
    1920msgid "Comment Form Quicktags Options"
    2021msgstr ""
    2122
    22 #: /comment-form-quicktags.php:109
     23#: comment-form-quicktags.php:180
    2324msgid "Comment Form Quicktags"
    2425msgstr ""
    2526
    26 #: /comment-form-quicktags.php:120
     27#: comment-form-quicktags.php:193
    2728msgid "Are you sure?"
    2829msgstr ""
    2930
    30 #: /comment-form-quicktags.php:155
     31#: comment-form-quicktags.php:237
    3132msgid "Settings"
    3233msgstr ""
    3334
    34 #: /comment-form-quicktags.php:212
     35#: comment-form-quicktags.php:324 comment-form-quicktags.php:334
    3536msgid "Options saved."
    3637msgstr ""
    3738
    38 #: /comment-form-quicktags.php:217
     39#: comment-form-quicktags.php:342
    3940msgid "Options removed."
    4041msgstr ""
    4142
    42 #: /comment-form-quicktags.php:225
     43#: comment-form-quicktags.php:350
    4344msgid "Javascript is needed! "
    4445msgstr ""
    4546
    46 #: /comment-form-quicktags.php:227
     47#: comment-form-quicktags.php:352
    4748msgid "Tag Options"
    4849msgstr ""
    4950
    50 #: /comment-form-quicktags.php:229
     51#: comment-form-quicktags.php:354
    5152msgid "Click a tag which you want to edit or input ID which you want to add."
    5253msgstr ""
    5354
    54 #: /comment-form-quicktags.php:230
     55#: comment-form-quicktags.php:355
    5556msgid "Edit other field."
    5657msgstr ""
    5758
    58 #: /comment-form-quicktags.php:231
     59#: comment-form-quicktags.php:356
    5960msgid "Click Edit/Add button."
    6061msgstr ""
    6162
    62 #: /comment-form-quicktags.php:232
     63#: comment-form-quicktags.php:357
    6364msgid "Sort tags by dragging."
    6465msgstr ""
    6566
    66 #: /comment-form-quicktags.php:233
     67#: comment-form-quicktags.php:358
    6768msgid "After that, click Update Tags button to save."
    6869msgstr ""
    6970
    70 #: /comment-form-quicktags.php:235
    71 #, php-format
    72 msgid "<strong>[Info]</strong> Allowed tags in comments: <code class=\"tags\">%s</code>."
     71#: comment-form-quicktags.php:360
     72#, possible-php-format
     73msgid ""
     74"<strong>[Info]</strong> Allowed tags in comments: <code class=\"tags\">%s</"
     75"code>."
    7376msgstr ""
    7477
    75 #: /comment-form-quicktags.php:236
    76 msgid "<strong>[Note]</strong> There are special IDs: ed_link, ed_img and ed_close."
     78#: comment-form-quicktags.php:361
     79msgid ""
     80"<strong>[Note]</strong> There are special IDs: ed_link, ed_img and ed_close."
    7781msgstr ""
    7882
    79 #: /comment-form-quicktags.php:252
     83#: comment-form-quicktags.php:379
    8084msgid "ID<span>*</span>"
    8185msgstr ""
    8286
    83 #: /comment-form-quicktags.php:255
     87#: comment-form-quicktags.php:382
    8488msgid "Display<span>*</span>"
    8589msgstr ""
    8690
    87 #: /comment-form-quicktags.php:258
     91#: comment-form-quicktags.php:385
    8892msgid "Start tag"
    8993msgstr ""
    9094
    91 #: /comment-form-quicktags.php:261
     95#: comment-form-quicktags.php:388
    9296msgid "End tag"
    9397msgstr ""
    9498
    95 #: /comment-form-quicktags.php:264
     99#: comment-form-quicktags.php:391
    96100msgid "Access key"
    97101msgstr ""
    98102
    99 #: /comment-form-quicktags.php:269
     103#: comment-form-quicktags.php:396
    100104msgid "Edit/Add"
    101105msgstr ""
    102106
    103 #: /comment-form-quicktags.php:270
     107#: comment-form-quicktags.php:397
    104108msgid "Delete"
    105109msgstr ""
    106110
    107 #: /comment-form-quicktags.php:271
     111#: comment-form-quicktags.php:398
    108112msgid "Clear fields"
    109113msgstr ""
    110114
    111 #: /comment-form-quicktags.php:280
     115#: comment-form-quicktags.php:407
    112116msgid "Update Tags"
    113117msgstr ""
    114118
    115 #: /comment-form-quicktags.php:285
    116 #: /comment-form-quicktags.php:290
     119#: comment-form-quicktags.php:411
     120msgid "Role limitation"
     121msgstr ""
     122
     123#: comment-form-quicktags.php:414
     124msgid "Use role limitation"
     125msgstr ""
     126
     127#: comment-form-quicktags.php:417
     128msgid "Select the roles that can use quicktags."
     129msgstr ""
     130
     131#: comment-form-quicktags.php:429
     132msgid "Update roles"
     133msgstr ""
     134
     135#: comment-form-quicktags.php:433 comment-form-quicktags.php:438
    117136msgid "Remove options"
    118137msgstr ""
    119138
    120 #: /comment-form-quicktags.php:286
    121 msgid "You can remove the above options from the database. All the settings return to default."
     139#: comment-form-quicktags.php:434
     140msgid ""
     141"You can remove the above options from the database. All the settings return "
     142"to default."
    122143msgstr ""
    123 
Note: See TracChangeset for help on using the changeset viewer.