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


PHP Ad::hasSentRequest方法代码示例

本文整理汇总了PHP中Ad::hasSentRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Ad::hasSentRequest方法的具体用法?PHP Ad::hasSentRequest怎么用?PHP Ad::hasSentRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ad的用法示例。


在下文中一共展示了Ad::hasSentRequest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 /**
  * Display a specified ad.
  *
  * @param int $id
  * @return Response
  */
 public function show($id)
 {
     try {
         $session = Session::get('user');
         $adService = new SoapClient(Config::get('wsdl.ad'), array());
         $messageService = new SoapClient(Config::get('wsdl.message'), array());
         $result = $adService->getAdById(array("adId" => $id, "includeCreatorStatistics" => true));
         $ad = new Ad($result->ad);
         if ($ad->requested) {
             $request = $ad->getRequestByUser($session['data']->id);
             if (isset($request)) {
                 $ad->status = $request->status;
                 $ad->user_request = $request;
                 $ad->user_requested = true;
             } else {
                 $ad->user_requested = false;
             }
         }
         if (isset($ad->requests->item) && !is_array($ad->requests->item)) {
             $ad->requests->item = array($ad->requests->item);
         }
         $ad->activeReq = 0;
         if (isset($ad->requests->item)) {
             foreach ($ad->requests->item as $k => $request) {
                 if ($request->status != 'CANCELED' && $request->status != 'DECLINED' && $request->status != 'UNACCEPTED') {
                     $ad->activeReq++;
                 }
             }
         }
         if (!$ad->online) {
             if ($ad->approved) {
                 $ad->status = "APPROVED";
             } else {
                 if ($ad->approval == null) {
                     $ad->status = "PENDING";
                 } else {
                     $ad->status = "DECLINED";
                 }
             }
         } elseif ($ad->sold) {
             $requestor = $ad->getAcceptedRequest()->user;
             if (isset($requestor->avatar)) {
                 $ad->requestor = $requestor->avatar->id;
             } else {
                 $ad->requestor = null;
             }
             $ad->status = "SOLD";
         } elseif ($ad->expired) {
             $ad->status = "EXPIRED";
         } elseif (!$ad->hasActiveRequest()) {
             $ad->status = "NO_REQUESTS";
         } elseif ($ad->hasSentRequest()) {
             $requestor = $ad->getAcceptedRequest()->user;
             if (isset($requestor->avatar)) {
                 $ad->requestor = $requestor->avatar->id;
             } else {
                 $ad->requestor = null;
             }
             $ad->status = "SENT";
         } elseif ($ad->hasAcceptedRequest()) {
             $requestor = $ad->getAcceptedRequest()->user;
             if (isset($requestor->avatar)) {
                 $ad->requestor = $requestor->avatar->id;
             } else {
                 $ad->requestor = null;
             }
             $ad->status = "SELECTED";
         } else {
             $ad->status = "ACTIVE";
         }
         $ad->canEdit = $ad->owner && !$ad->hasActiveRequest() && $ad->statistics->numBookmarks == 0 && $ad->statistics->numComments == 0 && $ad->statistics->numShares == 0;
         $ad->canDelete = $ad->owner && (!$ad->hasActiveRequest() || $ad->expired);
         $comments = $messageService->getCommentsByAd(array("adId" => $ad->id, "lastCommentId" => -1, "numComments" => 11));
         if (isset($comments->comment)) {
             if (!is_array($comments->comment)) {
                 $comments = array($comments->comment);
             } else {
                 $comments = $comments->comment;
             }
         }
         return array('ad' => $ad, 'comments' => $comments);
     } catch (Exception $ex) {
         return $ex;
     }
 }
开发者ID:Yatko,项目名称:Gifteng,代码行数:91,代码来源:AdController.php


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