我有一个树登录页面作为我在调查中的第一页。问题是,如果用户没有选择任何节点并单击下一步按钮,他将被重定向到同一页面。问题是他没有收到任何错误信息。
我希望用户收到一条错误消息“请选择一个组”请查看以下执行此操作的代码
(PS 检查 Display() 函数)
纠正我哪里出错了
<?php
/**
* File: TreeLoginWidget.php
*
*
* Purpose: display tree page.
*
* Dependents: none
*
* Dependencies: SurveyItem
*
* Classes:
* 1. PinWidget
*
* Interface/public functions:
*
* Notes: ???
*
* Todo: none
*
**/
class DisplayTreeLoginWidget extends DisplayItem
{
function DisplayTreeLoginWidget(& $sourceObj)
{
// debug
if( $pDebugTraceFlag == _ID_FLAG_ON ) GDebugTraceFunc( __CLASS__." :: ".__FUNCTION__ );
$this->node = 0;
$surveywidget = getDataFromSession("surveywidget");
DisplayItem::DisplayItem();
$_SESSION["profile"]["rootNode"]=0;
if($_GET["nodeId"]) {
setDataToSession("postVar","");
}
$this->sourceObj =& $sourceObj;
}
/**
* Purpose: display pin page label text
*
* Input Params: none
*
* Output Params: none
*
* Return Value: none
*
* Notes:
*/
function display()
{
global $skin_path,$skin,$path;
setDataToSession("skipPage", 0);
setDataToSession('HideSave&Resume',0);
$currentPageNumber = currentPageNumber();
if($currentPageNumber!=1) {
setDataToSession('HideSave&Resume',1);
}
echo "<script type=\"text/javascript\" src=\"".$path."../lib/java/commonFuncs.js\"></script>";
// include the header
include_once ("../lib/include/path.inc.php");
include_once ("../lib/include/jshelper.php");
include_once("display/tree.inc.php");
include_once("display/commonTreeLayout.php");
include_once ("../lib/include/commonTreeCode.php");
setUpTreeAppProperty();
$postVar = getDataFromSession("postVar");
if(is_array($postVar)) {
$_POST = $postVar;
}
if($this->sourceObj->displayType == "expanded") {
$postVar["Expand_All"] = "Expand All";
$this->sourceObj->displayType = "";
}
if($this->sourceObj->levelShowing != "") {
setDataToSession("levelShowing",$this->sourceObj->levelShowing);
}
setUpElist($postVar, $_GET);
$verifiedStartingNode = getTreeStartingNode();
/** $matchedIdArr contains matched nodeIds or empty if no matches found/no search performed */
$matchedIdArr = doSearch($verifiedStartingNode, $postVar);
$eList = getEList();
$Tree = new TreeWithRadioButton($this->sourceObj);
$Tree->reSetupElist();
$startingNode = &$Tree->nodesArr[$verifiedStartingNode];
echo "<div class=\"body2 IE6trans\">";
displaySearchTable();
if(!$postVar["searchSubmit"]) {
$matchedIdArr = array(getDataFromSession("data,node_id"));
}
displayTree('Search Organization Structure', '', '', $startingNode, $eList, $matchedIdArr, $maxDepth, get_path_prefix(),$this->sourceObj->_errorMsg,$this->sourceObj->_prompt);
echo "<script type=\"text/javascript\">";
echo "$(document).ready(function () { $('input[name=\"wildText\"]').keyup(function(event){ if(event.keyCode == 13){ $('input[name=\"searchSubmit\"]').click(); } }); });";
echo "</script>";
echo "</div>";
}
/**
* Purpose: storing error message to _errorMsg
*
* Input Params: none
*
* Output Params: none
*
* Return Value: Boolean - true or false
*
* Notes:
*/
function validate()
{
// debug
if( $pDebugTraceFlag == _ID_FLAG_ON ) GDebugTraceFunc( __CLASS__." :: ".__FUNCTION__ );
$surveywidget = getDataFromSession('surveywidget');
$this->getPostData();
$this->sourceObj->_errorMsg = "";
$lastVisitedWidgetOid_Tree = getDataFromSession("lastVisitedWidgetOid_Tree");
setDataToSession("lastVisitedWidgetOid" , $lastVisitedWidgetOid_Tree);
setLoginUserLanguage($this->node);
$operations = ((strcmp($this->operation,getText2($surveywidget->saveResumeButtonText)) == 0)||
(strcmp($this->operation,getText2($surveywidget->backButtonText)) == 0)||
(strcmp($this->operation,getText2($surveywidget->nextButtonText)) == 0));
if(($operations) && ($this->node != "")) {
setDataToSession("data,node_id",$this->node);
// used to track the node id assigned to this pin when more than one login is used
setDataToSession("tree_login,node_id",$this->node);
setDataToSession("tree_login_before_saveresume,node_id",$this->node);
//Custom -
$oids = getListOfOidAndNodes(Array($this->node));
$_SESSION["conditionNodeList"] = $oids;
//End Custom
if(!getDataFromSession('multiLoginIndex')) {
$multiLoginIndex = 1;
} else {
$multiLoginIndex = getDataFromSession('multiLoginIndex');
}
$multiLoginIndex++;
setDataToSession("multiLoginIndex",$multiLoginIndex);
$this->sourceObj->_errorMsg = "";
} else if(($operations) && ($this->node == "")){
$this->sourceObj->_errorMsg = "Please select a group";
return false;
} else {
return false;
}
if($this->node == "") {
$this->node = 0;
}
// user click save&resume before visiting login page, we are redirecting to login page, That time user enter invalid node_id we are mainting save&resume flag to 1 for displaying submitbutton(it act like as save&resume)
if(getDataFromSession('save&resumeflag') == 1) {
setDataToSession('save&resumeloginpage',1);
}
return true;
}
/**
* Purpose: get post data
*
* Input Params: none
*
* Output Params: none
*
* Return Value: none
*
* Notes:
*/
function getPostData()
{
// debug
if( $pDebugTraceFlag == _ID_FLAG_ON ) GDebugTraceFunc( __CLASS__." :: ".__FUNCTION__ );
$postVar["exactText"] = (empty($_REQUEST["exactText"])==1) ?"" :stripslashes($_REQUEST["exactText"]);
$postVar["wildText"] = (empty($_REQUEST["wildText"])==1) ?"" :stripslashes($_REQUEST["wildText"]);
$postVar["searchSubmit"] = (empty($_REQUEST["searchSubmit"])==1) ?"" :$_REQUEST["searchSubmit"];
$postVar["Collapse_All"] = (empty($_REQUEST["Collapse_All"])==1) ?"" :$_REQUEST["Collapse_All"];
$postVar["idText"] = (empty($_REQUEST["idText"])==1) ?"" :$_REQUEST["idText"];
$postVar["node"] = (empty($_REQUEST["node"])==1) ?"" :$_REQUEST["node"];
$this->node = ($_REQUEST["node"] == "") ?"" :$_REQUEST["node"];
$this->operation = (empty($_REQUEST["Operation"])==1) ?"" :$_REQUEST["Operation"];
if($postVar["Collapse_All"]) {
$postVar["wildText"] = "";
}
setDataToSession('postVar',$postVar);
setDataToSession('Operation',$this->operation);
setDataToSession('node',$this->node);
}
}
?>