recordsLinked = true; } function setUser($userInstance) { $this->user = $userInstance; } function getUser() { return $this->user; } function serializeToSend() { $category = $this->moduleName; if (empty($category)) { $category = "General"; } return array( 'alertid' => (string)$this->alertid, 'name' => $this->name, 'category' => $category, 'refreshRate'=> $this->refreshRate, 'description'=> $this->description, 'recordsLinked'=> $this->recordsLinked ); } abstract function query(); abstract function queryParameters(); function message() { return (string) $this->executeCount(); } /*function execute() { global $adb; $result = $adb->pquery($this->query(), $this->queryParameters()); return $result; }*/ function executeCount() { global $adb; $result = $adb->pquery($this->countQuery(), $this->queryParameters()); return $adb->query_result($result, 0, 'count'); } // Function provided to enable sub-classes to over-ride in case required protected function countQuery() { return mkCountQuery($this->query()); } static function models() { global $adb; $models = array(); $handlerResult = $adb->pquery("SELECT * FROM vtiger_mobile_alerts WHERE deleted = 0", array()); if ($adb->num_rows($handlerResult)) { while ($handlerRow = $adb->fetch_array($handlerResult)) { $handlerPath = $handlerRow['handler_path']; if (file_exists($handlerPath)) { checkFileAccessForInclusion($handlerPath); include_once $handlerPath; $alertModel = new $handlerRow['handler_class']; $alertModel->alertid = $handlerRow['id']; $models[] = $alertModel; } } } return $models; } static function modelWithId($alertid) { $models = self::models(); foreach($models as $model) { if ($model->alertid == $alertid) return $model; } return false; } }