/** * load help content from db */ public function loadContent() { $help_content = HelpContent::getContentByRoute(); foreach ($help_content as $row) { $this->addPlainText($row['label'] ?: '', $this->interpolate($row['content'], $this->variables), $row['icon'] ? Icon::create($row['icon'], 'info_alt') : null, URLHelper::getURL('dispatch.php/help_content/edit/' . $row['content_id']), URLHelper::getURL('dispatch.php/help_content/delete/' . $row['content_id'])); } if (!count($help_content) && $this->help_admin) { $this->addPlainText('', '', null, null, null, URLHelper::getURL('dispatch.php/help_content/edit/new' . '?help_content_route=' . get_route())); } }
/** * fetches help content conflicts * * @return array set of help content */ public static function GetConflicts() { $conflicts = array(); $query = "SELECT content_id AS idx, help_content.*\n FROM help_content\n WHERE installation_id = ?\n ORDER BY route"; $statement = DBManager::get()->prepare($query); $statement->execute(array($GLOBALS['STUDIP_INSTALLATION_ID'])); $ret = $statement->fetchGrouped(PDO::FETCH_ASSOC); foreach ($ret as $index => $data) { $query = "SELECT content_id AS idx, help_content.*\n FROM help_content\n WHERE global_content_id = ? AND language = ? AND studip_version >= ? AND installation_id <> ?\n ORDER BY studip_version DESC LIMIT 1"; $statement = DBManager::get()->prepare($query); $statement->execute(array($data['global_content_id'], $data['language'], $data['studip_version'], $GLOBALS['STUDIP_INSTALLATION_ID'])); $ret2 = $statement->fetchGrouped(PDO::FETCH_ASSOC); if (count($ret2)) { $conflicts[] = HelpContent::GetContentObjects(array_merge(array($index => $data), $ret2)); } } return $conflicts; }
/** * delete help content * * @param String $id id of help content */ function delete_action($id) { if (!$this->help_admin) { return $this->render_nothing(); } // Output as dialog (Ajax-Request) or as Stud.IP page? if ($this->via_ajax) { header('X-Title: ' . _('Hilfe-Text löschen')); } CSRFProtection::verifySecurityToken(); $this->help_content = HelpContent::GetContentByID($id); if (is_object($this->help_content)) { if (Request::submitted('delete_help_content')) { PageLayout::postMessage(MessageBox::success(sprintf(_('Der Hilfe-Text zur Route "%s" wurde gelöscht.'), $this->help_content->route))); $this->help_content->delete(); header('X-Dialog-Close: 1'); return $this->render_nothing(); } } // prepare delete dialog $this->help_content_id = $id; }