Unified comment deletion in Opensurveysondage::deleteComment

This commit is contained in:
Marcos García de La Fuente 2014-01-05 20:58:27 +01:00
parent 1e6c0c0b1a
commit 224208c9bb
3 changed files with 19 additions and 4 deletions

View File

@ -142,8 +142,7 @@ if ($idcomment)
// Security check
if (!$user->rights->opensurvey->write) accessforbidden();
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$idcomment;
$resql = $db->query($sql);
$resql = $object->deleteComment($idcomment);
}
if ($action == 'edit') {

View File

@ -478,6 +478,23 @@ class Opensurveysondage extends CommonObject
return true;
}
/**
* Deletes a comment of the poll
*
* @param int $id_comment Id of the comment
* @return boolean False in case of the query fails, true if it was successful
*/
public function deleteComment($id_comment) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$id_comment.' AND id_sondage = '.$this->id_sondage;
$resql = $this->db->query($sql);
if (!$resql) {
return false;
}
return true;
}
/**
* Cleans all the class variables before doing an update or an insert
*

View File

@ -205,8 +205,7 @@ if ($testmodifier)
$idcomment=GETPOST('deletecomment','int');
if ($idcomment)
{
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$idcomment;
$resql = $db->query($sql);
$resql = $object->deleteComment($idcomment);
}