/** * Init blog posting form * * @param int $a_blog_id * @param bool $a_insert * @return ilPropertyFormGUI */ protected function initPostingForm($a_blog_id, $a_insert = false) { global $ilCtrl, $ilUser; include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($ilCtrl->getFormAction($this)); if ($a_insert) { $form->setTitle($this->lng->txt("cont_insert_blog")); } else { $form->setTitle($this->lng->txt("cont_update_blog")); } $options = array(); include_once "Modules/Blog/classes/class.ilBlogPosting.php"; $postings = ilBlogPosting::getAllPostings($a_blog_id); if ($postings) { foreach ($postings as $post) { // could be posting from someone else if ($post["author"] == $ilUser->getId()) { $date = new ilDateTime($post["date"], IL_CAL_DATETIME); $title = $post["title"] . " - " . ilDatePresentation::formatDate($date); $cbox = new ilCheckboxInputGUI($title, "posting"); $cbox->setValue($post["id"]); $options[] = $cbox; } } } asort($options); $obj = new ilCheckboxGroupInputGUI($this->lng->txt("cont_pc_blog_posting"), "posting"); $obj->setRequired(true); $obj->setOptions($options); $form->addItem($obj); $blog_id = new ilHiddenInputGUI("blog_id"); $blog_id->setValue($a_blog_id); $form->addItem($blog_id); if ($a_insert) { $form->addCommandButton("create_blog", $this->lng->txt("save")); $form->addCommandButton("cancelCreate", $this->lng->txt("cancel")); } else { $obj->setValue($this->content_obj->getPostings()); $form->addCommandButton("update", $this->lng->txt("save")); $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel")); } return $form; }