From 069496024103fc605d0ae089d9dc54993807f15c Mon Sep 17 00:00:00 2001 From: Menno Dekker Date: Wed, 1 Sep 2010 11:31:12 +0000 Subject: [PATCH] dev: combined newsurvey and edit screen, defaults are more clear to see now and both screens have all the options (some where missing from the newsurvey screen) git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@9098 b72ed6b6-b9f8-46b5-92b4-906544132732 --- admin/html.php | 1846 ++++++++++++++++++++++-------------------------- 1 file changed, 841 insertions(+), 1005 deletions(-) diff --git a/admin/html.php b/admin/html.php index b3e5e67a1b8..59661a86901 100644 --- a/admin/html.php +++ b/admin/html.php @@ -2510,47 +2510,179 @@ // Editing the survey -if ($action == "editsurveysettings") +if ($action == "editsurveysettings" || $action == "newsurvey") { - if(bHasRight($surveyid,'edit_survey_property')) + if (($action == "newsurvey" && !$_SESSION['USER_RIGHT_CREATE_SURVEY']) || + ($action == "editsurveysettings" && !bHasRight($surveyid,'edit_survey_property'))) { - $js_admin_includes[]='scripts/surveysettings.js'; - $esquery = "SELECT * FROM {$dbprefix}surveys WHERE sid=$surveyid"; - $esresult = db_execute_assoc($esquery); //Checked - while ($esrow = $esresult->FetchRow()) - { - $esrow = array_map('htmlspecialchars', $esrow); + include("access_denied.php"); + } + else + { + $js_admin_includes[] = 'scripts/surveysettings.js'; + + if ($action == "newsurvey") { + //New survey, set the defaults + $esrow = array(); + $esrow['active'] = 'N'; + $esrow['format'] = 'G'; //Group-by-group mode + $esrow['template'] = $defaulttemplate; + $esrow['allowsave'] = 'Y'; + $esrow['allowprev'] = 'N'; + $esrow['printanswers'] = 'N'; + $esrow['publicstatistics'] = 'N'; + $esrow['publicgraphs'] = 'N'; + $esrow['public'] = 'Y'; + $esrow['autoredirect'] = 'N'; + $esrow['tokenlength'] = 15; + $esrow['allowregister'] = 'N'; + $esrow['usecookie'] = 'N'; + $esrow['usecaptcha'] = 'D'; + $esrow['htmlemail'] = 'Y'; + $esrow['notification'] = 0; //No notification + $esrow['private'] = 'Y'; + $esrow['datestamp'] = 'N'; + $esrow['ipaddr'] = 'N'; + $esrow['refurl'] = 'N'; + $esrow['tokenanswerspersistence'] = 'N'; + $esrow['assesments'] = 'N'; + $esrow['startdate'] = ''; + $esrow['expires'] = ''; + $esrow['showwelcome'] = 'Y'; + $esrow['emailresponseto'] = ''; + $esrow['assessments'] = 'Y'; + + $dateformatdetails=getDateFormatData($_SESSION['dateformat']); + + $editsurvey = PrepareEditorScript(); + + $editsurvey .="\n"; // header - $editsurvey = "
".$clang->gT("Edit survey settings")."
\n"; + $editsurvey .= "
" . $clang->gT("Create, import or copy survey") . "
\n"; + } elseif ($action == "editsurveysettings") { + //Fetch survey info + $esquery = "SELECT * FROM {$dbprefix}surveys WHERE sid=$surveyid"; + $esresult = db_execute_assoc($esquery); //Checked + while ($esrow = $esresult->FetchRow()) { + $esrow = array_map('htmlspecialchars', $esrow); + } + + // header + $editsurvey = "
" . $clang->gT("Edit survey settings") . "
\n"; + } + + // beginning TABs section - create tab pane + if ($action == "newsurvey") { + $editsurvey .= "
\n"; + $editsurvey .= "
gT("Error: You have to enter a title for this survey.", 'js') . "');\" >\n"; - // beginning TABs section - create tab pane + // General & Contact TAB + $editsurvey .= "

" . $clang->gT("General") . "

\n"; + + // Survey Language + $editsurvey .= "
  • \n" + . "\n"; + + //Use the current user details for the default administrator name and email for this survey + $query = "SELECT full_name, email FROM " . db_table_name('users') . " WHERE users_name = " . db_quoteall($_SESSION['user']); + $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg()); + $owner = $result->FetchRow(); + //Degrade gracefully to $siteadmin details if anything is missing. + if (empty($owner['full_name'])) + $owner['full_name'] = $siteadminname; + if (empty($owner['email'])) + $owner['email'] = $siteadminemail; + + $editsurvey .= " " . $clang->gT("*This setting cannot be changed later!") . "
  • \n"; + + $editsurvey .= "" + . "
  • \n" + . " " . $clang->gT("*Required") . "
  • \n" + . "
  • \n" + . "" + . getEditor("survey-desc", "description", "[" . $clang->gT("Description:", "js") . "]", '', '', '', $action) + . "
  • \n" + . "
  • \n" + . "" + . getEditor("survey-welc", "welcome", "[" . $clang->gT("Welcome message:", "js") . "]", '', '', '', $action) + . "
  • \n" + . "
  • \n" + . "" + . getEditor("survey-endtext", "endtext", "[" . $clang->gT("End message:", "js") . "]", '', '', '', $action) + . "
  • \n"; + + // End URL + $editsurvey .= "
  • \n" + . "
  • \n"; + + // URL description + $editsurvey.= "
  • \n" + . "
  • \n" + + //Default date format + . "
  • \n" + . "
  • " + + . "
  • \n" + . "
  • \n" + . "
  • \n" + . "
  • \n" + . "
  • \n" + . "
  • \n" + . "
  • \n" + . "
  • \n"; + + $editsurvey.= "
"; + + + // End General TAB + $editsurvey .= "
\n"; + } elseif ($action == "editsurveysettings") { $editsurvey .= "
\n"; - $editsurvey .= "\n"; + $editsurvey .= "gT("Error: You have to enter a title for this survey.", 'js') . "');\" >\n"; + // General & Contact TAB - $editsurvey .= "

".$clang->gT("General")."

    \n"; + $editsurvey .= "

    " . $clang->gT("General") . "

    \n"; // Base Language - $editsurvey .= "
  • \n" - .GetLanguageNameFromCode($esrow['language']) - . "
  • \n" - - // Additional languages listbox - . "
  • \n" - . "
    \n"; - } - else - { - $editsurvey .= "\n"; - } - $editsurvey .= "\n"; + if ($esrow['usecaptcha'] == "N") { + $editsurvey .= " selected='selected'"; + } + $editsurvey .= ">------------- / ------------ / ---------\n" + . "\n\n"; - // date stamp - $editsurvey .= "
  • \n"; - if ($esrow['active'] == "Y") - { - $editsurvey .= "\n"; - if ($esrow['datestamp'] != "Y") {$editsurvey .= " ".$clang->gT("Responses will not be date stamped.");} - else {$editsurvey .= $clang->gT("Responses will be date stamped.");} - $editsurvey .= " (".$clang->gT("Cannot be changed").")\n" - . "\n"; - $editsurvey .= "\n"; - } - else - { - $editsurvey .= "gT("If you switch email mode, you'll have to review your email templates to fit the new format", "js") . "');\">\n" . "\n" + if ($esrow['htmlemail'] == "Y") { + $editsurvey .= " selected='selected'"; + } + $editsurvey .= ">" . $clang->gT("Yes") . "\n" . "\n" - . "\n"; + if ($esrow['htmlemail'] == "N") { + $editsurvey .= " selected='selected'"; + } + + $editsurvey .= ">" . $clang->gT("No") . "\n" + . "
  • \n"; + + // End Publication and access control TAB + $editsurvey .= "\n"; + + // Notification and Data management TAB + $editsurvey .= "

    " . $clang->gT("Notification & Data Management") . "

      \n"; + + + //NOTIFICATION + $editsurvey .= "
    • \n" + . "\n" + . "
    • \n"; + + //EMAIL SURVEY RESPONSES TO + $editsurvey .= "
    • \n" + . "\n" + . "
    • \n"; + + //ANONYMOUS + $editsurvey .= "
    • \n"; + + if ($esrow['active'] == "Y") { + $editsurvey .= "\n"; + if ($esrow['private'] == "N") { + $editsurvey .= " " . $clang->gT("This survey is NOT anonymous."); + } else { + $editsurvey .= $clang->gT("Answers to this survey are anonymized."); } - $editsurvey .= "
    • \n"; + $editsurvey .= " (" . $clang->gT("Cannot be changed") . ")\n" + . "\n"; + $editsurvey .= "\n"; + } else { + $editsurvey .= "\n"; + } + $editsurvey .= "\n"; + + // date stamp + $editsurvey .= "
    • \n"; + if ($esrow['active'] == "Y") { + $editsurvey .= "\n"; + if ($esrow['datestamp'] != "Y") { + $editsurvey .= " " . $clang->gT("Responses will not be date stamped."); + } else { + $editsurvey .= $clang->gT("Responses will be date stamped."); + } + $editsurvey .= " (" . $clang->gT("Cannot be changed") . ")\n" + . "\n"; + $editsurvey .= "\n"; + } else { + $editsurvey .= "\n"; + } + $editsurvey .= "
    • \n"; - // Ip Addr - $editsurvey .= "
    • \n"; + // Ip Addr + $editsurvey .= "
    • \n"; - if ($esrow['active'] == "Y") - { - $editsurvey .= "\n"; - if ($esrow['ipaddr'] != "Y") {$editsurvey .= " ".$clang->gT("Responses will not have the IP address logged.");} - else {$editsurvey .= $clang->gT("Responses will have the IP address logged");} - $editsurvey .= " (".$clang->gT("Cannot be changed").")\n" - . "\n"; - $editsurvey .= "\n"; + if ($esrow['active'] == "Y") { + $editsurvey .= "\n"; + if ($esrow['ipaddr'] != "Y") { + $editsurvey .= " " . $clang->gT("Responses will not have the IP address logged."); + } else { + $editsurvey .= $clang->gT("Responses will have the IP address logged"); } - else - { - $editsurvey .= "\n"; + $editsurvey .= " (" . $clang->gT("Cannot be changed") . ")\n" + . "\n"; + $editsurvey .= "\n"; + } else { + $editsurvey .= "\n"; + } - $editsurvey .= "
    • \n"; + $editsurvey .= "\n"; - // begin REF URL Block - $editsurvey .= "
    • \n"; + // begin REF URL Block + $editsurvey .= "
    • \n"; - if ($esrow['active'] == "Y") - { - $editsurvey .= "\n"; - if ($esrow['refurl'] != "Y") {$editsurvey .= " ".$clang->gT("Responses will not have their referring URL logged.");} - else {$editsurvey .= $clang->gT("Responses will have their referring URL logged.");} - $editsurvey .= " (".$clang->gT("Cannot be changed").")\n" - . "\n"; - $editsurvey .= "\n"; + if ($esrow['active'] == "Y") { + $editsurvey .= "\n"; + if ($esrow['refurl'] != "Y") { + $editsurvey .= " " . $clang->gT("Responses will not have their referring URL logged."); + } else { + $editsurvey .= $clang->gT("Responses will have their referring URL logged."); } - else - { - $editsurvey .= "\n"; + } else { + $editsurvey .= "\n"; + } + $editsurvey .= "
    • \n"; + // BENBUN - END REF URL Block + // Token answers persistence + $editsurvey .= "
    • \n" + . "\n"; - } - $editsurvey .= "
    • \n"; - // BENBUN - END REF URL Block - - // Token answers persistence - $editsurvey .= "
    • \n" - . "
    • \n"; - - // Enable assessments - $editsurvey .= "
    • \n" - . "
    • \n"; - - - - // End Notification and Data management TAB - $editsurvey .= "
    \n"; - - // Ending First TABs Form - $editsurvey .= "" - . "\n" - . "\n" - . "\n" - . "\n" - .""; + if ($esrow['tokenanswerspersistence'] == "N") { + $editsurvey .= " selected='selected'"; + } + $editsurvey .= ">" . $clang->gT("No") . "\n" + . "\n"; + // Enable assessments + $editsurvey .= "
  • \n" + . "
  • \n"; - // TAB Uploaded Resources Management + // End Notification and Data management TAB + $editsurvey .= "\n"; + + // Ending First TABs Form + if ($action == "newsurvey") { + $editsurvey .= "\n"; + } elseif ($action == "editsurveysettings") { + $editsurvey .= "\n" + ."\n" + . "\n" + . "\n"; + } + $editsurvey .= ""; + + if ($action == "newsurvey" ) { + // Import TAB + $editsurvey .= "

    " . $clang->gT("Import survey") . "

    \n"; + + // Import Survey + $editsurvey .= "
    \n" + . "
      \n" + . "
    • \n" + . "
    • \n" + . "
    • \n" + . "
    \n" + . "

    \n" + . "

    \n"; + + // End Import TAB + $editsurvey .= "
    \n"; - $ZIPimportAction = " onclick='if (validatefilename(this.form,\"".$clang->gT('Please select a file to import!','js')."\")) {this.form.submit();}'"; - if (!function_exists("zip_open")) - { - $ZIPimportAction = " onclick='alert(\"".$clang->gT("zip library not supported by PHP, Import ZIP Disabled","js")."\");'"; + // Copy survey TAB + $editsurvey .= "

    " . $clang->gT("Copy survey") . "

    \n"; + + // Copy survey + $editsurvey .= "
    \n" + . "
      \n" + . "
    • \n" + . " " . $clang->gT("*Required") . "
    • \n" + . "
    • \n" + . "" + . "" . $clang->gT("*Required") . "
    • \n" + . "
    • \n" + . "
    • \n" + . "
    • \n" + . "
    • \n" + . "
    • \n" + . "
    • \n" + . "
    • \n" + . "
    \n" + . "

    \n" + . "

    \n"; + + // End Copy survey TAB + $editsurvey .= "
    \n"; + } elseif ($action = "editsurveysettings") { + // TAB Uploaded Resources Management + $ZIPimportAction = " onclick='if (validatefilename(this.form,\"" . $clang->gT('Please select a file to import!', 'js') . "\")) {this.form.submit();}'"; + if (!function_exists("zip_open")) { + $ZIPimportAction = " onclick='alert(\"" . $clang->gT("zip library not supported by PHP, Import ZIP Disabled", "js") . "\");'"; } $disabledIfNoResources = ''; - if (hasResources($surveyid,'survey') === false) - { + if (hasResources($surveyid, 'survey') === false) { $disabledIfNoResources = " disabled='disabled'"; } - $editsurvey .= "

    ".$clang->gT("Uploaded Resources Management")."

    \n" - . "
    \n" - . "\n" - . "\n" - . "
      \n" - . "
    • \n" - . "gT("Browse Uploaded Resources")."\" $disabledIfNoResources />
    • \n" - . "
    • \n" - . "gT("Export Resources As ZIP Archive")."\" $disabledIfNoResources />
    • \n" - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    \n"; + $editsurvey .= "

    " . $clang->gT("Uploaded Resources Management") . "

    \n" + . "
    \n" + . "\n" + . "\n" + . "
      \n" + . "
    • \n" + . "gT("Browse Uploaded Resources") . "\" $disabledIfNoResources />
    • \n" + . "
    • \n" + . "gT("Export Resources As ZIP Archive") . "\" $disabledIfNoResources />
    • \n" + . "
    • \n" + . "
    • \n" + . "
    • \n" + . "
    • \n" + . "
    \n"; // End TAB Uploaded Resources Management $editsurvey .= "
    \n"; + } - // End TAB pane - $editsurvey .= "
    \n"; - + // End TAB pane + $editsurvey .= "\n"; - // The external button to sumbit Survey edit changes - $editsurvey .= "

    \n"; - $editsurvey .= "

    \n"; + // The external button to sumbit Survey edit changes + if ($action == "newsurvey") { + $cond = "if (isEmpty(document.getElementById(\"surveyls_title\"), \"" . $clang->gT("Error: You have to enter a title for this survey.", 'js') . "\"))"; + $editsurvey .= "

    \n"; + } elseif ($action == "editsurveysettings") { + $cond = "if (UpdateLanguageIDs(mylangs,\"" . $clang->gT("All questions, answers, etc for removed languages will be lost. Are you sure?", "js") . "\"))"; + $editsurvey .= "

    \n"; + $editsurvey .= "

    \n"; } - } - else - { - include("access_denied.php"); - } - } if ($action == "updatesurveysettingsandeditlocalesettings" || $action == "editsurveylocalesettings") // Edit survey step 2 - editing language dependent settings @@ -3297,392 +3522,6 @@ include("quota.php"); } -// Show the screen to order groups - -if ($action == "newsurvey") -{ - if($_SESSION['USER_RIGHT_CREATE_SURVEY']) - { - $js_admin_includes[]='scripts/surveysettings.js'; - $dateformatdetails=getDateFormatData($_SESSION['dateformat']); - - $newsurvey = PrepareEditorScript(); - - // header - $newsurvey .= "
    " - . "".$clang->gT("Create, import or copy survey")."
    \n"; - - $newsurvey .="\n"; - - // begin Tabs section - $newsurvey .= "
    \n"; - $newsurvey .= "
    gT("Error: You have to enter a title for this survey.",'js')."');\" >\n"; - - // General and Contact TAB - $newsurvey .= "

    ".$clang->gT("General")."

    \n"; - - // * Survey Language - $newsurvey .= "
    • \n" - . " ".$clang->gT("*This setting cannot be changed later!")."
    • \n"; - - $newsurvey .= "" - . "
    • \n" - . " ".$clang->gT("*Required")."
    • \n" - . "
    • \n" - . "" - . getEditor("survey-desc","description", "[".$clang->gT("Description:", "js")."]",'','','',$action) - . "
    • \n" - . "
    • \n" - . "" - . getEditor("survey-welc","welcome", "[".$clang->gT("Welcome message:", "js")."]",'','','',$action) - . "
    • \n" - . "
    • \n" - . "" - . getEditor("survey-endtext","endtext", "[".$clang->gT("End message:", "js")."]",'','','',$action) - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    • \n"; - $newsurvey .= "
    • \n" - . "
    \n"; - - // End General TAB - // Create Survey Button - $newsurvey .= "

    gT("Error: You have to enter a title for this survey.",'js')."')) { document.getElementById('addnewsurvey').submit(); }; return false;\" value='".$clang->gT("Save survey")."' />

    \n"; - - $newsurvey .= "
    \n"; - - // Presentation and navigation TAB - $newsurvey .= "

    ".$clang->gT("Presentation & Navigation")."

    \n"; - - - $newsurvey .= "
    • \n" - . "\n" - . "
    • \n"; - $newsurvey .= "
    • \n" - . "\n" - . "\n" - . "\n" - . "
    • \n"; - - //ALLOW PREV - $newsurvey .= "
    • \n" - . "
    • \n"; - - //Result printing - $newsurvey .= "
    • \n" - . "
    • \n"; - - //Public statistics - $newsurvey .= "
    • \n" - . "
    • \n"; - - //Public statistics graphs - $newsurvey .= "
    • \n" - . "
    • \n"; - - //List survey publicly - $newsurvey .= "
    • \n" - . "
    • \n"; - - // End URL - $newsurvey .= "
    • \n" - . "
    • \n"; - - // URL description - $newsurvey.= "
    • \n" - . "gT("Automatically load URL when survey complete?")."\n" - . "
    • " - - //Default date format - . "
    • \n" - . "
    "; - - - // End Presention and navigation TAB - // Create Survey Button - $newsurvey .= "

    gT("Error: You have to enter a title for this survey.",'js')."')) { document.getElementById('addnewsurvey').submit(); }; return false;\" value='".$clang->gT("Save survey")."' />

    \n"; - $newsurvey .= "
    \n"; - - // Publication and access control TAB - $newsurvey .= "

    ".$clang->gT("Publication & Access control")."

      \n"; - - - // Use tokens - /* $newsurvey .= "
    • \n" - . "
    • \n"; */ - - // Set token length - $newsurvey .= "
    • \n" - . "" - . "
    • \n"; - - // Public registration - $newsurvey .= "
    • \n" - . "
    • \n"; - - // Timed Start - $newsurvey .= "
    • \n" - . "" - . " ".sprintf($clang->gT("Date format: %s"), $dateformatdetails['dateformat'].' hh:nn')."
    • \n"; - - // Expiration - $newsurvey .= "
    • \n" - . "" - . " ".sprintf($clang->gT("Date format: %s"), $dateformatdetails['dateformat'].' hh:nn')."
    • \n"; - - //COOKIES - $newsurvey .= "
    • \n" - . "
    • \n"; - - - // Use Captcha - $newsurvey .= "
    • \n" - . "
    • \n"; - - // Email format - $newsurvey .= "
    • \n" - . "
    \n"; - - // End Publication and access control TAB - // Create Survey Button - $newsurvey .= "

    gT("Error: You have to enter a title for this survey.",'js')."')) { document.getElementById('addnewsurvey').submit(); }; return false;\" value='".$clang->gT("Save survey")."' />

    \n"; - $newsurvey .= "
    \n"; - - // Notification and Data management TAB - $newsurvey .= "

    ".$clang->gT("Notification & Data Management")."

      \n"; - - //NOTIFICATIONS - $newsurvey .= "
    • \n" - . "
    • \n"; - - //EMAIL SURVEY RESPONSES TO - $newsurvey .= "
    • \n" - . "\n" - . "
    • \n"; - - // ANONYMOUS - $newsurvey .= "
    • \n"; - $newsurvey .= "
    • \n"; - - // Datestamp - $newsurvey .= "
    • \n" - . "
    • \n"; - - // IP Address - $newsurvey .= "
    • \n" - . "
    • \n"; - - // Referring URL - $newsurvey .= "
    • \n" - . "
    • \n"; - - // Token answers persistence - $newsurvey .= "
    • \n" - . "
    • \n"; - - // enable assessment mote - $newsurvey .= "
    • \n" - . "
    \n"; - - - // end of addnewsurvey form - $newsurvey .= "\n"; - - // End Notification and Data management TAB - // Create Survey Button - $newsurvey .= "

    gT("Error: You have to enter a title for this survey.",'js')."')) { document.getElementById('addnewsurvey').submit(); }; return false;\" value='".$clang->gT("Save survey")."' />

    \n"; - $newsurvey .= "
    \n"; - $newsurvey .= "
    \n"; - - // Import TAB - $newsurvey .= "

    ".$clang->gT("Import survey")."

    \n"; - - // Import Survey - $newsurvey .= "
    \n" - . "
      \n" - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    \n" - . "

    \n" - . "

    \n"; - - // End Import TAB - $newsurvey .= "
    \n"; - - // Copy survey TAB - $newsurvey .= "

    ".$clang->gT("Copy survey")."

    \n"; - - // Copy survey - $newsurvey .= "
    \n" - . "
      \n" - . "
    • \n" - . " ".$clang->gT("*Required")."
    • \n" - . "
    • \n" - . "" - . "".$clang->gT("*Required")."
    • \n" - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    • \n" - . "
    \n" - . "

    \n" - . "

    \n"; - - // End Copy survey TAB - $newsurvey .= "
    \n"; - - // End TAB pane - $newsurvey .= "
    \n"; - - } - else - { - include("access_denied.php"); - } -} - - function replacenewline ($texttoreplace) { $texttoreplace = str_replace( "\n", '
    ', $texttoreplace); @@ -3696,7 +3535,6 @@ function replacenewline ($texttoreplace) return $new_str; } - /** * showadminmenu() function returns html text for the administration button bar * @@ -3837,6 +3675,4 @@ function showadminmenu() } return $adminmenu; -} - - +} \ No newline at end of file