function action_write() { $user = $this->user; if (!$user->can_add) { $this->template->content = new View('kwalbum/invalidpermission'); return; } $date = $this->date; if (!$date) { $date = date('Y-m-d'); } $time = date('H:i'); $content = new View('kwalbum/user/write'); $content->user_is_admin = $user->is_admin; $content->location = $this->location; $content->tags = 'news,'; if (isset($_POST['group_option'])) { $content->same_group = $_POST['group_option'] == 'existing'; } else { $content->same_group = false; } if (isset($this->tags)) { $content->tags .= implode(',', $this->tags); } $content->date = $date; $content->time = $time; if (isset($_POST['act'])) { $adder = new Kwalbum_ItemAdder($this->user); $id = $adder->save_write(); if ($id) { $content->message = "There has been success in saving your words!<br/><a href='{$this->url}/~{$id}'>Go read them now to make sure they are correct.</a>"; $content->same_group = true; } else { Kohana::$log->add('~user/write', 'ItemAdder failed to save_write item'); $content->message = 'Your words were not saved. Try again or report the error and save your message somewhere else for now.'; $content->location = $_POST['loc']; $content->tags = $_POST['tags']; $content->date = $_POST['date']; $content->time = $_POST['time']; $content->description = $_POST['description']; } } $template = $this->template; $template->content = $content; $template->title = 'Write'; $template->head .= html::script('kwalbum/media/ajax/write.js'); }