/** * 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>'; }
function asd_news_addClang($params) { global $REX; $id = $params['id']; $name = $params['name']; $now = new DateTime(); $error = false; $sql = new rex_sql(); $sql->setQuery('SELECT * FROM `' . rex_asd_news_config::getTable() . '` WHERE `clang` = ' . $REX['START_CLANG_ID']); for ($i = 1; $i <= $sql->getRows(); $i++) { $save = new rex_sql(); $save->setTable(rex_asd_news_config::getTable()); $save->setValues($sql->getRow()); $save->setValue('clang', $id); $save->setValue('createdAt', $now->format('Y-m-d H:i:s')); $save->setValue('updatedAt', $now->format('Y-m-d H:i:s')); $save->setValue('publishedAt', '0000-00-00 00:00:00'); $save->setValue('createdBy', $REX['USER']->getValue('user_id')); $save->setValue('updatedBy', $REX['USER']->getValue('user_id')); $save->setValue('publishedBy', 0); $save->setValue('status', 0); unset($save->values['news_id']); if (!$save->insert()) { $error = $save->getError(); } } if ($error) { echo rex_warning('ASD News: Neuigkeiten in der Sprache "' . $name . '" konnten nicht angelegt werden<br />' . $error); } else { echo rex_info('ASD News: Neuigkeiten in der Sprache "' . $name . '" wurden angelegt'); } }
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 a724_generatePathnamesFromTable($params) { $debug = false; $sql = new rex_sql(); $results = $sql->getArray('SELECT article_id, url_table, url_table_parameters FROM rex_a724_frau_schultze WHERE url_table != "" AND url_table_parameters != ""'); $URLPATH = array(); if ($sql->getRows() >= 1) { a724_deletePathnamesFromTable(); foreach ($results as $result) { if (is_array($result) && count($result) > 0) { $path = rex_getUrl($result['article_id']) . '/'; $path = str_replace('.html', '', $path); $table = $result['url_table']; $params = unserialize($result['url_table_parameters']); $col_name = $params[$table][$table . "_name"]; $col_id = $params[$table][$table . "_id"]; // Daten zum Aufbau der Urls holen $sqlu = new rex_sql(); $sqlu->setDebug($debug); $res = $sqlu->getArray('SELECT ' . $col_name . ' AS name, ' . $col_id . ' AS id FROM ' . $table); if ($sqlu->getRows() >= 1) { // Urls in die Datenbank schreiben $sqli = new rex_sql(); $sqli->setDebug($debug); foreach ($res as $re) { $table_path = $path . strtolower(rex_parse_article_name($re['name'])) . '.html'; $table_id = $re['id']; $URLPATH[$result['url_table']][$table_id] = $table_path; $sqli->setTable('rex_a724_frau_schultze'); $sqli->setValue('article_id', $result['article_id']); $sqli->setValue('status', '1'); $sqli->setValue('url_table', $result['url_table']); $sqli->setValue('name', $table_path); $sqli->insert(); } } } } } rex_put_file_contents(A724_URL_TABLE_PATHLIST, "<?php\n\$URLPATH = " . var_export($URLPATH, true) . ";\n"); }
function getInsertValue($value) { $value = (array) $value; $section =& $this->getSection(); // Alle vorhanden Werte löschen $sql = new rex_sql(); $sql->setTable($this->foreignTable); $sql->setWhere($section->_getWhereString()); $sql->delete(); // und anschließend alle neu eintragen foreach ($value as $val) { // Parameter aus der Ursprungstabelle mit abspeichern damit später darüber verknüpft werden kann foreach ($section->getWhere() as $whereColName => $whereColValue) { $sql->setValue($whereColName, $whereColValue); } // Den zu speichernden Wert $sql->setValue($this->foreignField, $val); $sql->setTable($this->foreignTable); $sql->insert(); } // null zurückgeben, damit zu diesem Feld nichts im rexForm gespeichert wird return null; }
function execute() { // echo "DB EXECUTE"; // return; $sql = new rex_sql(); if ($this->params["debug"]) { $sql->debugsql = TRUE; } $main_table = ""; if (isset($this->action["elements"][2]) && $this->action["elements"][2] != "") { $main_table = $this->action["elements"][2]; } else { $main_table = $this->params["main_table"]; } if ($main_table == "") { $this->params["form_show"] = TRUE; $this->params["hasWarnings"] = TRUE; $this->params["warning_messages"][] = $this->params["Error-Code-InsertQueryError"]; return FALSE; } $sql->setTable($main_table); $where = ""; if (isset($this->action["elements"][3]) && trim($this->action["elements"][3]) != "") { $where = trim($this->action["elements"][3]); } // SQL Objekt mit Werten füllen foreach ($this->elements_sql as $key => $value) { $sql->setValue($key, $value); if ($where != "") { $where = str_replace('###' . $key . '###', addslashes($value), $where); } } if ($where != "") { $sql->setWhere($where); $sql->update(); $flag = "update"; } else { $sql->insert(); $flag = "insert"; $id = $sql->getLastId(); $this->elements_email["ID"] = $id; // $this->elements_sql["ID"] = $id; if ($id == 0) { $this->params["form_show"] = TRUE; $this->params["hasWarnings"] = TRUE; $this->params["warning_messages"][] = $this->params["Error-Code-InsertQueryError"]; } } }
function execute() { $subject_key = $this->action["elements"][2]; $body_key = $this->action["elements"][3]; $user_id_key = $this->action["elements"][4]; foreach ($this->elements_sql as $key => $value) { if ($subject_key == $key) { $subject = $value; } if ($body_key == $key) { $body = $value; } if ($user_id_key == $key) { $from_user_id = $value; } // echo "<br /> $key => $value"; } if ($subject == "" or $body == "" or $from_user_id == "") { return FALSE; } // User auslesen $gu = new rex_sql(); // $gu->debugsql = 1; // $gu->setQuery('select * from rex_com_user where id<>"'.$from_user_id.'" order by id'); $gu->setQuery('select * from rex_com_user order by id'); foreach ($gu->getArray() as $user) { $user_body = $body; $user_subject = $subject; $to_user_id = $user["id"]; // Empfaenger einbauen $in = new rex_sql(); // $in->debugsql = 1; $in->setTable("rex_com_message"); $in->setValue("user_id", $to_user_id); $in->setValue("from_user_id", $from_user_id); $in->setValue("to_user_id", $to_user_id); $in->setValue("subject", $user_subject); $in->setValue("body", $user_body); $in->setValue("create_datetime", time()); $in->insert(); /* $in = new rex_sql; // $in->debugsql = 1; $in->setTable("rex_com_message"); $in->setValue("user_id",$from_user_id); $in->setValue("from_user_id",$from_user_id); $in->setValue("to_user_id",$to_user_id); $in->setValue("subject",$user_subject); $in->setValue("body",$user_body); $in->setValue("create_datetime",time()); $in->insert(); */ rex_com_user::exeAction($to_user_id, "sendemail_newmessage", $user); } }
/** * 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(); } }
static function syncCatname2Artname($params) { global $REX, $I18N; $id = $params['id']; $clang = $params['clang']; $name = $params['data']['catname']; if ($name != '') { $sql = new rex_sql(); $sql->setTable($REX['TABLE_PREFIX'] . 'article'); $sql->setWhere('id=' . $id . ' AND clang=' . $clang); $sql->setValue('name', $name); $sql->addGlobalUpdateFields(); $sql->update(); rex_deleteCacheArticle($id, $clang); } }
function rex_setup_setUtf8() { global $REX; $gt = new rex_sql(); $gt->setQuery("show tables"); foreach ($gt->getArray() as $t) { $table = $t["Tables_in_" . $REX['DB']['1']['NAME']]; $gc = new rex_sql(); $gc->setQuery("show columns from {$table}"); if (substr($table, 0, strlen($REX['TABLE_PREFIX'])) == $REX['TABLE_PREFIX']) { $columns = array(); $pri = ""; foreach ($gc->getArray() as $c) { $columns[] = $c["Field"]; if ($pri == "" && $c["Key"] == "PRI") { $pri = $c["Field"]; } } if ($pri != "") { $gr = new rex_sql(); $gr->setQuery("select * from {$table}"); foreach ($gr->getArray() as $r) { reset($columns); $privalue = $r[$pri]; $uv = new rex_sql(); $uv->setTable($table); $uv->setWhere($pri . '= "' . $privalue . '"'); foreach ($columns as $key => $column) { if ($pri != $column) { $value = $r[$column]; $newvalue = utf8_decode($value); $uv->setValue($column, addslashes($newvalue)); } } $uv->update(); } } } } }
/** * Erstellt eine Clang * * @param $id Id der Clang * @param $name Name der Clang */ function rex_addCLang($id, $name) { global $REX; $REX['CLANG'][$id] = $name; $content = ""; foreach ($REX['CLANG'] as $cur => $val) { $content .= "\$REX['CLANG']['{$cur}'] = \"{$val}\";\n"; } $file = $REX['INCLUDE_PATH'] . "/clang.inc.php"; rex_replace_dynamic_contents($file, $content); $add = new rex_sql(); $add->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where clang='0'"); $fields = $add->getFieldnames(); $adda = new rex_sql(); // $adda->debugsql = 1; for ($i = 0; $i < $add->getRows(); $i++) { $adda->setTable($REX['TABLE_PREFIX'] . "article"); foreach ($fields as $key => $value) { if ($value == 'pid') { echo ''; } else { if ($value == 'clang') { $adda->setValue('clang', $id); } else { if ($value == 'status') { $adda->setValue('status', '0'); } else { $adda->setValue($value, rex_addslashes($add->getValue($value))); } } } } $adda->insert(); $add->next(); } $add = new rex_sql(); $add->setQuery("insert into " . $REX['TABLE_PREFIX'] . "clang set id='{$id}',name='{$name}'"); // ----- EXTENSION POINT rex_register_extension_point('CLANG_ADDED', '', array('id' => $id, 'name' => $name)); rex_generateAll(); }
$gm->setQuery('select * from rex_module where ausgabe LIKE "%' . $searchtext . '%"'); $module_id = 0; $module_name = ""; foreach ($gm->getArray() as $module) { $module_id = $module["id"]; $module_name = $module["name"]; } if (isset($_REQUEST["install"]) && $_REQUEST["install"] == 1) { $xform_module_name = "rex - X-Form"; // Daten einlesen $in = rex_get_file_contents($REX["INCLUDE_PATH"] . "/addons/xform/module/module_in.inc"); $out = rex_get_file_contents($REX["INCLUDE_PATH"] . "/addons/xform/module/module_out.inc"); $mi = new rex_sql(); // $mi->debugsql = 1; $mi->setTable("rex_module"); $mi->setValue("eingabe", addslashes($in)); $mi->setValue("ausgabe", addslashes($out)); // altes Module aktualisieren if (isset($_REQUEST["module_id"]) && $module_id == $_REQUEST["module_id"]) { $mi->setWhere('id="' . $module_id . '"'); $mi->update(); echo rex_info('Modul "' . $module_name . '" wurde aktualisiert'); } else { $mi->setValue("name", $xform_module_name); $mi->insert(); echo rex_info('XForm Modul wurde angelegt unter "' . $xform_module_name . '"'); } } ?> <div class="rex-addon-output">
function createTable($mifix = "", $data_table, $params = array(), $debug = FALSE) { // Tabelle erstellen wenn noch nicht vorhanden $c = rex_sql::factory(); $c->debugsql = $debug; $c->setQuery('CREATE TABLE IF NOT EXISTS `' . $data_table . '` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY );'); // Tabellenset in die Basics einbauen, wenn noch nicht vorhanden $c = new rex_sql(); $c->debugsql = $debug; $c->setQuery('DELETE FROM rex_xform_table where table_name="' . $data_table . '"'); $c->setTable('rex_xform_table'); $params["table_name"] = $data_table; if (!isset($params["status"])) { $params["status"] = 1; } if (!isset($params["name"])) { $params["name"] = 'Tabelle "' . $data_table . '"'; } if (!isset($params["prio"])) { $params["prio"] = 100; } if (!isset($params["search"])) { $params["search"] = 0; } if (!isset($params["hidden"])) { $params["hidden"] = 0; } if (!isset($params["export"])) { $params["export"] = 0; } foreach ($params as $k => $v) { $c->setValue($k, $v); } $c->insert(); return TRUE; }
} $err_msg .= $I18N->msg('setup_041'); } if ($err_msg == "") { $ga = new rex_sql(); $ga->setQuery("select * from " . $REX['TABLE_PREFIX'] . "user where login='******'"); if ($ga->getRows() > 0) { $err_msg .= $I18N->msg('setup_042'); } else { if ($REX['PSWFUNC'] != '') { $redaxo_user_pass = call_user_func($REX['PSWFUNC'], $redaxo_user_pass); } $user = new rex_sql(); // $user->debugsql = true; $user->setTable($REX['TABLE_PREFIX'] . 'user'); $user->setValue('name', 'Administrator'); $user->setValue('login', $redaxo_user_login); $user->setValue('psw', $redaxo_user_pass); $user->setValue('rights', '#admin[]#dev[]#import[]#stats[]#moveSlice[]#'); $user->addGlobalCreateFields('setup'); $user->setValue('status', '1'); if (!$user->insert()) { $err_msg .= $I18N->msg("setup_043"); } } } } else { $gu = new rex_sql(); $gu->setQuery("select * from " . $REX['TABLE_PREFIX'] . "user LIMIT 1"); if ($gu->getRows() == 0) { $err_msg .= $I18N->msg('setup_044');
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; }
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; }
$IMOD = new rex_sql(); $IMOD->setTable($REX['TABLE_PREFIX'] . 'module'); $IMOD->setValue('name', $mname); $IMOD->setValue('eingabe', $eingabe); $IMOD->setValue('ausgabe', $ausgabe); $IMOD->addGlobalCreateFields(); $message = $IMOD->insert($I18N->msg('module_added')); } else { $modultyp->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'module where id=' . $modul_id); if ($modultyp->getRows() == 1) { $old_ausgabe = $modultyp->getValue('ausgabe'); // $modultyp->setQuery("UPDATE ".$REX['TABLE_PREFIX']."modultyp SET name='$mname', eingabe='$eingabe', ausgabe='$ausgabe' WHERE id='$modul_id'"); $UMOD = new rex_sql(); $UMOD->setTable($REX['TABLE_PREFIX'] . 'module'); $UMOD->setWhere('id=' . $modul_id); $UMOD->setValue('name', $mname); $UMOD->setValue('eingabe', $eingabe); $UMOD->setValue('ausgabe', $ausgabe); $UMOD->addGlobalUpdateFields(); $message = $UMOD->update($I18N->msg('module_updated') . ' | ' . $I18N->msg('articel_updated')); $new_ausgabe = stripslashes($ausgabe); if ($old_ausgabe != $new_ausgabe) { // article updaten - nur wenn ausgabe sich veraendert hat $gc = new rex_sql(); $gc->setQuery("SELECT DISTINCT(" . $REX['TABLE_PREFIX'] . "article.id) FROM " . $REX['TABLE_PREFIX'] . "article\r\n LEFT JOIN " . $REX['TABLE_PREFIX'] . "article_slice ON " . $REX['TABLE_PREFIX'] . "article.id=" . $REX['TABLE_PREFIX'] . "article_slice.article_id\r\n WHERE " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id='{$modul_id}'"); for ($i = 0; $i < $gc->getRows(); $i++) { rex_deleteCacheArticle($gc->getValue($REX['TABLE_PREFIX'] . "article.id")); $gc->next(); } } }
$amessage = $AART->getError(); } } rex_generateArticle($id); // ----- EXTENSION POINT $amessage = rex_register_extension_point('ART_ADDED', $amessage, array('id' => $id, 'status' => 0, 'name' => $article_name, 're_id' => $category_id, 'prior' => $Position_New_Article, 'path' => $KATPATH, 'template_id' => $template_id)); } elseif (!empty($artedit_function) && $article_id != '' && $KATPERM) { // --------------------- ARTIKEL EDIT $Position_Article = (int) $Position_Article; if ($Position_Article == 0) { $Position_Article = 1; } $EA = new rex_sql(); $EA->setTable($REX['TABLE_PREFIX'] . "article"); $EA->setWhere("id='{$article_id}' and clang={$clang}"); $EA->setValue('name', $article_name); $EA->setValue('template_id', $template_id); // $EA->setValue('path',$KATPATH); $EA->addGlobalUpdateFields(); $EA->setValue('prior', $Position_Article); if ($EA->update()) { $amessage = $I18N->msg('article_updated'); // ----- PRIOR rex_newArtPrio($category_id, $clang, $Position_Article, $thisArt->getValue('prior')); rex_generateArticle($article_id); // ----- EXTENSION POINT $amessage = rex_register_extension_point('ART_UPDATED', $amessage, array('id' => $article_id, 'status' => $thisArt->getValue('status'), 'name' => $article_name, 'clang' => $clang, 're_id' => $category_id, 'prior' => $Position_Article, 'path' => $KATPATH, 'template_id' => $template_id)); } else { $amessage = $EA->getError(); } } elseif ($function == 'artdelete_function' && $article_id != '' && $KATPERM && !$REX_USER->hasPerm('editContentOnly[]')) {
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> <div class="rex-form rex-form-content-editmode-add-slice"> <form action="index.php#slice' . $I_ID . '" method="post" id="REX_FORM" enctype="multipart/form-data"> <fieldset class="rex-form-col-1"> <legend><span>' . $I18N->msg('add_block') . '</span></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 . '" /> <div class="rex-content-editmode-module-name"> <h3 class="rex-hl4"> ' . $I18N->msg("module") . ': <span>' . htmlspecialchars($MOD->getValue("name")) . '</span> </h3> </div> <div class="rex-form-wrapper"> <div class="rex-form-row"> <div class="rex-content-editmode-slice-input"> <div class="rex-content-editmode-slice-input-2"> ' . $MOD->getValue("eingabe") . ' </div> </div> </div> </div> </fieldset> <fieldset class="rex-form-col-1"> <div class="rex-form-wrapper"> <div class="rex-form-row"> <p class="rex-form-col-a rex-form-submit"> <input class="rex-form-submit" type="submit" name="btn_save" value="' . $I18N->msg('add_block') . '"' . rex_accesskey($I18N->msg('add_block'), $REX['ACKEY']['SAVE']) . ' /> </p> </div> </div> </fieldset> </form> </div> <script type="text/javascript"> <!-- jQuery(function($) { $(":input:visible:enabled:not([readonly]):first", $("form#REX_FORM")).focus(); }); //--> </script>'; // Beim Add hier die Meldung ausgeben if ($this->slice_id == 0) { if ($this->warning != '') { echo rex_warning($this->warning); } if ($this->info != '') { echo rex_info($this->info); } } $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; }
$deleteuser->setQuery("DELETE FROM " . $REX['TABLE_PREFIX'] . "user WHERE user_id = '{$user_id}' LIMIT 1"); $message = $I18N->msg("user_deleted"); unset($user_id); } else { $message = $I18N->msg("user_notdeleteself"); } } elseif (isset($FUNC_ADD) and $FUNC_ADD != '' and (isset($save) and $save == '')) { // bei add default selected $sel_sprachen->setSelected("0"); } elseif (isset($FUNC_ADD) and $FUNC_ADD != '' and (isset($save) and $save == 1)) { $adduser = new rex_sql(); $adduser->setQuery("SELECT * FROM " . $REX['TABLE_PREFIX'] . "user WHERE login = '******'"); if ($adduser->getRows() == 0 and $userlogin != '') { $adduser = new rex_sql(); $adduser->setTable($REX['TABLE_PREFIX'] . 'user'); $adduser->setValue('name', $username); if ($REX['PSWFUNC'] != '') { $userpsw = call_user_func($REX['PSWFUNC'], $userpsw); } $adduser->setValue('psw', $userpsw); $adduser->setValue('login', $userlogin); $adduser->setValue('description', $userdesc); $adduser->addGlobalCreateFields(); if (isset($userstatus) and $userstatus == 1) { $adduser->setValue('status', 1); } else { $adduser->setValue('status', 0); } $perm = ''; if (isset($useradmin) and $useradmin == 1) { $perm .= '#' . 'admin[]';
$presavestatus = rex_post('presavestatus', 'array'); $postsavestatus = rex_post('postsavestatus', 'array'); $previewmode = 0; foreach ($previewstatus as $status) { $previewmode |= $status; } $presavemode = 0; foreach ($presavestatus as $status) { $presavemode |= $status; } $postsavemode = 0; foreach ($postsavestatus as $status) { $postsavemode |= $status; } $faction->setTable($REX['TABLE_PREFIX'] . 'action'); $faction->setValue('name', $name); $faction->setValue('preview', $previewaction); $faction->setValue('presave', $presaveaction); $faction->setValue('postsave', $postsaveaction); $faction->setValue('previewmode', $previewmode); $faction->setValue('presavemode', $presavemode); $faction->setValue('postsavemode', $postsavemode); if ($function == 'add') { $faction->addGlobalCreateFields(); if ($faction->insert()) { $info = $I18N->msg('action_added'); } else { $warning = $faction->getError(); } } else { $faction->addGlobalUpdateFields();
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(); } }
/** * @access public * @return Returns <code>true</code> on success or <code>false</code> on error */ function save() { $sql = new rex_sql(); $sql->setTable($this->_getTableName()); $sql->setValue('re_file_id', $this->getParentId()); $sql->setValue('category_id', $this->getCategoryId()); $sql->setValue('filetype', $this->getType()); $sql->setValue('filename', $this->getFileName()); $sql->setValue('originalname', $this->getOrgFileName()); $sql->setValue('filesize', $this->getSize()); $sql->setValue('width', $this->getWidth()); $sql->setValue('height', $this->getHeight()); $sql->setValue('title', $this->getTitle()); if ($this->getId() !== null) { $sql->addGlobalUpdateFields(); $sql->setWhere('file_id=' . $this->getId() . ' LIMIT 1'); return $sql->update(); } else { $sql->addGlobalCreateFields(); return $sql->insert(); } }
/** * Übernimmt die gePOSTeten werte in ein rex_sql-Objekt. * * @param array $params * @param rex_sql $sqlSave rex_sql-objekt, in das die aktuellen Werte gespeichert werden sollen * @param rex_sql $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält */ public static function fetchRequestValues(&$params, &$sqlSave, $sqlFields) { if (rex_request_method() != 'post') { return; } for ($i = 0; $i < $sqlFields->getRows(); $i++, $sqlFields->next()) { $fieldName = $sqlFields->getValue('name'); $fieldType = $sqlFields->getValue('type_id'); $fieldAttributes = $sqlFields->getValue('attributes'); // dont save restricted fields $attrArray = rex_string::split($fieldAttributes); if (isset($attrArray['perm'])) { if (!rex::getUser()->hasPerm($attrArray['perm'])) { continue; } unset($attrArray['perm']); } // Wert in SQL zum speichern $saveValue = self::getSaveValue($fieldName, $fieldType, $fieldAttributes); $sqlSave->setValue($fieldName, $saveValue); // Werte im aktuellen Objekt speichern, dass zur Anzeige verwendet wird if (isset($params['activeItem'])) { $params['activeItem']->setValue($fieldName, $saveValue); } } }
exit; } else { $message = $I18N->msg('content_error_movecategory'); } } else { $message = $I18N->msg('no_rights_to_this_function'); } } // ------------------------------------------ END: MOVE CATEGORY // ------------------------------------------ START: SAVE METADATA if (rex_post('savemeta', 'string')) { $meta_sql = new rex_sql(); $meta_sql->setTable($REX['TABLE_PREFIX'] . "article"); // $meta_sql->debugsql = 1; $meta_sql->setWhere("id='{$article_id}' AND clang={$clang}"); $meta_sql->setValue('name', $meta_article_name); $meta_sql->addGlobalUpdateFields(); if ($meta_sql->update()) { $article->setQuery("SELECT * FROM " . $REX['TABLE_PREFIX'] . "article WHERE id='{$article_id}' AND clang='{$clang}'"); $message = $I18N->msg("metadata_updated") . $message; rex_generateArticle($article_id); // ----- EXTENSION POINT $message = rex_register_extension_point('ART_META_UPDATED', $message, array('id' => $article_id, 'clang' => $clang, 'name' => $meta_article_name)); } else { $message .= $meta_sql->getError(); } } // ------------------------------------------ END: SAVE METADATA // ------------------------------------------ START: CONTENT HEAD MENUE $num_ctypes = count($REX['CTYPE']); $ctype_menu = '';
/** * Holt ein upgeloadetes File und legt es in den Medienpool * Dabei wird kontrolliert ob das File schon vorhanden ist und es * wird eventuell angepasst, weiterhin werden die Fileinformationen übergeben * * @param $FILE * @param $rex_file_category * @param $FILEINFOS * @param $userlogin */ function rex_medienpool_saveMedia($FILE, $rex_file_category, $FILEINFOS, $userlogin = null) { global $REX, $I18N; $rex_file_category = (int) $rex_file_category; $gc = new rex_sql(); $gc->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'file_category WHERE id=' . $rex_file_category); if ($gc->getRows() != 1) { $rex_file_category = 0; } $FILENAME = $FILE['name']; $FILESIZE = $FILE['size']; $FILETYPE = $FILE['type']; $NFILENAME = rex_medienpool_filename($FILENAME); $message = ''; // ----- neuer filename $dstFile = $REX['MEDIAFOLDER'] . '/' . $NFILENAME; // ----- dateiupload $upload = true; if (!@move_uploaded_file($FILE['tmp_name'], $dstFile) && !@copy($FILE['tmp_name'], $dstFile)) { $message .= $I18N->msg("pool_file_movefailed"); $ok = 0; $upload = false; } if ($upload) { chmod($dstFile, $REX['FILEPERM']); // get widht height $size = @getimagesize($dstFile); $FILESQL = new rex_sql(); $FILESQL->setTable($REX['TABLE_PREFIX'] . 'file'); $FILESQL->setValue('filetype', $FILETYPE); $FILESQL->setValue('title', $FILEINFOS['title']); $FILESQL->setValue('filename', $NFILENAME); $FILESQL->setValue('originalname', $FILENAME); $FILESQL->setValue('filesize', $FILESIZE); $FILESQL->setValue('width', $size[0]); $FILESQL->setValue('height', $size[1]); $FILESQL->setValue('category_id', $rex_file_category); // TODO Create + Update zugleich? $FILESQL->addGlobalCreateFields($userlogin); $FILESQL->addGlobalUpdateFields($userlogin); $FILESQL->insert(); $ok = 1; $message .= $I18N->msg("pool_file_added"); } $RETURN['title'] = $FILEINFOS['title']; $RETURN['width'] = $size[0]; $RETURN['height'] = $size[1]; $RETURN['type'] = $FILETYPE; $RETURN['msg'] = $message; $RETURN['ok'] = $ok; $RETURN['filename'] = $NFILENAME; $RETURN['old_filename'] = $FILENAME; return $RETURN; }
/** * Callbackfunktion, damit in subklassen der Value noch beeinflusst werden kann * kurz vorm speichern. */ protected function preSave($fieldsetName, $fieldName, $fieldValue, rex_sql $saveSql) { static $setOnce = false; if (!$setOnce) { $fieldnames = $this->sql->getFieldnames(); if (in_array('updateuser', $fieldnames)) { $saveSql->setValue('updateuser', rex::getUser()->getValue('login')); } if (in_array('updatedate', $fieldnames)) { $saveSql->setDateTimeValue('updatedate', time()); } if (!$this->isEditMode()) { if (in_array('createuser', $fieldnames)) { $saveSql->setValue('createuser', rex::getUser()->getValue('login')); } if (in_array('createdate', $fieldnames)) { $saveSql->setDateTimeValue('createdate', time()); } } $setOnce = true; } return $fieldValue; }
if ($func == 'delete') { $sql = new rex_sql(); $sql->setTable(rex_asd_news_config::getTable()); $sql->setWhere('id=' . $id . ' AND clang = ' . $clang); if ($sql->delete()) { echo rex_info($I18N->msg('asd_news_deleted')); } else { echo rex_warning($sql->getError()); } $func = ''; } if ($func == 'unpublish') { $sql = new rex_sql(); $sql->setTable(rex_asd_news_config::getTable()); $sql->setWhere('id=' . $id . ' AND clang = ' . $clang); $sql->setValue('publishedAt', '0000-00-00 00:00:00'); $sql->setValue('publishedBy', 0); $successMessage = $I18N->msg('asd_news_unpublished_s'); if (rex_asd_news_config::getConfig('published-lang') == 'all') { $sql->setWhere('`id` = ' . $id); $successMessage = $I18N->msg('asd_news_unpublished_m'); } if ($sql->update()) { echo rex_info($successMessage); } else { echo rex_warning($sql->getError()); } $func = ''; } if ($func == '') { $list = new rex_list('
/** * @access public * @return Returns <code>true</code> on success or <code>false</code> on error */ function save() { $sql = new rex_sql(); $sql->setTable($this->_getTableName()); $sql->setValue('re_id', $this->getParentId()); $sql->setValue('name', $this->getName()); $sql->setValue('path', $this->getPath()); $sql->setValue('hide', $this->isHidden()); if ($this->getId() !== null) { $sql->addGlobalUpdateFields(); $sql->setWhere('id=' . $this->getId() . ' LIMIT 1'); return $sql->update(); } else { $sql->addGlobalCreateFields(); return $sql->insert(); } }
function createTable($mifix = '', $data_table, $params = array(), $debug = false) { // Tabelle erstellen wenn noch nicht vorhanden $c = rex_sql::factory(); $c->debugsql = $debug; $c->setQuery('CREATE TABLE IF NOT EXISTS `' . $data_table . '` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY );'); // Tabellenset in die Basics einbauen, wenn noch nicht vorhanden $c = new rex_sql(); $c->debugsql = $debug; $c->setQuery('DELETE FROM ' . rex_xform_manager_table::table() . ' where table_name="' . $data_table . '"'); $c->setTable(rex_xform_manager_table::table()); $params['table_name'] = $data_table; if (!isset($params['status'])) { $params['status'] = 1; } if (!isset($params['name'])) { $params['name'] = 'Tabelle "' . $data_table . '"'; } if (!isset($params['prio'])) { $params['prio'] = 100; } if (!isset($params['search'])) { $params['search'] = 0; } if (!isset($params['hidden'])) { $params['hidden'] = 0; } if (!isset($params['export'])) { $params['export'] = 0; } foreach ($params as $k => $v) { $c->setValue($k, $v); } $c->insert(); return true; }