Removed duplicate code
This commit is contained in:
parent
2e995fc20b
commit
7a1af8656a
@ -293,21 +293,12 @@ print '<form name="formulaire5" action="#" method="POST">'."\n";
|
||||
print_fiche_titre($langs->trans("CommentsOfVoters"),'','');
|
||||
|
||||
// Comment list
|
||||
$sql = 'SELECT id_comment, usercomment, comment';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments';
|
||||
$sql.= " WHERE id_sondage='".$db->escape($numsondage)."'";
|
||||
$sql.= " ORDER BY id_comment";
|
||||
$resql = $db->query($sql);
|
||||
$num_rows=$db->num_rows($resql);
|
||||
if ($num_rows > 0)
|
||||
{
|
||||
$i = 0;
|
||||
while ( $i < $num_rows)
|
||||
{
|
||||
$obj=$db->fetch_object($resql);
|
||||
print '<a href="'.dol_buildpath('/opensurvey/adminstuds.php',1).'?deletecomment='.$obj->id_comment.'&id='.$numsondageadmin.'"> '.img_picto('', 'delete.png').'</a> ';
|
||||
print $obj->usercomment.' : '.dol_nl2br($obj->comment)." <br>";
|
||||
$i++;
|
||||
$comments = $object->getComments();
|
||||
|
||||
if ($comments) {
|
||||
foreach ($comments as $comment) {
|
||||
print '<a href="'.dol_buildpath('/opensurvey/adminstuds.php',1).'?deletecomment='.$comment->id_comment.'&id='.$numsondageadmin.'"> '.img_picto('', 'delete.png').'</a> ';
|
||||
print $comment->usercomment.': '.dol_nl2br($comment->comment)." <br>";
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -320,7 +311,7 @@ print '<br>';
|
||||
// Add comment
|
||||
print $langs->trans("AddACommentForPoll") . '<br>';
|
||||
print '<textarea name="comment" rows="2" cols="80"></textarea><br>'."\n";
|
||||
print $langs->trans("Name") .' : <input type=text name="commentuser"><br>'."\n";
|
||||
print $langs->trans("Name") .': <input type="text" name="commentuser" value="'.$user->getFullName($langs).'"><br>'."\n";
|
||||
print '<input type="submit" class="button" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans("AddComment")).'"><br>'."\n";
|
||||
if (isset($erreur_commentaire_vide) && $erreur_commentaire_vide=="yes") {
|
||||
print "<font color=#FF0000>" . $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Name")) . "</font>";
|
||||
|
||||
@ -517,5 +517,30 @@ class Opensurveysondage extends CommonObject
|
||||
$this->canedit=0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all comments for the current opensurvey poll
|
||||
*
|
||||
* @return Object[]
|
||||
*/
|
||||
public function getComments() {
|
||||
|
||||
$sql = 'SELECT id_comment, usercomment, comment';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments';
|
||||
$sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'";
|
||||
$sql.= " ORDER BY id_comment";
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
$num_rows=$this->db->num_rows($resql);
|
||||
|
||||
$comments = array();
|
||||
|
||||
if ($num_rows > 0) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$comments[] = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
return $comments;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -697,23 +697,16 @@ print '<br>';
|
||||
|
||||
|
||||
// Comment list
|
||||
$sql = 'SELECT id_comment, usercomment, comment';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments';
|
||||
$sql.= " WHERE id_sondage='".$db->escape($numsondage)."'";
|
||||
$sql.= " ORDER BY id_comment";
|
||||
$resql = $db->query($sql);
|
||||
$num_rows=$db->num_rows($resql);
|
||||
if ($num_rows > 0)
|
||||
$comments = $object->getComments();
|
||||
|
||||
if ($comments)
|
||||
{
|
||||
$i = 0;
|
||||
print "<br><b>" . $langs->trans("CommentsOfVoters") . " :</b><br>\n";
|
||||
while ( $i < $num_rows)
|
||||
{
|
||||
$obj=$db->fetch_object($resql);
|
||||
|
||||
foreach ($comments as $obj) {
|
||||
print '<div class="comment"><span class="usercomment">';
|
||||
if (in_array($obj->usercomment, $listofvoters)) print '<a href="'.$_SERVER["PHP_SELF"].'?deletecomment='.$obj->id_comment.'&sondage='.$numsondage.'"> '.img_picto('', 'delete.png').'</a> ';
|
||||
print $obj->usercomment.' :</span> <span class="comment">'.dol_nl2br($obj->comment)."</span></div>";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user