Promote Block * @copyright Tamaranga */ class PromoteBlock extends Block { /** @var int item id */ public $itemId; /** @var bool item owner is current user */ public $itemOwner = false; public function init() { parent::init(); $this->setTemplate('item/promote.block', 'listings'); $this->setKey('view.promote.block'); $this->setTitle(_t('view', 'Advertise')); } public function data() { $data = parent::data(); if (! $this->available()) { return false; } $data['url'] = Listings::url('item.promote', ['id' => $this->itemId, 'from' => 'view']); return $data; } public function available() { return ( $this->app->servicesEnabled('listings') && Listings::itemViewPromoteAvailable($this->itemOwner) ); } }