Commit 5cd86010 authored by GROSS-AMBLARD David's avatar GROSS-AMBLARD David
Browse files

Tidy-up useless comments

parent 23ab518b
......@@ -79,14 +79,7 @@ function restart($conn)
* @param $file_name : the name of a file containing SQL queries
* param $conn : A valid database PDO connection
*/
function executeSqlFile($file_name, $conn)
/*{
$sql = file_get_contents($file_name);
$conn->exec($sql) or die ("reset DB error");
}
*/
{
function executeSqlFile($file_name, $conn){
$file_content = file($file_name);
$query = "";
foreach ($file_content as $sql_line) {
......@@ -216,12 +209,7 @@ function insertAnswer($conn, $id, $artifactid, $value, $mass, $isAjax=false, $he
$stmt->bindParam(':user', $user, PDO::PARAM_INT);
$stmt->bindParam(':artifact', $artifact, PDO::PARAM_STR);
//if (isset($_REQUEST['choice'])) {
// $stmt->bindParam(':artifact', $_REQUEST['choice'], PDO::PARAM_INT);
//} else {
// $stmt->bindParam(':artifact', $artifact, PDO::PARAM_INT);
//}
$stmt->execute() or die(mysql_error());
// indicated that the task has been answered
......@@ -334,22 +322,11 @@ function DEPRECATEDchooseArtifactH($conn, $id, $artifact)
{
debug("called");
$user=$_SESSION['id'];
//echo " artifact choosen ".$id. "</br>";
// GET CLASSID
$sql_classid = " select CLASSID from ARTIFACT where ID = $id";
$stmt_classid = $conn->query($sql_classid);
$classid=$stmt_classid->fetch()['CLASSID'];
$_SESSION['artifactclass_active'] = $classid;
$_SESSION['artifact_active'] = $id;
//echo " artifact active ".$_SESSION['artifact_active']. " et classid ".$classid."</br>";
/*$sql_tablename = " select TABLENAME from ARTIFACTCLASS where ID = $id";
$stmt_tablename = $conn->query($sql_tablename);
$tablename=$stmt_tablename->fetch()['TABLENAME'];*/
//$_SESSION['tablename']
//$sql_tablename = " select TABLENAME from ARTIFACTCLASS where ID = $id";
if ($id == "") {
$sql = " select description, definition from ARTIFACTCLASS where ID = 51";
......@@ -373,12 +350,10 @@ function DEPRECATEDchooseArtifactH($conn, $id, $artifact)
$artifact=load_artifact($artifact_def);
/* ROLE DE ATTRIBUTES */
$conn->query("delete from CURRENTARTIFACT where USER=".$_SESSION['id']." and NAME='".$_SESSION['tablename']."'");
$artifact_tablename=$stmt_tablename->fetch()['TABLENAME'];
$_SESSION['tablename'] = $artifact_tablename;
//$conn->query("insert into CURRENTARTIFACT(ID,NAME,USER) values (1,'UserArtifact', 1)");
$stmt = $conn->prepare("insert into CURRENTARTIFACT(ID,NAME,USER) values (:id,:name,:user)");
......
......@@ -26,7 +26,7 @@ require("drawArtifact.php");
session_start();
try { // grobal exception catcher
try { // global exception catcher
@debug("Session id: ".$_SESSION['id']);
@debug("GET parameter: project ".$_GET['project']);
......@@ -78,9 +78,6 @@ switch ($mode) {
case "saveSkill":
saveSkill($conn);
break;
case "skyline": // david: deprecated, to delete
showSkyTasks($conn);
break;
case "showTasks":
showTasks($conn);
break;
......@@ -101,19 +98,15 @@ switch ($mode) {
if (isset($_POST['name']) && isset($_POST['MyRadio'])) {
//if ($)
$radioVal = $_POST["MyRadio"];
if ($radioVal == "q1") {
//echo "selection ". $_POST["myselect"];
$_POST['answer'] = $_POST["select_".$radioVal];
$typeanswer = 1;
} elseif ($radioVal == "q2") {
//echo "taxon, eh?". $_POST["taxprecis"];
$_POST['answer'] = $_POST["select_".$radioVal];
$typeanswer = 2;
} elseif ($radioVal == "qPrecis") {
//echo "taxon, eh?". $_POST["taxprecis"];
$_POST['answer'] = $_POST["select_".$radioVal];
$typeanswer = 3;
}
......@@ -195,11 +188,6 @@ switch ($mode) {
if (isset($_SESSION['username'])) {
debug("logged");
// $stmt = $conn->prepare("select wallet from UserProfile where id=:id");
// $stmt->bindParam(':id', $_SESSION["id"], PDO::PARAM_INT);
// $stmt->execute();
// $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
// $line = $stmt->fetch();
@$var = array("ID" => $_SESSION['username']);
} else {
debug("unlogged");
......
......@@ -43,27 +43,7 @@
}else if((int)@$line["availability"]>0){
$_POST["2"]="checked";
}
/*
$stmt = $conn->prepare("select * from Cities where iduser=:id");
$stmt->bindParam(':id', $_SESSION["id"], PDO::PARAM_STR);
$stmt->execute();
$cities="";
foreach($stmt as $city){
$cities=$cities.$city['city'].",";
}
$cities=substr($cities, 0, -1);
if($line["gender"]=="Male"){
$_POST["Male"]="checked";
}else if(@$line["gender"]=="Female"){
$_POST["Female"]="checked";
}
$availability = explode(",", @$line["availability"]);
for($i = 0; $i < count($availability); $i++){
$_POST[$availability[$i]]="selected";
}
*/
$VIEW['MAIN'].=HTMLform("index.php","POST",
HTMLh1("".$_SESSION['username']."'s profile").
HTMLtag("textarea",array("id"=>"description","name"=>"description","placeholder"=>"Description")).@$line["description"].HTMLclosingtag("textarea").HTMLbr().HTMLbr().
......@@ -77,76 +57,6 @@
HTMLp("Some times per year: ",array("id"=>"deb")).
HTMLtag("input",array("type"=>"radio",isset($_POST["2"]) ? $_POST["2"] : ''=>"","name"=>"availability","value"=>"2","required"=>"")).HTMLbr().HTMLbr().
HTMLtag("div",array("class"=>"lined")).
/*
HTMLp("Age").
HTMLinput("number","age",@$line["age"],"Age",true, "").HTMLbr().HTMLbr().
HTMLp("Gender").
HTMLp("Female : ",array("id"=>"deb")).
HTMLtag("input",array("type"=>"radio",isset($_POST["Female"]) ? $_POST["Female"] : ''=>"","name"=>"gender","value"=>"Female","required"=>"")).HTMLbr().
HTMLp("Male : ",array("id"=>"deb")).
HTMLtag("input",array("type"=>"radio",isset($_POST["Male"]) ? $_POST["Male"] : ''=>"","name"=>"gender","value"=>"Male","required"=>"")).HTMLbr().HTMLbr().
HTMLtag("div",array("class"=>"lined")).
HTMLp("A city you can easily visit").
HTMLinput("text","city",@$line["city"],"City",true, "").HTMLbr().HTMLclosingtag("div").
// HTMLtag("div",array("class"=>"lined marged")).
// HTMLp("List the cities close to you :").
// HTMLinput("text","cities",$cities,"Paris,Madrid,Rennes...",true, "").HTMLbr().HTMLclosingtag("div").
HTMLbr().HTMLbr().
HTMLp("When are you available to do tasks :").HTMLtag("div",array("class"=>"lined")).
HTMLp("Monday :").
HTMLtag("select",array("name"=>"mondayAvailability[]","multiple"=>"")).
HTMLtagblock("option",array("value"=>"0",isset($_POST["0"]["0"]) ? $_POST["0"]["0"] : $select =>""),"Morning").
HTMLtagblock("option",array("value"=>"1",isset($_POST["0"]["1"]) ? $_POST["0"]["1"] : $select =>""),"Noon").
HTMLtagblock("option",array("value"=>"2",isset($_POST["0"]["2"]) ? $_POST["0"]["2"] : $select =>""),"Afternoon").
HTMLtagblock("option",array("value"=>"3",isset($_POST["0"]["3"]) ? $_POST["0"]["3"] : $select =>""),"Evening").HTMLclosingtag("select").HTMLclosingtag("div").
HTMLtag("div",array("class"=>"lined marged")).HTMLp("Tuesday :").
HTMLtag("select",array("name"=>"tuesdayAvailability[]","multiple"=>"")).
HTMLtagblock("option",array("value"=>"0",isset($_POST["1"]["0"]) ? $_POST["1"]["0"] : $select =>""),"Morning").
HTMLtagblock("option",array("value"=>"1",isset($_POST["1"]["1"]) ? $_POST["1"]["1"] : $select =>""),"Noon").
HTMLtagblock("option",array("value"=>"2",isset($_POST["1"]["2"]) ? $_POST["1"]["2"] : $select =>""),"Afternoon").
HTMLtagblock("option",array("value"=>"3",isset($_POST["1"]["3"]) ? $_POST["1"]["3"] : $select =>""),"Evening").HTMLclosingtag("select").HTMLclosingtag("div").
HTMLtag("div",array("class"=>"lined marged")).HTMLp("Wednesday :").
HTMLtag("select",array("name"=>"wednesdayAvailability[]","multiple"=>"")).
HTMLtagblock("option",array("value"=>"0",isset($_POST["2"]["0"]) ? $_POST["2"]["0"] : $select =>""),"Morning").
HTMLtagblock("option",array("value"=>"1",isset($_POST["2"]["1"]) ? $_POST["2"]["1"] : $select =>""),"Noon").
HTMLtagblock("option",array("value"=>"2",isset($_POST["2"]["2"]) ? $_POST["2"]["2"] : $select =>""),"Afternoon").
HTMLtagblock("option",array("value"=>"3",isset($_POST["2"]["3"]) ? $_POST["2"]["3"] : $select =>""),"Evening").HTMLclosingtag("select").HTMLclosingtag("div").
HTMLtag("div",array("class"=>"lined marged")).HTMLp("Thursday :").
HTMLtag("select",array("name"=>"thursdayAvailability[]","multiple"=>"")).
HTMLtagblock("option",array("value"=>"0",isset($_POST["3"]["0"]) ? $_POST["3"]["0"] : $select =>""),"Morning").
HTMLtagblock("option",array("value"=>"1",isset($_POST["3"]["1"]) ? $_POST["3"]["1"] : $select =>""),"Noon").
HTMLtagblock("option",array("value"=>"2",isset($_POST["3"]["2"]) ? $_POST["3"]["2"] : $select =>""),"Afternoon").
HTMLtagblock("option",array("value"=>"3",isset($_POST["3"]["3"]) ? $_POST["3"]["3"] : $select =>""),"Evening").HTMLclosingtag("select").HTMLclosingtag("div").
HTMLtag("div",array("class"=>"lined marged")).HTMLp("Friday :").
HTMLtag("select",array("name"=>"fridayAvailability[]","multiple"=>"")).
HTMLtagblock("option",array("value"=>"0",isset($_POST["4"]["0"]) ? $_POST["4"]["0"] : $select =>""),"Morning").
HTMLtagblock("option",array("value"=>"1",isset($_POST["4"]["1"]) ? $_POST["4"]["1"] : $select =>""),"Noon").
HTMLtagblock("option",array("value"=>"2",isset($_POST["4"]["2"]) ? $_POST["4"]["2"] : $select =>""),"Afternoon").
HTMLtagblock("option",array("value"=>"3",isset($_POST["4"]["3"]) ? $_POST["4"]["3"] : $select =>""),"Evening").HTMLclosingtag("select").HTMLclosingtag("div").
HTMLtag("div",array("class"=>"lined marged")).HTMLp("Saturday :").
HTMLtag("select",array("name"=>"saturdayAvailability[]","multiple"=>"")).
HTMLtagblock("option",array("value"=>"0",isset($_POST["5"]["0"]) ? $_POST["5"]["0"] : $select =>""),"Morning").
HTMLtagblock("option",array("value"=>"1",isset($_POST["5"]["1"]) ? $_POST["5"]["1"] : $select =>""),"Noon").
HTMLtagblock("option",array("value"=>"2",isset($_POST["5"]["2"]) ? $_POST["5"]["2"] : $select =>""),"Afternoon").
HTMLtagblock("option",array("value"=>"3",isset($_POST["5"]["3"]) ? $_POST["5"]["3"] : $select =>""),"Evening").HTMLclosingtag("select").HTMLclosingtag("div").
HTMLtag("div",array("class"=>"lined marged")).HTMLp("Sunday :").
HTMLtag("select",array("name"=>"sundayAvailability[]","multiple"=>"")).
HTMLtagblock("option",array("value"=>"0",isset($_POST["6"]["0"]) ? $_POST["6"]["0"] : $select =>""),"Morning").
HTMLtagblock("option",array("value"=>"1",isset($_POST["6"]["1"]) ? $_POST["6"]["1"] : $select =>""),"Noon").
HTMLtagblock("option",array("value"=>"2",isset($_POST["6"]["2"]) ? $_POST["6"]["2"] : $select =>""),"Afternoon").
HTMLtagblock("option",array("value"=>"3",isset($_POST["6"]["3"]) ? $_POST["6"]["3"] : $select =>""),"Evening").HTMLclosingtag("select").HTMLclosingtag("div").HTMLbr().HTMLbr().
HTMLtag("input",array("type"=>"text","id"=>"datepicker","name"=>"availability","placeholder"=>"Select months","required"=>"","value"=>@$line["availability"])).
"<script type=\"text/javascript\">
$(function () {
$('#datepicker').datepicker({
multidate: true,
format: 'MM',
minViewMode: 'months',
maxViewMode: 'months',
startView: 'months'
});
});
</script>".HTMLbr().HTMLbr().*/
HTMLinput("hidden","mode","saveProfile",null,false,"").
HTMLinput("submit","submit","Save changes",null,false,"").HTMLbr()
);
......
......@@ -64,19 +64,6 @@ function showLogin($conn)
EOT;
$VIEW['MAIN'] .= "<div class='alert alert-success'>" . HTMLbr() . HTMLbr() . HTMLcenter(HTMLform("index.php", "POST", HTMLh1("Please log in or create an account") . HTMLbr() . HTMLinput("hidden", "mode", "login").HTMLinput("text", "username", null, "username", true) . HTMLbr() . HTMLinput("password", "password", null, "password", true) . HTMLbr() . HTMLinput("submit", "submit", "log in !", null, false, 'btn btn-dark') . HTMLbr()));
/*
* $VIEW['MAIN'].=HTMLcenter(HTMLform(
* "index.php",
* "POST",
* HTMLbr().
* HTMLbr().
* HTMLh1("or").
* HTMLinput("hidden", "username", "anonymous").
* HTMLinput("hidden", "password", "anonymous").
* HTMLinput("submit", "submit", "Connect anonymously", null, false, 'btn btn-dark')
* ));
*/
$VIEW['MAIN'] .= HTMLcenter(HTMLform("index.php", "POST", HTMLbr() . HTMLinput("hidden", "mode", "register") . HTMLinput("submit", "submit", "Create an account", null, false, 'btn btn-dark')));
if (isset($_SESSION["wrong"])) {
......@@ -420,24 +407,17 @@ function initializeUserProjectArtifact($conn, $user, $project)
* initialization with CROWDFLOW
* on select in one project, append user to artifact
*/
// echo ' here '. $user. ' </br> ';
// echo ' here '. $project. ' </br> ';
if ($project == 'SPIPOLL') {
$sql_project = "select id from artifactclass where project ='" . $project . "'";
$stmt_project = $conn->query($sql_project);
// $val =$stmt_project->fetch()['ID'];
$val = $stmt_project->fetchAll();
// print_r($val);
// echo count($val). " </br> ";
if (count($val) > 1) {
foreach ($val as $k => $v) {
// echo $k. " - ".$v[0]. " </br> ";
$sql_checkartifact = "select if((select count(*) = 0 from artifact where classid = " . $v[0] . " and ownerid = " . $user . "), 1, 0 )";
$stmt_checkartifact = $conn->query($sql_checkartifact);
$check = $stmt_checkartifact->fetch();
// echo "check value : ".$check[0]." </br> ";
if ($check[0] == 1) {
$sql = "insert into artifact(ownerid,classid,state,node,attributes) values (:ownerid, :classid, :state, :node, :attributes)";
$stmt = $conn->prepare($sql);
......@@ -517,9 +497,6 @@ function showAwaitingActivites($conn)
function showRunningActivities($conn){
global $VIEW;
// showing running artifacts of the user
//$table = $conn->query("select concat(description,' [',Artifact.id,']'), Artifact.id, concat('index.php?mode=showTasks&activity=',description),'button' from Artifact,ArtifactClass where project='" . $_SESSION['project'] . "' and Artifact.classid=ArtifactClass.id and Artifact.ownerid=" . $_SESSION['id'] . " order by Artifact.classid, Artifact.id");
$table = $conn->query("select description, Artifact.id, concat('index.php?mode=showTasks&activitydesc=',description,'&activityid=',Artifact.id),'button' from Artifact,ArtifactClass where project='" . $_SESSION['project'] . "' and Artifact.classid=ArtifactClass.id and Artifact.ownerid=" . $_SESSION['id'] . " order by Artifact.classid, Artifact.id");
$mylist = $table->fetchAll(PDO::FETCH_NUM);
......@@ -648,7 +625,6 @@ function showAllTasks($conn, $displayAlert = false)
$stmt = $conn->prepare("select * from users");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
// echo $_SESSION['tablename']. '</br>';
$query = "SELECT id, title, description, sum(level) as level from Task,Skills,Profile
where Task.id=Profile.idtask
......@@ -677,10 +653,7 @@ function showCurrentArtifact($conn)
on current.id=states.id join
" . $artifactName . "
on " . $artifactName . ".ID=states.attributes)";
/*
* echo " query ".$query. " </br> ";
* echo " tablename : ".$artifactName." </br> ";
*/
$_SESSION['tablename'] = $artifactName;
showQueryAnswer($conn, "Current Artifact", $query, array(
'id',
......@@ -741,18 +714,6 @@ function showTaskList($conn, $title, $query, $displayThanks = false)
}
$finalform = "<table class='table table-striped table-bordered'><tr><td>Sorry, no task today for this activity</td></tr></table>";
/*
*
* $finalform= HTMLinput("hidden", "artifactclass", $_SESSION['activity_desc']).HTMLtable(
* array(
* HTMLtr(array(HTMLth(""))),
* HTMLtr(array(HTMLtd(HTMLinput("submit","lauchartifact","Start",null,null,"btn btn-success"))))
* ),
* array(
* "class" => "table table-striped table-bordered"
* )
* );
*/
if ($rowcount > 0) {
$finalform = HTMLtable(array(
......@@ -798,9 +759,6 @@ function chooseActivityProject($conn, $id)
{
debug("called");
$user = $_SESSION['id'];
// echo " artifact choosen ".$id. "</br>";
// echo "delete from CURRENTARTIFACT where USER=".$_SESSION['id']." and NAME='".$_SESSION['tablename']."' </br>";
$conn->query("delete from currentartifact where user=" . $_SESSION['id'] . " and name='" . $_SESSION['tablename'] . "'");
......@@ -809,16 +767,6 @@ function chooseActivityProject($conn, $id)
$stmt_id = $conn->query($sql_id);
$artifactid = $stmt_id->fetch()['id'];
$_SESSION['artifact_active'] = $artifactid;
// echo " artifact active ".$_SESSION['artifact_active']. " et classid ".$classid."</br>";
/*
* $sql_tablename = " select TABLENAME from ARTIFACTCLASS where ID = $id";
* $stmt_tablename = $conn->query($sql_tablename);
* $tablename=$stmt_tablename->fetch()['TABLENAME'];
*/
// $_SESSION['tablename']
// $sql_tablename = " select TABLENAME from ARTIFACTCLASS where ID = $id";
if ($id == "") {
$sql = " select description, definition from artifactclass where ID = 51";
......@@ -841,14 +789,9 @@ function chooseActivityProject($conn, $id)
$artifact = load_artifact($artifact_def);
// echo ' -> '.$artifact. ' </br>';
$stmt_tablename = $conn->query($sql_tablename);
$artifact_tablename = $stmt_tablename->fetch()['tablename'];
$_SESSION['tablename'] = $artifact_tablename;
/* ROLE DE ATTRIBUTES */
// $conn->query("insert into CURRENTARTIFACT(ID,NAME,USER) values (1,'UserArtifact', 1)");
$stmt = $conn->prepare("insert into currentartifact(id,name,user) values (:id,:name,:user)");
......@@ -857,13 +800,6 @@ function chooseActivityProject($conn, $id)
$stmt->bindParam(':user', $_SESSION['id'], PDO::PARAM_INT);
$stmt->execute() or die(mysql_error());
// echo $artifact_def. ' </br> ';
/* ROLE DE ATTRIBUTES */
// $conn->query("delete from CURRENTARTIFACT where USER=".$_SESSION['id']." and NAME='".$_SESSION['tablename']."'");
// $artifact_tablename=$stmt_tablename->fetch()['TABLENAME'];
// $_SESSION['tablename'] = $artifact_tablename;
$_SESSION['artifactclass_active'] = $id;
update($conn, $artifact);
......@@ -875,17 +811,10 @@ function showActivityProject($conn, $title, $query, $exception = null)
{
global $VIEW;
$res = "";
/*
* if ($displayThanks) {
* $res .= "&nbsp;<h2 class=\"alert alert-success\" role=\"alert\">Thank you for your answer</h2>";
* }
*/
$res .= HTMLh1($title);
// $res.=HTMLinput("hidden", "mode", "answer");
$header = HTMLtr(array(
HTMLth("Id"),
// HTMLth("Title"),
HTMLth("Description"),
HTMLth("Table name")
));
......@@ -1069,14 +998,8 @@ function showArtifactsTable($conn)
$res = "<div class='allArtifacts'>";
$res .= HTMLh2($title);
// $res.=HTMLform("index.php?mode=showTasks", "POST", $form);
/* MODIF 1 */
// $res.="\n<form action=\"index.php\" method=\"POST\">\n";
$res .= "\n<form action=\"index.php?mode=showAllTasks\" method=\"POST\">\n";
/* MODIF 2 */
// $res.=HTMLinput("hidden", "mode", "insertAnswer");
$res .= HTMLinput("hidden", "mode", "chooseArtifactH");
$res .= HTMLinput("hidden", "id", "1");
......@@ -1084,7 +1007,7 @@ function showArtifactsTable($conn)
$artifactTable = $line['tablename'];
if (! empty($artifactTable)) {
debug($artifactTable);
// (select ID, CLASSID, STATE, NODE, ATTRIBUTES from ARTIFACT where OWNERID=".$_SESSION["id"].") as art join
$query = "select * from
(select id, classid, ownerid as owner, state, node, attributes from artifact) as art join
(select id as classid, tablename, definition from artifactclass) as artclass
......@@ -1095,14 +1018,10 @@ function showArtifactsTable($conn)
(select id, classid, ownerid as owner, state, node, attributes from artifact) as art join
(select id as classid, description, definition from artifactclass) as artclass";
}
/*
* echo " </br> ALL ARTIFACT </br> ";
* echo $query. " </br> ";
* echo $artifactTable;
*/
debug($query);
$res .= HTMLh3($artifactTable);
$res .= "<table class='table table-striped'>\n"; // <caption>$artifactTable</caption>
$res .= "<table class='table table-striped'>\n";
try {
$stmt = $conn->prepare($query);
$stmt->bindParam(':artifactTable', $artifactTable, PDO::PARAM_STR);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment