Exemple #1
0
 /**
  * The basic properties of a file object are stored in table object_data.
  * This is not sufficient for a file object. Therefore we create additional
  * properties in table file_data.
  * This method has been put into a separate operation, to allow a WebDAV Null resource
  * (class.ilObjNull.php) to become a file object.
  */
 function createProperties($a_upload = false, $a_prevent_meta_data_creation = false)
 {
     global $ilDB, $tree;
     // Create file directory
     $this->initFileStorage();
     $this->file_storage->create();
     if ($a_upload) {
         return true;
     }
     // not upload mode
     require_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_createEntry($this->getId(), "create", $this->getFileName() . ",1");
     $this->addNewsNotification("file_created");
     require_once "./Services/News/classes/class.ilNewsItem.php";
     $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET['ref_id']);
     if ($default_visibility == "public") {
         ilBlockSetting::_write("news", "public_notifications", 1, 0, $this->getId());
     }
     $q = "INSERT INTO file_data (file_id,file_name,file_type,file_size,version,f_mode) " . "VALUES (" . $ilDB->quote($this->getId(), 'integer') . "," . $ilDB->quote($this->getFileName(), 'text') . "," . $ilDB->quote($this->getFileType(), 'text') . "," . $ilDB->quote((int) $this->getFileSize(), 'integer') . "," . $ilDB->quote(1, 'integer') . "," . $ilDB->quote($this->getMode(), 'text') . ")";
     $res = $ilDB->manipulate($q);
     // no meta data handling for file list files
     if ($this->getMode() != "filelist" && !$a_prevent_meta_data_creation) {
         $this->createMetaData();
     }
 }
 /**
  * FORM NewsItem: Init form.
  *
  * @param	int	$a_mode	Form Edit Mode (IL_FORM_EDIT | IL_FORM_CREATE)
  */
 public function initFormNewsItem($a_mode)
 {
     global $lng, $ilTabs;
     $ilTabs->clearTargets();
     //$this->setTabs();
     $lng->loadLanguageModule("news");
     include "Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form_gui = new ilPropertyFormGUI();
     // Property Title
     $text_input = new ilTextInputGUI($lng->txt("news_news_item_title"), "news_title");
     $text_input->setInfo("");
     $text_input->setRequired(true);
     $text_input->setMaxLength(200);
     $this->form_gui->addItem($text_input);
     // Property Content
     $text_area = new ilTextAreaInputGUI($lng->txt("news_news_item_content"), "news_content");
     $text_area->setInfo("");
     $text_area->setRequired(false);
     $this->form_gui->addItem($text_area);
     // Property Visibility
     $radio_group = new ilRadioGroupInputGUI($lng->txt("news_news_item_visibility"), "news_visibility");
     $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "users");
     $radio_group->addOption($radio_option);
     $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "public");
     $radio_group->addOption($radio_option);
     $radio_group->setInfo($lng->txt("news_news_item_visibility_info"));
     $radio_group->setRequired(false);
     $radio_group->setValue("users");
     $this->form_gui->addItem($radio_group);
     // Property ContentLong
     $text_area = new ilTextAreaInputGUI($lng->txt("news_news_item_content_long"), "news_content_long");
     $text_area->setInfo($lng->txt("news_news_item_content_long_info"));
     $text_area->setRequired(false);
     $text_area->setCols("40");
     $text_area->setRows("8");
     $text_area->setUseRte(true);
     $this->form_gui->addItem($text_area);
     // save and cancel commands
     if (in_array($a_mode, array(IL_FORM_CREATE, IL_FORM_RE_CREATE))) {
         $this->form_gui->addCommandButton("saveNewsItem", $lng->txt("save"));
         $this->form_gui->addCommandButton("cancelSaveNewsItem", $lng->txt("cancel"));
     } else {
         $this->form_gui->addCommandButton("updateNewsItem", $lng->txt("save"));
         $this->form_gui->addCommandButton("cancelUpdateNewsItem", $lng->txt("cancel"));
     }
     $this->form_gui->setTitle($lng->txt("news_news_item_head"));
     $this->form_gui->setFormAction($this->ctrl->getFormAction($this));
     $this->form_gui->setTitleIcon(ilUtil::getImagePath("icon_news.png"));
     $news_set = new ilSetting("news");
     if (!$news_set->get("enable_rss_for_internal")) {
         $this->form_gui->removeItemByPostVar("news_visibility");
     } else {
         $nv = $this->form_gui->getItemByPostVar("news_visibility");
         if (is_object($nv)) {
             $nv->setValue(ilNewsItem::_getDefaultVisibilityForRefId($_GET["ref_id"]));
         }
     }
 }
 /**
  * Init setting form
  */
 function initSettingsForm()
 {
     global $ilUser, $lng, $ilCtrl, $ilSetting, $ilTabs;
     $ilTabs->clearTargets();
     $news_set = new ilSetting("news");
     $enable_internal_rss = $news_set->get("enable_rss_for_internal");
     $public = ilBlockSetting::_lookup($this->getBlockType(), "public_notifications", 0, $this->block_id);
     $public_feed = ilBlockSetting::_lookup($this->getBlockType(), "public_feed", 0, $this->block_id);
     $hide_block = ilBlockSetting::_lookup($this->getBlockType(), "hide_news_block", 0, $this->block_id);
     $hide_news_per_date = ilBlockSetting::_lookup($this->getBlockType(), "hide_news_per_date", 0, $this->block_id);
     $hide_news_date = ilBlockSetting::_lookup($this->getBlockType(), "hide_news_date", 0, $this->block_id);
     if ($hide_news_date != "") {
         $hide_news_date = explode(" ", $hide_news_date);
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->settings_form = new ilPropertyFormGUI();
     $this->settings_form->setTitle($lng->txt("news_settings"));
     $this->settings_form->setTitleIcon(ilUtil::getImagePath("icon_news.png"));
     // hide news block for learners
     if ($this->getProperty("hide_news_block_option")) {
         $ch = new ilCheckboxInputGUI($lng->txt("news_hide_news_block"), "hide_news_block");
         $ch->setInfo($lng->txt("news_hide_news_block_info"));
         $ch->setChecked($hide_block);
         $this->settings_form->addItem($ch);
         $hnpd = new ilCheckboxInputGUI($lng->txt("news_hide_news_per_date"), "hide_news_per_date");
         $hnpd->setInfo($lng->txt("news_hide_news_per_date_info"));
         $hnpd->setChecked($hide_news_per_date);
         $dt_prop = new ilDateTimeInputGUI($lng->txt("news_hide_news_date"), "hide_news_date");
         if ($hide_news_date != "") {
             $dt_prop->setDate(new ilDateTime($hide_news_date[0] . ' ' . $hide_news_date[1], IL_CAL_DATETIME));
         }
         #$dt_prop->setDate($hide_news_date[0]);
         #$dt_prop->setTime($hide_news_date[1]);
         $dt_prop->setShowTime(true);
         //$dt_prop->setInfo($lng->txt("news_hide_news_date_info"));
         $hnpd->addSubItem($dt_prop);
         $this->settings_form->addItem($hnpd);
     }
     // default visibility
     if ($this->getProperty("default_visibility_option") && $enable_internal_rss) {
         $default_visibility = ilBlockSetting::_lookup($this->getBlockType(), "default_visibility", 0, $this->block_id);
         if ($default_visibility == "") {
             $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET["ref_id"]);
         }
         // Default Visibility
         $radio_group = new ilRadioGroupInputGUI($lng->txt("news_default_visibility"), "default_visibility");
         $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "users");
         $radio_group->addOption($radio_option);
         $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "public");
         $radio_group->addOption($radio_option);
         $radio_group->setInfo($lng->txt("news_news_item_visibility_info"));
         $radio_group->setRequired(false);
         $radio_group->setValue($default_visibility);
         $this->settings_form->addItem($radio_group);
     }
     // public notifications
     if ($this->getProperty("public_notifications_option") && $enable_internal_rss) {
         $ch = new ilCheckboxInputGUI($lng->txt("news_notifications_public"), "notifications_public");
         $ch->setInfo($lng->txt("news_notifications_public_info"));
         $ch->setChecked($public);
         $this->settings_form->addItem($ch);
     }
     // extra rss feed
     if ($enable_internal_rss) {
         $ch = new ilCheckboxInputGUI($lng->txt("news_public_feed"), "notifications_public_feed");
         $ch->setInfo($lng->txt("news_public_feed_info"));
         $ch->setChecked($public_feed);
         $this->settings_form->addItem($ch);
     }
     //$this->settings_form->addCheckboxProperty($lng->txt("news_public_feed"), "notifications_public_feed",
     //	"1", $public_feed, $lng->txt("news_public_feed_info"));
     //if ($this->getProperty("public_notifications_option"))
     //{
     //	$this->settings_form->addCheckboxProperty($lng->txt("news_notifications_public"), "notifications_public",
     //		"1", $public, $lng->txt("news_notifications_public_info"));
     //}
     $this->settings_form->addCommandButton("saveSettings", $lng->txt("save"));
     $this->settings_form->addCommandButton("cancelSettings", $lng->txt("cancel"));
     $this->settings_form->setFormAction($ilCtrl->getFormaction($this));
 }
 public function createSettings()
 {
     // news settings (public notifications yes/no)
     include_once "./Services/News/classes/class.ilNewsItem.php";
     $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET["ref_id"]);
     if ($default_visibility == "public") {
         ilBlockSetting::_write("news", "public_notifications", 1, 0, $this->getId());
     }
     return true;
 }