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