本文整理汇总了PHP中Review::loadById方法的典型用法代码示例。如果您正苦于以下问题:PHP Review::loadById方法的具体用法?PHP Review::loadById怎么用?PHP Review::loadById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Review
的用法示例。
在下文中一共展示了Review::loadById方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processPendingReviewsNotifications
function processPendingReviewsNotifications()
{
// Check if it is time to process notifications
if (!isset($_REQUEST['force']) && !canProcessNotifications()) {
return;
}
// process pending journal notifications
$pendingReviews = Review::getReviewsWithPendingJournalNotifications();
if ($pendingReviews !== false && count($pendingReviews) > 0) {
echo "<br/>Processing " . count($pendingReviews) . " reviews.";
foreach ($pendingReviews as $review) {
$tReview = new Review();
$tReview->loadById($review['reviewer_id'], $review['reviewee_id']);
if ($tReview->journal_notified == 0) {
Utils::sendReviewNotification($tReview->reviewee_id, 'update', $tReview->getReviews($tReview->reviewee_id, $tReview->reviewer_id, ' AND r.reviewer_id=' . $tReview->reviewer_id));
} else {
Utils::sendReviewNotification($tReview->reviewee_id, 'new', $tReview->getReviews($tReview->reviewee_id, $tReview->reviewer_id, ' AND r.reviewer_id=' . $tReview->reviewer_id));
}
$tReview->journal_notified = 1;
$tReview->save('reviewer_id', 'reviewee_id');
usleep(4000000);
}
} else {
echo "<br />Processed. No pending Reviews.";
}
resetCronFile();
}
示例2: review
public function review($id)
{
$this->view = null;
try {
Utils::checkLogin();
$user = User::find($id);
$currentUser = User::find(Session::uid());
if (!$user->getId() || $user->getId() == $currentUser->getId()) {
throw new Exception('Invalid user id');
}
$review = new Review();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$userReview = trim($_POST['userReview']);
if ($review->loadById($currentUser->getId(), $user->getId())) {
if (!$userReview) {
$oReview = $review->getReviews($user->getId(), $currentUser->getId(), ' AND r.reviewer_id=' . $reviewer_id);
$cond = 'reviewer_id = ' . $currentUser->getId() . ' AND reviewee_id = ' . $user->getId();
if (!$review->removeRow($cond)) {
throw new Exception('Cannot delete review! Please retry later');
}
Utils::sendReviewNotification($user->getId(), "delete", $oReview);
$message = 'Review deleted';
} else {
if (!strcmp($review->review, $userReview)) {
throw new Exception('No changes made');
}
$review->review = $userReview;
$review->journal_notified = 0;
if (!$review->save('reviewer_id', 'reviewee_id')) {
throw new Exception('Cannot update review! Please retry later');
}
$message = 'Review updated';
}
} else {
if (!$userReview) {
throw new Exception('New empty review is not saved');
}
if (!$review->insertNew(array('reviewer_id' => $currentUser->getId(), 'reviewee_id' => $user->getId(), 'review' => $userReview, 'journal_notified' => -1))) {
throw new Exception('Cannot create new review! Please retry later');
}
$myReview = $review->getReviews($user->getId(), $currentUser->getId(), ' AND r.reviewer_id = ' . $currentUser->getId());
if (count($myReview) == 0) {
$cond = 'reviewer_id = ' . $currentUser->getId() . ' AND reviewee_id = ' . $user->getId();
$review->removeRow($cond);
throw new Exception('Review with no paid fee is not allowed');
}
$message = 'Review saved';
}
} else {
$userReview = $message = '';
if ($review->loadById($currentUser->getId(), $user->getId())) {
$userReview = $review->review;
}
}
echo json_encode(array('success' => true, 'message' => $message, 'myReview' => $userReview));
} catch (Exception $e) {
echo json_encode(array('success' => false, 'message' => $e->getMessage()));
}
}