本文整理汇总了PHP中DataValidator::validate_node_id方法的典型用法代码示例。如果您正苦于以下问题:PHP DataValidator::validate_node_id方法的具体用法?PHP DataValidator::validate_node_id怎么用?PHP DataValidator::validate_node_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataValidator
的用法示例。
在下文中一共展示了DataValidator::validate_node_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*
* @param Node $n The node for which calculate the previous and next node link
* @param array $params
*/
public function __construct(Node $n, $params = array())
{
$this->_currentNode = $n->id;
$prevId = DataValidator::validate_node_id($params['prevId']);
if ($prevId !== false) {
$this->_previousNode = $prevId;
} else {
$this->findPreviousNode($n, $params['userLevel']);
}
$nextId = DataValidator::validate_node_id($params['nextId']);
if ($nextId !== false) {
$this->_nextNode = $nextId;
} else {
$this->findNextNode($n, $params['userLevel']);
}
/**
* @author giorgio 08/ott/2013
* check if this is a node wich has been generated when creating a test.
* If it is, next node is the first topic of the test.
* BUT, I'll pass the computed $this->_nextNode to give a callBack point
* to be used when user is in the last topic of the test.
*/
if (MODULES_TEST && strpos($n->type, (string) constant('ADA_PERSONAL_EXERCISE_TYPE')) === 0) {
if (isset($GLOBALS['dh'])) {
$GLOBALS['dh']->disconnect();
}
$test_db = AMATestDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester']));
$res = $test_db->test_getNodes(array('id_nodo_riferimento' => $n->id));
if (!empty($res) && count($res) == 1 && !AMA_DataHandler::isError($res)) {
$node = array_shift($res);
$this->_nextTestNode = $node['id_nodo'];
}
/**
* @author giorgio 06/nov/2013
* must check if computed $this->_previousNode points to a test
* and get last topic if it does.
*/
if (!is_null($this->_previousNode)) {
$res = $test_db->test_getNodes(array('id_nodo_riferimento' => $this->_previousNode));
} else {
$res = array();
}
if (!empty($res) && count($res) == 1 && !AMA_DataHandler::isError($res)) {
$node = array_shift($res);
$test = NodeTest::readTest($node['id_nodo'], $test_db);
$this->_prevTestTopic = count($test->_children);
$this->_prevTestNode = $node['id_nodo'];
}
$test_db->disconnect();
}
}
示例2: read_node_from_DB
/**
* Reads a ADA node from database.
*
* @param string $id_node - a valid ADA node identifier. e.g. '1_0'
* @return a Node object on success, on failure raises a ADA_Error.
*/
function read_node_from_DB($id_node)
{
if (DataValidator::validate_node_id($id_node) !== FALSE) {
$read_id_node = $id_node;
} else {
$read_id_node = isset($_SESSION['sess_id_node']) ? $_SESSION['sess_id_node'] : null;
}
if (isset($read_id_node)) {
$nodeObj = new Node($read_id_node);
if ($nodeObj->full == 0) {
/*
* Return a ADA_Error object with delayedErrorHandling set to TRUE.
*/
return new ADA_Error(NULL, translateFN('Errore in lettura oggetto nodo'), 'read_node_from_DB', ADA_ERROR_ID_NODE_REQUIRED_BUT_NOT_FOUND, NULL, NULL, TRUE);
}
return $nodeObj;
}
/*
* Return a ADA_Error object with delayedErrorHandling set to TRUE.
*/
return new ADA_Error(NULL, translateFN('Errore in lettura oggetto nodo'), 'read_node_from_DB', ADA_ERROR_ID_NODE_REQUIRED_BUT_NOT_FOUND, NULL, NULL, TRUE);
}
示例3: parameter_controlFN
function parameter_controlFN($neededObjAr = array(), $allowedUsersAr = array())
{
$invalid_session = FALSE;
$invalid_user = FALSE;
$invalid_node = FALSE;
$invalid_course = FALSE;
$invalid_course_instance = FALSE;
$invalid_user_level = FALSE;
$guest_user_not_allowed = FALSE;
/*
* ADA common data handler
*/
$common_dh = isset($GLOBALS['common_dh']) ? $GLOBALS['common_dh'] : null;
if (!$common_dh instanceof AMA_Common_DataHandler) {
$common_dh = AMA_Common_DataHandler::instance();
$GLOBALS['common_dh'] = $common_dh;
}
/*
* User object: always load a user
*/
$sess_id_user = isset($_SESSION['sess_id_user']) ? (int) $_SESSION['sess_id_user'] : 0;
$sess_userObj = read_user($sess_id_user);
if (ADA_Error::isError($sess_userObj)) {
$sess_userObj->handleError();
}
$_SESSION['sess_id_user'] = $sess_id_user;
if ($sess_userObj instanceof ADAGenericUser) {
$_SESSION['sess_userObj'] = $sess_userObj;
/*
* Check if this user is allowed to access the current module
*/
if (!in_array($sess_userObj->getType(), $allowedUsersAr)) {
header('Location: ' . $sess_userObj->getHomePage());
exit;
}
} else {
unset($_SESSION['sess_userObj']);
$invalid_user = TRUE;
}
$id_profile = $sess_userObj->getType();
/*
* Get needed object for this user from $neededObjAr
*/
if (is_array($neededObjAr) && isset($neededObjAr[$id_profile]) && is_array($neededObjAr[$id_profile])) {
$thisUserNeededObjAr = $neededObjAr[$id_profile];
} else {
$thisUserNeededObjAr = array();
}
/*
*
* 'default_tester' AL MOMENTO VIENE RICHIESTO SOLO DA USER.php
* QUI ABBIAMO NECESSITA' DI CANCELLARE LA VARIABILE DI SESSIONE
* sess_id_course.
* Gia' che ci siamo facciamo unset anche di sess_id_node
* e di sess_id_course_instance
*
* Tester selection:
*
* se ho richiesto la connessione al database del tester di default,
* controllo che il tipo di utente sia ADAUser (al momento e' l'unico ad
* avere questa necessita').
*
* se non ho richiesto la connessione al tester di default, allora verifico
* se l'utente e' di tipo ADAUser, e ottengo la connessione al database
* tester appropriato.
*/
if (in_array('default_tester', $thisUserNeededObjAr) && $id_profile == AMA_TYPE_STUDENT) {
$_SESSION['sess_selected_tester'] = NULL;
unset($_SESSION['sess_id_course']);
unset($_SESSION['sess_id_course_instance']);
unset($_SESSION['sess_id_node']);
} else {
if ($id_profile == AMA_TYPE_STUDENT) {
if (isset($_REQUEST['id_course'])) {
$id_course = DataValidator::is_uinteger($_REQUEST['id_course']);
} else {
$id_course = false;
}
if (isset($_SESSION['sess_id_course'])) {
$sess_id_course = DataValidator::is_uinteger($_SESSION['sess_id_course']);
} else {
$sess_id_course = false;
}
if (isset($_REQUEST['id_node'])) {
$req_id_node = DataValidator::validate_node_id($_REQUEST['id_node']);
} else {
$req_id_node = false;
}
if ($id_course === FALSE && $sess_id_course === FALSE && $req_id_node !== FALSE) {
$id_course = substr($req_id_node, 0, strpos($req_id_node, '_'));
}
if ($id_course !== FALSE && $id_course !== $sess_id_course) {
$tester_infoAr = $common_dh->get_tester_info_from_id_course($id_course);
if (AMA_Common_DataHandler::isError($tester_infoAr)) {
$selected_tester = NULL;
} else {
$selected_tester = $tester_infoAr['puntatore'];
}
$_SESSION['sess_selected_tester'] = $selected_tester;
}
//.........这里部分代码省略.........