public function fork($name, Scalr_Account_User $user, $envId = null)
{
$script = new static();
$script->name = $name;
$script->description = $this->description;
$script->os = $this->os;
$script->isSync = $this->isSync;
$script->allowScriptParameters = $this->allowScriptParameters;
$script->timeout = $this->timeout;
$script->accountId = $user->getAccountId() ?: NULL;
$script->envId = $envId ? $envId : $this->envId;
$script->createdById = $user->getId();
$script->createdByEmail = $user->getEmail();
$script->save();
$version = new ScriptVersion();
$version->scriptId = $script->id;
$version->changedById = $user->getId();
$version->changedByEmail = $user->getEmail();
$version->content = $this->getLatestVersion()->content;
$version->version = 1;
$version->save();
return $script;
}