corey34
Active Member
I want to update the query that displays the total subscriber count in the customer dashboard. Currently, the way that count works is it displays all subscribers in all mailing lists, but we bill only on confirmed subscribers, so we'd like the count in the dashboard to display only confirmed subscribers, as well, to keep things consistent for the user.
Currently, we've added a line of code to the DashboardController.php file to make this modification, but obviously we'd prefer to build this as an extension so it doesn't get overwritten in a future upgrade. What's the best way to create the extension? Do I need to replicate the entire getGlanceStats() function in an extension to override the existing query, or is there a way to use an extension to append the line of code in question to the existing query? I'm still getting familiar with the Yii framework in general and the MailWizz framework in particular, so I'd appreciate any input you can offer.
Below is the code in question, with the last line displayed being the line I've added to change the parameters of the query.
Currently, we've added a line of code to the DashboardController.php file to make this modification, but obviously we'd prefer to build this as an extension so it doesn't get overwritten in a future upgrade. What's the best way to create the extension? Do I need to replicate the entire getGlanceStats() function in an extension to override the existing query, or is there a way to use an extension to append the line of code in question to the existing query? I'm still getting familiar with the Yii framework in general and the MailWizz framework in particular, so I'd appreciate any input you can offer.
Below is the code in question, with the last line displayed being the line I've added to change the parameters of the query.
PHP:
protected function getGlanceStats()
{
$customer = Yii::app()->customer->getModel();
$customer_id = (int)$customer->customer_id;
$cacheKey = md5('customer.'.$customer_id.'.dashboard.glanceStats');
$cache = Yii::app()->cache;
if (($items = $cache->get($cacheKey))) {
return $items;
}
$criteria = new CDbCriteria();
$criteria->compare('t.customer_id', $customer_id);
$criteria->addNotInCondition('t.status', array(Lists::STATUS_PENDING_DELETE));
$subsCriteria = new CDbCriteria();
$subsCriteria->addInCondition('t.list_id', $customer->getAllListsIdsNotMerged());
$subsCriteria->addInCondition('t.status', array('confirmed'));