private function onCheckout(array $argv) { if (count($argv) < 3) { return $this->showRepoHelp('checkout'); } $type = strtolower($argv[0]); if (!Dog_Repo::isValidType($type)) { return $this->error('err_type'); } $url = $argv[1]; if (!GWF_Validator::isValidURL($url) || !GWF_HTTP::pageExists($url)) { // return $this->error('err_url'); } $name = $argv[2]; if (!Dog_Repo::isNameValid($name)) { return $this->error('err_name_invalid'); } if (Dog_Repo::repoExists($name, $url)) { return $this->error('err_dup'); } $user = NULL; $pass = NULL; if (isset($argv[3])) { $user = $argv[3]; $pass = isset($argv[4]) ? $argv[4] : ''; } $repo = new Dog_Repo(array('repo_id' => '0', 'repo_type' => $type, 'repo_name' => $name, 'repo_url' => $url, 'repo_user' => $user, 'repo_pass' => $pass, 'repo_options' => '0')); if (!$repo->insert()) { return $this->error('err_database'); } $this->rply('msg_checking_out', array($name)); $repo->checkout(); }
public function on_repo_checkout_Pb() { GDO::table('Dog_Repo')->createTable(true); GDO::table('Dog_RepoSubscribes')->createTable(true); GDO::table('Dog_RepoUsers')->createTable(true); GWF_File::removeDir(Dog_Repo::baseDir(), false, true, true); $argv = $this->argv(); $argc = count($argv); if ($argc !== 3) { return $this->showHelp('checkout'); } $type = $argv[1]; if (!Dog_Repo::isValidType($type)) { return $this->rply('err_software'); } $url = @parse_url($argv[2]); if (!isset($url['scheme'])) { return $this->rply('err_url', $url); } $url = $argv[2]; if (!GWF_HTTP::pageExists($url)) { return $this->rply('err_connect'); } $name = $argv[0]; if (!Dog_Repo::isValidName($name)) { return $this->rply('err_repo_name'); } if (Dog_Repo::exists($name)) { return $this->rply('err_repo_taken'); } if (!GWF_File::createDir(Dog_Repo::repoDir($name))) { return $this->rply('err_create_dir'); } if (!($repo = Dog_Repo::create($url, $name, $type))) { return Dog::err('ERR_DATABASE', array(__FILE__, __LINE__)); } call_user_func(array($this, 'checkout_' . $type), $repo); }