/** * Required parameter check * @param $params params extracted from the POST */ protected function validateParams($params) { $required = array('eventid', 'startdate', 'enddate', 'increment', 'userdefs'); foreach ($required as $arg) { if (!isset($params[$arg])) { $this->dieUsageMsg(array('missingparam', $arg)); } } // check if event id parses to an int greater than zero if ((int) $params['eventid'] < 0) { $this->dieUsage('Invalid event ID', 'badeventid'); } // check start and end date are of proper format if ($params['startdate'] != 0 && strptime(SpecialClickTracking::space_out_date($params['startdate']), "%Y %m %d") === false) { $this->dieUsage("startdate not in YYYYMMDD format: <<{$params['startdate']}>>", 'badstartdate'); } if ($params['enddate'] != 0 && strptime(SpecialClickTracking::space_out_date($params['enddate']), "%Y %m %d") === false) { $this->dieUsage("enddate not in YYYYMMDD format: <<{$params['enddate']}>>", 'badenddate'); } // check if increment is a positive int if ((int) $params['increment'] <= 0) { $this->dieUsage('Invalid increment', 'badincrement'); } if (json_decode($params['userdefs']) == null) { $this->dieUsage("Invalid JSON encoding <<{$params['userdefs']}>>", 'badjson'); } }
static function getTimeConstraints($minTime, $maxTime) { if ($minTime == 0 || $maxTime == 0 || strptime(SpecialClickTracking::space_out_date($minTime), "%Y %m %d") === false || strptime(SpecialClickTracking::space_out_date($minTime), "%Y %m %d") === false) { return array(); } else { // the dates are stored in the DB as MW_TIMESTAMP formats, add the zeroes to fix that $minTime .= "000000"; $maxTime .= "000000"; $dbr = wfGetDB(DB_SLAVE); // time constraint array return array("`action_time` >= " . $dbr->addQuotes($minTime), "`action_time` <= " . $dbr->addQuotes($maxTime)); } }