Plugin Directory

Changeset 475745


Ignore:
Timestamp:
12/15/2011 07:26:04 AM (14 years ago)
Author:
mohanjith
Message:

1.0.2

  • Switch frontend WYSIWYG editor to TinyMCE and Quicktags
  • WordPress 3.3 compatibility
Location:
qa/trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • qa/trunk

    • Property svn:ignore set to
      .komodotools
      *.komodoproject
  • qa/trunk/core/admin.php

    r380225 r475745  
    5151        add_action( 'wp_ajax_qa-get-caps', array( &$this, 'ajax_get_caps' ) );
    5252        add_action( 'wp_ajax_qa-save', array( &$this, 'ajax_save' ) );
     53       
     54        add_filter( 'user_has_cap', array(&$this, 'user_has_cap'), 10, 3);
    5355    }
    5456
     
    179181        // add/remove capabilities
    180182        global $wp_roles;
     183       
     184        $qa_capabilities_set = get_option('qa_capabilties_set', array());
    181185
    182186        $role = $_POST['roles'];
    183187
    184188        $all_caps = array_keys( $this->capability_map );
    185         $to_add = array_keys( $_POST['capabilities'] );
     189        if (isset($_POST['capabilities'])) {
     190            $to_add = array_keys( $_POST['capabilities'] );
     191        } else {
     192            $to_add = array();
     193        }
    186194        $to_remove = array_diff( $all_caps, $to_add );
    187195
     
    199207            )
    200208        );
    201 
     209       
     210        $qa_capabilities_set[$role] = true;
     211       
     212        update_option( 'qa_capabilties_set', array_unique( $qa_capabilities_set ));
     213       
    202214        update_option( QA_OPTIONS_NAME, $options );
    203215
     
    220232            echo "<p>Rendering of admin template " . QA_PLUGIN_DIR . "ui-admin/{$name}.php failed</p>";
    221233    }
     234   
     235        function user_has_cap($allcaps, $caps = null, $args = null) {
     236        global $current_user, $blog_id, $post;
     237       
     238        $qa_capabilities_set = get_option('qa_capabilties_set', array());
     239       
     240        $capable = false;
     241       
     242        $qa_cap_set = false;
     243        foreach ($current_user->roles as $role) {
     244            if (isset($qa_capabilities_set[$role])) {
     245                $qa_cap_set = true;
     246            }
     247        }
     248       
     249        if (!$qa_cap_set && preg_match('/(_question|_questions|_answer|_answers)/i', join($caps, ',')) > 0) {
     250            if (in_array('administrator', $current_user->roles)) {
     251                foreach ($caps as $cap) {
     252                    $allcaps[$cap] = 1;
     253                }
     254                return $allcaps;
     255            }
     256           
     257            foreach ($caps as $cap) {
     258                $capable = false;
     259               
     260                switch ($cap) {
     261                    case 'read_questions' or 'read_answers':
     262                        $capable = true;
     263                        break;
     264                    default:
     265                        if (isset($args[1]) && isset($args[2])) {
     266                            if (current_user_can(preg_replace('/_question|_answer/i', '_post', $cap), $args[1], $args[2])) {
     267                                $capable = true;
     268                            }
     269                        } else if (isset($args[1])) {
     270                            if (current_user_can(preg_replace('/_question|_answer/i', '_post', $cap), $args[1])) {
     271                                $capable = true;
     272                            }
     273                        } else if (current_user_can(preg_replace('/_question|_answer/i', '_post', $cap))) {
     274                            $capable = true;
     275                        }
     276                        break;
     277                }
     278               
     279                if ($capable) {
     280                    $allcaps[$cap] = 1;
     281                }
     282            }
     283        }
     284        return $allcaps;
     285    }
    222286}
    223287
  • qa/trunk/core/core.php

    r384127 r475745  
    295295     */
    296296    function load_default_style() {
     297        global $wp_version;
     298       
    297299        if ( !is_qa_page() )
    298300            return;
     
    304306        if ( !current_theme_supports( 'qa_script' ) ) {
    305307            if ( is_qa_page( 'ask' ) || is_qa_page( 'edit' ) || is_qa_page( 'single' ) ) {
    306                 wp_enqueue_style( 'cleditor', QA_PLUGIN_URL . 'default-templates/js/cleditor/jquery.cleditor.css', array(), '1.3.0-l10n' );
    307 
    308                 wp_enqueue_script( 'cleditor', QA_PLUGIN_URL . 'default-templates/js/cleditor/jquery.cleditor.js', array( 'jquery' ), '1.3.0-l10n' );
     308                if (version_compare($wp_version, "3.3", "<")) {
     309                    wp_enqueue_style( 'cleditor', QA_PLUGIN_URL . 'default-templates/js/cleditor/jquery.cleditor.css', array(), '1.3.0-l10n' );
     310                    wp_enqueue_script( 'cleditor', QA_PLUGIN_URL . 'default-templates/js/cleditor/jquery.cleditor.js', array( 'jquery' ), '1.3.0-l10n' );
     311                }
    309312
    310313                wp_enqueue_script( 'suggest' );
  • qa/trunk/core/template-tags.php

    r384127 r475745  
    321321
    322322function the_question_form() {
    323     global $wp_query;
     323    global $wp_query, $wp_version;
    324324
    325325    if ( is_qa_page( 'edit' ) ) {
     
    362362    </table>
    363363
    364     <textarea name="question_content"><?php echo esc_textarea( $question->post_content ); ?></textarea>
     364    <?php if (version_compare($wp_version, "3.3") >= 0) { ?>
     365    <?php wp_editor( $question->post_content, 'question_content', array('media_buttons' => false)); ?>
     366    <?php } else { ?>
     367    <textarea name="question_content" class="wp32"><?php echo esc_textarea( $question->post_content ); ?></textarea>
     368    <?php } ?>
    365369
    366370    <table id="question-taxonomies">
     
    437441
    438442function the_answer_form() {
    439     global $wp_query;
     443    global $wp_query, $wp_version;
    440444
    441445    if ( is_qa_page( 'edit' ) ) {
     
    463467    <input type="hidden" name="answer_id" value="<?php echo esc_attr( $answer->ID ); ?>" />
    464468
    465     <p><textarea name="answer"><?php echo esc_textarea( $answer->post_content ); ?></textarea></p>
     469    <?php if (version_compare($wp_version, "3.3") >= 0) { ?>
     470        <p><?php wp_editor(  $answer->post_content, 'answer', array('media_buttons' => false)); ?></p>
     471    <?php } else { ?>
     472        <p><textarea name="answer" class="wp32"><?php echo esc_textarea( $answer->post_content ); ?></textarea></p>
     473    <?php } ?>
    466474
    467475    <?php the_qa_submit_button(); ?>
  • qa/trunk/default-templates/css/general.css

    r380225 r475745  
    158158.question-status {
    159159    float: left;
    160     height: 38px;
     160    height: 70px;
    161161    margin-right: 5px;
    162162    padding: 5px;
     
    460460}
    461461
    462 #question-form textarea,
    463 #answer-form textarea {
     462#question-form textarea.wp32,
     463#answer-form textarea.wp32 {
    464464    width: 600px;
    465465    height: 200px;
    466466}
    467467
    468 #question-form textarea,
    469 #answer-form textarea,
     468#question-form textarea.wp32,
     469#answer-form textarea.wp32,
    470470.cleditorMain {
    471471    margin: 20px 0;
  • qa/trunk/default-templates/js/init.js

    r384127 r475745  
    55    }
    66
    7     // Add CLEditor
     7    // Add CLEditor if needed
    88    var $editor = $('#question-form, #answer-form').find('textarea');
    9     if ( $editor.length ) {
     9    if ( $editor.length && $editor.cleditor) {
    1010        $editor.cleditor({
    1111            width: 616,
  • qa/trunk/qa-lite.php

    r386642 r475745  
    1 <?php
    2 /*
    3 Plugin Name: Q&A Lite
    4 Plugin URI: http://premium.wpmudev.org/project/qa-wordpress-questions-and-answers-plugin
    5 Description: Q&A Lite allows any WordPress site to have a fully featured questions and answers section - just like StackOverflow, Yahoo Answers, Quora and more...
    6 Author: scribu (Incsub)
    7 Version: 1.0.1
    8 Author URI: http://premium.wpmudev.org/
    9 WDP ID: 224
    10 */
    11 
    12 /*
    13 
    14 Copyright 2007-2011 Incsub, (http://incsub.com)
    15 
    16 This program is free software; you can redistribute it and/or modify
    17 it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
    18 the Free Software Foundation.
    19 
    20 This program is distributed in the hope that it will be useful,
    21 but WITHOUT ANY WARRANTY; without even the implied warranty of
    22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    23 GNU General Public License for more details.
    24 
    25 You should have received a copy of the GNU General Public License
    26 along with this program; if not, write to the Free Software
    27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    28 
    29 */
    30 
    31 // The plugin version
    32 define( 'QA_VERSION', '1.0.1' );
    33 
    34 // The full url to the plugin directory
    35 define( 'QA_PLUGIN_URL', WP_PLUGIN_URL . '/' . basename( dirname( __FILE__ ) ) . '/' );
    36 
    37 // The full path to the plugin directory
    38 define( 'QA_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . basename( dirname( __FILE__ ) ) . '/' );
    39 
    40 // The text domain for strings localization
    41 define( 'QA_TEXTDOMAIN', 'questions-and-answers' );
    42 
    43 // The key for the options array
    44 define( 'QA_OPTIONS_NAME', 'qa_options' );
    45 
    46 // The minimum number of seconds between two user posts
    47 define( 'QA_FLOOD_SECONDS', 10 );
    48 
    49 // Reputation multipliers
    50 define( 'QA_ANSWER_ACCEPTED', 15 );
    51 define( 'QA_ANSWER_ACCEPTING', 2 );
    52 define( 'QA_ANSWER_UP_VOTE', 10 );
    53 define( 'QA_QUESTION_UP_VOTE', 5 );
    54 define( 'QA_DOWN_VOTE', -2 );
    55 define( 'QA_DOWN_VOTE_PENALTY', -1 );
    56 
    57 // Pagination
    58 define( 'QA_ANSWERS_PER_PAGE', 20 );
    59 
    60 // Load plugin files
    61 include_once QA_PLUGIN_DIR . 'core/core.php';
    62 include_once QA_PLUGIN_DIR . 'core/answers.php';
    63 include_once QA_PLUGIN_DIR . 'core/edit.php';
    64 include_once QA_PLUGIN_DIR . 'core/votes.php';
    65 include_once QA_PLUGIN_DIR . 'core/functions.php';
    66 include_once QA_PLUGIN_DIR . 'core/template-tags.php';
    67 include_once QA_PLUGIN_DIR . 'core/widgets.php';
    68 include_once QA_PLUGIN_DIR . 'core/ajax.php';
    69 
    70 if ( is_admin() ) {
    71     include_once QA_PLUGIN_DIR . 'core/admin.php';
    72 }
    73 
  • qa/trunk/readme.txt

    r394178 r475745  
    33Tags: questions, answers, community, Q&A, stackoverflow, wordpress-plugins
    44Requires at least: 3.1
    5 Tested up to: 3.2
     5Tested up to: 3.3
    66Stable tag: trunk
    77
     
    7272== Changelog ==
    7373
     74= 1.0.2 =
     75* Switch frontend WYSIWYG editor to TinyMCE and Quicktags
     76* WordPress 3.3 compatibility
     77
    7478= 1.0.1 =
    7579* show message when non-logged-in user tries to vote
Note: See TracChangeset for help on using the changeset viewer.