当前位置: 首页>>代码示例>>PHP>>正文


PHP Notifications::recordAction方法代码示例

本文整理汇总了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;
 }
开发者ID:Javas01,项目名称:sharemail-server,代码行数:48,代码来源:GlobalEmail.php


注:本文中的Notifications::recordAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。