Skip to content

Commit

Permalink
dev Moved function showmainmenu to html.php
Browse files Browse the repository at this point in the history
dev WIP: Adjusted the upgrade scripts
New feature: Use @@SURVEYURL@@ in invitation/reminder emails to be able to use it inside an <a href > link

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev_cs@8311 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Jan 26, 2010
1 parent ca2ce8e commit 7b4c78b
Show file tree
Hide file tree
Showing 8 changed files with 340 additions and 323 deletions.
9 changes: 5 additions & 4 deletions admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
include('access_denied.php');
}

if(isset($_SESSION['loginID']) && $action!='login')
if(isset($_SESSION['loginID']))
{
//VARIOUS DATABASE OPTIONS/ACTIONS PERFORMED HERE
if ($action == 'delsurvey' || $action == 'delgroup' ||
Expand Down Expand Up @@ -454,8 +454,8 @@
!isset($vvoutput) && !isset($tokenoutput) && !isset($exportoutput) && !isset($templatesoutput) && !isset($iteratesurveyoutput) && (substr($action,0,4)!= 'ajax') && ($action!='update') &&
(isset($surveyid) || $action=='listurveys' || $action=='personalsettings' || //Still to check
$action=='editsurvey' || $action=='updatesurvey' || $action=='ordergroups' ||
$action=='newsurvey' || $action=='listsurveys' ||
$action=='surveyrights' || $action=='quotas') )
$action=='newsurvey' || $action=='listsurveys' || $action=='globalsettings' || $action=='editusergroups' ||
$action=='surveyrights' || $action=='quotas' || $action=='editusers' || $action=='' || $action=='login') )
{
if ($action=='editsurvey' || $action=='updatesurvey')
{
Expand Down Expand Up @@ -558,6 +558,7 @@
if (isset($dumpdboutput)) {$adminoutput.= $dumpdboutput;}
if (isset($exportspssoutput)) {$adminoutput.= $exportspssoutput;}
if (isset($exportroutput)) {$adminoutput.= $exportroutput;}
if (isset($loginsummary)) {$adminoutput.= $loginsummary;}


if (!isset($printablesurveyoutput) && $subaction!='export' && (substr($action,0,4)!= 'ajax'))
Expand Down Expand Up @@ -617,7 +618,7 @@
{ //not logged in
sendcacheheaders();
if (!isset($_SESSION['metaHeader'])) {$_SESSION['metaHeader']='';}
$adminoutput = getAdminHeader($_SESSION['metaHeader']).$adminoutput; // All future output is written into this and then outputted at the end of file
$adminoutput = getAdminHeader($_SESSION['metaHeader']).$adminoutput.$loginsummary; // All future output is written into this and then outputted at the end of file
unset($_SESSION['metaHeader']);
$adminoutput.= "</div>\n".getAdminFooter("http://docs.limesurvey.org", $clang->gT("LimeSurvey Online Manual"));
}
Expand Down
151 changes: 147 additions & 4 deletions admin/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
$listsurveys .= "</tr>" ;
}

$listsurveys.="</tbody><tfoot><tr class='header'>
$listsurveys.="</tbody><tfoot><tr>
<td colspan=\"11\">&nbsp;</td>".
"</tr></tfoot>";
$listsurveys.="</table><br />" ;
Expand Down Expand Up @@ -1906,7 +1906,7 @@
$result = db_execute_assoc($query); //Checked
if($result->RecordCount() > 0 || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
{
$usersummary = "<table width='100%' border='0'>\n<tr><td colspan='6' class='header'>\n"
$usersummary = "<table width='100%' border='0'>\n<tr><td colspan='6'>\n"
. "".$clang->gT("Set Survey Rights")."</td></tr>\n";

$usersummary .= "<th align='center'>".$clang->gT("Edit Survey Property")."</th>\n"
Expand Down Expand Up @@ -2120,7 +2120,7 @@
. "<th align=\"center\"><img src=\"$imagefiles\\help.gif\" alt=\"".$clang->gT("Export")."\"></th>\n"
. "<th align=\"center\"><img src=\"$imagefiles\\help.gif\" alt=\"".$clang->gT("Delete Survey")."\"></th>\n"
. "<th align=\"center\"><img src=\"$imagefiles\\help.gif\" alt=\"".$clang->gT("Activate Survey")."\"></th>\n"
. "<th class=\"header\">".$clang->gT("Action")."</th>\n"
. "<th>".$clang->gT("Action")."</th>\n"
. "</tr></thead>\n";

if (isset($usercontrolSameGroupPolicy) &&
Expand Down Expand Up @@ -3550,4 +3550,147 @@ function replacenewline ($texttoreplace)

return $new_str;
}
?>


/**
* showadminmenu() function returns html text for the administration button bar
*
* @global string $homedir
* @global string $scriptname
* @global string $surveyid
* @global string $setfont
* @global string $imagefiles
* @return string $adminmenu
*/
function showadminmenu()
{
global $homedir, $scriptname, $surveyid, $setfont, $imagefiles, $clang, $debug, $action, $updateavailable, $updatebuild, $updateversion, $updatelastcheck;

$adminmenu = "<div class='menubar'>\n";
if ($_SESSION['pw_notify'] && $debug<2) {$adminmenu .="<div class='alert'>".$clang->gT("Warning: You are still using the default password ('password'). Please change your password and re-login again.")."</div>";}
$adminmenu .="<div class='menubar-title'>\n"
. "<div class='menubar-title-left'>\n"
. "<strong>".$clang->gT("Administration")."</strong>";
if(isset($_SESSION['loginID']))
{
$adminmenu .= " -- ".$clang->gT("Logged in as:"). " <strong>"
. "<a href=\"#\" onclick=\"window.open('$scriptname?action=personalsettings', '_top')\" title=\"".$clang->gTview("Edit your personal preferences")."\" >"
. $_SESSION['user']." <img src='$imagefiles/profile_edit.png' name='ProfileEdit' alt='".$clang->gT("Edit your personal preferences")."' /></a>"
. "</strong>\n";
}
$adminmenu .="</div>\n";
if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1 && isset($updatelastcheck) && $updatelastcheck>0 && isset($updateavailable) && $updateavailable==1)
{
$adminmenu .="<div class='menubar-title-right'><a href='$scriptname?action=globalsettings'>".sprintf($clang->gT('Update available: %s'),$updateversion."($updatebuild)").'</a></div>';
}
$adminmenu .= "</div>\n"
. "<div class='menubar-main'>\n"
. "<div class='menubar-left'>\n"
. "<a href=\"#\" onclick=\"window.open('$scriptname', '_top')\" title=\"".$clang->gTview("Default Administration Page")."\">"
. "<img src='$imagefiles/home.png' name='HomeButton' alt='".$clang->gT("Default Administration Page")."' /></a>\n";

$adminmenu .= "<img src='$imagefiles/blank.gif' alt='' width='11' />\n"
. "<img src='$imagefiles/seperator.gif' alt='' />\n";

// Edit users
$adminmenu .="<a href=\"#\" onclick=\"window.open('$scriptname?action=editusers', '_top')\" title=\"".$clang->gTview("Create/Edit Users")."\" >"
."<img src='$imagefiles/security.png' name='AdminSecurity' alt='".$clang->gT("Create/Edit Users")."' /></a>";

$adminmenu .="<a href=\"#\" onclick=\"window.open('$scriptname?action=editusergroups', '_top')\" title=\"".$clang->gTview("Create/Edit Groups")."\" >"
."<img src='$imagefiles/usergroup.png' alt='".$clang->gT("Create/Edit Groups")."' /></a>\n" ;

if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
{
$adminmenu .= "<a href=\"#\" onclick=\"window.open('$scriptname?action=globalsettings', '_top')\" title=\"".$clang->gTview("Global settings")."\" >"
. "<img src='$imagefiles/global.png' name='GlobalSettings' alt='". $clang->gT("Global settings")."' /></a>"
. "<img src='$imagefiles/seperator.gif' alt='' border='0' hspace='0' />\n";
}
// Check data integrity
if($_SESSION['USER_RIGHT_CONFIGURATOR'] == 1)
{
$adminmenu .= "<a href=\"#\" onclick=\"window.open('$scriptname?action=checkintegrity', '_top')\" title=\"".$clang->gTview("Check Data Integrity")."\">".
"<img src='$imagefiles/checkdb.png' name='CheckDataIntegrity' alt='".$clang->gT("Check Data Integrity")."' /></a>\n";
}
else
{
$adminmenu .= "<img src='$imagefiles/blank.gif' alt='' width='40' />\n";
}

// list surveys
$adminmenu .= "<a href=\"#\" onclick=\"window.open('$scriptname?action=listsurveys', '_top')\" title=\"".$clang->gTview("List Surveys")."\" >\n"
."<img src='$imagefiles/surveylist.png' name='ListSurveys' alt='".$clang->gT("List Surveys")."' onclick=\"window.open('$scriptname?action=listsurveys', '_top')\" />"
."</a>" ;

// db backup & label editor
if($_SESSION['USER_RIGHT_CONFIGURATOR'] == 1)
{
$adminmenu .= "<a href=\"#\" onclick=\"window.open('$scriptname?action=dumpdb', '_top')\" title=\"".$clang->gTview("Backup Entire Database")."\">\n"
."<img src='$imagefiles/backup.png' name='ExportDB' alt='". $clang->gT("Backup Entire Database")."' />"
."</a>\n"
."<img src='$imagefiles/seperator.gif' alt='' border='0' hspace='0' />\n";
}
else
{
$adminmenu .= "<img src='$imagefiles/blank.gif' alt='' width='40' />\n";
}
if($_SESSION['USER_RIGHT_MANAGE_LABEL'] == 1)
{
$adminmenu .= "<a href=\"#\" onclick=\"window.open('$scriptname?action=labels', '_top')\" title=\"".$clang->gTview("Edit label sets")."\">\n"
."<img src='$imagefiles/labels.png' name='LabelsEditor' alt='". $clang->gT("Edit label sets")."' /></a>\n"
."<img src='$imagefiles/seperator.gif' alt='' border='0' hspace='0' />\n";
}
else
{
$adminmenu .= "<img src='$imagefiles/blank.gif' alt='' width='40' />\n";
}
if($_SESSION['USER_RIGHT_MANAGE_TEMPLATE'] == 1)
{
$adminmenu .= "<a href=\"#\" onclick=\"window.open('$scriptname?action=templates', '_top')\" title=\"".$clang->gTview("Template Editor")."\" >"
."<img src='$imagefiles/templates.png' name='EditTemplates' title='' alt='". $clang->gT("Template Editor")."' /></a>\n";
}
// survey select box
$adminmenu .= "</div><div class='menubar-right'><span class=\"boxcaption\">".$clang->gT("Surveys").":</span>"
. "<select onchange=\"window.open(this.options[this.selectedIndex].value,'_top')\">\n"
. getsurveylist()
. "</select>\n";

if($_SESSION['USER_RIGHT_CREATE_SURVEY'] == 1)
{
$adminmenu .= "<a href=\"#\" onclick=\"window.open('$scriptname?action=newsurvey', '_top')\""
."title=\"".$clang->gTview("Create or Import New Survey")."\" >"
."<img src='$imagefiles/add.png' name='AddSurvey' title='' alt='". $clang->gT("Create or Import New Survey")."' /></a>\n";
}


if(isset($_SESSION['loginID'])) //ADDED to prevent errors by reading db while not logged in.
{
// Logout
$adminmenu .= "<img src='$imagefiles/seperator.gif' alt='' border='0' hspace='0' />"
. "<a href=\"#\" onclick=\"window.open('$scriptname?action=logout', '_top')\" title=\"".$clang->gTview("Logout")."\" >"
. "<img src='$imagefiles/logout.png' name='Logout' alt='".$clang->gT("Logout")."'/></a>";

//Show help
$adminmenu .= "<a href=\"http://docs.limesurvey.org\" target='_blank' title=\"".$clang->gTview("LimeSurvey Online manual")."\" >"
. "<img src='$imagefiles/showhelp.png' name='ShowHelp' alt='". $clang->gT("LimeSurvey Online manual")."'/></a>";

$adminmenu .= "</div>"
. "</div>\n"
. "</div>\n";
// $adminmenu .= "<p style='margin:0;font-size:1px;line-height:1px;height:1px;'>&nbsp;</p>"; //CSS Firefox 2 transition fix
if (!isset($action) && !isset($surveyid) && count(getsurveylist(true))==0)
{
$adminmenu.= '<div style="width:500px;margin:0 auto;">'
.'<h2>'.sprintf($clang->gT("Welcome to %s!"),'LimeSurvey').'</h2>'
.'<p>'.$clang->gT("Some piece-of-cake steps to create your very own first survey:").'<br/>'
.'<ol>'
.'<li>'.sprintf($clang->gT('Create a new survey clicking on the %s icon in the upper right.'),"<img src='$imagefiles/add_small.png' name='ShowHelp' title='' alt='". $clang->gT("Add survey")."'/>").'</li>'
.'<li>'.$clang->gT('Create a new group inside your survey.').'</li>'
.'<li>'.$clang->gT('Create one or more question inside the new group.').'</li>'
.'<li>'.sprintf($clang->gT('Done. Test your survey using the %s icon.'),"<img src='$imagefiles/do_small.png' name='ShowHelp' title='' alt='". $clang->gT("Test survey")."'/>").'</li>'
.'</ol></p><br />&nbsp;</div>';
}

}
return $adminmenu;
}

21 changes: 1 addition & 20 deletions admin/login_check.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@

if (!isset($logoutsummary))
{
$loginsummary = "<form name='loginform' id='loginform' method='post' action='$rooturl/admin/admin.php' ><br /><strong>".$clang->gT("You have to login first.")."</strong><br /> <br />";
$loginsummary = "<form name='loginform' id='loginform' method='post' action='$rooturl/admin/admin.php' ><p><strong>".$clang->gT("You have to login first.")."</strong><br /> <br />";
}
else
{
Expand Down Expand Up @@ -212,22 +212,3 @@
$loginsummary .= " </script>\n";
}
}

if (isset($loginsummary))
{
$adminoutput.= "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"
."\t<tr>\n"
."\t\t<td valign='top' align='center' bgcolor='#F8F8FF'>\n";

if(isset($_SESSION['loginID']))
{
$adminoutput.= showadminmenu();
}
$adminoutput.= $loginsummary;

$adminoutput.= "\t\t</td>\n";
$adminoutput.= "\t</tr>\n";
$adminoutput.= "</table>\n";
}

?>
2 changes: 1 addition & 1 deletion admin/scripts/admin_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $(document).ready(function(){
}, $.datepicker.regional[userlanguage]);
}

$('.header').addClass("ui-widget-header");
$('div.header').addClass("ui-widget-header");
$('.menubar-title').addClass("ui-widget-header");
$('button,input[type=submit],input[type=button],input[type=reset]').addClass("limebutton ui-state-default ui-corner-all");
$('button,input[type=submit],input[type=button],input[type=reset]').hover(
Expand Down
2 changes: 2 additions & 0 deletions admin/tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -1267,10 +1267,12 @@
if ( $modrewrite )
{
$fieldsarray["{SURVEYURL}"]="<a href='$publicurl/$surveyid/lang-".trim($emrow['language'])."/tk-{$emrow['token']}'>".htmlspecialchars("$publicurl/$surveyid/lang-".trim($emrow['language'])."/tk-{$emrow['token']}")."</a>";
$fieldsarray["@@SURVEYURL@@"]="$publicurl/$surveyid/lang-".trim($emrow['language'])."/tk-{$emrow['token']}";
}
else
{
$fieldsarray["{SURVEYURL}"]="<a href='$publicurl/index.php?lang=".trim($emrow['language'])."&sid=$surveyid&token={$emrow['token']}'>".htmlspecialchars("$publicurl/index.php?lang=".trim($emrow['language'])."&sid=$surveyid&token={$emrow['token']}")."</a>";
$fieldsarray["@@SURVEYURL@@"]="$publicurl/index.php?lang=".trim($emrow['language'])."&amp;sid=$surveyid&amp;token={$emrow['token']}";
}
}

Expand Down
42 changes: 37 additions & 5 deletions admin/update/upgrade-mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,12 @@ function db_upgrade($oldversion) {
modify_database("", "ALTER TABLE `prefix_questions` ADD `parent_qid` integer NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE `prefix_questions` ADD `default_value` text"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE `prefix_answers` ADD `scale_id` tinyint NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE `prefix_answers` DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(`qid`,`code`,`language`,`scale_id`)"); echo $modifyoutput; flush();

//-Move all 'answers' that are subquestions to the questions table
//-Move all 'labels' that are answers to the answers table
//-Transscript the default values where applicable
upgrade_answer_tables143();
upgrade_tables143();

modify_database("", "ALTER TABLE `prefix_questions` DROP COLUMN `default_value`"); echo $modifyoutput; flush();
modify_database("", "UPDATE `prefix_settings_global` SET `stg_value`='143' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
Expand Down Expand Up @@ -546,19 +547,50 @@ function upgrade_question_attributes142()
}
}

function upgrade_answer_tables143()
function upgrade_tables143()
{
global $modifyoutput,$dbprefix, $connect;
$answerquery = "select a.*,q.sid from {$dbprefix}answers a,{$dbprefix}questions q where a.qid=q.qid and q.type in ('1','A','B','C','E','F','H',';',':','P','Q')";

// Convert answers to subquestions
$answerquery = "select a.*, q.sid, q.gid from {$dbprefix}answers a,{$dbprefix}questions q where a.qid=q.qid and q.type in ('1','A','B','C','E','F','H',';',':','M','P','Q')";
$answerresult = db_execute_assoc($answerquery);
if (!$answerresult) {return "Database Error";}
else
{
while ( $row = $answerresult->FetchRow() )
{
modify_database("","INSERT INTO {$dbprefix}questions (sid, gid, parent_qid, title, question, question_order, language) VALUES ({$row['sid']},{$row['gid']},{$row['qid']},".db_quoteall($row['code']).",".db_quoteall($row['answer']).",{$row['sortorder']},".db_quoteall($row['language']).")"); echo $modifyoutput; flush();
}
}
modify_database("","delete {$dbprefix}answers from {$dbprefix}answers LEFT join {$dbprefix}questions ON {$dbprefix}answers.qid={$dbprefix}questions.qid where {$dbprefix}questions.type in ('1','A','B','C','E','F','H',';',':')"); echo $modifyoutput; flush();

// Convert labels to answers
$answerquery = "select qid ,type ,lid ,lid1, language from {$dbprefix}questions where parent_qid=0 and type in ('1','F','H','M','P',';',':','W','Z')";
$answerresult = db_execute_assoc($answerquery);
if (!$answerresult)
{
return "Database Error";
}
else
{
while ( $row = $answerresult->FetchRow() )
{
$labelquery="Select * from {$dbprefix}labels where lid={$row['lid']} and language=".db_quoteall($row['language']);
$labelresult = db_execute_assoc($labelquery);
while ( $lrow = $labelresult->FetchRow() )
{
modify_database("","INSERT INTO {$dbprefix}questions (sid,gid,parent_qid,title,question,question_order,language) VALUES ({$row['sid']},{$row['gid']},{$row['qid']},".db_quoteall($row['code']).",".db_quoteall($row['answer']).",{$row['sortorder']},".db_quoteall($row['language']).")"); echo $modifyoutput; flush();
modify_database("","INSERT INTO {$dbprefix}answers (qid, code, answer, sortorder, language) VALUES ({$row['qid']},".db_quoteall($lrow['code']).",".db_quoteall($lrow['title']).",{$lrow['sortorder']},".db_quoteall($lrow['language']).")"); echo $modifyoutput; flush();
}
if ($row['type']=='1')
{
$labelquery="Select * from {$dbprefix}labels where lid={$row['lid1']} and language=".db_quoteall($row['language']);
$labelresult = db_execute_assoc($labelquery);
while ( $lrow = $labelresult->FetchRow() )
{
modify_database("","INSERT INTO {$dbprefix}answers (qid, code, answer, sortorder, language, scale_id) VALUES ({$row['qid']},".db_quoteall($lrow['code']).",".db_quoteall($lrow['title']).",{$lrow['sortorder']},".db_quoteall($lrow['language']).",1)"); echo $modifyoutput; flush();
}
}
}
modify_database("","delete {$dbprefix}answers from {$dbprefix}answers LEFT join {$dbprefix}questions ON {$dbprefix}answers.qid={$dbprefix}questions.qid where {$dbprefix}questions.type in ('1','A','B','C','E','F','H',';',':')"); echo $modifyoutput; flush();
}

}

0 comments on commit 7b4c78b

Please sign in to comment.