/** Handles creation of non Stimulus submissions on user profile Identifies the genre from the associated table and show and show them in the sidebar menu */ public function action_create() { $this->_enable_editor = true; $id = $this->request->param('id'); $item_map = array('Story Writing' => 'Story', 'Film' => 'Film', 'Music' => 'Music', 'Photography' => 'Photos'); $submission = null; $errors = array(); if (isset($_REQUEST['submission_id'])) { $submission = ORM::Factory('submission', $_REQUEST['submission_id']); if ($submission->status == Model_Submission::STATUS_PUBLISHED) { $this->request->redirect("/user"); } } else { $submission = new Model_Submission(); $submission->owner_id = $this->user->id; if (!$id) { $id = "Story Writing"; } } $genre_list = ORM::factory("genre")->order_by('genre_name', 'DESC')->find_all(); $rule = null; foreach ($genre_list as $item) { $menu = new Model_Ui_Menuitem($item_map[$item->genre_name], "/" . $this->request->controller() . "/create/" . $item->genre_name); $menu->id = $item->id; if ($submission->default_genre_id == $item->id) { $menu->active = true; $rule = $item; } else { if ($id == $item->name) { $menu->active = true; $rule = $item; } } $this->_secondary_menu[] = $menu; } if (!$submission->default_genre_id && $rule) { $submission->default_genre_id = $rule->id; } $errors = $submission->handle_submission_create_edit($this); $this->_view = new View("submissions/create_edit"); $this->_view->bind("rule", $rule); $this->_view->bind("submission", $submission); $this->_view->set("errors", $errors); }
/** Create a submission for a Challenge */ public function action_participate() { $this->clear_sidebar(); $this->_enable_editor = true; $submission = null; $errors = array(); if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') { $post_max = ini_get('post_max_size'); $errors['content_file'] = "File Size exceeds maximum upload limit {$post_max}"; } $stimulus = ORM::Factory('stimulus', $this->request->param('id')); $this->set_stimulus_menu($stimulus); $path = $stimulus->main_image; if ($stimulus->content_id) { $content = ORM::factory('content', $stimulus->content_id); $item = $content->get_generated_preset(Model_Content_Viewable::PRESET_THUMB_200_X); if ($item) { $path = $item->file_path; } } if (isset($_REQUEST['submission_id'])) { $submission = ORM::Factory('submission', $_REQUEST['submission_id']); } else { $submission = new Model_Submission(); $submission->stimulus_id = $stimulus->id; $submission->default_genre_id = $stimulus->genre_id; } if (empty($submission->id) && isset($_POST['draft']) && !empty($stimulus->tos)) { if (!isset($_POST['tos'])) { $errors['tos'] = 'Please Agree to The Contest Terms of Service'; } } if (empty($errors)) { $errors = $submission->handle_submission_create_edit($this); } if ($submission->status == 'PUBLISHED') { $this->request->redirect("/submissions/view/" . $submission->id); } $this->add_to_sidebar(new View("common/image_block", array('img' => $path))); $this->_view = new View("submissions/create_edit"); $this->_view->bind("rule", $stimulus); $this->_view->bind("submission", $submission); $this->_view->set("errors", $errors); }