/** * Konstruktor. Stellt die Daten der Kategorie aus der Datenbank zusammen. * @param int $kategorie_id Kategorie ID. * @param int $clang_id Redaxo SprachID. * @param string $table_prefix Redaxo Tabellen Praefix ($REX['TABLE_PREFIX']) */ public function __construct($kategorie_id, $clang_id, $table_prefix = "rex_") { $this->table_prefix = $table_prefix; // Sprachfallback $query_prove = "SELECT * FROM " . $this->table_prefix . "d2u_stellenmarkt_kategorien_lang AS lang " . "WHERE kategorie_id = " . $kategorie_id . " " . "ORDER BY clang_id DESC"; $result_prove = new rex_sql(); $result_prove->setQuery($query_prove); $num_rows_prove = $result_prove->getRows(); $is_lang_available = false; $fallback_lang_id = 0; for ($i = 0; $i < $num_rows_prove; $i++) { if ($result_prove->getValue("lang.clang_id") == $clang_id) { $is_lang_available = true; } else { $fallback_lang_id = $result_prove->getValue("lang.clang_id"); } $result_prove->next(); } $sql_clang_id = $clang_id; if ($is_lang_available == false) { $sql_clang_id = $fallback_lang_id; } $query = "SELECT * FROM " . $this->table_prefix . "d2u_stellenmarkt_kategorien AS kategorien " . "LEFT JOIN " . $this->table_prefix . "d2u_stellenmarkt_kategorien_lang AS lang " . "ON kategorien.kategorie_id = lang.kategorie_id " . "WHERE kategorien.kategorie_id = " . $kategorie_id . " " . "AND (clang_id = " . $sql_clang_id . " OR clang_id IS NULL) " . "LIMIT 0, 1"; $result = new rex_sql(); $result->setQuery($query); $num_rows = $result->getRows(); if ($num_rows > 0) { $this->kategorie_id = $result->getValue("kategorie_id"); if ($result->getValue("clang_id") != "") { $this->clang_id = $result->getValue("clang_id"); } $this->interne_bezeichnung = $result->getValue("interne_bezeichnung"); $this->name = $result->getValue("name"); } }
/** * Alle Metafelder löschen, nicht das nach einem Import in der Parameter Tabelle * noch Datensätze zu Feldern stehen, welche nicht als Spalten in der * rex_article angelegt wurden! */ function rex_a62_metainfo_cleanup($params) { global $REX; // Cleanup nur durchführen, wenn auch die rex_article Tabelle neu angelegt wird if (isset($params['force']) && $params['force'] != true && strpos($params['content'], 'CREATE TABLE `' . $REX['TABLE_PREFIX'] . 'article`') === false && strpos($params['content'], 'CREATE TABLE ' . $REX['TABLE_PREFIX'] . 'article') === false) { return; } require_once $REX['INCLUDE_PATH'] . '/addons/metainfo/classes/class.rex_table_manager.inc.php'; $sql = new rex_sql(); $sql->setQuery('SELECT name FROM ' . $REX['TABLE_PREFIX'] . '62_params'); for ($i = 0; $i < $sql->getRows(); $i++) { if (substr($sql->getValue('name'), 0, 4) == 'med_') { $tableManager = new rex_a62_tableManager($REX['TABLE_PREFIX'] . 'file'); } else { $tableManager = new rex_a62_tableManager($REX['TABLE_PREFIX'] . 'article'); } $tableManager->deleteColumn($sql->getValue('name')); $sql->next(); } // evtl reste aufräumen $tablePrefixes = array('article' => array('art_', 'cat_'), 'file' => array('med_')); foreach ($tablePrefixes as $table => $prefixes) { $table = $REX['TABLE_PREFIX'] . $table; $tableManager = new rex_a62_tableManager($table); foreach (rex_sql::showColumns($table) as $column) { $column = $column['name']; if (in_array(substr($column, 0, 4), $prefixes)) { $tableManager->deleteColumn($column); } } } $sql = new rex_sql(); $sql->setQuery('DELETE FROM ' . $REX['TABLE_PREFIX'] . '62_params'); rex_generateAll(); }
function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0) { // ***** SELECT FESTLEGEN $SEL = new rex_select(); $SEL->setName('FORM[' . $this->params["form_name"] . '][el_' . $this->id . '][]'); $SEL->setId("el_" . $this->id); $SEL->setSize(5); $SEL->setMultiple(1); // ***** SQL - ROHDATEN ZIEHEN $sql = $this->elements[5]; $teams = new rex_sql(); $teams->debugsql = $this->params["debug"]; $teams->setQuery($sql); for ($t = 0; $t < $teams->getRows(); $t++) { $SEL->addOption($teams->getValue($this->elements[7]), $teams->getValue($this->elements[6])); $teams->next(); } $wc = ""; // if (isset($warning["el_" . $this->getId()])) $wc = $warning["el_" . $this->getId()]; $SEL->setStyle('class="multipleselect ' . $wc . '"'); // ***** EINGELOGGT ODER NICHT SETZEN if ($send == 0) { // erster aufruf // Daten ziehen if ($this->params["main_id"] > 0) { $this->value = array(); $g = new rex_sql(); $g->debugsql = $this->params["debug"]; $g->setQuery('select ' . $this->elements[3] . ' from ' . $this->elements[1] . ' where ' . $this->elements[2] . '=' . $this->params["main_id"]); $gg = $g->getArray(); if (is_array($gg)) { foreach ($gg as $g) { $this->value[] = $g[$this->elements[3]]; } } } } // ***** AUSWAHL SETZEN if (is_array($this->value)) { foreach ($this->value as $val) { $SEL->setSelected($val); } } // ***** AUSGEBEN $form_output[] = ' <p class="formmultipleselect"> <label class="multipleselect ' . $wc . '" for="el_' . $this->id . '" >' . $this->elements[4] . '</label> ' . $SEL->get() . ' </p>'; }
/** * SET CONTENT OF ROBOTS.TXT * * @return (string) robots.txt */ public function setContent($content) { global $REX; $out = ''; $langs = array_keys($REX['CLANG']); // get clang ids $defaultRobotsTxt = 'User-agent: *' . "\r\n" . 'Disallow:'; if (!$REX['ADDON']['seo42']['settings']['no_robots_txt_auto_disallow']) { foreach ($langs as $lang) { $query = "SELECT id FROM " . $REX['TABLE_PREFIX'] . "article WHERE seo_noindex = '1' AND status = 1 AND clang = " . $lang; $sql = new rex_sql(); $sql->setQuery($query); for ($i = 1; $i <= $sql->getRows(); $i++) { $out .= "Disallow: /" . seo42::getTrimmedUrl($sql->getValue('id'), $lang) . "\r\n"; $sql->next(); } } } if ($out != '') { $out = "User-agent: *" . "\r\n" . $out . "\r\n"; } if ($out == '' && $content == '') { $this->robots_txt = $defaultRobotsTxt; } else { $this->robots_txt = $out . $content; } }
/** * publish a news by id & clang * if publish-lang == all => $clang is not needed, but must be set * @param $id * @param $clang * @param DateTime $time * @return string */ public static function publishNews($id, $clang, DateTime $time) { /** * @var array $REX * @var i18n $I18N */ global $REX, $I18N; $sql = new rex_sql(); $sql->setTable(rex_asd_news_config::getTable()); $sql->setWhere('`id` = ' . $id . ' AND `clang` = ' . $clang); if (rex_asd_news_config::getConfig('published-lang') == 'all') { $sql->setWhere('`id` = ' . $id); } $sql->setValue('publishedAt', $time->format('Y-m-d H:i')); $sql->setValue('publishedBy', $REX['USER']->getValue('user_id')); $sql->setValue('status', 1); $sql->update(); $sql->setQuery('SELECT * FROM `' . rex_asd_news_config::getTable() . '` WHERE `id` = ' . $id . ' AND `clang` = ' . $clang); return ' <td>' . $id . '</td> <td>' . $sql->getValue('title') . '</td> <td><span>' . $time->format('d.m.Y H:i') . '</span></td> <td><a href="' . self::getBaseUrl($clang) . 'unpublish&id=' . $id . '" class="rex-online" onclick="return confirm(\'' . $I18N->msg('asd_news_really_unpublish') . '\');">' . $I18N->msg('asd_news_published') . '</a></td> <td><a href="' . self::getBaseUrl($clang) . 'edit&id=' . $id . '">' . $I18N->msg('edit') . '</a></td> <td><a href="' . self::getBaseUrl($clang) . 'delete&id=' . $id . '" onclick="return confirm(\'' . $I18N->msg('asd_news_really_delete') . '\');">' . $I18N->msg('delete') . '</a></td> <td><a href="' . self::getBaseUrl($clang) . 'status&id=' . $id . '" class="rex-online">' . $I18N->msg('status_online') . '</a></td>'; }
/** * Returns if the user has a role. * * @return bool */ public function hasRole() { if (self::$roleClass && !is_object($this->role) && ($role = $this->sql->getValue('role'))) { $class = self::$roleClass; $this->role = $class::get($role); } return is_object($this->role); }
function rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $from_re_sliceid = 0, $to_revision_delete = FALSE) { global $REX; if ($to_revision_delete) { $dc = new rex_sql(); // $dc->debugsql = 1; $dc->setQuery('delete from ' . $REX['TABLE_PREFIX'] . 'article_slice where article_id=' . $article_id . ' and clang=' . $clang . ' and revision=' . $to_revision_id); } if ($from_revision_id == $to_revision_id) { return false; } $gc = new rex_sql(); // $gc->debugsql = 1; $gc->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article_slice where re_article_slice_id='{$from_re_sliceid}' and article_id='{$article_id}' and clang='{$clang}' and revision='{$from_revision_id}'"); if ($gc->getRows() == 1) { // letzt slice_id des ziels holen .. $glid = new rex_sql(); // $glid->debugsql = 1; $glid->setQuery("\n\t\t\t\t\tselect \n\t\t\t\t\t\tr1.id, r1.re_article_slice_id\n\t from \n\t\t\t\t\t\t" . $REX['TABLE_PREFIX'] . "article_slice as r1\n\t\t\t\t\tleft join " . $REX['TABLE_PREFIX'] . "article_slice as r2 on r1.id = r2.re_article_slice_id\n\t where \n\t\t\t\t\t\tr1.article_id = {$article_id} and r1.clang = {$clang} and \n\t\t\t\t\t\tr2.id is NULL and \n\t\t\t\t\t\tr1.revision='{$to_revision_id}';"); if ($glid->getRows() == 1) { $to_last_slice_id = $glid->getValue("r1.id"); } else { $to_last_slice_id = 0; } $ins = new rex_sql(); // $ins->debugsql = 1; $ins->setTable($REX['TABLE_PREFIX'] . "article_slice"); $cols = new rex_sql(); $cols->setquery("SHOW COLUMNS FROM " . $REX['TABLE_PREFIX'] . "article_slice"); for ($j = 0; $j < $cols->rows; $j++, $cols->next()) { $colname = $cols->getValue("Field"); if ($colname == "re_article_slice_id") { $value = $to_last_slice_id; } elseif ($colname == "revision") { $value = $to_revision_id; } elseif ($colname == "createdate") { $value = time(); } elseif ($colname == "updatedate") { $value = time(); } elseif ($colname == "createuser") { $value = $REX["USER"]->getValue("login"); } elseif ($colname == "updateuser") { $value = $REX["USER"]->getValue("login"); } else { $value = $gc->getValue($colname); } if ($colname != "id") { $ins->setValue($colname, $ins->escape($value)); } } $ins->insert(); // id holen und als re setzen und weitermachen.. rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $gc->getValue("id")); return true; } rex_generateArticle($article_id); return true; }
function execute() { global $REX; $gt = new rex_sql(); if ($this->params["debug"]) { $gt->debugsql = true; } $gt->setQuery('select * from rex_xform_email_template where name="' . $this->action["elements"][2] . '"'); if ($gt->getRows() == 1) { $mail_to = $REX['ERROR_EMAIL']; if (isset($this->action["elements"][3]) && $this->action["elements"][3] != "") { foreach ($this->elements_email as $key => $value) { if ($this->action["elements"][3] == $key) { $mail_to = $value; } } } if (isset($this->action["elements"][4]) && $this->action["elements"][4] != "") { $mail_to = $this->action["elements"][4]; } $mail_from = $gt->getValue("mail_from"); $mail_subject = $gt->getValue("subject"); $mail_body = $gt->getValue("body"); foreach ($this->elements_email as $search => $replace) { $mail_from = str_replace('###' . $search . '###', $replace, $mail_from); $mail_subject = str_replace('###' . $search . '###', $replace, $mail_subject); $mail_body = str_replace('###' . $search . '###', $replace, $mail_body); $mail_from = str_replace('***' . $search . '***', urlencode($replace), $mail_from); $mail_subject = str_replace('***' . $search . '***', urlencode($replace), $mail_subject); $mail_body = str_replace('***' . $search . '***', urlencode($replace), $mail_body); } $mail = new rex_mailer(); $mail->AddAddress($mail_to, $mail_to); $mail->WordWrap = 80; $mail->FromName = $mail_from; $mail->From = $mail_from; $mail->Subject = $mail_subject; $mail->Body = nl2br($mail_body); $mail->AltBody = strip_tags($mail_body); // $mail->IsHTML(true); if (!$mail->Send()) { echo "FAILED"; } } }
public static function init() { global $REX; self::$curClang = $REX['CUR_CLANG']; $sql = new rex_sql(); $sql->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'string_table'); foreach ($REX['CLANG'] as $clangId => $clangName) { for ($i = 0; $i < $sql->getRows(); $i++) { $key = $sql->getValue('keyname'); $value = nl2br($sql->getValue('value_' . $clangId)); self::$stringTable[$clangId][$key] = $value; self::$stringTableKeys[$clangId][] = $REX['ADDON']['string_table']['settings']['key_start_token'] . $key . $REX['ADDON']['string_table']['settings']['key_end_token']; self::$stringTableValues[$clangId][] = $value; $sql->next(); } $sql->reset(); } }
public static function init() { global $REX; $sql = new rex_sql(); $sql->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'tracking_code WHERE id = 1'); if ($sql->getRows() > 0) { self::$trackingCode = $sql->getValue('tracking_code'); } }
function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0) { $SEL = new rex_select(); $SEL->setName('FORM[' . $this->params["form_name"] . '][el_' . $this->id . ']'); $SEL->setId("el_" . $this->id); $SEL->setSize(1); $sql = $this->elements[4]; $teams = new rex_sql(); $teams->debugsql = $this->params["debug"]; $teams->setQuery($sql); $sqlnames = array(); if ($this->elements[3] != 1) { // mit --- keine auswahl --- $SEL->addOption($this->elements[3], "0"); } for ($t = 0; $t < $teams->getRows(); $t++) { $SEL->addOption($teams->getValue($this->elements[6]), $teams->getValue($this->elements[5])); if (isset($this->elements[7])) { $sqlnames[$teams->getValue($this->elements[5])] = $teams->getValue($this->elements[7]); } $teams->next(); } $wc = ""; if (isset($warning["el_" . $this->getId()])) { $wc = $warning["el_" . $this->getId()]; } $SEL->setStyle(' class="select ' . $wc . '"'); if ($this->value == "" && isset($this->elements[7]) && $this->elements[7] != "") { $this->value = $this->elements[7]; } $SEL->setSelected($this->value); $form_output[] = ' <p class="formselect"> <label class="select ' . $wc . '" for="el_' . $this->id . '" >' . $this->elements[2] . '</label> ' . $SEL->get() . ' </p>'; $email_elements[$this->elements[1]] = stripslashes($this->value); if (isset($sqlnames[$this->value])) { $email_elements[$this->elements[1] . '_SQLNAME'] = stripslashes($sqlnames[$this->value]); } if (!isset($this->elements[8]) || $this->elements[8] != "no_db") { $sql_elements[$this->elements[1]] = $this->value; } }
/** * delete the metafields */ public static function delFields() { global $REX; $sql = new rex_sql(); $sql->setQuery('SELECT `name` FROM ' . $REX['TABLE_PREFIX'] . '62_params WHERE `name` LIKE "asd_%"'); $delFields = array(); for ($i = 1; $i <= $sql->getRows(); $i++) { $delFields[] = a62_delete_field($sql->getValue('name')); $sql->next(); } return self::checkErrorMessage($delFields); }
/** * @param array $params * @return array */ public static function isImageInUse($params) { /** @var i18n $I18N */ global $I18N; $sql = new rex_sql(); $sqlCols = rex_asd_news_config::getConfig('sql'); $sql->setQuery('SELECT `id`, `title` FROM `' . rex_asd_news_config::getTable() . '` WHERE `' . $sqlCols['picture'] . '` = "' . $params['filename'] . '"'); if ($sql->getRows()) { $message = $I18N->msg('asd_news') . '<br /><ul>'; for ($i = 1; $i <= $sql->getRow(); $i++) { $message .= ' <li> <a href="index.php?page=' . rex_asd_news_config::getName() . '&func=edit&id=' . $sql->getValue('id') . '"> ' . $sql->getValue('title') . ' </a> </li>'; } $message .= '</ul>'; $params['subject'][] = $message; } return $params['subject']; }
/** * Gibt den HTML Content zurück */ function get() { $table = $this->getTable(); $field = $this->getField(); $foreignField = $this->getForeignField(); $value = $this->formatValue(); $qry = 'SELECT ' . $field . ' FROM ' . $table . ' WHERE ' . $foreignField . ' = "' . $value . '"'; $sql = new rex_sql(); // $sql->debugsql = true; $sql->setQuery($qry); if ($sql->getRows() == 1) { return $sql->getValue($field); } return ''; }
function getValue($value) { if (!is_array($value)) { $value = array(); $section =& $this->getSection(); // Alle vorhanden Werte löschen $sql = new rex_sql(); $sql->setQuery('SELECT `' . $this->foreignField . '` FROM `' . $this->foreignTable . '` WHERE ' . $section->_getWhereString()); for ($i = 0; $i < $sql->getRows(); $i++) { $value[] = $sql->getValue($this->foreignField); $sql->next(); } } return $value; }
/** * update the article id in the url_control sql table * @param int $id */ public static function updateArticleId($id) { global $REX; $sql = new rex_sql(); $sql->setTable($REX['TABLE_PREFIX'] . 'url_control_generate'); $sql->setWhere('`table` = "' . rex_asd_news_config::getTable() . '"'); $sql->select('id'); for ($i = 1; $i <= $sql->getRows(); $i++) { $saveSql = new rex_sql(); $saveSql->setTable($REX['TABLE_PREFIX'] . 'url_control_generate'); $saveSql->setWhere('`id` = ' . $sql->getValue('id')); $saveSql->setValue('article_id', $id); $saveSql->update(); $sql->next(); } }
/** * Konstruktor. Stellt die Daten des Kontaktes aus der Datenbank zusammen. * @param int $kontakt_id Kontakt ID. * @param String $table_prefix. Redaxo Tabellen Praefix ($REX['TABLE_PREFIX']) */ public function __construct($kontakt_id, $table_prefix = "rex_") { $this->table_prefix = $table_prefix; $query = "SELECT * FROM " . $this->table_prefix . "d2u_stellenmarkt_kontakt " . "WHERE kontakt_id = " . $kontakt_id; $result = new rex_sql(); $result->setQuery($query); $num_rows = $result->getRows(); if ($num_rows > 0) { $this->kontakt_id = $result->getValue("kontakt_id"); $this->name = $result->getValue("name"); if ($result->getValue("bild") != "") { $this->bild = $result->getValue("bild"); } $this->telefon = $result->getValue("telefon"); $this->email = $result->getValue("email"); } }
/** * Erweitert das Meta-Formular um die neuen Meta-Felder */ function rex_a62_metainfo_form($params) { // Nur beim EDIT gibts auch ein Medium zum bearbeiten if ($params['extension_point'] == 'MEDIA_FORM_EDIT') { $params['activeItem'] = $params['media']; // Hier die category_id setzen, damit keine Warnung entsteht (REX_LINK_BUTTON) $params['activeItem']->setValue('category_id', 0); } else { if ($params['extension_point'] == 'MEDIA_ADDED') { global $REX; $sql = new rex_sql(); $qry = 'SELECT file_id FROM ' . $REX['TABLE_PREFIX'] . 'file WHERE filename="' . $params['filename'] . '"'; $sql->setQuery($qry); if ($sql->getRows() == 1) { $params['file_id'] = $sql->getValue('file_id'); } else { trigger_error('Error occured during file upload', E_USER_ERROR); exit; } } } return _rex_a62_metainfo_form('med_', $params, '_rex_a62_metainfo_med_handleSave'); }
/** * Holt alle zugehörigen Kurse aus der Datenbank. * @param boolean $nur_online TRUE, wenn nur online Kurse ausgegeben werden, * sonst false * @return Kurse[] Array mit Kursobjekten. */ public function getAllKurse($nur_online = TRUE) { $query = "SELECT kurs_id FROM " . $this->table_prefix . "d2u_kurse_kurse " . "WHERE (terminkategorie_ids LIKE '%|" . $this->terminkategorie_id . "|%' " . " OR terminkategorie_ids = '" . $this->terminkategorie_id . "') "; if ($nur_online) { $query .= "AND status = 'online' " . "AND (datum_von = '' OR datum_von >= '" . date("Y-m-d", time()) . "') "; } $query .= "ORDER BY datum_von, titel"; $result = new rex_sql(); $result->setQuery($query); $num_rows = $result->getRows(); $kurse = array(); for ($i = 0; $i < $num_rows; $i++) { $kurse[] = new Kurs($result->getValue("kurs_id"), $this->table_prefix); $result->next(); } return $kurse; }
// $KAT->debugsql = true; $KAT->setQuery("SELECT * FROM " . $REX['TABLE_PREFIX'] . "article WHERE id={$category_id} AND startpage=1 AND clang={$clang}"); if ($KAT->getRows() != 1) { // kategorie existiert nicht if ($category_id != 0) { $category_id = 0; $article_id = 0; } } else { // kategorie existiert $KPATH = explode('|', $KAT->getValue('path')); $KATebene = count($KPATH) - 1; for ($ii = 1; $ii < $KATebene; $ii++) { $SKAT = new rex_sql(); $SKAT->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE id=' . $KPATH[$ii] . ' AND startpage=1 AND clang=' . $clang); $catname = str_replace(' ', ' ', $SKAT->getValue('catname')); $catid = $SKAT->getValue('id'); if ($SKAT->getRows() == 1) { if ($KATPERM || $REX_USER->hasPerm('csw[' . $catid . ']') || $REX_USER->hasPerm('csr[' . $catid . ']')) { $KATout .= '<li>: <a href="index.php?page=structure&category_id=' . $catid . '&clang=' . $clang . '"' . rex_tabindex() . '>' . $catname . '</a> </li>'; $KATPATH .= $KPATH[$ii] . "|"; if ($REX_USER->hasPerm('csw[' . $catid . ']')) { $KATPERM = true; } } } } if ($KATPERM || $REX_USER->hasPerm('csw[' . $category_id . ']') || $REX_USER->hasPerm('csr[' . $category_id . ']')) { $catname = str_replace(' ', ' ', $KAT->getValue('catname')); $KATout .= '<li>: <a href="index.php?page=structure&category_id=' . $category_id . '&clang=' . $clang . '"' . rex_tabindex() . '>' . $catname . '</a> </li>'; $KATPATH .= $category_id . '|';
<?php // Uebersichtsliste if ($func == '') { // Wenn eine Kategorie geloescht wurde koennen die lang-Objekte noch existieren und ... $query_to_delete = "SELECT lang.kategorie_id, kategorien.kategorie_id " . "FROM `" . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_kategorien_lang` AS lang " . "LEFT JOIN `" . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_kategorien` AS kategorien " . "ON lang.kategorie_id = kategorien.kategorie_id " . "WHERE kategorien.kategorie_id IS NULL " . "GROUP BY lang.kategorie_id"; $result_to_delete = new rex_sql(); $result_to_delete->setQuery($query_to_delete); $num_rows_to_delete = $result_to_delete->getRows(); for ($i = 0; $i < $num_rows_to_delete; $i++) { // ... muessen zuerst geloescht werden $delete_qry = 'DELETE FROM ' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_kategorien_lang ' . 'WHERE kategorie_id = ' . $result_to_delete->getValue("lang.kategorie_id"); $delete_sql = new rex_sql(); $delete_data = $delete_sql->getArray($delete_qry); $result_to_delete->next(); } /* * Liste anlegen */ $sql = 'SELECT kategorie_id, interne_bezeichnung FROM ' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_kategorien AS kategorien ' . 'ORDER BY interne_bezeichnung ASC'; $list = rex_list::factory($sql, 100); // Spalten mit Sortierfunktion $list->setColumnSortable('interne_bezeichnung'); $imgHeader = '<a href="' . $list->getUrl(array('func' => 'add')) . '"><img src="media/metainfo_plus.gif" alt="add" title="add" /></a>'; // Hinzufuegen Button $list->addColumn($imgHeader, '<img src="media/metainfo.gif" alt="field" title="field" />', 0, array('<th class="rex-icon">###VALUE###</th>', '<td class="rex-icon">###VALUE###</td>')); // Edit Button unterhalb des hinzufuegen Buttons $list->setColumnParams($imgHeader, array('func' => 'edit', 'entry_id' => '###kategorie_id###')); // Labels $list->setColumnLabel('kategorie_id', $I18N_STELLEN->msg('id')); $list->setColumnLabel('interne_bezeichnung', $I18N_STELLEN->msg('interne_bezeichnung'));
<?php // title: Test für das Backend // Zugriff auf Usertabelle $_sql = new rex_sql(); $_result = $_sql->setQuery('SELECT login,name,description,session_id FROM ' . $REX['TABLE_PREFIX'] . 'user WHERE session_id <> "" ORDER BY login ASC '); echo '<h1>Angemeldete Benutzer</h1>'; echo '<ul>'; for ($i = 0; $i < $_sql->getRows(); $i++) { echo '<li>' . $_sql->getValue('login') . ': ' . $_sql->getValue('name') . ' ' . $_sql->getValue('description') . '</li>'; $_sql->next(); } echo '</ul>';
function getGuestbook($user_id, $aid, $params = array()) { global $REX; $MY = FALSE; if (is_object($REX['COM_USER']) && $REX['COM_USER']->getValue("rex_com_user.id") == $user_id) { $MY = TRUE; } $u = new rex_sql(); $u->setQuery("select * from rex_com_user where id=" . $user_id); if ($u->getRows() != 1) { return ""; } // ***** ADD MESSAGE if (is_object($REX['COM_USER']) && $_REQUEST["add_message"] != "") { $text = $_REQUEST["text"]; if ($text == "") { $errormessage = '<p class="warning" colspan=2>Es wurde keine Nachricht eingetragen !</p>'; } else { $addmsgsql = new rex_sql(); $addmsgsql->setTable("rex_com_guestbook"); $addmsgsql->setValue("user_id", $user_id); $addmsgsql->setValue("from_user_id", $REX['COM_USER']->getValue("id")); $addmsgsql->setValue("text", $text); $addmsgsql->setValue("create_datetime", time()); $addmsgsql->insert(); if ($user_id != $REX['COM_USER']->getValue('rex_com_user.id')) { rex_com_user::exeAction($user_id, "sendemail_guestbook", array("user_id" => $REX['COM_USER']->getValue('rex_com_user.id'), "firstname" => $REX['COM_USER']->getValue('rex_com_user.firstname'), "name" => $REX['COM_USER']->getValue('rex_com_user.name'), "login" => $REX['COM_USER']->getValue('rex_com_user.login'), "to_user_id" => $u->getValue('rex_com_user.id'), "to_firstname" => $u->getValue('rex_com_user.firstname'), "to_name" => $u->getValue('rex_com_user.name'), "to_login" => $u->getValue('rex_com_user.login'))); } } } elseif ($MY && $_REQUEST["delete_message"] != "") { $msg_id = (int) $_REQUEST["msg_id"]; if ($msg_id == 0) { $errormessage = '<p class="warning">Es wurde keine Nachricht ausgewählt!</p>'; } else { $addmsgsql = new rex_sql(); // $addmsgsql->debugsql = 1; $addmsgsql->setQuery('delete from rex_com_guestbook where id=' . $msg_id . ' and user_id="' . $REX['COM_USER']->getValue("id") . '"'); } } // ***** SHOW MESSAGES $guestsql = new rex_sql(); $guestsql->debugsql = 0; $guestsql->setQuery("SELECT * \n\t\t\tFROM rex_com_guestbook \n\t\t\tLEFT JOIN rex_com_user ON rex_com_guestbook.from_user_id=rex_com_user.id \n\t\t\tWHERE rex_com_guestbook.user_id='" . $user_id . "' \n\t\t\tORDER BY rex_com_guestbook.create_datetime desc"); if ($guestsql->getRows() <= 0) { $echo .= '<p class="com-whitebox">Kein Gästebucheintrag vorhanden !</p>'; } else { $cl = ""; for ($i = 0; $i < $guestsql->getRows(); $i++) { // $cl $echo .= ' <div class="com-guestbook"> <div class="com-image"> <p class="image">' . rex_com_showUser($guestsql, "image") . '</p> </div> <div class="com-content"> <div class="com-content-2"> <div class="com-content-name"> <p><span class="color-1">' . rex_com_showUser($guestsql, "name") . ', ' . rex_com_showUser($guestsql, "city", "", FALSE) . '</span> <br />' . rex_com_formatter($guestsql->getValue("rex_com_guestbook.create_datetime"), 'datetime') . ' </p> </div> <p><b>' . nl2br(htmlspecialchars($guestsql->getValue("rex_com_guestbook.text"))) . '</b></p>'; if ($guestsql->getValue("rex_com_user.motto") != '') { $echo .= '<p>Motto: ' . $guestsql->getValue("rex_com_user.motto") . '</p>'; } if ($MY) { $link_params = array_merge($params, array("user_id" => $user_id, "delete_message" => 1, "msg_id" => $guestsql->getValue("rex_com_guestbook.id"))); $echo .= '<br /><p class="link-button"><a href="' . rex_getUrl($aid, '', $link_params) . '"><span>Löschen</span></a></p>'; } $echo .= '</div></div> <div class="clearer"> </div> </div>'; if ($cl == "") { $cl = ' class="alternative"'; } else { $cl = ""; } $guestsql->next(); } } // $echo .= '</tr></table>'; if (is_object($REX['COM_USER'])) { $echo .= '<div id="rex-form" class="com-guestbook-form spcl-bgcolor"> <form action="' . $REX["FRONTEND_FILE"] . '" method="post" id="guestbookform"> <h2>Einen neuen Eintrag schreiben</h2> ' . $errormessage . ' <input type="hidden" name="add_message" value="1" /> <input type="hidden" name="user_id" value="' . $user_id . '" /> <input type="hidden" name="article_id" value="' . $aid . '" /> '; foreach ($params as $k => $v) { $echo .= '<input type="hidden" name="' . $k . '" value="' . htmlspecialchars($v) . '" />'; } $echo .= ' <p class="formtextarea"> <label for="f-message">Nachricht:</label> <textarea id="f-message" name="text" cols="40" rows="4" /></textarea> </p> <p class="link-save"> <a href="javascript:void(0);" onclick="document.getElementById(\'guestbookform\').submit()"><span>Speichern</span></a></p> </p> <div class="clearer"> </div> </form> </div>'; } return $echo; }
/** * Indexes a certain article. * * @param int $_id * @param mixed $_clang * * @return int */ function indexArticle($_id, $_clang = false) { global $REX; if ($_clang === false) { $langs = $this->languages; } else { $langs = array(intval($_clang) => $this->languages[intval($_clang)]); } $return = array(); $keywords = array(); foreach ($langs as $langID => $v) { if (in_array($_id, $this->excludeIDs)) { $return[$v] = A587_ART_EXCLUDED; continue; } $REX['CUR_CLANG'] = $langID; $delete = new rex_sql(); $where = sprintf("ftable = '%s' AND fid = %d AND clang = %d", $delete->escape($this->tablePrefix . 'article'), $_id, $langID); // delete from cache $select = new rex_sql(); $select->setTable($this->tablePrefix . '587_searchindex'); $select->setWhere($where); $select->select('id'); $indexIds = array(); foreach ($select->getArray() as $result) { $indexIds[] = $result['id']; } $this->deleteCache($indexIds); // delete old $delete->setTable($this->tablePrefix . '587_searchindex'); $delete->setWhere($where); $delete->delete(); // index article $article = OOArticle::getArticleById(intval($_id), $langID); if (is_object($article) and ($article->isOnline() or $this->indexOffline)) { $this->beginFrontendMode(); if (ini_get('allow_url_fopen') and $this->indexViaHTTP) { $articleText = @file_get_contents('http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], '/redaxo/') + 1) . rex_geturl($_id, $langID, '', '&')); } elseif ($_id != 0 and $this->dontIndexRedirects) { $rex_article = new rex_article(intval($_id), $langID); $article_content_file = $this->generatedPath . '/articles/' . $_id . '.' . $langID . '.content'; if (!file_exists($article_content_file)) { include_once $this->includePath . "/functions/function_rex_generate.inc.php"; $generated = rex_generateArticleContent($_id, $langID); if ($generated !== true) { $return[$v] = A587_ART_IDNOTFOUND; continue; } } if (file_exists($article_content_file) and preg_match($this->encodeRegex('~(header\\s*\\(\\s*["\']\\s*Location\\s*:)|(rex_redirect\\s*\\()~is'), rex_get_file_contents($article_content_file))) { $return[$v] = A587_ART_REDIRECT; continue; } if ($this->indexWithTemplate) { $articleText = $rex_article->getArticleTemplate(); } else { $articleText = $rex_article->getArticle(); } if ($this->ep_outputfilter) { $tmp = array('artid' => $REX['ARTICLE_ID'], 'clang' => $REX['CUR_CLANG']); $REX['ARTICLE_ID'] = $_id; $REX['CUR_CLANG'] = $langID; $articleText = rex_register_extension_point('OUTPUT_FILTER', $articleText, array('environment' => 'frontend', 'sendcharset' => false)); $REX['ARTICLE_ID'] = $tmp['artid']; $REX['CUR_CLANG'] = $tmp['clang']; } } $insert = new rex_sql(); $articleData = array(); $articleData['texttype'] = 'article'; $articleData['ftable'] = $this->tablePrefix . 'article'; $articleData['fcolumn'] = NULL; $articleData['clang'] = $article->getClang(); $articleData['fid'] = intval($_id); $articleData['catid'] = $article->getCategoryId(); $articleData['unchangedtext'] = $insert->escape($articleText); $articleData['plaintext'] = $insert->escape($plaintext = $this->getPlaintext($articleText)); if (array_key_exists($REX['TABLE_PREFIX'] . 'article', $this->includeColumns)) { $additionalValues = array(); $select->flush(); $select->setTable($REX['TABLE_PREFIX'] . 'article'); $select->setWhere('id = ' . $_id . ' AND clang = ' . $langID); $select->select('`' . implode('`,`', $this->includeColumns[$REX['TABLE_PREFIX'] . 'article']) . '`'); foreach ($this->includeColumns[$REX['TABLE_PREFIX'] . 'article'] as $col) { $additionalValues[$col] = $select->getValue($col); } $articleData['values'] = $insert->escape(serialize($additionalValues)); } foreach (preg_split($this->encodeRegex('~[[:punct:][:space:]]+~ism'), $plaintext) as $keyword) { if ($this->significantCharacterCount <= mb_strlen($keyword, 'UTF-8')) { $keywords[] = array('search' => $keyword, 'clang' => $langID); } } $articleData['teaser'] = $insert->escape($this->getTeaserText($plaintext)); $insert->setTable($this->tablePrefix . '587_searchindex'); $insert->setValues($articleData); $insert->insert(); $this->endFrontendMode(); $return[$langID] = A587_ART_GENERATED; } } $this->storeKeywords($keywords, false); return $return; }
$module_id = $CM->getValue($REX['TABLE_PREFIX'] . "article_slice.modultyp_id"); // ----- RECHTE AM MODUL ? if ($REX_USER->hasPerm("admin[]") || $REX_USER->hasPerm("dev[]") || $REX_USER->hasPerm("module[{$module_id}]") || $REX_USER->hasPerm("module[0]")) { // rechte sind vorhanden // ctype beachten // verschieben / vertauschen // article regenerieren. $slice_id = $CM->getValue($REX['TABLE_PREFIX'] . "article_slice.id"); $slice_article_id = $CM->getValue("article_id"); $re_slice_id = $CM->getValue($REX['TABLE_PREFIX'] . "article_slice.re_article_slice_id"); $slice_ctype = $CM->getValue($REX['TABLE_PREFIX'] . "article_slice.ctype"); $gs = new rex_sql(); // $gs->debugsql = 1; $gs->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article_slice where article_id='{$slice_article_id}'"); for ($i = 0; $i < $gs->getRows(); $i++) { $SID[$gs->getValue("re_article_slice_id")] = $gs->getValue("id"); $SREID[$gs->getValue("id")] = $gs->getValue("re_article_slice_id"); $SCTYPE[$gs->getValue("id")] = $gs->getValue("ctype"); $gs->next(); } $message = $I18N->msg('slice_moved_error'); // ------ moveup if ($function == "moveup") { if ($SREID[$slice_id] > 0) { if ($SCTYPE[$SREID[$slice_id]] == $slice_ctype) { $gs->setQuery("update " . $REX['TABLE_PREFIX'] . "article_slice set re_article_slice_id='" . $SREID[$SREID[$slice_id]] . "' where id='" . $slice_id . "'"); $gs->setQuery("update " . $REX['TABLE_PREFIX'] . "article_slice set re_article_slice_id='" . $slice_id . "' where id='" . $SREID[$slice_id] . "'"); if ($SID[$slice_id] > 0) { $gs->setQuery("update " . $REX['TABLE_PREFIX'] . "article_slice set re_article_slice_id='" . $SREID[$slice_id] . "' where id='" . $SID[$slice_id] . "'"); } $message = $I18N->msg('slice_moved');
function regenerateArticlesByModultypId($modules) { global $PHP_SELF, $module_id, $FORM, $REX_USER, $REX, $I18N; include_once $REX[INCLUDE_PATH] . "/clang.inc.php"; $modules = explode("__", $modules); array_pop($modules); $gc = new rex_sql(); foreach ($modules as $modul_id) { $gc->setQuery("SELECT DISTINCT(" . $REX['TABLE_PREFIX'] . "article.id) FROM " . $REX['TABLE_PREFIX'] . "article\n \t LEFT JOIN " . $REX['TABLE_PREFIX'] . "article_slice ON " . $REX['TABLE_PREFIX'] . "article.id=" . $REX['TABLE_PREFIX'] . "article_slice.article_id\n \t WHERE " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id='{$modul_id}'"); for ($i = 0; $i < $gc->getRows(); $i++) { rex_generateArticle($gc->getValue($REX['TABLE_PREFIX'] . "article.id")); $gc->next(); } } }
function addSlice($I_ID, $module_id) { global $REX, $I18N; $MOD = new rex_sql(); $MOD->setQuery("SELECT * FROM " . $REX['TABLE_PREFIX'] . "module WHERE id={$module_id}"); if ($MOD->getRows() != 1) { $slice_content = rex_warning($I18N->msg('module_doesnt_exist')); } else { $slice_content = ' <a name="addslice"></a> <form action="index.php#slice' . $I_ID . '" method="post" id="REX_FORM" enctype="multipart/form-data"> <fieldset> <legend class="rex-lgnd">' . $I18N->msg('add_block') . '</legend> <input type="hidden" name="article_id" value="' . $this->article_id . '" /> <input type="hidden" name="page" value="content" /> <input type="hidden" name="mode" value="' . $this->mode . '" /> <input type="hidden" name="slice_id" value="' . $I_ID . '" /> <input type="hidden" name="function" value="add" /> <input type="hidden" name="module_id" value="' . $module_id . '" /> <input type="hidden" name="save" value="1" /> <input type="hidden" name="clang" value="' . $this->clang . '" /> <input type="hidden" name="ctype" value="' . $this->ctype . '" /> <p class="rex-cnt-mdl-name"> ' . $I18N->msg("module") . ': <span>' . htmlspecialchars($MOD->getValue("name")) . '</span> </p> <div class="rex-cnt-slc-ipt"><div class="rex-cnt-slc-ipt2"> ' . $MOD->getValue("eingabe") . ' </div></div> <p class="rex-sbmt"> <input type="submit" name="btn_save" value="' . $I18N->msg('add_block') . '"' . rex_accesskey($I18N->msg('add_block'), $REX['ACKEY']['SAVE']) . ' /> </p> </fieldset> </form> '; // Beim Add hier die Meldung ausgeben if ($this->slice_id == 0 && $this->message != '') { echo rex_warning($this->message); } $dummysql = new rex_sql(); // Den Dummy mit allen Feldern aus rex_article_slice füllen $slice_fields = new rex_sql(); $slice_fields->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'article_slice LIMIT 1'); foreach ($slice_fields->getFieldnames() as $fieldname) { switch ($fieldname) { case 'clang': $def_value = $this->clang; break; case 'ctype': $def_value = $this->ctype; break; case 'modultyp_id': $def_value = $module_id; break; case 'article_id': $def_value = $this->article_id; break; case 'id': $def_value = 0; break; default: $def_value = ''; } $dummysql->setValue($REX['TABLE_PREFIX'] . 'article_slice.' . $fieldname, $def_value); } $slice_content = $this->replaceVars($dummysql, $slice_content); } return $slice_content; }
$link = ""; $csuchtxt = rex_request("csuchtxt", "string", ""); if ($csuchtxt != "") { $link .= "&csuchtxt=" . urlencode($csuchtxt); } $csuchfeld = rex_request("csuchfeld", "array"); $SUCHSEL = new rexselect(); $SUCHSEL->setMultiple(1); $SUCHSEL->setSize(5); $SUCHSEL->setName("csuchfeld[]"); $SUCHSEL->setStyle("width:100%;"); $ssql = new rex_sql(); //$ssql->debugsql = 1; $ssql->setQuery("select * from " . $table_field . " order by prior"); for ($i = 0; $i < $ssql->getRows(); $i++) { $SUCHSEL->addOption($ssql->getValue("name"), $ssql->getValue("userfield")); if (!is_array($csuchfeld)) { $SUCHSEL->setSelected($ssql->getValue("field")); } $ssql->next(); } foreach ($csuchfeld as $cs) { $SUCHSEL->setSelected($cs); $link .= "&csuchfeld[]=" . $cs; } $cstatus = rex_request("cstatus", "string"); $STATUSSEL = new rexselect(); $STATUSSEL->setName("cstatus"); $STATUSSEL->setStyle("width:100%;"); $STATUSSEL->addOption("Aktiv & Inaktiv", ""); $STATUSSEL->addOption("Aktiv", 1);
/** * rex_rewriter_generate_pathnames * generiert die Pathlist, abhŠngig von Aktion * @author markus.staab[at]redaxo[dot]de Markus Staab * @package redaxo4.2 */ function rex_rewriter_generate_pathnames($params) { global $REX, $REXPATH; if (file_exists(FULLNAMES_PATHLIST)) { require_once FULLNAMES_PATHLIST; } if (!isset($REXPATH)) { $REXPATH = array(); } if (!isset($params['extension_point'])) { $params['extension_point'] = ''; } $where = ''; switch ($params['extension_point']) { // ------- sprachabhängig, einen artikel aktualisieren case 'CAT_DELETED': case 'ART_DELETED': unset($REXPATH[$params['id']]); break; case 'CAT_ADDED': case 'CAT_UPDATED': case 'ART_ADDED': case 'ART_UPDATED': $where = '(id=' . $params['id'] . ' AND clang=' . $params['clang'] . ') OR (path LIKE "%|' . $params['id'] . '|%" AND clang=' . $params['clang'] . ')'; break; // ------- alles aktualisieren // ------- alles aktualisieren case 'ALL_GENERATED': default: $where = '1=1'; break; } if ($where != '') { $db = new rex_sql(); // $db->debugsql=true; $db->setQuery('SELECT id,clang,path,startpage FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE ' . $where . ' and revision=0'); while ($db->hasNext()) { $clang = $db->getValue('clang'); $pathname = ''; if (count($REX['CLANG']) > 1) { $pathname = $REX['CLANG'][$clang] . '/'; } // pfad über kategorien bauen $path = trim($db->getValue('path'), '|'); if ($path != '') { $path = explode('|', $path); foreach ($path as $p) { $ooc = OOCategory::getCategoryById($p, $clang); $name = $ooc->getName(); unset($ooc); // speicher freigeben $pathname = rex_rewriter_appendToPath($pathname, $name); } } $ooa = OOArticle::getArticleById($db->getValue('id'), $clang); if ($ooa->isStartArticle()) { $ooc = $ooa->getCategory(); $catname = $ooc->getName(); unset($ooc); // speicher freigeben $pathname = rex_rewriter_appendToPath($pathname, $catname); } // eigentlicher artikel anhängen $name = $ooa->getName(); unset($ooa); // speicher freigeben $pathname = rex_rewriter_appendToPath($pathname, $name); $pathname = substr($pathname, 0, strlen($pathname) - 1) . '.html'; $REXPATH[$db->getValue('id')][$db->getValue('clang')] = $pathname; $db->next(); } } rex_put_file_contents(FULLNAMES_PATHLIST, "<?php\n\$REXPATH = " . var_export($REXPATH, true) . ";\n"); }
function organizePriorities($newPrio, $oldPrio) { if ($newPrio == $oldPrio) { return; } if ($newPrio < $oldPrio) { $addsql = 'desc'; } else { $addsql = 'asc'; } $sql = new rex_sql(); $sql->debugsql =& $this->debug; $sql->setQuery('SELECT field_id FROM ' . $this->tableName . ' WHERE name LIKE "' . $this->metaPrefix . '%" ORDER BY prior, updatedate ' . $addsql); $updateSql = new rex_sql(); $updateSql->debugsql =& $this->debug; for ($i = 0; $i < $sql->getRows(); $i++) { $updateSql->setTable($this->tableName); $updateSql->setValue('prior', $i + 1); $updateSql->setWhere('name LIKE "' . $this->metaPrefix . '%" AND field_id = ' . $sql->getValue('field_id')); $updateSql->update(); $sql->next(); } }