public function delete($id) { $id = (int) $id; $this->_access->query("START TRANSACTION"); $manageRateDomain = new RateDomainManager(); $manageRateQuality = new RateQualityManager(); $manageRateDomain->deleteByActivityId($id); $manageRateQuality->deleteByActivityId($id); $manageQuestion = new QuestionManager(); $questions = $manageQuestion->getQuestionsOfQuiz($id); foreach ($questions as $q) { $manageQuestion->delete($q->getId()); } $this->deleteResultByQuiz($id); $quiz = $this->getById($id); if ($quiz->getPostId() !== 0) { $this->unpost($quiz); } $this->_access->delete(StudyPressDB::getTableNameVisite(), array(StudyPressDB::COL_ID_ACTIVITY_VISITE => $id)); $this->_access->delete(StudyPressDB::getTableNameActivity(), array(StudyPressDB::COL_ID_ACTIVITY => $id)); if ($this->isError()) { $m = $this->getMessageError(); $this->_access->query("ROLLBACK"); $this->_access->setMsgError($m); } else { $this->_access->query("COMMIT"); } }
public function delete($id) { $id = (int) $id; $this->_access->query("START TRANSACTION"); $manageRateDomain = new RateDomainManager(); $manageRateQuality = new RateQualityManager(); $manageRateDomain->deleteByActivityId($id); $manageRateQuality->deleteByActivityId($id); $manageSlide = new SlideManager(); $slides = $manageSlide->getSlidesOfLesson($id); foreach ($slides as $slide) { $manageSlide->delete($slide->id()); } $lesson = $this->getById($id); if ($lesson->getPostId() !== 0) { $this->unpost($lesson); } $this->_access->delete(StudyPressDB::getTableNameVisite(), array(StudyPressDB::COL_ID_ACTIVITY_VISITE => $id)); $this->_access->delete(StudyPressDB::getTableNameActivity(), array(StudyPressDB::COL_ID_ACTIVITY => $id)); if ($this->isError()) { $m = $this->getMessageError(); $this->_access->query("ROLLBACK"); $this->_access->setMsgError($m); } else { $this->_access->query("COMMIT"); } }
<?php global $tr; require_once '_AutoLoadClassAjax.php'; $aResponse['error'] = false; $aResponse['message'] = ''; if (StudyPressUserWP::isLoggedIn()) { if (isset($_POST['action'])) { if (htmlentities($_POST['action'], ENT_QUOTES, 'UTF-8') == 'rating') { $activityId = (int) (isset($_POST['idBox']) ? $_POST['idBox'] : 0); $value = (int) (isset($_POST['rate']) ? $_POST['rate'] : 0); $userId = (int) (isset($_POST['user']) ? $_POST['user'] : 0); $domainId = (int) (isset($_POST['domain']) ? $_POST['domain'] : 0); $managerRate = new RateDomainManager(); $managerDomain = new DomainManager(); $currentUser = new StudyPressUserWP(); if ($value >= 1 && $value <= 5 && $currentUser->id() === $userId && $managerDomain->getById($domainId)) { if ($rate = $managerRate->voteExist($activityId, $userId, $domainId)) { $rate->setValue($value); $rate->setDateRate(StudyPressDB::getCurrentDateTime()); $managerRate->update($rate->getId(), $rate); } else { $managerRate->add(new RateDomain(array('value' => $value, 'userId' => $userId, 'activityId' => $activityId, 'dateRate' => StudyPressDB::getCurrentDateTime(), 'domainId' => $domainId))); } if ($managerRate->isError()) { $success = false; } else { $success = true; } } else { $success = false;
} $managerRate = new RateQualityManager(); ?> <!-- Div rating--> <div class="sp-rater"> <div class="sp-btn-rater"></div> <div class="sp-content-rater hide"> <!-- Rate Quality --> <div class="sp-rater-quality"> <?php $managerDomain = new DomainManager(); $managerRateDomain = new RateDomainManager(); $domains = $managerDomain->getAll(); ?> <h2><?php if ($domains) { echo $tr->__("Overall rating"); } else { echo $tr->__("Rating"); } ?> </h2> <div class="sp-rate-quality" data-id="<?php echo $id; ?> " data-user="<?php