Ejemplo n.º 1
0
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     $prev = clone $this;
     if (!empty($this->id)) {
         $prev->load($this->id);
     }
     if ($save = parent::save($src, $orderingFilter, $ignore)) {
         if ($prev->subscription_enabled && empty($this->subscription_enabled)) {
             // if it was previously enabled and now is disabled
             Tienda::load('TiendaHelperJuga', 'helpers.juga');
             $helper = new TiendaHelperJuga();
             $helper->doExpiredSubscription($this);
         }
     }
     return $save;
 }
Ejemplo n.º 2
0
 /**
  * Marks a subscription as expired
  * and sends the expired email to the user
  * 
  * @param $subscription_id
  * @param object $item Single item from the Subscriptions model 
  * @param $issues If this is subscription by issues
  * @return unknown_type
  */
 function setExpired($subscription_id, $item = '', $issues = false)
 {
     // change status = '0'
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $subscription = JTable::getInstance('Subscriptions', 'TiendaTable');
     $subscription->subscription_id = $subscription_id;
     $subscription->subscription_enabled = 0;
     if ($issues) {
         $subscription->expires_datetime = JFactory::getDate()->toMySQL();
     }
     if (!$subscription->save()) {
         $this->setError($subscription->getError());
         return false;
     }
     // fire plugin event onAfterExpiredSubscription
     JPluginHelper::importPlugin('tienda');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onAfterExpiredSubscription', array($subscription));
     if (empty($item)) {
         JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
         $model = JModel::getInstance('Subscriptions', 'TiendaModel');
         $model->setId($subscription_id);
         $item = $model->getItem();
     }
     //remove user in juga group if integration exist
     Tienda::load('TiendaHelperJuga', 'helpers.juga');
     $helperJuga = new TiendaHelperJuga();
     if ($helperJuga->isInstalled()) {
         if ($helperJuga->doExpiredSubscription($item)) {
             //do something
             //either send email or raised message
         }
     }
     // Email user that their subs expired
     if (!empty($item)) {
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $helper->sendEmailNotices($item, 'subscription_expired');
     }
     return true;
 }