function user_is_role($email, $role) { $return_value = 0; $user_id = user_exist_sqlsrv($email); $role_id = role_to_roleid($role); global $conn; $qry = "SELECT count(*) AS count FROM user_role WHERE user_id = ? AND role_id = ? AND active = 1"; $params = array(&$user_id, &$role_id); $rst = sqlsrv_prepare($conn, $qry, $params); sqlsrv_execute($rst); sqlsrv_fetch($rst); error_log("checked {$email} for role {$role} using {$user_id} and {$role_id}"); $return_value = sqlsrv_get_field($rst, 0); sql_errors_display("from user is role"); return $return_value; }
function save_response() { global $action; global $conn; //echo("found action=" + $action); //echo("saving response "); global $assignment_id; foreach ($_REQUEST as $key => $value) { $result = substr_compare($key, 'item', 0, 4); echo 'compare (confirm) result is: ' . $result . "\n"; if ($result == 0) { $item_id = substr($key, 4); $query_params = array($assignment_id, $item_id, $_REQUEST[$key]); sql_errors_display(); echo "save an item: {$assignment_id}, {$item_id}, " . $_REQUEST[$key] . " \n"; $qry = "{call dbo.sp_save_survey_response(?,?,?)}"; $rst = sqlsrv_query($conn, $qry, $query_params); } else { $item_id = substr($key, 6); echo "item id is {$item_id}, key is {$key} \n"; echo "value is " . $_REQUEST[$key] . "\n"; $query_params = array($assignment_id, $item_id, $_REQUEST[$key]); $qry = "{call dbo.sp_save_survey_response_text(?,?,?)}"; $rst = sqlsrv_query($conn, $qry, $query_params); sql_errors_display(); echo "t_item here result is {$result} \n"; } echo 'a request key is ' . $key . "\n"; ${$key} = $value; } //echo("received in ajax call: " . $_REQUEST); }