projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replaces removed function get_not_registered_user.
[platal.git]
/
modules
/
survey
/
survey.inc.php
diff --git
a/modules/survey/survey.inc.php
b/modules/survey/survey.inc.php
index
5d5087a
..
6d8a410
100644
(file)
--- a/
modules/survey/survey.inc.php
+++ b/
modules/survey/survey.inc.php
@@
-1,6
+1,6
@@
<?php
/***************************************************************************
<?php
/***************************************************************************
- * Copyright (C) 2003-20
09
Polytechnique.org *
+ * Copyright (C) 2003-20
10
Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-83,6
+83,7
@@
class Survey
if ($this->mode == self::MODE_ALL) {
$args['promos'] = '';
}
if ($this->mode == self::MODE_ALL) {
$args['promos'] = '';
}
+ $args['promos'] = str_replace(' ', '', $args['promos']);
$this->promos = ($args['promos'] == '' || preg_match('#^(\d{4}-?|(\d{4})?-\d{4})(,(\d{4}-?|(\d{4})?-\d{4}))*$#', $args['promos']))? $args['promos'] : '#';
}
// }}}
$this->promos = ($args['promos'] == '' || preg_match('#^(\d{4}-?|(\d{4})?-\d{4})(,(\d{4}-?|(\d{4})?-\d{4}))*$#', $args['promos']))? $args['promos'] : '#';
}
// }}}
@@
-189,7
+190,7
@@
class Survey
$nbf = count($line);
$users = array();
if ($this->isMode(self::MODE_XIDENT)) { // if the mode is non anonymous
$nbf = count($line);
$users = array();
if ($this->isMode(self::MODE_XIDENT)) { // if the mode is non anonymous
- $users = User::getBulkUsersWithUIDs(XDB::fetchAllAssoc('vid', 'SELECT v.id AS vid, v.u
ser_
id
+ $users = User::getBulkUsersWithUIDs(XDB::fetchAllAssoc('vid', 'SELECT v.id AS vid, v.uid
FROM survey_votes AS v
WHERE v.survey_id = {?}
ORDER BY vid ASC',
FROM survey_votes AS v
WHERE v.survey_id = {?}
ORDER BY vid ASC',
@@
-340,7
+341,7
@@
class Survey
return null;
}
$sql = 'SELECT id, title, end, mode
return null;
}
$sql = 'SELECT id, title, end, mode
- FROM survey
_survey
s
+ FROM surveys
WHERE '.$where.'
ORDER BY end DESC;';
if ($tpl) {
WHERE '.$where.'
ORDER BY end DESC;';
if ($tpl) {
@@
-355,7
+356,7
@@
class Survey
public static function retrieveSurvey($sid)
{
$sql = 'SELECT questions, title, description, end, mode, promos
public static function retrieveSurvey($sid)
{
$sql = 'SELECT questions, title, description, end, mode, promos
- FROM survey
_survey
s
+ FROM surveys
WHERE id={?}';
$res = XDB::query($sql, $sid);
$data = $res->fetchOneAssoc();
WHERE id={?}';
$res = XDB::query($sql, $sid);
$data = $res->fetchOneAssoc();
@@
-371,7
+372,7
@@
class Survey
public static function retrieveSurveyInfo($sid)
{
$sql = 'SELECT title, description, end, mode, promos
public static function retrieveSurveyInfo($sid)
{
$sql = 'SELECT title, description, end, mode, promos
- FROM survey
_survey
s
+ FROM surveys
WHERE id={?}';
$res = XDB::query($sql, $sid);
return $res->fetchOneAssoc();
WHERE id={?}';
$res = XDB::query($sql, $sid);
return $res->fetchOneAssoc();
@@
-409,7
+410,7
@@
class Survey
public function updateSurvey()
{
if ($this->valid) {
public function updateSurvey()
{
if ($this->valid) {
- $sql = 'UPDATE survey
_survey
s
+ $sql = 'UPDATE surveys
SET questions={?},
title={?},
description={?},
SET questions={?},
title={?},
description={?},
@@
-432,8
+433,8
@@
class Survey
// {{{ functions vote() and hasVoted() : handles vote to a survey
public function vote($uid, $args)
{
// {{{ functions vote() and hasVoted() : handles vote to a survey
public function vote($uid, $args)
{
- XDB::execute('INSERT INTO survey_votes
- SET
survey_id={?}, user_id=
{?};', $this->id, $uid); // notes the user as having voted
+ XDB::execute('INSERT INTO
survey_votes
+ SET
survey_id = {?}, uid =
{?};', $this->id, $uid); // notes the user as having voted
$vid = XDB::insertId();
for ($i = 0; $i < count($this->questions); $i++) {
$ans = $this->questions[$i]->checkAnswer($args[$i]);
$vid = XDB::insertId();
for ($i = 0; $i < count($this->questions); $i++) {
$ans = $this->questions[$i]->checkAnswer($args[$i]);
@@
-450,9
+451,9
@@
class Survey
public function hasVoted($uid)
{
public function hasVoted($uid)
{
- $res = XDB::query('SELECT id
- FROM survey_votes
- WHERE
survey_id={?} AND user_id=
{?};', $this->id, $uid); // checks whether the user has already voted
+ $res = XDB::query('SELECT
id
+ FROM
survey_votes
+ WHERE
survey_id = {?} AND uid =
{?};', $this->id, $uid); // checks whether the user has already voted
return ($res->numRows() != 0);
}
// }}}
return ($res->numRows() != 0);
}
// }}}
@@
-461,7
+462,7
@@
class Survey
public static function deleteSurvey($sid)
{
$sql = 'DELETE s.*, v.*, a.*
public static function deleteSurvey($sid)
{
$sql = 'DELETE s.*, v.*, a.*
- FROM survey
_survey
s AS s
+ FROM surveys AS s
LEFT JOIN survey_votes AS v
ON v.survey_id=s.id
LEFT JOIN survey_answers AS a
LEFT JOIN survey_votes AS v
ON v.survey_id=s.id
LEFT JOIN survey_answers AS a