Plugin Directory

Changeset 504350


Ignore:
Timestamp:
02/13/2012 03:33:19 PM (14 years ago)
Author:
down_under
Message:

New Feature : Option to choose whether to list private surveys or not!

Location:
surveypress
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • surveypress/tags/1.0.9/survey-press.php

    r484436 r504350  
    6666$show_option_survey_notification  = 'show_survey_notification';
    6767$show_option_import_users         = 'import_users';
    68 $same_option_password              = 'same_password';
     68$same_option_password             = 'same_password';
     69$list_option_public_surveys       = 'list_public_survey_only';
    6970// respective values from database.
    7071// Read in existing option value from database
     
    105106}
    106107
     108if ( get_option( $list_option_public_surveys ) == '' )
     109{
     110    $list_value_public_surveys = 1;
     111}
     112else
     113{
     114    $list_value_public_surveys = (int) get_option( $list_option_public_surveys );
     115}
    107116
    108117/**
  • surveypress/tags/1.0.9/view/config-menu.php

    r484436 r504350  
    1010global $db_value_host,$db_value_name,$db_value_pwd,$db_value_user,$db_value_prefix,$db_value_url;
    1111
    12 global $show_value_survey_notification,$db_connection_error_name,$db_connection_error;
     12global $list_value_public_surveys,$show_value_survey_notification,$db_connection_error_name,$db_connection_error;
    1313
    1414
     
    179179    global $lsdb;
    180180    //$lsdb = new wpdb( $db_value_user, $db_value_pwd, $db_value_name, $db_value_host );
    181 
    182     $public_surveys = $lsdb->get_results( "SELECT a.sid, b.surveyls_title, a.publicstatistics
    183                                           FROM ".$db_value_prefix."surveys AS a
    184                                           INNER JOIN ".$db_value_prefix."surveys_languagesettings AS b
    185                                           ON ( surveyls_survey_id = a.sid AND surveyls_language = a.language )
    186                                           WHERE surveyls_survey_id=a.sid
    187                                           AND surveyls_language=a.language
    188                                           AND a.active='Y'
    189                                           AND a.listpublic='Y'
    190                                           AND ((a.expires >= '".date("Y-m-d H:i")."') OR (a.expires is null))
    191                                           AND ((a.startdate <= '".date("Y-m-d H:i")."') OR (a.startdate is null))
    192                                           ORDER BY surveyls_title" );
     181    $query = "SELECT a.sid, b.surveyls_title, a.listpublic
     182              FROM ".$db_value_prefix."surveys AS a
     183              INNER JOIN ".$db_value_prefix."surveys_languagesettings AS b
     184              ON ( surveyls_survey_id = a.sid AND surveyls_language = a.language )
     185              WHERE surveyls_survey_id=a.sid
     186              AND surveyls_language=a.language
     187              AND a.active='Y'
     188              AND ((a.expires >= '".date("Y-m-d H:i")."') OR (a.expires is null))
     189              AND ((a.startdate <= '".date("Y-m-d H:i")."') OR (a.startdate is null))
     190              ORDER BY surveyls_title";
     191               
     192    $public_surveys = $lsdb->get_results( $query );
    193193   
    194194    //number of surveys active and public
    195     $count = 0;
     195    $publiccount  = 0;
     196    //number of surveys active and private
     197    $privatecount = 0;
    196198    //public active surveys information
    197     $survey = array();
     199    $publicsurvey  = array();
     200    //private active surveys information
     201    $privatesurvey = array();
    198202         
    199203    if ( $public_surveys )
     
    201205        foreach ( $public_surveys as $surveyinfo )
    202206        {
    203             $survey[$count]['sid']   = $surveyinfo->sid;
    204             $survey[$count]['title'] = $surveyinfo->surveyls_title;
    205            
    206             $count = $count + 1;
     207            if ( $surveyinfo->listpublic == 'Y' )
     208            {
     209                $publicsurvey[$publiccount]['sid']   = $surveyinfo->sid;
     210                $publicsurvey[$publiccount]['title'] = $surveyinfo->surveyls_title;
     211               
     212                $publiccount++;
     213            }
     214            else
     215            {
     216                $privatesurvey[$privatecount]['sid']   = $surveyinfo->sid;
     217                $privatesurvey[$privatecount]['title'] = $surveyinfo->surveyls_title;
     218               
     219                $privatecount++;
     220            }
    207221        }
    208222    }       
     
    214228    <br/>
    215229    <?php
    216     if ( $count ) //there exist some public and active surveys.
    217     {
    218         printf(__("You can take following %d public survey(s), if you haven't already. Take them now :"), $count);
    219        
    220         $temp = 0;
    221         while ( $temp < $count )
    222         {
    223             if ( $temp == 0)
    224             {
    225                 echo "<ul type='disc'>";
    226             }
    227             printf(__("<li> <a href='".$db_value_url."/index.php?sid=".$survey[$temp]['sid']."' target='_blank'><strong> %s </strong></a> </li>"), $survey[$temp]['title']);
    228            
    229             if ( $temp == ( $count - 1 ) )
    230             {
    231                 echo "</ul>";
    232             }
    233             $temp = $temp + 1;
    234         } //end while
     230   
     231    $count = $publiccount; //public surveys will always be displayed!
     232    if ( ((int)$list_value_public_surveys == 1 ) )
     233    {
     234        $count += $privatecount; //private surveys should be shown,hence add the count
     235    }
     236   
     237    if ( $count > 0 ) //there exist some active surveys which should be shown.
     238    {
     239       
     240        printf(__("You can take following %d survey(s), if you haven't already. Take them now :"), $count );
     241    ?>
     242    <br /><br />
     243    <?php   
     244        if ( $publiccount > 0 ) //show public surveys
     245        {
     246            echo "<b>".__("Public Survey(s)")."</b> :";
     247       
     248       
     249            $temp = 0;
     250            while ( $temp < $publiccount )
     251            {
     252                if ( $temp == 0)
     253                {
     254                    echo "<ul type='disc'>";
     255                }
     256                printf(__("<li> <a href='".$db_value_url."/index.php?sid=".$publicsurvey[$temp]['sid']."' target='_blank'><strong> %s </strong></a> </li>"), $publicsurvey[$temp]['title']);
     257               
     258                if ( $temp == ( $publiccount - 1 ) )
     259                {
     260                    echo "</ul>";
     261                }
     262                $temp = $temp + 1;
     263            } //end while
     264        }
     265       
     266        if ( $privatecount > 0 && ((int)$list_value_public_surveys == 1 ) ) //shwo private surveys if (they exist and should be shown)
     267        {
     268            echo "<b>".__("Private Survey(s)")."</b> :";
     269       
     270       
     271            $temp = 0;
     272            while ( $temp < $privatecount )
     273            {
     274                if ( $temp == 0)
     275                {
     276                    echo "<ul type='disc'>";
     277                }
     278                printf(__("<li> <a href='".$db_value_url."/index.php?sid=".$privatesurvey[$temp]['sid']."' target='_blank'><strong> %s </strong></a> </li>"), $privatesurvey[$temp]['title']);
     279               
     280                if ( $temp == ( $privatecount - 1 ) )
     281                {
     282                    echo "</ul>";
     283                }
     284                $temp = $temp + 1;
     285            } //end while
     286        }
    235287    }
    236288    else
    237289    {
    238        echo _e("No public survey(s) to take at the moment.");
     290       echo _e("No survey(s) to take at the moment.");
    239291    }
    240292   
  • surveypress/tags/1.0.9/view/option-menu.php

    r484436 r504350  
    77 
    88//global variables
    9 global $apply_option_default_permissions,$show_option_survey_notification,$show_option_import_users,$same_option_password;
    10 global $apply_value_default_permissions,$show_value_survey_notification,$show_value_import_users,$same_value_password;
     9global $apply_option_default_permissions,$show_option_survey_notification,$show_option_import_users,$same_option_password,$list_option_public_surveys;
     10global $apply_value_default_permissions,$show_value_survey_notification,$show_value_import_users,$same_value_password,$list_value_public_surveys;
    1111
    1212//output the heading.
     
    3636            $show_value_import_users         = (int) $_POST[ $show_option_import_users ];
    3737            $same_value_password             = (int) $_POST[ $same_option_password ];
    38                
     38            $list_value_public_surveys       = (int) $_POST[ $list_option_public_surveys ];
    3939       
    4040            // Save the posted values in the database
     
    4343            update_option( $show_option_import_users, $show_value_import_users );
    4444            update_option( $same_option_password, $same_value_password );
     45            update_option( $list_option_public_surveys, $list_value_public_surveys );
    4546       
    4647            // Put an settings updated message on the screen
     
    117118        <tr valign="top">
    118119        <th scope="row">
     120        <?php _e("List private active surveys in user dashboard?", 'menu-test' ); ?>
     121        </th>
     122        <td>
     123        <p>
     124        <label>
     125        <input type="radio" name="<?php echo $list_option_public_surveys; ?>" value="1" <?php if((int)$list_value_public_surveys) { ?> checked="checked" <?php } ?> />
     126        <?php _e("Yes"); ?>
     127        </label>
     128        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     129        <label>
     130        <input type="radio" name="<?php echo $list_option_public_surveys; ?>" value="0" <?php if(!((int)$list_value_public_surveys)) { ?> checked="checked" <?php } ?> />
     131        <?php _e("No"); ?>
     132        </label>
     133        <br /><span class="description">( If set to "Yes", users will see all active surveys(public+private) else only 'Public' surveys will be displayed. Effective only if 'Show user survey(s) to be taken' is set to 'Show'. )</span>
     134       
     135        </p>
     136        </td>
     137        </tr>
     138       
     139        <tr valign="top">
     140        <th scope="row">
    119141        <?php _e("Import users from Wordpress to LimeSurvey?", 'menu-test' ); ?>
    120142        </th>
  • surveypress/trunk/survey-press.php

    r484436 r504350  
    6666$show_option_survey_notification  = 'show_survey_notification';
    6767$show_option_import_users         = 'import_users';
    68 $same_option_password              = 'same_password';
     68$same_option_password             = 'same_password';
     69$list_option_public_surveys       = 'list_public_survey_only';
    6970// respective values from database.
    7071// Read in existing option value from database
     
    105106}
    106107
     108if ( get_option( $list_option_public_surveys ) == '' )
     109{
     110    $list_value_public_surveys = 1;
     111}
     112else
     113{
     114    $list_value_public_surveys = (int) get_option( $list_option_public_surveys );
     115}
    107116
    108117/**
  • surveypress/trunk/view/config-menu.php

    r484436 r504350  
    1010global $db_value_host,$db_value_name,$db_value_pwd,$db_value_user,$db_value_prefix,$db_value_url;
    1111
    12 global $show_value_survey_notification,$db_connection_error_name,$db_connection_error;
     12global $list_value_public_surveys,$show_value_survey_notification,$db_connection_error_name,$db_connection_error;
    1313
    1414
     
    179179    global $lsdb;
    180180    //$lsdb = new wpdb( $db_value_user, $db_value_pwd, $db_value_name, $db_value_host );
    181 
    182     $public_surveys = $lsdb->get_results( "SELECT a.sid, b.surveyls_title, a.publicstatistics
    183                                           FROM ".$db_value_prefix."surveys AS a
    184                                           INNER JOIN ".$db_value_prefix."surveys_languagesettings AS b
    185                                           ON ( surveyls_survey_id = a.sid AND surveyls_language = a.language )
    186                                           WHERE surveyls_survey_id=a.sid
    187                                           AND surveyls_language=a.language
    188                                           AND a.active='Y'
    189                                           AND a.listpublic='Y'
    190                                           AND ((a.expires >= '".date("Y-m-d H:i")."') OR (a.expires is null))
    191                                           AND ((a.startdate <= '".date("Y-m-d H:i")."') OR (a.startdate is null))
    192                                           ORDER BY surveyls_title" );
     181    $query = "SELECT a.sid, b.surveyls_title, a.listpublic
     182              FROM ".$db_value_prefix."surveys AS a
     183              INNER JOIN ".$db_value_prefix."surveys_languagesettings AS b
     184              ON ( surveyls_survey_id = a.sid AND surveyls_language = a.language )
     185              WHERE surveyls_survey_id=a.sid
     186              AND surveyls_language=a.language
     187              AND a.active='Y'
     188              AND ((a.expires >= '".date("Y-m-d H:i")."') OR (a.expires is null))
     189              AND ((a.startdate <= '".date("Y-m-d H:i")."') OR (a.startdate is null))
     190              ORDER BY surveyls_title";
     191               
     192    $public_surveys = $lsdb->get_results( $query );
    193193   
    194194    //number of surveys active and public
    195     $count = 0;
     195    $publiccount  = 0;
     196    //number of surveys active and private
     197    $privatecount = 0;
    196198    //public active surveys information
    197     $survey = array();
     199    $publicsurvey  = array();
     200    //private active surveys information
     201    $privatesurvey = array();
    198202         
    199203    if ( $public_surveys )
     
    201205        foreach ( $public_surveys as $surveyinfo )
    202206        {
    203             $survey[$count]['sid']   = $surveyinfo->sid;
    204             $survey[$count]['title'] = $surveyinfo->surveyls_title;
    205            
    206             $count = $count + 1;
     207            if ( $surveyinfo->listpublic == 'Y' )
     208            {
     209                $publicsurvey[$publiccount]['sid']   = $surveyinfo->sid;
     210                $publicsurvey[$publiccount]['title'] = $surveyinfo->surveyls_title;
     211               
     212                $publiccount++;
     213            }
     214            else
     215            {
     216                $privatesurvey[$privatecount]['sid']   = $surveyinfo->sid;
     217                $privatesurvey[$privatecount]['title'] = $surveyinfo->surveyls_title;
     218               
     219                $privatecount++;
     220            }
    207221        }
    208222    }       
     
    214228    <br/>
    215229    <?php
    216     if ( $count ) //there exist some public and active surveys.
    217     {
    218         printf(__("You can take following %d public survey(s), if you haven't already. Take them now :"), $count);
    219        
    220         $temp = 0;
    221         while ( $temp < $count )
    222         {
    223             if ( $temp == 0)
    224             {
    225                 echo "<ul type='disc'>";
    226             }
    227             printf(__("<li> <a href='".$db_value_url."/index.php?sid=".$survey[$temp]['sid']."' target='_blank'><strong> %s </strong></a> </li>"), $survey[$temp]['title']);
    228            
    229             if ( $temp == ( $count - 1 ) )
    230             {
    231                 echo "</ul>";
    232             }
    233             $temp = $temp + 1;
    234         } //end while
     230   
     231    $count = $publiccount; //public surveys will always be displayed!
     232    if ( ((int)$list_value_public_surveys == 1 ) )
     233    {
     234        $count += $privatecount; //private surveys should be shown,hence add the count
     235    }
     236   
     237    if ( $count > 0 ) //there exist some active surveys which should be shown.
     238    {
     239       
     240        printf(__("You can take following %d survey(s), if you haven't already. Take them now :"), $count );
     241    ?>
     242    <br /><br />
     243    <?php   
     244        if ( $publiccount > 0 ) //show public surveys
     245        {
     246            echo "<b>".__("Public Survey(s)")."</b> :";
     247       
     248       
     249            $temp = 0;
     250            while ( $temp < $publiccount )
     251            {
     252                if ( $temp == 0)
     253                {
     254                    echo "<ul type='disc'>";
     255                }
     256                printf(__("<li> <a href='".$db_value_url."/index.php?sid=".$publicsurvey[$temp]['sid']."' target='_blank'><strong> %s </strong></a> </li>"), $publicsurvey[$temp]['title']);
     257               
     258                if ( $temp == ( $publiccount - 1 ) )
     259                {
     260                    echo "</ul>";
     261                }
     262                $temp = $temp + 1;
     263            } //end while
     264        }
     265       
     266        if ( $privatecount > 0 && ((int)$list_value_public_surveys == 1 ) ) //shwo private surveys if (they exist and should be shown)
     267        {
     268            echo "<b>".__("Private Survey(s)")."</b> :";
     269       
     270       
     271            $temp = 0;
     272            while ( $temp < $privatecount )
     273            {
     274                if ( $temp == 0)
     275                {
     276                    echo "<ul type='disc'>";
     277                }
     278                printf(__("<li> <a href='".$db_value_url."/index.php?sid=".$privatesurvey[$temp]['sid']."' target='_blank'><strong> %s </strong></a> </li>"), $privatesurvey[$temp]['title']);
     279               
     280                if ( $temp == ( $privatecount - 1 ) )
     281                {
     282                    echo "</ul>";
     283                }
     284                $temp = $temp + 1;
     285            } //end while
     286        }
    235287    }
    236288    else
    237289    {
    238        echo _e("No public survey(s) to take at the moment.");
     290       echo _e("No survey(s) to take at the moment.");
    239291    }
    240292   
  • surveypress/trunk/view/option-menu.php

    r484436 r504350  
    77 
    88//global variables
    9 global $apply_option_default_permissions,$show_option_survey_notification,$show_option_import_users,$same_option_password;
    10 global $apply_value_default_permissions,$show_value_survey_notification,$show_value_import_users,$same_value_password;
     9global $apply_option_default_permissions,$show_option_survey_notification,$show_option_import_users,$same_option_password,$list_option_public_surveys;
     10global $apply_value_default_permissions,$show_value_survey_notification,$show_value_import_users,$same_value_password,$list_value_public_surveys;
    1111
    1212//output the heading.
     
    3636            $show_value_import_users         = (int) $_POST[ $show_option_import_users ];
    3737            $same_value_password             = (int) $_POST[ $same_option_password ];
    38                
     38            $list_value_public_surveys       = (int) $_POST[ $list_option_public_surveys ];
    3939       
    4040            // Save the posted values in the database
     
    4343            update_option( $show_option_import_users, $show_value_import_users );
    4444            update_option( $same_option_password, $same_value_password );
     45            update_option( $list_option_public_surveys, $list_value_public_surveys );
    4546       
    4647            // Put an settings updated message on the screen
     
    117118        <tr valign="top">
    118119        <th scope="row">
     120        <?php _e("List private active surveys in user dashboard?", 'menu-test' ); ?>
     121        </th>
     122        <td>
     123        <p>
     124        <label>
     125        <input type="radio" name="<?php echo $list_option_public_surveys; ?>" value="1" <?php if((int)$list_value_public_surveys) { ?> checked="checked" <?php } ?> />
     126        <?php _e("Yes"); ?>
     127        </label>
     128        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     129        <label>
     130        <input type="radio" name="<?php echo $list_option_public_surveys; ?>" value="0" <?php if(!((int)$list_value_public_surveys)) { ?> checked="checked" <?php } ?> />
     131        <?php _e("No"); ?>
     132        </label>
     133        <br /><span class="description">( If set to "Yes", users will see all active surveys(public+private) else only 'Public' surveys will be displayed. Effective only if 'Show user survey(s) to be taken' is set to 'Show'. )</span>
     134       
     135        </p>
     136        </td>
     137        </tr>
     138       
     139        <tr valign="top">
     140        <th scope="row">
    119141        <?php _e("Import users from Wordpress to LimeSurvey?", 'menu-test' ); ?>
    120142        </th>
Note: See TracChangeset for help on using the changeset viewer.