示例#1
0
文件: School.php 项目: krisrita/udo
 function subscribeAction()
 {
     $request = $this->getRequest();
     if ('POST' == $request->getMethod()) {
         $ssotoken = $this->post()->get("ssotoken");
         $actionId = $this->post()->get("actionId");
         $schoolId = $this->post()->get("schoolId");
     } else {
         $ssotoken = $this->get("ssotoken");
         $actionId = $this->get("actionId");
         $schoolId = $this->get("schoolId");
     }
     if (!$ssotoken || !$actionId || !$schoolId) {
         $this->displayJsonUdo(Common_Error::ERROR_PARAM);
     }
     //获取用户id
     $userModel = new UserModel();
     $uid = $userModel->getUserId($ssotoken);
     if (is_array($uid)) {
         $this->displayJsonUdo(Common_Error::INVALID_TOKEN, "", $uid['msg']);
     }
     //订阅/取消订阅频道
     $schoolModel = new SchoolModel();
     $sub = $schoolModel->subscribe($uid, $actionId, $schoolId);
     switch ($sub) {
         case 1:
             $msg = "订阅成功!";
             break;
         case 2:
             $msg = "订阅成功!";
             break;
         case 3:
             $msg = "您已经订阅过该频道啦~~";
             break;
         case 4:
             $msg = "取消成功~~";
             break;
         case 5:
             $msg = "您已经取消过该频道啦~~";
             break;
         case 6:
             $msg = "取消失败";
             break;
         case 7:
             $msg = "订阅失败了~~再试一次吧~~";
             break;
         case 8:
             $msg = "取消失败";
             break;
         default:
             $msg = "失败了~~";
             break;
     }
     $this->displayJsonUdo(Common_Error::ERROR_SUCCESS, "", $msg);
 }