Setzt eine Update-Anweisung auf die angegebene Tabelle
mit den angegebenen Werten und WHERE Parametern ab.
public update ( ) |
/** * 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 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"]; } } }
/** * 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); } }
$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(); $faction->setWhere('id=' . $action_id); if ($faction->update()) { $info = $I18N->msg('action_updated'); } else { $warning = $faction->getError(); } } if (isset($goon) and $goon != '') { $save = 'nein'; } else { $function = ''; } } if ($save != '1') { if ($function == 'edit') { $legend = $I18N->msg('action_edit') . ' [ID=' . $action_id . ']'; $action = new rex_sql();
$perm .= '#clang[' . $_perm . ']'; } } // userperm mylang if (!isset($userperm_mylang) or $userperm_mylang == "") { $userperm_mylang = 'be_lang[default]'; } $perm .= '#' . $userperm_mylang; // userperm_module if (isset($userperm_module)) { foreach ($userperm_module as $_perm) { $perm .= '#module[' . $_perm . ']'; } } $updateuser->setValue('rights', $perm . '#'); $updateuser->update(); if (isset($FUNC_UPDATE) && $FUNC_UPDATE != '') { unset($user_id); unset($FUNC_UPDATE); } $message = $I18N->msg('user_data_updated'); } elseif (isset($FUNC_DELETE) and $FUNC_DELETE != '') { // man kann sich selbst nicht löschen.. if ($REX_USER->getValue("user_id") != $user_id) { $deleteuser = new rex_sql(); $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"); }
function save() { $fieldName = $this->getFieldValue('name'); // Den alten Wert aus der DB holen // Dies muss hier geschehen, da in parent::save() die Werte für die DB mit den // POST werten überschrieben werden! $fieldOldName = ''; $fieldOldPrior = 9999999999999; // dirty, damit die prio richtig läuft... $fieldOldDefault = ''; if ($this->sql->getRows() == 1) { $fieldOldName = $this->sql->getValue('name'); $fieldOldPrior = $this->sql->getValue('prior'); $fieldOldDefault = $this->sql->getValue('default'); } if (parent::save()) { global $REX, $I18N; $this->organizePriorities($this->getFieldValue('prior'), $fieldOldPrior); rex_generateAll(); $fieldName = $this->addPrefix($fieldName); $fieldType = $this->getFieldValue('type'); $fieldDefault = $this->getFieldValue('default'); $sql = rex_sql::getInstance(); $result = $sql->getArray('SELECT `dbtype`, `dblength` FROM `' . $REX['TABLE_PREFIX'] . '62_type` WHERE id=' . $fieldType); $fieldDbType = $result[0]['dbtype']; $fieldDbLength = $result[0]['dblength']; // TEXT Spalten dürfen in MySQL keine Defaultwerte haben if ($fieldDbType == 'text') { $fieldDefault = null; } if ($this->isEditMode()) { // Spalte in der Tabelle verändern $tmRes = $this->tableManager->editColumn($fieldOldName, $fieldName, $fieldDbType, $fieldDbLength, $fieldDefault); } else { // Spalte in der Tabelle anlegen $tmRes = $this->tableManager->addColumn($fieldName, $fieldDbType, $fieldDbLength, $fieldDefault); } if ($tmRes) { // DefaultWerte setzen if ($fieldDefault != $fieldOldDefault) { $upd = new rex_sql(); $upd->setTable($this->tableManager->getTableName()); $upd->setWhere('`' . $fieldName . '`="' . addSlashes($fieldOldDefault) . '"'); $upd->setValue($fieldName, addSlashes($fieldDefault)); return $upd->update(); } // Default werte haben schon zuvor gepasst, daher true zurückgeben return true; } } return false; }
$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 = ''; if ($num_ctypes > 0) { $listElements = array();
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(); } }
/** * Ändert den Status des Artikels * * @param int $article_id Id des Artikels die gelöscht werden soll * @param int $clang Id der Sprache * @param int|null $status Status auf den der Artikel gesetzt werden soll, oder NULL wenn zum nächsten Status weitergeschaltet werden soll * * @return array Ein Array welches den status sowie eine Fehlermeldung beinhaltet */ function rex_articleStatus($article_id, $clang, $status = null) { global $REX, $I18N; $success = false; $message = ''; $artStatusTypes = rex_articleStatusTypes(); $GA = new rex_sql(); $GA->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where id='{$article_id}' and clang={$clang}"); if ($GA->getRows() == 1) { // Status wurde nicht von außen vorgegeben, // => zyklisch auf den nächsten Weiterschalten if (!$status) { $newstatus = ($GA->getValue('status') + 1) % count($artStatusTypes); } else { $newstatus = $status; } $EA = new rex_sql(); $EA->setTable($REX['TABLE_PREFIX'] . "article"); $EA->setWhere("id='{$article_id}' and clang={$clang}"); $EA->setValue('status', $newstatus); $EA->addGlobalUpdateFields(); if ($EA->update()) { $message = $I18N->msg('article_status_updated'); rex_deleteCacheArticle($article_id, $clang); // ----- EXTENSION POINT $message = rex_register_extension_point('ART_STATUS', $message, array('id' => $article_id, 'clang' => $clang, 'status' => $newstatus)); $success = true; } else { $message = $EA->getError(); } } else { $message = $I18N->msg("no_such_category"); } return array($success, $message); }
$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(); } } } } if (isset($goon) and $goon != '') { $save = 'nein'; } else {
if ($function == "add") { $attributes = rex_setAttributes("ctype", $ctypes, ""); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalCreateFields(); if ($TPL->insert()) { $template_id = $TPL->getLastId(); $message = $I18N->msg("template_added"); } else { $message = $TPL->getError(); } } else { $attributes = rex_setAttributes("ctype", $ctypes, $attributes); $TPL->setWhere("id='{$template_id}'"); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalUpdateFields(); $message = $TPL->update($I18N->msg("template_updated")); } // werte werden direkt wieder ausgegeben $templatename = stripslashes($templatename); $content = stripslashes($content); rex_deleteDir($REX['INCLUDE_PATH'] . "/generated/templates", 0); if (isset($goon) and $goon != "") { $function = "edit"; $save = "nein"; } else { $function = ""; } } if (!isset($save) or $save != "ja") { echo '<a name="edit"></a>'; // Ctype Handling
// Gruppen $a = new rex_sql(); $a->setTable("rex_62_params"); $a->setValue("title", "Gruppen"); $a->setValue("name", "art_com_groups"); $a->setValue("prior", "12"); $a->setValue("type", "3"); $a->setValue("attributes", "multiple=multiple"); $a->setValue("params", "select name as label,id from rex_com_group order by label"); $a->setValue("validate", NULL); $a->addGlobalCreateFields(); $g = new rex_sql(); $g->setQuery('select * from rex_62_params where name="art_com_groups"'); if ($g->getRows() == 1) { $a->setWhere('name="art_com_groups"'); $a->update(); } else { $a->insert(); } $g = new rex_sql(); $g->setQuery('show columns from rex_article Like "art_com_groups"'); if ($g->getRows() == 0) { $a->setQuery("ALTER TABLE `rex_article` ADD `art_com_groups` VARCHAR( 255 ) NOT NULL"); } // ************************************************************** CACHE LOESCHEN $info = rex_generateAll(); // quasi kill cache .. $REX['ADDON']['install']['auth'] = 1; if ($error != "") { $REX['ADDON']['install']['auth'] = 0; $REX['ADDON']['installmsg']['auth'] = $error;
/** * 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_mediapool_updateMedia($FILE, &$FILEINFOS, $userlogin = null) { global $REX, $I18N; $RETURN = array(); $FILESQL = new rex_sql(); // $FILESQL->debugsql = 1; $FILESQL->setTable($REX['TABLE_PREFIX'] . 'file'); $FILESQL->setWhere('file_id=' . $FILEINFOS["file_id"]); $FILESQL->setValue('title', $FILEINFOS["title"]); $FILESQL->setValue('category_id', $FILEINFOS["rex_file_category"]); $msg = ''; $updated = false; if ($_FILES['file_new']['name'] != '' && $_FILES['file_new']['name'] != 'none') { $ffilename = $_FILES['file_new']['tmp_name']; $ffiletype = $_FILES['file_new']['type']; $ffilesize = $_FILES['file_new']['size']; if ($ffiletype == $FILEINFOS["filetype"] || OOMedia::compareImageTypes($ffiletype, $FILEINFOS["filetype"])) { if (move_uploaded_file($ffilename, $REX['MEDIAFOLDER'] . '/' . $FILEINFOS["filename"]) || copy($ffilename, $REX['MEDIAFOLDER'] . '/' . $FILEINFOS["filename"])) { $RETURN["msg"] = $I18N->msg('pool_file_changed'); $FILEINFOS["filetype"] = $ffiletype; $FILEINFOS["filesize"] = $ffilesize; $FILESQL->setValue('filetype', $FILEINFOS["filetype"]); // $FILESQL->setValue('originalname',$ffilename); $FILESQL->setValue('filesize', $FILEINFOS["filesize"]); if ($size = @getimagesize($REX['MEDIAFOLDER'] . '/' . $FILEINFOS["filename"])) { $FILESQL->setValue('width', $size[0]); $FILESQL->setValue('height', $size[1]); } @chmod($REX['MEDIAFOLDER'] . '/' . $FILEINFOS["filename"], $REX['FILEPERM']); $updated = true; } else { $RETURN["msg"] = $I18N->msg('pool_file_upload_error'); } } else { $RETURN["msg"] = $I18N->msg('pool_file_upload_errortype'); } } $RETURN["ok"] = 0; if (!isset($RETURN["msg"])) { $RETURN["msg"] = $I18N->msg('pool_file_infos_updated'); $RETURN["filename"] = $FILEINFOS["filename"]; $RETURN["filetype"] = $FILEINFOS["filetype"]; $RETURN["file_id"] = $FILEINFOS["file_id"]; $RETURN["ok"] = 1; } $FILESQL->addGlobalUpdateFields(); $FILESQL->update(); /* $RETURN['title'] = $FILEINFOS['title']; $RETURN['type'] = $FILETYPE; $RETURN['msg'] = $message; // Aus BC gruenden hier mit int 1/0 $RETURN['ok'] = $success ? 1 : 0; $RETURN['filename'] = $NFILENAME; $RETURN['old_filename'] = $FILENAME; */ return $RETURN; }
} else { $warning = $IMOD->getError(); } } 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(); if ($UMOD->update()) { $info = $I18N->msg('module_updated') . ' | ' . $I18N->msg('articel_updated'); } else { $warning = $UMOD->getError(); } $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(); } } }
/** * @param rex_news_form $form * @param $id * @param $clang */ public static function saveOverLangValues(rex_news_form $form, $id, $clang) { global $REX; $lang = new rex_sql(); $lang->setQuery('SELECT `id` FROM `' . $REX['TABLE_PREFIX'] . 'clang` WHERE `id` != ' . $clang); for ($i = 1; $i <= $lang->getRows(); $i++) { $sql = new rex_sql(); $sql->setTable($form->getTableName()); $sql->setDebug(true); $sql->setWhere('`id` = ' . $id . ' AND `clang` = ' . $lang->getValue('id')); $sql->select('id'); $sql->setTable($form->getTableName()); $sql->setDebug(true); $sql->setWhere('`id` = ' . $id . ' AND `clang` = ' . $lang->getValue('id')); if (OOAddon::isAvailable('metainfo')) { $sql->setValues($form->getMetaValues()); } if ($sql->getRows()) { $sql->setValues(array_intersect_key($form->getValues(), array_flip($form->getOverSavedFields()))); $sql->setValue('clang', $lang->getValue('id')); $sql->setValue('id', $id); $sql->update(); } else { $sql->setValues($form->getValues()); $sql->setValue('clang', $lang->getValue('id')); $sql->setValue('id', $id); $sql->insert(); } $lang->next(); } }
if ($function == "add") { $attributes = rex_setAttributes("ctype", $ctypes, ""); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalCreateFields(); if ($TPL->insert()) { $template_id = $TPL->getLastId(); $info = $I18N->msg("template_added"); } else { $warning = $TPL->getError(); } } else { $attributes = rex_setAttributes("ctype", $ctypes, $attributes); $TPL->setWhere("id='{$template_id}'"); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalUpdateFields(); if ($TPL->update()) { $info = $I18N->msg("template_updated"); } else { $warning = $TPL->getError(); } } // werte werden direkt wieder ausgegeben $templatename = stripslashes($templatename); $content = stripslashes($content); rex_deleteDir($REX['INCLUDE_PATH'] . "/generated/templates", 0); if (isset($goon) and $goon != "") { $function = "edit"; $save = "nein"; } else { $function = ""; }
$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[]')) { // --------------------- ARTIKEL DELETE $message = rex_deleteArticle($article_id); $re_id = $thisArt->getValue("re_id"); // ----- PRIO $CL = $REX['CLANG'];
/** * Kopiert die Metadaten eines Artikels in einen anderen Artikel * * @param $from_id ArtikelId des Artikels, aus dem kopiert werden (Quell ArtikelId) * @param $to_id ArtikelId des Artikel, in den kopiert werden sollen (Ziel ArtikelId) * @param [$from_clang] ClangId des Artikels, aus dem kopiert werden soll (Quell ClangId) * @param [$to_clang] ClangId des Artikels, in den kopiert werden soll (Ziel ClangId) * @param [$params] Array von Spaltennamen, welche kopiert werden sollen */ function rex_copyMeta($from_id, $to_id, $from_clang = 0, $to_clang = 0, $params = array()) { global $REX, $REX_USER; $from_clang = (int) $from_clang; $to_clang = (int) $to_clang; $from_id = (int) $from_id; $to_id = (int) $to_id; if (!is_array($params)) { $params = array(); } if ($from_id == $to_id && $from_clang == $to_clang) { return false; } $gc = new rex_sql(); $gc->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where clang='{$from_clang}' and id='{$from_id}'"); if ($gc->getRows() == 1) { $uc = new rex_sql(); // $uc->debugsql = 1; $uc->setTable($REX['TABLE_PREFIX'] . "article"); $uc->setWhere("clang='{$to_clang}' and id='{$to_id}'"); $uc->addGlobalUpdateFields(); foreach ($params as $key => $value) { $var = $gc->getValue("{$value}"); $uc->setValue("{$value}", $var); } $uc->update(); rex_generateArticle($to_id, false); return true; } return false; }
$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"> <h2 class="rex-hl2">Modul installieren</h2> <div class="rex-addon-content"> <p> Um die XForm sinnvoll nutzen können, muß ein Modul erstellt werden, <br />mit welchem man die entsprechenden Formulare erstellen kann.
$user_id = $REX_USER->getValue('user_id'); // --------------------------------- Title rex_title($I18N->msg('profile_title'), ''); // --------------------------------- FUNCTIONS if (rex_post('upd_profile_button', 'string')) { $updateuser = new rex_sql(); $updateuser->setTable($REX['TABLE_PREFIX'] . 'user'); $updateuser->setWhere('user_id=' . $user_id); $updateuser->setValue('name', $username); if ($REX['PSWFUNC'] != '' && $userpsw != $sql->getValue($REX['TABLE_PREFIX'] . 'user.psw')) { $userpsw = call_user_func($REX['PSWFUNC'], $userpsw); } $updateuser->setValue('psw', $userpsw); $updateuser->setValue('description', $userdesc); $updateuser->addGlobalUpdateFields(); if ($updateuser->update()) { $info = $I18N->msg('user_data_updated'); } else { $warning = $updateuser->getError(); } } // ---------------------------------- ERR MSG if ($info != '') { echo rex_info($info); } if ($warning != '') { echo rex_warning($warning); } // --------------------------------- FORMS $sql = new rex_login_sql(); $sql->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'user where user_id=' . $user_id);
$func = rex_request('func', 'string'); $css = rex_request('css', 'string'); // Update if ($func == 'update') { $sqlu = new rex_sql(); $sqlu->debugsql = 0; $query = 'SELECT configuration FROM ' . $table . ' WHERE id = 1 AND ptype = 1 '; $sql = new rex_sql(); $sql->debugsql = 0; $sql->setQuery($query); if ($sql->getRows() > 0) { $sqlu->setTable($table); $sqlu->setValue('id', '1'); $sqlu->setValue('configuration', $css); $sqlu->setWhere('id = 1 AND ptype = 1'); if ($sqlu->update()) { echo rex_info($I18N->msg('tinymce_css_saved')); } else { echo rex_warning($I18N->msg('tinymce_css_not_saved')); } } else { $sqlu->setTable($table); $sqlu->setValue('id', '1'); $sqlu->setValue('name', 'css'); $sqlu->setValue('ptype', '1'); $sqlu->setValue('description', 'CSS fuer den TinyMCE'); $sqlu->setValue('configuration', $css); if ($sqlu->insert()) { echo rex_info($I18N->msg('tinymce_css_saved')); } else { echo rex_warning($I18N->msg('tinymce_css_not_saved'));
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(' SELECT `id`, `title`, `publishedAt`, `status` FROM `' . rex_asd_news_config::getTable() . '` WHERE `clang` = ' . $clang . ' ORDER BY CASE WHEN `publishedAt` = "0000-00-00 00:00:00" THEN 1 ELSE 0
echo '</fieldset> </form> </div>'; } // *************************************** EXTRA FUNCTIONS if ($PERMALL && $media_method == 'updatecat_selectedmedia') { $selectedmedia = rex_post('selectedmedia', 'array'); if ($selectedmedia[0] > 0) { foreach ($selectedmedia as $file_id) { $db = new rex_sql(); // $db->debugsql = true; $db->setTable($REX['TABLE_PREFIX'] . 'file'); $db->setWhere('file_id=' . $file_id); $db->setValue('category_id', $rex_file_category); $db->addGlobalUpdateFields(); $db->update(); $msg = $I18N->msg('pool_selectedmedia_moved'); } } else { $msg = $I18N->msg('pool_selectedmedia_error'); } } if ($PERMALL && $media_method == 'delete_selectedmedia') { $selectedmedia = rex_post("selectedmedia", "array"); if ($selectedmedia[0] > 0) { $msg = ""; foreach ($selectedmedia as $file_id) { $gf = new rex_sql(); $gf->setQuery("select * from " . $REX['TABLE_PREFIX'] . "file where file_id='{$file_id}'"); if ($gf->getRows() == 1) { $file_name = $gf->getValue("filename");
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(); } } } } }
public static function setTableField($table_name, array $table_field) { unset($table_field['id']); if ($table_name == '') { throw new Exception('table_name must be set'); } if (count($table_field) == 0) { throw new Exception('field must be a filled array'); } $fieldIdentifier = array('type_id' => $table_field['type_id'], 'type_name' => $table_field['type_name'], 'name' => $table_field['name']); $currentFields = rex_xform_manager_table::get($table_name)->getFields($fieldIdentifier); // validate specials if ($table_field['type_id'] == 'validate') { $table_field['list_hidden'] = 1; $table_field['search'] = 0; } self::createMissingFieldColumns($table_field); if (count($currentFields) > 1) { throw new Exception('more than one field found for table: ' . $table_name . ' with Fieldidentifier: ' . implode(', ', $fieldIdentifier) . ''); } elseif (count($currentFields) == 0) { // Insert $field_insert = new rex_sql(); $field_insert->debugsql = self::$debug; $field_insert->setTable(rex_xform_manager_field::table()); $field_insert->setValue('table_name', $table_name); foreach ($table_field as $field_name => $field_value) { $field_insert->setValue($field_name, $field_value); } if (!isset($table['prio'])) { $field_insert->setValue('prio', rex_xform_manager_table::get($table_name)->getMaximumPrio() + 1); } $field_insert->insert(); } else { // Update $currentField = $currentFields[0]->toArray(); foreach ($table_field as $field_name => $field_value) { $currentField[$field_name] = $field_value; } $field_update = new rex_sql(); $field_update->debugsql = self::$debug; $field_update->setTable(rex_xform_manager_field::table()); $add_where = array(); foreach ($fieldIdentifier as $field => $value) { $add_where[] = '`' . mysql_real_escape_string($field) . '`="' . mysql_real_escape_string($table_name) . '"'; } $where = 'table_name="' . mysql_real_escape_string($table_name) . '"'; if (count($add_where) > 0) { $where .= ' and (' . implode(' and ', $add_where) . ') '; } $field_update->setWhere($where); foreach ($table_field as $field_name => $field_value) { $field_update->setValue($field_name, $field_value); } $field_update->update(); } }
/** * @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(); } }
$warning = $I18N->msg('pool_file_not_found'); $subpage = ""; } } // *************************************** EXTRA FUNCTIONS if ($PERMALL && $media_method == 'updatecat_selectedmedia') { $selectedmedia = rex_post('selectedmedia', 'array'); if ($selectedmedia[0] > 0) { foreach ($selectedmedia as $file_id) { $db = new rex_sql(); // $db->debugsql = true; $db->setTable($REX['TABLE_PREFIX'] . 'file'); $db->setWhere('file_id=' . $file_id); $db->setValue('category_id', $rex_file_category); $db->addGlobalUpdateFields(); if ($db->update()) { $info = $I18N->msg('pool_selectedmedia_moved'); } else { $warning = $I18N->msg('pool_selectedmedia_error'); } } } else { $warning = $I18N->msg('pool_selectedmedia_error'); } } if ($PERMALL && $media_method == 'delete_selectedmedia') { $selectedmedia = rex_post("selectedmedia", "array"); if (count($selectedmedia) > 0) { $warning = array(); $info = array(); foreach ($selectedmedia as $file_id) {
/** * @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 deleteMessage($message_id) { // reply $r_sql = new rex_sql(); if ($this->debug) { $r_sql->debugsql = 1; } $r_sql->setQuery("select * from rex_com_board where message_id='{$message_id}' and board_id='" . $this->boardname . "'"); if ($r_sql->getRows() == 1) { if ($r_sql->getValue("re_message_id") != 0) { // reply $ur_sql = new rex_sql(); if ($this->debug) { $ur_sql->debugsql = 1; } $ur_sql->setTable("rex_com_board"); $ur_sql->setWhere("message_id='{$message_id}'"); $ur_sql->setValue("status", 0); $ur_sql->update(); $message_id = $r_sql->getValue("re_message_id"); // update topic $u_sql = new rex_sql(); if ($this->debug) { $u_sql->debugsql = 1; } $u_sql->setQuery("select * from rex_com_board where re_message_id='{$message_id}' and status='1'"); $u_sql->setTable("rex_com_board"); $u_sql->setWhere("message_id='{$message_id}'"); $u_sql->setValue("replies", $u_sql->getRows()); $u_sql->update(); $this->msg["bb_msg_id"] = $r_sql->getValue("re_message_id"); $return = $this->showMessage(); } else { // topic $u_sql = new rex_sql(); if ($this->debug) { $u_sql->debugsql = 1; } $u_sql->setTable("rex_com_board"); $u_sql->setWhere("message_id='{$message_id}' or re_message_id='{$message_id}'"); $u_sql->setValue("status", 0); $u_sql->update(); $this->errmsg = $this->text[250]; $return = $this->showMessages(); } } else { $this->errmsg = $this->text[260]; $return = $this->showMessages(); } return $return; }