function ajaxAskRecordLike($isSessionValid = false, $mode = 'question', $userid = 0, $id = 0) { if ($isSessionValid) { require_once PATH_CORE . '/classes/log.class.php'; $logObj = new log($this->db); if ($mode == 'question') { // record the like in the log $logItem = $logObj->serialize(0, $userid, 'likeQuestion', $id); $inLog = $logObj->update($logItem); if ($inLog) { $aqTable = new askQuestionsTable($this->db); $qr = $aqTable->getRowObject(); $qr->load($id); $qr->numLikes += 1; $qr->update(); $code = '<a href="#" class="voteLink" onclick="return askRecordLike(\'' . $mode . '\',' . $id . ');" title="like this question">Like</a> ' . $qr->numLikes; } else { $code = 'You already liked this!'; } } else { // mode : answer $logItem = $logObj->serialize(0, $userid, 'likeAnswer', $id); $inLog = $logObj->update($logItem); if ($inLog) { $aaTable = new askAnswersTable($this->db); $ar = $aaTable->getRowObject(); $ar->load($id); $ar->numLikes += 1; $ar->update(); $code = '<a href="#" class="voteLink" onclick="return askRecordLike(\'' . $mode . '\',' . $id . ');" title="like this question">Like</a> ' . $ar->numLikes; } else { $code = 'You already liked this!'; } } } else { $code = '<a href="' . URL_CANVAS . '?p=ask" requirelogin="******">Please authorize ' . SITE_TITLE . ' with Facebook before continuing.</a>'; } return $code; }