Unified comment deletion in Opensurveysondage::deleteComment
This commit is contained in:
parent
1e6c0c0b1a
commit
224208c9bb
@ -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') {
|
||||
|
||||
@ -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
|
||||
*
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user