/**
  * @inheritDoc BaseElementModel::getStatus()
  *
  * @return string|null
  */
 public function getStatus()
 {
     $status = parent::getStatus();
     if ($status == static::ENABLED && $this->postDate) {
         $currentTime = DateTimeHelper::currentTimeStamp();
         $postDate = $this->postDate->getTimestamp();
         $expiryDate = $this->expiryDate ? $this->expiryDate->getTimestamp() : null;
         if ($postDate <= $currentTime && (!$expiryDate || $expiryDate > $currentTime)) {
             return static::LIVE;
         } else {
             if ($postDate > $currentTime) {
                 return static::PENDING;
             } else {
                 return static::EXPIRED;
             }
         }
     }
     return $status;
 }
 /**
  * Routes the request when the URI matches an element.
  *
  * @param BaseElementModel $element
  *
  * @return array|bool|mixed
  */
 public function routeRequestForMatchedElement(BaseElementModel $element)
 {
     // Make sure that the entry is actually live
     if ($element->getStatus() == EntryModel::LIVE) {
         $section = $element->getSection();
         // Make sure the section is set to have URLs and is enabled for this locale
         if ($section->hasUrls && array_key_exists(craft()->language, $section->getLocales())) {
             return array('action' => 'templates/render', 'params' => array('template' => $section->template, 'variables' => array('entry' => $element)));
         }
     }
     return false;
 }
 /**
  * Pending -  has all required attributes and is disabled or
  *              does not have all required attributes
  * Ready -    has all required attributes, and is enabled
  * Archived - has been sent, or exported and manually marked archived
  */
 public function getStatus()
 {
     $status = parent::getStatus();
     // Required attributes :$campaign->mailer && $campaign->template
     // Enabled : static::ENABLED
     // Disabled : static::DISABLED
     // Archived : static::ARCHIVED
     // Sent (track sent dates in a sent log table)
     //
     // @todo We can make this conditional statement more
     // advanced and check for the Service Provider and determine
     // specific things about each service provider to decide if an
     // email is ready or not.  For now, we'll just check to see if
     // it has a service provider and text template.
     $campaign = sproutEmail()->campaigns->getCampaignById($this->campaignId);
     switch ($status) {
         case BaseElementModel::DISABLED:
             return static::DISABLED;
             break;
         case BaseElementModel::ENABLED:
             if ($this->sent) {
                 return static::ARCHIVED;
             }
             if (empty($campaign->template) or empty($campaign->mailer)) {
                 return static::PENDING;
             }
             return static::READY;
             break;
         case BaseElementModel::ARCHIVED:
             return static::ARCHIVED;
             break;
     }
 }
 /**
  * Routes the request when the URI matches a product.
  *
  * @param BaseElementModel $element
  *
  * @return array|bool|mixed
  */
 public function routeRequestForMatchedElement(BaseElementModel $element)
 {
     /** @var Market_ProductModel $element */
     if ($element->getStatus() == Market_ProductModel::LIVE) {
         $productType = $element->type;
         if ($productType->hasUrls) {
             return ['action' => 'templates/render', 'params' => ['template' => $productType->template, 'variables' => ['product' => $element]]];
         }
     }
     return false;
 }
 /**
  * Returns the entry status based on actual values and dynamic checking
  *
  * Disabled - Entry is disabled
  * Archived - Entry has been manually set to archived
  * Pending  - Entry is enabled but some requirements are not yet met
  * Ready    - Entry is enabled and all requirements are met
  *
  * @return string
  */
 public function getStatus()
 {
     $status = parent::getStatus();
     $campaign = sproutEmail()->campaigns->getCampaignById($this->campaignId);
     switch ($status) {
         case BaseElementModel::DISABLED:
             return static::DISABLED;
             break;
         case BaseElementModel::ENABLED:
             if ($this->sent) {
                 return static::ARCHIVED;
             }
             if (empty($campaign->mailer) || empty($campaign->template)) {
                 return static::PENDING;
             }
             return static::READY;
             break;
         case BaseElementModel::ARCHIVED:
             return static::ARCHIVED;
             break;
     }
 }