function post_resource($data) { $authorCurrent = hyoo_author::make(); if ($this->key && $this !== $authorCurrent) { return so_output::forbidden("User [{$this->name}] is already registered"); } $this->about = $data['hyoo_author_about'] ?: $this->about; $this->key = so_crypt::hash($this->uri, so_user::make()->key); $this->exists = true; so_cookie::make('hyoo_author_name')->value = $this->name; #return so_output::ok( 'Updated' ); return so_output::created((string) $this); }
function move_resource($data) { $name = strtr($data['hyoo_article_name'], array("\n" => '', "\r" => '')); $force = $data['so_conflict_force'] == 'true'; $target = hyoo_article::makeInstance()->name($name)->primary(); if ($target === $this) { return so_output::ok('Same name'); } if ($target->exists && !$force) { return so_output::conflict('Article already exists'); } $target->content = $this->content; $target->annotation = $this->annotation; $target->exists = true; if ($this->exists && $target->author === $this->author) { $this->content = " /Article moved to [new location\\{$target}]/.\n"; $this->exists = false; } return so_output::created((string) $target); }