Plugin Directory

Changeset 1135656


Ignore:
Timestamp:
04/15/2015 07:20:42 PM (11 years ago)
Author:
awesome-ug
Message:
  • Fixed problems with errors on further steps
  • Made (int) for steps
  • Returning shortcode content and not echo it
  • Changed collation of tables to utf8_general_ci
  • Changed to more secure getting path function
  • Fixed text mistake on separator
Location:
questions
Files:
90 added
7 edited

Legend:

Unmodified
Added
Removed
  • questions/trunk/README.txt

    r1131329 r1135656  
    6666== Changelog ==
    6767
     68= 1.0.0 beta 7 =
     69* Fixed problems with errors on further steps
     70* Made (int) for steps
     71* Returning shortcode content and not echo it
     72* Changed collation of tables to utf8_general_ci
     73* Changed to more secure getting path function
     74* Fixed text mistake on separator
     75
    6876= 1.0.0 beta 6 =
    6977* Fixed result charts bug
  • questions/trunk/components/charts/shortcodes.php

    r1131329 r1135656  
    6262        endforeach;
    6363       
    64         echo $html;
     64        return $html;
    6565    }
    6666   
     
    8888        endforeach;
    8989       
    90         echo $html;
     90        return $html;
    9191    }
    9292   
  • questions/trunk/components/core/process-response.php

    r1131247 r1135656  
    5050    } // end constructor
    5151   
     52    /**
     53     * Adding filter for the content to show Survey
     54     */
    5255    public function add_post_filter(){
    5356        add_filter( 'the_content', array( $this, 'the_content' ) );
    5457    }
    5558   
     59    /**
     60     * The filtered content gehts a survey
     61     * @param string $content
     62     * @return strint $content
     63     */
    5664    public function the_content( $content ){
    5765        global $post, $questions_global;
     
    6775    }
    6876   
     77    /**
     78     * Showing survey
     79     * @param int $survey_id
     80     * @return string $survey_html
     81     */
    6982    public function show_survey( $survey_id ){
    7083        if( TRUE === $this->check_restrictions( $survey_id ) ):
     
    7487        endif;
    7588    }
    76 
     89   
     90    /**
     91     * Check restrictions
     92     *
     93     * Checking restrictions if user can participate
     94     *
     95     * @param int $survey_id
     96     * @return boolean $can_participate
     97     */
    7798    private function check_restrictions( $survey_id ){
    7899        $participiant_restrictions = get_post_meta( $survey_id, 'participiant_restrictions', TRUE );
     
    130151    }
    131152   
     153    /**
     154     * Survey form
     155     *
     156     * Creating form HTML
     157     *
     158     * @param int $survey_id
     159     * @return string $html
     160     */
    132161    private function survey_form( $survey_id ){
    133162        global $questions_response_errors, $questions_survey_id;
     
    137166       
    138167        if( array_key_exists( 'questions_next_step', $_POST ) && 0 == count( $questions_response_errors ) ):
    139             $next_step = $_POST[ 'questions_next_step' ];
    140         else:
    141             $next_step = 0;
     168            $next_step = (int) $_POST[ 'questions_next_step' ];
     169        else:
     170            $next_step = (int) $_POST[ 'questions_actual_step' ];
    142171        endif;
    143172       
    144173        if( array_key_exists( 'questions_submission_back', $_POST ) ):
    145             $next_step = $_POST[ 'questions_actual_step' ] - 1;
     174            $next_step = (int) $_POST[ 'questions_actual_step' ] - 1;
    146175        endif;
    147176       
     
    188217    }
    189218
     219    /**
     220     * Checks if a user can participate
     221     * @param int $survey_id
     222     * @param int $user_id
     223     * @return boolean $can_participate
     224     */
    190225    public function user_can_participate( $survey_id, $user_id = NULL ){
    191226        global $wpdb, $current_user;
     
    202237    }
    203238
     239    /**
     240     * Get numer of spits in survey
     241     * @param int $survey_id
     242     * @return int $splitter_count
     243     */
    204244    private function get_step_count( $survey_id ){
    205245        $survey = new Questions_Survey( $survey_id );
    206246        return $survey->splitter_count;
    207247    }
    208 
     248   
     249    /**
     250     * Getting elements of a survey
     251     * @param int $survey_id
     252     * @param int $step
     253     * @return array $elements
     254     */
    209255    public function get_elements( $survey_id, $step = 0 ){
    210256        $survey = new Questions_Survey( $survey_id );
     
    225271        return $elements[ $step ];
    226272    }
    227 
     273   
     274    /**
     275     * Processing entered data
     276     */
    228277    public function process_response( $wp_object ){
    229278        global $wpdb, $post, $questions_global, $questions_survey_id;
     
    261310        // Getting data of posted step
    262311        $survey_response = $_POST[ 'questions_response' ];
    263         $survey_actual_step = $_POST[ 'questions_actual_step' ];
     312        $survey_actual_step = (int) $_POST[ 'questions_actual_step' ];
    264313       
    265314        // Validating response values and setting up error variables
     
    291340    }
    292341
     342    /**
     343     * Saving response data
     344     */
    293345    private function save_response(){
    294346        global $questions_response_errors, $questions_survey_id;
     
    299351            return;
    300352       
    301         if( $_POST[ 'questions_actual_step' ] == $_POST[ 'questions_next_step' ]  && 0 == count( $questions_response_errors ) && !array_key_exists( 'questions_submission_back', $_POST ) ):
     353        if( (int) $_POST[ 'questions_actual_step' ] == (int) $_POST[ 'questions_next_step' ]  && 0 == count( $questions_response_errors ) && !array_key_exists( 'questions_submission_back', $_POST ) ):
    302354            $response = $_SESSION[ 'questions_response' ][ $questions_survey_id ];
    303355           
     
    315367    }
    316368   
     369    /**
     370     * Validating response
     371     * @param int $survey_id
     372     * @param array $response
     373     * @param int $step
     374     * @return boolean $validated
     375     */
    317376    public function validate_response( $survey_id, $response, $step ){
    318377        global $questions_response_errors;
     
    362421        endforeach;
    363422       
    364         if( is_array( $questions_response_errors) && array_key_exists( $element->id, $questions_response_errors) ):
     423        if( is_array( $questions_response_errors ) && array_key_exists( $element->id, $questions_response_errors ) ):
    365424            // ??? One Element at the end ???
    366425            if( is_array( $questions_response_errors[ $element->id ] ) && count( $questions_response_errors[ $element->id ] ) == 0 ):
     
    375434    }
    376435
     436    /**
     437     * Sub function for save_response
     438     * @param int $survey_id
     439     * @param array $response
     440     * @return boolean $saved
     441     */
    377442    private function save_data( $survey_id, $response ){
    378443        global $wpdb, $questions_global, $current_user;
     
    433498    }
    434499   
     500    /**
     501     * Has the user participated survey
     502     * @param int $survey_id
     503     * @param int $user_id
     504     * @return boolean $has_participated
     505     */
    435506    public function has_participated( $questions_id, $user_id = NULL ){
    436507        global $wpdb, $current_user, $questions_global;
     
    456527    }
    457528   
     529    /**
     530     * Has IP already participated
     531     * @param int $survey_id
     532     * @return boolean $has_participated
     533     */
    458534    public function ip_has_participated( $questions_id ){
    459535        global $wpdb, $questions_global;
     
    471547    }
    472548   
     549    /**
     550     * Sending out finish email to participator
     551     */
    473552    public function email_finished(){
    474553        global $post, $current_user;
     
    492571    }
    493572   
     573    /**
     574     * Text which will be shown after a user has participated successful
     575     * @param int $survey_id
     576     * @return string $html
     577     */
    494578    public function text_thankyou_for_participation( $survey_id ){
    495579        $show_results = get_post_meta( $survey_id, 'show_results', TRUE );
     
    507591    }
    508592   
     593    /**
     594     * Text which will be shown if a user has participated already
     595     * @param int $survey_id
     596     * @return string $html
     597     */
    509598    public function text_already_participated( $survey_id ){
    510599        $show_results = get_post_meta( $survey_id, 'show_results', TRUE );
     
    520609    }
    521610   
     611    /**
     612     * Showing results
     613     * @param int $survey_id
     614     * @return string $html
     615     */
    522616    public function show_results( $survey_id ){
    523617        $html = '<p>' . __( 'This are the actual results:', 'questions-locale' ) . '</p>';
    524         ob_start();
    525         do_shortcode( '[survey_results id="' . $survey_id . '"]' );
    526         $html.= ob_get_clean();
     618        $html.= do_shortcode( '[survey_results id="' . $survey_id . '"]' );
    527619       
    528620        return $html;
    529621    }
    530622   
     623    /**
     624     * Text which will be shown if a user has to login to participate
     625     * @return string $html
     626     */
    531627    public function text_not_logged_in(){
    532628        $html = '<div id="questions-not-logged-in">';
     
    536632    }
    537633   
     634    /**
     635     * Text which will be shown if a user cant participate
     636     * @return string $html
     637     */
    538638    public function text_cant_participate(){
    539639        $html = '<div id="questions-cant-participate">';
     
    546646$Questions_ProcessResponse = new Questions_ProcessResponse();
    547647
     648/**
     649 * Checks if a user has participated on a survey
     650 * @return int $survey_id
     651 * @return boolean $has_participated
     652 */
    548653function qu_user_has_participated( $questions_id, $user_id = NULL){
    549654    global $Questions_ProcessResponse;
  • questions/trunk/components/core/shortcodes.php

    r1131247 r1135656  
    5959        endif;
    6060       
    61         echo $Questions_ProcessResponse->show_survey( $atts[ 'id' ] );
     61        return $Questions_ProcessResponse->show_survey( $atts[ 'id' ] );
    6262    }
    6363   
  • questions/trunk/init.php

    r1131329 r1135656  
    44Plugin URI: http://www.awesome.ug
    55Description: Drag & drop your survey/poll with the WordPress Questions plugin.
    6 Version: 1.0.0 beta 6
     6Version: 1.0.0 beta 7
    77Author: awesome.ug
    88Author URI: http://www.awesome.ug
     
    9797            type char(50) NOT NULL,
    9898            UNIQUE KEY id (id)
    99             )";
     99            ) ENGINE = INNODB DEFAULT CHARSET = utf8;";
    100100           
    101101        dbDelta( $sql );
     
    108108            sort int(11) NOT NULL,
    109109            UNIQUE KEY id (id)
    110             )";
     110            ) ENGINE = INNODB DEFAULT CHARSET = utf8;";
    111111           
    112112        dbDelta( $sql );
     
    120120            cookie_key char(30) NOT NULL,
    121121            UNIQUE KEY id (id)
    122             )";
     122            ) ENGINE = INNODB DEFAULT CHARSET = utf8;";
    123123           
    124124        dbDelta( $sql );
     
    130130            value text NOT NULL,
    131131            UNIQUE KEY id (id)
    132             )";
     132            ) ENGINE = INNODB DEFAULT CHARSET = utf8;";
    133133           
    134134        dbDelta( $sql );
     
    140140            value text NOT NULL,
    141141            UNIQUE KEY id (id)
    142             )";
     142            ) ENGINE = INNODB DEFAULT CHARSET = utf8;";
    143143           
    144144        dbDelta( $sql );
     
    149149            user_id int(11) NOT NULL,
    150150            UNIQUE KEY id (id)
    151             )";
    152            
    153         dbDelta( $sql );
     151            ) ENGINE = INNODB DEFAULT CHARSET = utf8;";
     152           
     153        dbDelta( $sql );
     154       
     155        $sql = "ALTER TABLE $table_questions CONVERT TO CHARACTER SET utf8 collate utf8_general_ci;";
     156        $wpdb->query( $sql );
     157       
     158        $sql = "ALTER TABLE $table_answers CONVERT TO CHARACTER SET utf8 collate utf8_general_ci;";
     159        $wpdb->query( $sql );
     160       
     161        $sql = "ALTER TABLE $table_responds CONVERT TO CHARACTER SET utf8 collate utf8_general_ci;";
     162        $wpdb->query( $sql );
     163       
     164        $sql = "ALTER TABLE $table_respond_answers CONVERT TO CHARACTER SET utf8 collate utf8_general_ci;";
     165        $wpdb->query( $sql );
     166       
     167        $sql = "ALTER TABLE $table_participiants CONVERT TO CHARACTER SET utf8 collate utf8_general_ci;";
     168        $wpdb->query( $sql );
     169       
     170        $sql = "ALTER TABLE $table_settings CONVERT TO CHARACTER SET utf8 collate utf8_general_ci;";
     171        $wpdb->query( $sql );
    154172       
    155173        update_option( 'questions_db_version', '1.1.0' );
     
    264282    */
    265283    private static function get_folder(){
    266         $sub_folder = substr( dirname(__FILE__), strlen( ABSPATH ), ( strlen( dirname(__FILE__) ) - strlen( ABSPATH ) ) );
    267         $script_folder = ABSPATH . $sub_folder;
    268         return $script_folder;
     284        return plugin_dir_path( __FILE__ );
    269285    }
    270286   
  • questions/trunk/languages/questions-locale-de_DE.po

    r1131247 r1135656  
    44"Report-Msgid-Bugs-To: \n"
    55"POT-Creation-Date: 2015-04-09 15:39+0100\n"
    6 "PO-Revision-Date: 2015-04-09 15:41+0100\n"
     6"PO-Revision-Date: 2015-04-09 19:10+0100\n"
    77"Last-Translator: Sven Wagener <sven.wagener@rheinschmiede.de>\n"
    88"Language-Team: \n"
     
    676676#: ../components/elements/separator.php:18
    677677msgid "Separator"
    678 msgstr "Separatorn"
     678msgstr "Separator"
    679679
    680680# @ surveyval-locale
Note: See TracChangeset for help on using the changeset viewer.