public function actionPools() { $pool = Pools::model()->with('answers')->findByPk($_POST['poolId']); if(!PoolsIp::model()->count('ip = :ip AND pool_id = :id', array(':ip'=>$_SERVER['REMOTE_ADDR'], ':id'=>$pool->id))) { if(isset($_POST['value'])) { $pool->hits++; $poolsIp = new PoolsIp(); $poolsIp->answer_id = $_POST['value']; $poolsIp->pool_id = $pool->id; $poolsIp->ip = $_SERVER['REMOTE_ADDR']; $answer = Answers::model()->findByPk($_POST['value']); $answer->hits++; $answer->save(); $poolsIp->save(); $pool->save(); $refreshedPools = Pools::model()->with('answers')->findByPk($_POST['poolId']); $this->renderPartial('pool', array('pool'=>$refreshedPools), false, false); } } }
private function getPools($poolId = null) { $pools = new Pools(); $data = $pools->update($poolId); return $data; }
public function init() { $this->model = Pools::model()->findAll('active = :active', array(':active' => 1)); }
/** * Run - called by outside cron */ public static function Run() { // add here your code... // Class::Method(); $perform_actions = false; // update last time running $sql = 'SELECT cron_type, cron_run_last_time, cron_run_period, cron_run_period_value, CASE WHEN cron_run_last_time = \'0000-00-00 00:00:00\' THEN \'999\' WHEN cron_run_period = \'minute\' THEN TIMESTAMPDIFF(MINUTE, cron_run_last_time, \'' . date('Y-m-d H:i:s') . '\') ELSE TIMESTAMPDIFF(HOUR, cron_run_last_time, \'' . date('Y-m-d H:i:s') . '\') END as time_diff FROM ' . TABLE_SETTINGS; $result = database_query($sql, DATA_ONLY, FIRST_ROW_ONLY); if ($result['cron_type'] == 'batch') { $perform_actions = true; } else { if ($result['cron_type'] == 'non-batch' && $result['time_diff'] > $result['cron_run_period_value']) { $perform_actions = true; } else { $perform_actions = false; } } if ($perform_actions) { // update Feeds RSSFeed::UpdateFeeds(); if (self::$PROJECT == 'ShoppingCart') { // close expired discount campaigns Campaigns::UpdateStatus(); // remove expired orders Orders::RemoveExpired(); } else { if (self::$PROJECT == 'HotelSite') { // close expired discount campaigns Campaigns::UpdateStatus(); // close expired coupons Coupons::UpdateStatus(); // remove expired 'Preparing' bookings Bookings::RemoveExpired(); } else { if (self::$PROJECT == 'BusinnessDirectory') { // close expired lisitngs Listings::UpdateStatus(); // remove old inquiries Inquiries::RemoveOld(); } else { if (self::$PROJECT == 'MedicalAppointment') { // remove expired appointments Appointments::RemoveExpired(); // send reminders for patient and doctor Appointments::SendReminders(); } else { if (self::$PROJECT == 'MicroBlog') { // close expired polls Pools::UpdateStatus(); } } } } } // update last time running $sql = 'UPDATE ' . TABLE_SETTINGS . ' SET cron_run_last_time = \'' . date('Y-m-d H:i:s') . '\''; database_void_query($sql); } }
/** * 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 $id the ID of the model to be loaded * @return Pools the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Pools::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }