public function actionGetCounters() { Yii::import('mod.cart.models.Order'); Yii::import('mod.cart.models.ProductNotifications'); Yii::import('mod.support.models.TicketMessage'); $json = array(); if (Yii::app()->hasModule('comments')) { $json['comments'] = (int) Comments::model()->waiting()->count(); } $json['orders'] = (int) Order::model()->new()->count(); $json['notify'] = (int) ProductNotifications::model()->count(); $json['support'] = (int) TicketMessage::model()->count(); echo CJSON::encode($json); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = TicketMessage::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }