本文整理汇总了PHP中Scalr_Util_DateTime::convertTimeZone方法的典型用法代码示例。如果您正苦于以下问题:PHP Scalr_Util_DateTime::convertTimeZone方法的具体用法?PHP Scalr_Util_DateTime::convertTimeZone怎么用?PHP Scalr_Util_DateTime::convertTimeZone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalr_Util_DateTime
的用法示例。
在下文中一共展示了Scalr_Util_DateTime::convertTimeZone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBackupsList
private function getBackupsList($time = '')
{
$data = array();
$time = $time == '' ? time() : strtotime($time);
$query = "\n SELECT b.id AS backupId, b.farm_id AS farmId, b.service AS serviceName, b.dtcreated AS time, f.name AS farmName\n FROM `services_db_backups` b\n LEFT JOIN `farms` f ON b.farm_id = f.id\n WHERE b.status = ? AND b.env_id = ?\n AND DATE_FORMAT(CONVERT_TZ(b.dtcreated, 'SYSTEM', ?), '%Y-%m') = ?\n ";
$userTimezone = $this->user->getSetting(Scalr_Account_User::SETTING_UI_TIMEZONE);
if (empty($userTimezone)) {
$userTimezone = 'SYSTEM';
}
$args = array(Scalr_Db_Backup::STATUS_AVAILABLE, $this->getEnvironmentId(), $userTimezone, date('Y-m', $time));
if ($this->getParam('farmId')) {
$query .= ' AND b.farm_id = ?';
$args[] = $this->getParam('farmId');
}
if (!$this->request->isAllowed(Acl::RESOURCE_FARMS, Acl::PERM_FARMS_NOT_OWNED_FARMS)) {
$query .= " AND f.created_by_id = ?";
$args[] = $this->user->getId();
}
$dbBackupResult = $this->db->GetAll($query, $args);
foreach ($dbBackupResult as $row) {
$dt = new DateTime($row['time']);
Scalr_Util_DateTime::convertTimeZone($dt, $this->user->getSetting(Scalr_Account_User::SETTING_UI_TIMEZONE));
$row['time'] = $dt->format('h:ia');
if (empty($row['farmName'])) {
$row['farmName'] = '*removed farm*';
}
$data[$dt->format('j M')][] = $row;
}
return $data;
}
示例2: xListScriptingLogsAction
/**
* @param int $farmId
* @param string $serverId
* @param string $event
* @param string $eventId
* @param string $eventServerId
* @param int $scriptId
* @param int $schedulerId
* @param string $byDate
* @param string $fromTime
* @param string $toTime
* @param string $status
* @throws Scalr_Exception_Core
* @throws Scalr_Exception_InsufficientPermissions
*/
public function xListScriptingLogsAction($farmId = 0, $serverId = '', $event = '', $eventId = '', $eventServerId = '', $scriptId = 0, $schedulerId = 0, $byDate = '', $fromTime = '', $toTime = '', $status = '')
{
$this->request->restrictAccess(Acl::RESOURCE_LOGS_SCRIPTING_LOGS);
$sql = "SELECT * FROM scripting_log WHERE :FILTER:";
$args = [];
$farmSql = "SELECT id FROM farms WHERE env_id = ?";
$farmArgs = [$this->getEnvironmentId()];
list($farmSql, $farmArgs) = $this->request->prepareFarmSqlQuery($farmSql, $farmArgs);
$farms = $this->db->GetCol($farmSql, $farmArgs);
if ($farmId && in_array($farmId, $farms)) {
$sql .= ' AND farmid = ?';
$args[] = $farmId;
} else {
if (count($farms)) {
$sql .= ' AND farmid IN (' . implode(',', $farms) . ')';
} else {
$sql .= ' AND 0';
}
}
if ($serverId) {
$sql .= ' AND server_id = ?';
$args[] = $serverId;
}
if ($eventServerId) {
$sql .= ' AND event_server_id = ?';
$args[] = $eventServerId;
}
if ($eventId) {
$sql .= ' AND event_id = ?';
$args[] = $eventId;
}
if ($scriptId) {
/* @var $script Script */
$script = Script::findPk($scriptId);
if ($script && (!$script->accountId || $script->accountId == $this->user->getAccountId())) {
$scriptName = substr(preg_replace("/[^A-Za-z0-9]+/", "_", $script->name), 0, 50);
// because of column's length
$sql .= ' AND script_name = ?';
$args[] = $scriptName;
}
}
if ($schedulerId) {
$sql .= ' AND event = ?';
$args[] = 'Scheduler (TaskID: ' . $schedulerId . ')';
} else {
if ($event) {
$sql .= ' AND event = ?';
$args[] = $event;
}
}
if ($byDate) {
try {
$tz = $this->user->getSetting(Scalr_Account_User::SETTING_UI_TIMEZONE);
if (!$tz) {
$tz = 'UTC';
}
$tz = new DateTimeZone($tz);
$dtS = new DateTime($byDate, $tz);
$dtE = new DateTime($byDate, $tz);
if ($fromTime) {
$dtS = DateTime::createFromFormat('Y-m-d H:i', "{$byDate} {$fromTime}", $tz);
}
if ($toTime) {
$dtE = DateTime::createFromFormat('Y-m-d H:i', "{$byDate} {$toTime}", $tz);
} else {
$dtE = $dtE->add(new DateInterval('P1D'));
}
if ($dtS && $dtE) {
Scalr_Util_DateTime::convertTimeZone($dtS);
Scalr_Util_DateTime::convertTimeZone($dtE);
$sql .= ' AND dtadded > ? AND dtadded < ?';
$args[] = $dtS->format('Y-m-d H:i:s');
$args[] = $dtE->format('Y-m-d H:i:s');
}
} catch (Exception $e) {
}
}
if ($status === 'success') {
$sql .= ' AND exec_exitcode = ?';
$args[] = 0;
} else {
if ($status === 'failure') {
$sql .= ' AND exec_exitcode <> ?';
$args[] = 0;
}
//.........这里部分代码省略.........
示例3: xListOrchestrationLogsAction
/**
* @param int $farmId
* @param string $serverId
* @param string $eventId
* @param int $scriptId
* @param string $eventServerId
* @param int $schedulerId
* @param string $byDate
* @param string $fromTime
* @param string $toTime
* @param string $status
* @param string $event
* @param JsonData $sort
* @param int $start
* @param int $limit
* @param string $query
* @throws Scalr_Exception_Core
* @throws Scalr_Exception_InsufficientPermissions
*/
public function xListOrchestrationLogsAction($farmId = 0, $serverId = '', $eventId = '', $scriptId = 0, $eventServerId = '', $schedulerId = 0, $byDate = '', $fromTime = '', $toTime = '', $status = '', $event = '', JsonData $sort, $start = 0, $limit = 20, $query = '')
{
$this->request->restrictAccess(Acl::RESOURCE_LOGS_ORCHESTRATION_LOGS);
$o = new Entity\OrchestrationLog();
$f = new Entity\Farm();
$criteria = [Entity\Farm::STMT_FROM => "{$o->table()} JOIN {$f->table('f')} ON {$f->columnId('f')} = {$o->columnFarmId}", Entity\Farm::STMT_WHERE => $this->request->getFarmSqlQuery() . " AND {$f->columnEnvId('f')} = " . $this->db->qstr($this->getEnvironmentId())];
if ($farmId) {
$criteria[] = ['farmId' => $farmId];
}
if ($serverId) {
$criteria[] = ['serverId' => $serverId];
}
if ($eventId) {
$criteria[] = ['eventId' => $eventId];
}
if ($eventServerId) {
$criteria[] = ['eventServerId' => $eventServerId];
}
if ($scriptId) {
/* @var $script Script */
$script = Script::findPk($scriptId);
if ($script && $this->request->hasPermissions($script)) {
$scriptName = preg_replace("/[^A-Za-z0-9]+/", "_", $script->name);
$criteria[] = ['scriptName' => $scriptName];
}
}
if ($query || $event) {
$logEntity = new OrchestrationLog();
$eventEntity = new Event();
$criteria[AbstractEntity::STMT_FROM] = $criteria[AbstractEntity::STMT_FROM] . "\n LEFT JOIN {$eventEntity->table('e')}\n ON {$logEntity->columnEventId} = {$eventEntity->columnEventId('e')}\n ";
if ($event && $query) {
$query = $this->db->qstr('%' . $query . '%');
$criteria[AbstractEntity::STMT_WHERE] = $criteria[AbstractEntity::STMT_WHERE] . " AND (\n {$eventEntity->columnType('e')} = {$this->db->qstr($event)}\n OR ({$logEntity->columnType} LIKE {$query}\n AND {$logEntity->columnScriptName} LIKE {$query})\n )";
} else {
if ($event) {
$criteria[AbstractEntity::STMT_WHERE] = $criteria[AbstractEntity::STMT_WHERE] . " AND (\n {$eventEntity->columnType('e')} = {$this->db->qstr($event)}\n )";
} else {
$query = $this->db->qstr('%' . $query . '%');
$criteria[AbstractEntity::STMT_WHERE] = $criteria[AbstractEntity::STMT_WHERE] . " AND (\n ({$eventEntity->columnType('e')} LIKE {$query}\n OR {$logEntity->columnType} LIKE {$query}\n OR {$logEntity->columnScriptName} LIKE {$query})\n )";
}
}
}
if ($schedulerId) {
$criteria[] = ['taskId' => $schedulerId];
}
if ($byDate) {
try {
$tz = $this->user->getSetting(Scalr_Account_User::SETTING_UI_TIMEZONE) ?: 'UTC';
$tz = new DateTimeZone($tz);
$dtS = new DateTime($byDate, $tz);
$dtE = new DateTime($byDate, $tz);
if ($fromTime) {
$dtS = DateTime::createFromFormat('Y-m-d H:i', "{$byDate} {$fromTime}", $tz);
}
if ($toTime) {
$dtE = DateTime::createFromFormat('Y-m-d H:i', "{$byDate} {$toTime}", $tz);
} else {
$dtE = $dtE->add(new DateInterval('P1D'));
}
if ($dtS && $dtE) {
Scalr_Util_DateTime::convertTimeZone($dtS);
Scalr_Util_DateTime::convertTimeZone($dtE);
$criteria[] = ['added' => ['$gt' => $dtS]];
$criteria[] = ['added' => ['$lt' => $dtE]];
}
} catch (Exception $e) {
}
}
if ($status === 'success') {
$criteria[] = ['execExitCode' => 0];
} else {
if ($status === 'failure') {
$criteria[] = ['execExitCode' => ['$ne' => 0]];
}
}
$logs = OrchestrationLog::find($criteria, null, Scalr\UI\Utils::convertOrder($sort, ['id' => false], ['id', 'added']), $limit, $start, true);
$data = $this->prepareOrchestrationLogData($logs);
$this->response->data(['data' => $data, 'total' => $logs->totalNumber]);
}
示例4: xListScriptingLogsAction
public function xListScriptingLogsAction()
{
$this->request->restrictAccess(Acl::RESOURCE_LOGS_SCRIPTING_LOGS);
$this->request->defineParams(array('farmId' => array('type' => 'int'), 'serverId' => array('type' => 'string'), 'query' => array('type' => 'string'), 'sort' => array('type' => 'json', 'default' => array('property' => 'id', 'direction' => 'DESC'))));
$sql = "SELECT * FROM scripting_log WHERE :FILTER:";
$args = array();
$farms = $this->db->GetCol("SELECT id FROM farms WHERE env_id=?", array($this->getEnvironmentId()));
if ($this->getParam('farmId') && in_array($this->getParam('farmId'), $farms)) {
$sql .= ' AND farmid = ?';
$args[] = $this->getParam('farmId');
} else {
if (count($farms)) {
$sql .= ' AND farmid IN (' . implode(',', $farms) . ')';
} else {
$sql .= ' AND 0';
}
}
if ($this->getParam('serverId')) {
$sql .= ' AND server_id = ?';
$args[] = $this->getParam('serverId');
}
if ($this->getParam('eventId')) {
$sql .= ' AND event_id = ?';
$args[] = $this->getParam('eventId');
}
if ($this->getParam('byDate')) {
try {
$tz = $this->user->getSetting(Scalr_Account_User::SETTING_UI_TIMEZONE);
if (!$tz) {
$tz = 'UTC';
}
$tz = new DateTimeZone($tz);
$dtS = new DateTime($this->getParam('byDate'), $tz);
$dtE = new DateTime($this->getParam('byDate'), $tz);
if ($this->getParam('fromTime')) {
$dtS = DateTime::createFromFormat('Y-m-d H:i', $this->getParam('byDate') . ' ' . $this->getParam('fromTime'), $tz);
}
if ($this->getParam('toTime')) {
$dtE = DateTime::createFromFormat('Y-m-d H:i', $this->getParam('byDate') . ' ' . $this->getParam('toTime'), $tz);
} else {
$dtE = $dtE->add(new DateInterval('P1D'));
}
Scalr_Util_DateTime::convertTimeZone($dtS);
Scalr_Util_DateTime::convertTimeZone($dtE);
$sql .= ' AND dtadded > ? AND dtadded < ?';
$args[] = $dtS->format('Y-m-d H:i:s');
$args[] = $dtE->format('Y-m-d H:i:s');
} catch (Exception $e) {
}
}
$response = $this->buildResponseFromSql2($sql, array('id', 'dtadded'), array('script_name', 'server_id', 'event_server_id', 'event'), $args);
$cache = array();
foreach ($response["data"] as &$row) {
//
//target_data
//
if (!$cache['farm_names'][$row['farmid']]) {
$cache['farm_names'][$row['farmid']] = $this->db->GetOne("SELECT name FROM farms WHERE id=? LIMIT 1", array($row['farmid']));
}
$row['target_farm_name'] = $cache['farm_names'][$row['farmid']];
$row['target_farm_id'] = $row['farmid'];
$sInfo = $this->db->GetRow("SELECT role_id, farm_roleid, `index` FROM servers WHERE server_id = ? LIMIT 1", array($row['server_id']));
$row['target_farm_roleid'] = $sInfo['farm_roleid'];
if (!$cache['role_names'][$sInfo['role_id']]) {
$cache['role_names'][$sInfo['role_id']] = $this->db->GetOne("SELECT name FROM roles WHERE id=?", array($sInfo['role_id']));
}
$row['target_role_name'] = $cache['role_names'][$sInfo['role_id']];
$row['target_server_index'] = $sInfo['index'];
$row['target_server_id'] = $row['server_id'];
//
//event_data
//
if ($row['event_server_id']) {
$esInfo = $this->db->GetRow("SELECT role_id, farm_roleid, `index`, farm_id FROM servers WHERE server_id = ? LIMIT 1", array($row['event_server_id']));
if (!$cache['farm_names'][$esInfo['farm_id']]) {
$cache['farm_names'][$esInfo['farm_id']] = $this->db->GetOne("SELECT name FROM farms WHERE id=? LIMIT 1", array($esInfo['farm_id']));
}
$row['event_farm_name'] = $cache['farm_names'][$esInfo['farm_id']];
$row['event_farm_id'] = $esInfo['farm_id'];
$row['event_farm_roleid'] = $esInfo['farm_roleid'];
if (!$cache['role_names'][$esInfo['role_id']]) {
$cache['role_names'][$esInfo['role_id']] = $this->db->GetOne("SELECT name FROM roles WHERE id=? LIMIT 1", array($esInfo['role_id']));
}
$row['event_role_name'] = $cache['role_names'][$esInfo['role_id']];
$row['event_server_index'] = $esInfo['index'];
}
$row['dtadded'] = Scalr_Util_DateTime::convertTz($row['dtadded']);
if (\Scalr::config('scalr.system.scripting.logs_storage') == 'scalr') {
$row['execution_id'] = null;
}
if ($row['message']) {
$row['message'] = nl2br(htmlspecialchars($row['message']));
}
}
$this->response->data($response);
}
示例5: xSaveAction
public function xSaveAction()
{
$this->request->restrictAccess(Acl::RESOURCE_GENERAL_SCHEDULERTASKS, Acl::PERM_GENERAL_SCHEDULERTASKS_MANAGE);
$this->request->defineParams(array('id' => array('type' => 'integer'), 'name' => array('type' => 'string', 'validator' => array(Scalr_Validator::REQUIRED => true, Scalr_Validator::NOHTML => true)), 'type' => array('type' => 'string', 'validator' => array(Scalr_Validator::RANGE => array(Scalr_SchedulerTask::SCRIPT_EXEC, Scalr_SchedulerTask::LAUNCH_FARM, Scalr_SchedulerTask::TERMINATE_FARM, Scalr_SchedulerTask::FIRE_EVENT), Scalr_Validator::REQUIRED => true)), 'startTime', 'startTimeDate', 'restartEvery', 'timezone' => array('type' => 'string', 'validator' => array(Scalr_Validator::REQUIRED => true)), 'farmId' => array('type' => 'integer'), 'farmRoleId' => array('type' => 'integer'), 'serverId' => array('type' => 'string'), 'scriptOptions' => array('type' => 'array'), 'eventParams' => array('type' => 'array'), 'eventName' => array('type' => 'string')));
$task = Scalr_SchedulerTask::init();
if ($this->getParam('id')) {
$task->loadById($this->getParam('id'));
$this->user->getPermissions()->validate($task);
} else {
$task->accountId = $this->user->getAccountId();
$task->envId = $this->getEnvironmentId();
$task->status = Scalr_SchedulerTask::STATUS_ACTIVE;
}
$this->request->validate();
$params = array();
$timezone = new DateTimeZone($this->getParam('timezone'));
$startTm = $this->getParam('startTime') ? new DateTime($this->getParam('startTimeDate') . " " . $this->getParam('startTime'), $timezone) : NULL;
if ($startTm) {
Scalr_Util_DateTime::convertTimeZone($startTm, NULL);
}
$curTm = new DateTime();
if ($startTm && $startTm < $curTm && !$task->id) {
$this->request->addValidationErrors('startTimeDate', array('Start time must be greater then current time'));
}
switch ($this->getParam('type')) {
case Scalr_SchedulerTask::FIRE_EVENT:
case Scalr_SchedulerTask::SCRIPT_EXEC:
if ($this->getParam('serverId')) {
$dbServer = DBServer::LoadByID($this->getParam('serverId'));
$this->user->getPermissions()->validate($dbServer);
$task->targetId = $dbServer->GetFarmRoleObject()->ID;
$task->targetServerIndex = $dbServer->index;
$task->targetType = Scalr_SchedulerTask::TARGET_INSTANCE;
} else {
if ($this->getParam('farmRoleId')) {
$dbFarmRole = DBFarmRole::LoadByID($this->getParam('farmRoleId'));
$this->user->getPermissions()->validate($dbFarmRole);
$task->targetId = $dbFarmRole->ID;
$task->targetType = Scalr_SchedulerTask::TARGET_ROLE;
} else {
if ($this->getParam('farmId')) {
$dbFarm = DBFarm::LoadByID($this->getParam('farmId'));
$this->user->getPermissions()->validate($dbFarm);
$task->targetId = $dbFarm->ID;
$task->targetType = Scalr_SchedulerTask::TARGET_FARM;
} else {
$this->request->addValidationErrors('farmId', array('Farm ID is required'));
}
}
}
if ($this->getParam('type') == Scalr_SchedulerTask::SCRIPT_EXEC) {
/* @var $script Script */
$script = Script::findPk($this->getParam('scriptId'));
try {
if ($script) {
$script->checkPermission($this->user, $this->getEnvironmentId());
$task->scriptId = $this->getParam('scriptId');
$params['scriptId'] = $this->getParam('scriptId');
$params['scriptIsSync'] = $this->getParam('scriptIsSync');
$params['scriptTimeout'] = $this->getParam('scriptTimeout');
$params['scriptVersion'] = $this->getParam('scriptVersion');
$params['scriptOptions'] = $this->getParam('scriptOptions');
} else {
throw new Exception();
}
} catch (Exception $e) {
$this->request->addValidationErrors('scriptId', array('Script ID is required'));
}
} elseif ($this->getParam('type') == Scalr_SchedulerTask::FIRE_EVENT) {
if (!EventDefinition::findOne([['name' => $this->getParam('eventName')], ['$or' => [['accountId' => null], ['accountId' => $this->user->getAccountId()]]], ['$or' => [['envId' => null], ['envId' => $this->getEnvironmentId()]]]])) {
throw new Exception("Event definition not found");
}
$params['eventName'] = $this->getParam('eventName');
$params['eventParams'] = $this->getParam('eventParams');
}
break;
case Scalr_SchedulerTask::LAUNCH_FARM:
if ($this->getParam('farmId')) {
$dbFarm = DBFarm::LoadByID($this->getParam('farmId'));
$this->user->getPermissions()->validate($dbFarm);
$task->targetId = $dbFarm->ID;
$task->targetType = Scalr_SchedulerTask::TARGET_FARM;
} else {
$this->request->addValidationErrors('farmId', array('Farm ID is required'));
}
break;
case Scalr_SchedulerTask::TERMINATE_FARM:
if ($this->getParam('farmId')) {
$dbFarm = DBFarm::LoadByID($this->getParam('farmId'));
$this->user->getPermissions()->validate($dbFarm);
$task->targetId = $dbFarm->ID;
$task->targetType = Scalr_SchedulerTask::TARGET_FARM;
} else {
$this->request->addValidationErrors('farmId', array('Farm ID is required'));
}
$params['deleteDNSZones'] = $this->getParam('deleteDNSZones');
$params['deleteCloudObjects'] = $this->getParam('deleteCloudObjects');
break;
}
if (!$this->request->isValid()) {
//.........这里部分代码省略.........
示例6: xSaveAction
public function xSaveAction()
{
$this->request->defineParams(array('id' => array('type' => 'integer'), 'name' => array('type' => 'string', 'validator' => array(Scalr_Validator::REQUIRED => true, Scalr_Validator::NOHTML => true)), 'type' => array('type' => 'string', 'validator' => array(Scalr_Validator::RANGE => array(Scalr_SchedulerTask::SCRIPT_EXEC, Scalr_SchedulerTask::LAUNCH_FARM, Scalr_SchedulerTask::TERMINATE_FARM), Scalr_Validator::REQUIRED => true)), 'startTime', 'endTime', 'restartEvery', 'timezone' => array('type' => 'string', 'validator' => array(Scalr_Validator::REQUIRED => true)), 'farmId' => array('type' => 'integer'), 'farmRoleId' => array('type' => 'integer'), 'serverId' => array('type' => 'string')));
$task = Scalr_SchedulerTask::init();
if ($this->getParam('id')) {
$task->loadById($this->getParam('id'));
$this->user->getPermissions()->validate($task);
} else {
$task->accountId = $this->user->getAccountId();
$task->envId = $this->getEnvironmentId();
$task->status = Scalr_SchedulerTask::STATUS_ACTIVE;
}
$this->request->validate();
$params = array();
$timezone = new DateTimeZone($this->getParam('timezone'));
$startTm = $this->getParam('startTime') ? new DateTime($this->getParam('startTime'), $timezone) : NULL;
$endTm = $this->getParam('endTime') ? new DateTime($this->getParam('endTime'), $timezone) : NULL;
if ($startTm) {
Scalr_Util_DateTime::convertTimeZone($startTm, NULL);
}
if ($endTm) {
Scalr_Util_DateTime::convertTimeZone($endTm, NULL);
}
if ($startTm && $endTm && $endTm < $startTm) {
$this->request->addValidationErrors('endTimeDate', array('End time must be greater then start time'));
}
$curTm = new DateTime();
if ($startTm && $startTm < $curTm && !$task->id) {
$this->request->addValidationErrors('startTimeDate', array('Start time must be greater then current time'));
}
switch ($this->getParam('type')) {
case Scalr_SchedulerTask::SCRIPT_EXEC:
if ($this->getParam('serverId')) {
$dbServer = DBServer::LoadByID($this->getParam('serverId'));
$this->user->getPermissions()->validate($dbServer);
$task->targetId = $dbServer->GetFarmRoleObject()->ID;
$task->targetServerIndex = $dbServer->index;
$task->targetType = Scalr_SchedulerTask::TARGET_INSTANCE;
} else {
if ($this->getParam('farmRoleId')) {
$dbFarmRole = DBFarmRole::LoadByID($this->getParam('farmRoleId'));
$this->user->getPermissions()->validate($dbFarmRole);
$task->targetId = $dbFarmRole->ID;
$task->targetType = Scalr_SchedulerTask::TARGET_ROLE;
} else {
if ($this->getParam('farmId')) {
$dbFarm = DBFarm::LoadByID($this->getParam('farmId'));
$this->user->getPermissions()->validate($dbFarm);
$task->targetId = $dbFarm->ID;
$task->targetType = Scalr_SchedulerTask::TARGET_FARM;
} else {
$this->request->addValidationErrors('farmId', array('Farm ID is required'));
}
}
}
if ($this->getParam('scriptId')) {
// TODO: check scriptId and other vars
$params['scriptId'] = $this->getParam('scriptId');
$params['scriptIsSync'] = $this->getParam('scriptIsSync');
$params['scriptTimeout'] = $this->getParam('scriptTimeout');
$params['scriptVersion'] = $this->getParam('scriptVersion');
$params['scriptOptions'] = $this->getParam('scriptOptions');
} else {
$this->request->addValidationErrors('scriptId', array('Script ID is required'));
}
break;
case Scalr_SchedulerTask::LAUNCH_FARM:
if ($this->getParam('farmId')) {
$dbFarm = DBFarm::LoadByID($this->getParam('farmId'));
$this->user->getPermissions()->validate($dbFarm);
$task->targetId = $dbFarm->ID;
$task->targetType = Scalr_SchedulerTask::TARGET_FARM;
} else {
$this->request->addValidationErrors('farmId', array('Farm ID is required'));
}
break;
case Scalr_SchedulerTask::TERMINATE_FARM:
if ($this->getParam('farmId')) {
$dbFarm = DBFarm::LoadByID($this->getParam('farmId'));
$this->user->getPermissions()->validate($dbFarm);
$task->targetId = $dbFarm->ID;
$task->targetType = Scalr_SchedulerTask::TARGET_FARM;
} else {
$this->request->addValidationErrors('farmId', array('Farm ID is required'));
}
$params['deleteDNSZones'] = $this->getParam('deleteDNSZones');
$params['deleteCloudObjects'] = $this->getParam('deleteCloudObjects');
break;
}
if (!$this->request->isValid()) {
$this->response->failure();
$this->response->data($this->request->getValidationErrors());
return;
}
$task->name = $this->getParam('name');
$task->type = $this->getParam('type');
$task->comments = htmlspecialchars($this->getParam('comments'));
$task->timezone = $this->getParam('timezone');
$task->startTime = $startTm ? $startTm->format('Y-m-d H:i:s') : NULL;
$task->endTime = $endTm ? $endTm->format('Y-m-d H:i:s') : NULL;
//.........这里部分代码省略.........