/** * 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; }