public function delete($id) { try { $msg = new Msg($id); if (UserHelper::getProfileId() != $msg->getReceiver() and !UserHelper::isEditor()) { throw new fValidationException('not allowed'); } $msg->delete(); $this->ajaxReturn(array('result' => 'success')); } catch (fException $e) { $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage())); } }
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { if (isset($_GET['course_id'])) { $course_id = intval($_GET['course_id']); } if (isset($_GET['mbox_type'])) { $mbox_type = $_GET['mbox_type']; } if (isset($_POST['mid'])) { $mid = intval($_POST['mid']); $msg = new Msg($mid, $uid, 'any'); if (!$msg->error) { $msg->delete(); } exit(); } elseif (isset($_POST['all_inbox'])) { $inbox = new Mailbox($uid, $course_id); $msgs = $inbox->getInboxMsgs(); foreach ($msgs as $msg) { if (!$msg->error) { $msg->delete(); } } exit(); } elseif (isset($_POST['all_outbox'])) { $outbox = new Mailbox($uid, $course_id); $msgs = $outbox->getOutboxMsgs(); foreach ($msgs as $msg) {