本文整理汇总了PHP中Notifications::recordAction方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifications::recordAction方法的具体用法?PHP Notifications::recordAction怎么用?PHP Notifications::recordAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifications
的用法示例。
在下文中一共展示了Notifications::recordAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vote
public function vote($voteObj)
{
$userId = parent::getUserId();
if ($userId == false) {
return "Invalid AuthToken";
}
// Get the current vote
$sth = $this->db->prepare("SELECT * FROM Votes WHERE UserId = :userId AND ShareId = :shareId LIMIT 1");
$success = $sth->execute(array(":userId" => $userId, ":shareId" => $voteObj["shareId"]));
$result = $sth->fetch();
if ($success && $result != false) {
$up = 0;
$down = 0;
if ($voteObj["voteType"] == "down") {
// Change to a down vote
$down = 1;
} else {
if ($voteObj["voteType"] == "up") {
$up = 1;
}
}
$sthUpdateVote = $this->db->prepare("UPDATE Votes SET UpVote = :up, DownVote = :down WHERE UserId = :userId AND ShareId = :shareId LIMIT 1");
$sthUpdateVote->execute(array(":up" => $up, ":down" => $down, ":userId" => $userId, "shareId" => $voteObj["shareId"]));
//print_r($sthUpdateVote->errorInfo());
} else {
$up = 0;
$down = 0;
// Submit a new vote
if ($voteObj["voteType"] == "up") {
$up = 1;
} else {
if ($voteObj["voteType"] == "down") {
$down = 1;
}
}
$sthNewVote = $this->db->prepare("INSERT INTO Votes (VoteId, UserId, ShareId, UpVote, DownVote, Flag)\n\t\t\t\t\t\t\t\tVALUES ('', :userId, :shareId, :up, :down, 0)");
$sthNewVote->execute(array(":userId" => $userId, ":shareId" => $voteObj["shareId"], ":up" => $up, ":down" => $down));
}
// Update the rank after every vote
$this->_calculateRank($voteObj["shareId"]);
// Record the action
$notifications = new Notifications();
$notifications->recordAction($userId, $voteObj["voteType"], $voteObj["shareId"]);
$response = $this->defaultResponseObj;
$response["Success"] = true;
$response["Message"] = "Vote recorded";
return $response;
}