From 465485a1a220708d1e4e48ce2710203629982b96 Mon Sep 17 00:00:00 2001 From: Alex Killing Date: Thu, 20 Aug 2015 10:56:03 +0200 Subject: [PATCH] hide item group title --- .../ItemGroup/classes/class.ilItemGroupAR.php | 87 ++++++++++++ .../classes/class.ilObjItemGroup.php | 128 +++++++++--------- .../classes/class.ilObjItemGroupGUI.php | 36 ++++- .../classes/class.ilContainerContentGUI.php | 13 +- Services/Object/classes/class.ilObject2.php | 4 +- lang/ilias_de.lang | 4 +- lang/ilias_en.lang | 4 +- setup/sql/dbupdate_04.php | 35 +++++ 8 files changed, 239 insertions(+), 72 deletions(-) create mode 100644 Modules/ItemGroup/classes/class.ilItemGroupAR.php diff --git a/Modules/ItemGroup/classes/class.ilItemGroupAR.php b/Modules/ItemGroup/classes/class.ilItemGroupAR.php new file mode 100644 index 000000000000..b30c016d0201 --- /dev/null +++ b/Modules/ItemGroup/classes/class.ilItemGroupAR.php @@ -0,0 +1,87 @@ + + * @version $Id$ + * @ingroup + */ +class ilItemGroupAR extends ActiveRecord +{ + /** + * @return string + */ + static function returnDbTableName() { + return 'itgr_data'; + } + + /** + * @var int + * + * @con_is_primary true + * @con_is_unique true + * @con_has_field true + * @con_fieldtype integer + * @con_is_notnull true + * @con_length 4 + * @con_sequence false + */ + protected $id; + + /** + * @var string + * + * @con_has_field true + * @con_fieldtype integer + * @con_length 1 + * @con_is_notnull false + */ + protected $hide_title = ''; + + /** + * Get ID + * + * @return int ID + */ + public function getId() { + return $this->id; + } + + + /** + * Set ID + * + * @param int $id ID + */ + public function setId($id) { + $this->id = $id; + } + + /** + * Set hide title + * + * @param bool $a_hide_title hide title + */ + public function setHideTitle($a_hide_title) + { + $this->hide_title = $a_hide_title; + } + + + /** + * Get hide title + * + * @return bool hide title + */ + public function getHideTitle() + { + return $this->hide_title; + } +} + +?> \ No newline at end of file diff --git a/Modules/ItemGroup/classes/class.ilObjItemGroup.php b/Modules/ItemGroup/classes/class.ilObjItemGroup.php index 808aef630de9..3c57b3c14349 100644 --- a/Modules/ItemGroup/classes/class.ilObjItemGroup.php +++ b/Modules/ItemGroup/classes/class.ilObjItemGroup.php @@ -5,6 +5,9 @@ require_once "Services/Object/classes/class.ilObject2.php"; require_once "Services/Object/classes/class.ilObjectActivation.php"; +include_once("./Modules/ItemGroup/classes/class.ilItemGroupAR.php"); + + /** * Class ilObjItemGroup * @@ -19,6 +22,7 @@ class ilObjItemGroup extends ilObject2 protected $access_begin; // [timestamp] protected $access_end; // [timestamp] protected $access_visibility; // [bool] + protected $item_data_ar = null; // active record /** * Constructor @@ -29,14 +33,28 @@ class ilObjItemGroup extends ilObject2 */ function __construct($a_id = 0, $a_reference = true) { - global $tree, $objDefinition; + global $tree, $objDefinition, $ilDB; $this->tree = $tree; $this->obj_def = $objDefinition; - + $this->db = $ilDB; + + $this->item_data_ar = new ilItemGroupAR(); + parent::__construct($a_id, $a_reference); } - + + /** + * Set ID + * + * @param int $a_val ID + */ + function setId($a_val) + { + parent::setId($a_val); + $this->item_data_ar->setId($a_val); + } + /** * Init type */ @@ -44,37 +62,33 @@ function initType() { $this->type = "itgr"; } - + /** - * Read + * Set hide title + * + * @param bool $a_val hide title */ - protected function doRead() + function setHideTitle($a_val) { - global $ilDB; + $this->item_data_ar->setHideTitle($a_val); + } - /*$set = $ilDB->query("SELECT * FROM il_poll". - " WHERE id = ".$ilDB->quote($this->getId(), "integer")); - $row = $ilDB->fetchAssoc($set);*/ - - if ($this->ref_id) - { -/* $activation = ilObjectActivation::getItem($this->ref_id); - $this->setAccessType($activation["timing_type"]); - $this->setAccessBegin($activation["timing_start"]); - $this->setAccessEnd($activation["timing_end"]); - $this->setAccessVisibility($activation["visible"]);*/ - } + /** + * Get hide title + * + * @return bool hide title + */ + function getHideTitle() + { + return $this->item_data_ar->getHideTitle(); } - + /** - * Get properties array + * Read */ - protected function propertiesToDB() + protected function doRead() { - $fields = array( - ); - - return $fields; + $this->item_data_ar = new ilItemGroupAR($this->getId()); } /** @@ -82,19 +96,10 @@ protected function propertiesToDB() */ protected function doCreate() { - global $ilDB; - if($this->getId()) { - $fields = $this->propertiesToDB(); -// $fields["id"] = array("integer", $this->getId()); - -// $ilDB->insert("il_poll", $fields); - - - // object activation default entry will be created on demand - - + $this->item_data_ar->setId($this->getId()); + $this->item_data_ar->create(); } } @@ -103,26 +108,9 @@ protected function doCreate() */ protected function doUpdate() { - global $ilDB; - if($this->getId()) { - $fields = $this->propertiesToDB(); - -// $ilDB->update("il_poll", $fields, -// array("id"=>array("integer", $this->getId()))); - - - if($this->ref_id) - { -/* $activation = new ilObjectActivation(); - $activation->setTimingType($this->getAccessType()); - $activation->setTimingStart($this->getAccessBegin()); - $activation->setTimingEnd($this->getAccessEnd()); - $activation->toggleVisible($this->getAccessVisibility()); - $activation->update($this->ref_id);*/ - } - + $this->item_data_ar->update(); } } @@ -131,17 +119,9 @@ protected function doUpdate() */ protected function doDelete() { - global $ilDB; - if($this->getId()) - { - if($this->ref_id) - { -// ilObjectActivation::deleteAllEntries($this->ref_id); - } - -// $ilDB->manipulate("DELETE FROM il_poll". -// " WHERE id = ".$ilDB->quote($this->id, "integer")); + { + $this->item_data_ar->delete(); } } @@ -211,6 +191,24 @@ static function fixContainerItemGroupRefsAfterCloning($a_source_container, $a_co } $ilLog->write(__METHOD__.': 5'); } + + /** + * Lookup hide title + * + * @param int $a_id ID + * @return bool + */ + static function lookupHideTitle($a_id) + { + global $ilDB; + + $set = $ilDB->query("SELECT hide_title FROM itgr_data ". + " WHERE id = ".$ilDB->quote($a_id, "integer") + ); + $rec = $ilDB->fetchAssoc($set); + return $rec["hide_title"]; + } + } ?> \ No newline at end of file diff --git a/Modules/ItemGroup/classes/class.ilObjItemGroupGUI.php b/Modules/ItemGroup/classes/class.ilObjItemGroupGUI.php index 5c31360c5839..68ea4b094184 100755 --- a/Modules/ItemGroup/classes/class.ilObjItemGroupGUI.php +++ b/Modules/ItemGroup/classes/class.ilObjItemGroupGUI.php @@ -273,7 +273,41 @@ public function afterSaveCallback(ilObject $a_obj) $items = new ilItemGroupItems($this->object->getRefId()); $items->addItem($a_obj->getRefId()); $items->update(); - } + } + + /** + * Init object edit form + * + * @param ilPropertyFormGUI $a_form form + */ + protected function initEditCustomForm(ilPropertyFormGUI $a_form) + { + // hide title + $cb = new ilCheckboxInputGUI($this->lng->txt("itgr_hide_title"), "hide_title"); + $cb->setInfo($this->lng->txt("itgr_hide_title_info")); + $a_form->addItem($cb); + } + + /** + * Get edit form values (custom part) + * + * @param array $a_values form values + */ + function getEditFormCustomValues(&$a_values) + { + $a_values["hide_title"] = $this->object->getHideTitle(); + } + + /** + * Update (custom part) + * + * @param ilPropertyFormGUI $a_form form + */ + function updateCustom(ilPropertyFormGUI $a_form) + { + $this->object->setHideTitle($a_form->getInput("hide_title")); + } + } ?> \ No newline at end of file diff --git a/Services/Container/classes/class.ilContainerContentGUI.php b/Services/Container/classes/class.ilContainerContentGUI.php index d27db2cf81cb..c66d11254ff7 100644 --- a/Services/Container/classes/class.ilContainerContentGUI.php +++ b/Services/Container/classes/class.ilContainerContentGUI.php @@ -742,8 +742,17 @@ function renderItemGroup($a_itgr) $item_list_gui->getListItemHTML($a_itgr["ref_id"], $a_itgr["obj_id"], $a_itgr["title"], $a_itgr["description"]); $commands_html = $item_list_gui->getCommandsHTML(); - - $this->renderer->addCustomBlock($a_itgr["ref_id"], $a_itgr["title"], $commands_html); + + include_once("./Modules/ItemGroup/classes/class.ilObjItemGroup.php"); + if (ilObjItemGroup::lookupHideTitle($a_itgr["obj_id"]) && + !$this->getContainerGUI()->isActiveAdministrationPanel()) + { + $this->renderer->addCustomBlock($a_itgr["ref_id"], "", $commands_html); + } + else + { + $this->renderer->addCustomBlock($a_itgr["ref_id"], $a_itgr["title"], $commands_html); + } // render item group sub items diff --git a/Services/Object/classes/class.ilObject2.php b/Services/Object/classes/class.ilObject2.php index a5a361d8df73..0cc9b5d118b2 100755 --- a/Services/Object/classes/class.ilObject2.php +++ b/Services/Object/classes/class.ilObject2.php @@ -42,8 +42,8 @@ protected function doRead() } - final function getId() { return parent::getId(); } - final function setId($a_id) { return parent::setId($a_id); } + function getId() { return parent::getId(); } + function setId($a_id) { return parent::setId($a_id); } final function setRefId($a_id) { return parent::setRefId($a_id); } final function getRefId() { return parent::getRefId(); } final function getType() { return parent::getType(); } diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index b3de55821a45..878b3c38470a 100755 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -15673,4 +15673,6 @@ mail#:#mail_tpl_deleted_s#:#Die Textvorlage wurde erfolgreich gelöscht. mail#:#mail_template_missing_id#:#Die Aktion kann nicht ausgeführt werden, da die ID der Textvorlage nicht korrekt übertragen wurde. mail#:#mail_template_no_valid_context#:#Der gewählte Kontext ist nicht gültig. mail#:#mail_template_client#:#Textvorlage -mail#:#mail_template_client_info#:#Wählen Sie zwischen einer der verfügbaren Textvorlagen. Sie haben die Möglichkeit, die durch die Textvorlage angebotenen Platzhalter zu nutzen. Beim Wahl einer Textvorlage werden Nachrichte und Betreff in diesem Formular (falls in der Vorlage definiert) ersetzt. \ No newline at end of file +mail#:#mail_template_client_info#:#Wählen Sie zwischen einer der verfügbaren Textvorlagen. Sie haben die Möglichkeit, die durch die Textvorlage angebotenen Platzhalter zu nutzen. Beim Wahl einer Textvorlage werden Nachrichte und Betreff in diesem Formular (falls in der Vorlage definiert) ersetzt. +itgr#:#itgr_hide_title#:#Titel verbergen +itgr#:#itgr_hide_title_info#:#Der Titel des Objektblocks wird in der Präsentation für Lerner nicht angezeigt. \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index bc3b9b5b34e7..810b0ba0b196 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -15678,4 +15678,6 @@ mail#:#mail_tpl_deleted_s#:#The text template was successfully deleted. mail#:#mail_template_missing_id#:#Can't execute the action because the text template id is missing. mail#:#mail_template_no_valid_context#:#The given context is not valid. mail#:#mail_template_client#:#Text Template -mail#:#mail_template_client_info#:#Choose one of the available text templates and make use of it's placeholders. If you choose a text template, body and subject of this form (if defined in the text template) will be replaced. \ No newline at end of file +mail#:#mail_template_client_info#:#Choose one of the available text templates and make use of it's placeholders. If you choose a text template, body and subject of this form (if defined in the text template) will be replaced. +itgr#:#itgr_hide_title#:#Hide Title +itgr#:#itgr_hide_title_info#:#Hides title of item group in presentation for learner. \ No newline at end of file diff --git a/setup/sql/dbupdate_04.php b/setup/sql/dbupdate_04.php index 9f75516c5d44..0108d44276d0 100644 --- a/setup/sql/dbupdate_04.php +++ b/setup/sql/dbupdate_04.php @@ -9069,4 +9069,39 @@ <#4645> getStructure(); +?> +<#4646> +tableExists('itgr_data')) +{ + $ilDB->createTable('itgr_data', array( + 'id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'hide_title' => array( + 'type' => 'integer', + 'length' => 1, + 'notnull' => true, + 'default' => 0 + ) + )); + + $ilDB->addPrimaryKey('itgr_data',array('id')); +} +?> +<#4647> +query("SELECT * FROM object_data ". + " WHERE type = ".$ilDB->quote("itgr", "text") + ); +while ($rec = $ilDB->fetchAssoc($set)) +{ + $ilDB->manipulate("INSERT INTO itgr_data ". + "(id, hide_title) VALUES (". + $ilDB->quote($rec["obj_id"], "integer").",". + $ilDB->quote(0, "integer"). + ")"); +} ?> \ No newline at end of file