Skip to content

Commit

Permalink
Updated getsurveylist to have a new $returnwithouturl function parame…
Browse files Browse the repository at this point in the history
…ter which provides the survey list select options with the survey id in the option value instead of part of the url. This change is used for the survey copy feature.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@8591 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
David Olivier committed Apr 14, 2010
1 parent cb4f35c commit 14a2506
Showing 1 changed file with 62 additions and 17 deletions.
79 changes: 62 additions & 17 deletions common.php
Expand Up @@ -676,7 +676,7 @@ function db_tables_exist($table)
* @return string This string is returned containing <option></option> formatted list of existing surveys
*
*/
function getsurveylist($returnarray=false)
function getsurveylist($returnarray=false,$returnwithouturl=false)
{
global $surveyid, $dbprefix, $scriptname, $connect, $clang, $timeadjust;
static $cached = null;
Expand Down Expand Up @@ -713,25 +713,59 @@ function getsurveylist($returnarray=false)
if($sv['active']!='Y')
{
$inactivesurveys .= "<option ";
if($_SESSION['loginID'] == $sv['owner_id']) {$inactivesurveys .= " style=\"font-weight: bold;\"";}
if ($sv['sid'] == $surveyid) {$inactivesurveys .= " selected='selected'"; $svexist = 1;}
$inactivesurveys .=" value='$scriptname?sid={$sv['sid']}'>{$sv['surveyls_title']}</option>\n";
}
elseif($sv['expires']!='' && $sv['expires'] < date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust))
if($_SESSION['loginID'] == $sv['owner_id'])
{
$inactivesurveys .= " style=\"font-weight: bold;\"";
}
if ($sv['sid'] == $surveyid)
{
$inactivesurveys .= " selected='selected'"; $svexist = 1;
}
if ($returnwithouturl===false)
{
$inactivesurveys .=" value='$scriptname?sid={$sv['sid']}'>{$sv['surveyls_title']}</option>\n";
} else
{
$inactivesurveys .=" value='{$sv['sid']}'>{$sv['surveyls_title']}</option>\n";
}
} elseif($sv['expires']!='' && $sv['expires'] < date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust))
{
$expiredsurveys .="<option ";
if ($_SESSION['loginID'] == $sv['owner_id']) {$expiredsurveys .= " style=\"font-weight: bold;\"";}
if ($sv['sid'] == $surveyid) {$expiredsurveys .= " selected='selected'"; $svexist = 1;}
$expiredsurveys .=" value='$scriptname?sid={$sv['sid']}'>{$sv['surveyls_title']}</option>\n";
}
else
if ($_SESSION['loginID'] == $sv['owner_id'])
{
$expiredsurveys .= " style=\"font-weight: bold;\"";
}
if ($sv['sid'] == $surveyid)
{
$expiredsurveys .= " selected='selected'"; $svexist = 1;
}
if ($returnwithouturl===false)
{
$expiredsurveys .=" value='$scriptname?sid={$sv['sid']}'>{$sv['surveyls_title']}</option>\n";
} else
{
$expiredsurveys .=" value='{$sv['sid']}'>{$sv['surveyls_title']}</option>\n";
}
} else
{
$activesurveys .= "<option ";
if($_SESSION['loginID'] == $sv['owner_id']) {$activesurveys .= " style=\"font-weight: bold;\"";}
if ($sv['sid'] == $surveyid) {$activesurveys .= " selected='selected'"; $svexist = 1;}
$activesurveys .=" value='$scriptname?sid={$sv['sid']}'>{$sv['surveyls_title']}</option>\n";
if($_SESSION['loginID'] == $sv['owner_id'])
{
$activesurveys .= " style=\"font-weight: bold;\"";
}
if ($sv['sid'] == $surveyid)
{
$activesurveys .= " selected='selected'"; $svexist = 1;
}
if ($returnwithouturl===false)
{
$activesurveys .=" value='$scriptname?sid={$sv['sid']}'>{$sv['surveyls_title']}</option>\n";
} else
{
$activesurveys .=" value='{$sv['sid']}'>{$sv['surveyls_title']}</option>\n";
}
}
}
} // End Foreach
}
//Only show each activesurvey group if there are some
if ($activesurveys!='')
Expand All @@ -749,8 +783,19 @@ function getsurveylist($returnarray=false)
$surveyselecter .= "<optgroup label='".$clang->gT("Inactive")."' class='inactivesurveyselect'>\n";
$surveyselecter .= $inactivesurveys . "</optgroup>";
}
if (!isset($svexist)) {$surveyselecter = "<option selected='selected'>".$clang->gT("Please Choose...")."</option>\n".$surveyselecter;}
else {$surveyselecter = "<option value='$scriptname?sid='>".$clang->gT("None")."</option>\n".$surveyselecter;}
if (!isset($svexist))
{
$surveyselecter = "<option selected='selected'>".$clang->gT("Please Choose...")."</option>\n".$surveyselecter;
} else
{
if ($returnwithouturl===false)
{
$surveyselecter = "<option value='$scriptname?sid='>".$clang->gT("None")."</option>\n".$surveyselecter;
} else
{
$surveyselecter = "<option value=''>".$clang->gT("None")."</option>\n".$surveyselecter;
}
}
return $surveyselecter;
}

Expand Down

0 comments on commit 14a2506

Please sign in to comment.