/** * Update all visible links * @return */ protected function updateLinks() { global $ilCtrl; $this->checkPermission('write'); $this->activateTabs('content', ''); if (!is_array($_POST['ids'])) { ilUtil::sendFailure($this->lng->txt('select_one'), TRUE); $ilCtrl->redirect($this, 'view'); } // Validate $invalid = array(); foreach ($_POST['ids'] as $link_id) { $data = $_POST['links'][$link_id]; // handle internal links if ($_POST['tar_' . $link_id . '_ajax_type'] && $_POST['tar_' . $link_id . '_ajax_id']) { $data['tar'] = $_POST['links'][$link_id]['tar'] = $_POST['tar_' . $link_id . '_ajax_type'] . '|' . $_POST['tar_' . $link_id . '_ajax_id']; } if (!strlen($data['tit'])) { $invalid[] = $link_id; continue; } if (!strlen($data['tar'])) { $invalid[] = $link_id; continue; } if ($data['nam'] and !$data['val']) { $invalid[] = $link_id; continue; } if (!$data['nam'] and $data['val']) { $invalid[] = $link_id; continue; } } if (count($invalid)) { ilUtil::sendFailure($this->lng->txt('err_check_input')); $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.webr_manage.html', 'Modules/WebResource'); include_once './Modules/WebResource/classes/class.ilWebResourceEditableLinkTableGUI.php'; $table = new ilWebResourceEditableLinkTableGUI($this, 'view'); $table->setInvalidLinks($invalid); $table->parseSelectedLinks($_POST['ids']); $table->updateFromPost(); $this->tpl->setVariable('TABLE_LINKS', $table->getHTML()); return false; } include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php'; $links = new ilLinkResourceItems($this->object->getId()); // Save Settings foreach ($_POST['ids'] as $link_id) { $data = $_POST['links'][$link_id]; $links->setLinkId($link_id); $links->setTitle(ilUtil::stripSlashes($data['tit'])); $links->setDescription(ilUtil::stripSlashes($data['des'])); $links->setTarget(ilUtil::stripSlashes($data['tar'])); $links->setActiveStatus((int) $data['act']); $links->setDisableCheckStatus((int) $data['che']); $links->setValidStatus((int) $data['vali']); $links->update(); if (strlen($data['nam']) and $data['val']) { $param = new ilParameterAppender($this->object->getId()); $param->setName(ilUtil::stripSlashes($data['nam'])); $param->setValue((int) $data['val']); $param->add($link_id); } if ($this->isContainerMetaDataRequired()) { $this->object->setTitle(ilUtil::stripSlashes($data['tit'])); $this->object->setDescription(ilUtil::stripSlashes($data['des'])); $this->object->update(); } // TODO: Dynamic parameters } ilUtil::sendSuccess($this->lng->txt('settings_saved'), TRUE); $ilCtrl->redirect($this, 'view'); }
/** * Overwriten Metadata update listener for ECS functionalities * * @access public * */ public function MDUpdateListener($a_element) { global $ilLog; parent::MDUpdateListener($a_element); $md = new ilMD($this->getId(), 0, $this->getType()); if (!is_object($md_gen = $md->getGeneral())) { return false; } $title = $md_gen->getTitle(); foreach ($md_gen->getDescriptionIds() as $id) { $md_des = $md_gen->getDescription($id); $description = $md_des->getDescription(); break; } switch ($a_element) { case 'General': include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php'; if (ilLinkResourceItems::lookupNumberOfLinks($this->getId()) == 1) { $link_arr = ilLinkResourceItems::_getFirstLink($this->getId()); $link = new ilLinkResourceItems($this->getId()); $link->readItem($link_arr['link_id']); $link->setTitle($title); $link->setDescription($description); $link->update(); } break; default: return true; } return true; }