Пример #1
0
function action_edit()
{
    global $link;
    if (!isset($_GET['id'])) {
        header("Location: index.php");
    }
    $id = (int) $_GET['id'];
    if (!empty($_POST) && $id > 0) {
        articles_edit($link, $id, $_POST['title'], $_POST['date'], $_POST['content']);
        header("Location:index.php");
    }
    $article = articles_get($link, $id);
    require "../views/article_admin.php";
}
Пример #2
0
 public function action_edit()
 {
     $id = (int) $_GET['id'];
     if (!$id) {
         die("Не верный id");
     }
     $article_edit = articles_get($id);
     if (isset($_POST['submit'])) {
         articles_edit($_POST['id'], $_POST['name'], $_POST['content']);
         die(header('Location: index.php'));
     }
     $this->title .= '::Редактирование';
     $this->content = $this->Template('v/v_edit.php', array('article_edit' => $article_edit));
 }
Пример #3
0
function exec_articles_edit_args($id_article, $id_rubrique, $lier_trad, $id_version, $new)
{
	if (!$new AND (!autoriser('voir', 'article', $id_article) OR !autoriser('modifier','article', $id_article))) {
		include_spip('inc/minipres');
		echo minipres(_T('info_acces_interdit'));
	} else {
		$article_select = charger_fonction('article_select','inc');
		$row = $article_select($id_article ? $id_article : $new, $id_rubrique,  $lier_trad, $id_version);
		$id_rubrique = $row ? $row['id_rubrique'] : false;

		if (!$id_rubrique OR ($new AND !autoriser('creerarticledans','rubrique',$id_rubrique))) {
			include_spip('inc/minipres');
			echo minipres(_T('public:aucun_article'));
		} else articles_edit($id_article, $id_rubrique, $lier_trad, $id_version, $new, 'articles_edit_config', $row);
	}
}
Пример #4
0
    $action = "";
}
if ($action == "add") {
    if (!empty($_POST)) {
        articles_new($link, $_POST['title'], $_POST['date'], $_POST['content']);
        header("Location: index.php");
    }
    include "../views/article_admin.php";
} else {
    if ($action == "edit") {
        if (!isset($_GET['id'])) {
            header("Location: index.php");
        }
        $id = (int) $_GET['id'];
        if (!empty($_POST) && $id > 0) {
            articles_edit($link, $id, $_POST['title'], $_POST['date'], $_POST['content']);
            header("Location: index.php");
        }
        $article = articles_get($link, $id);
        include "../views/article_admin.php";
    } else {
        if ($action == 'delete') {
            $id = $_GET['id'];
            $article = articles_delete($link, $id);
            header("Location: index.php");
        } else {
            $articles = articles_all($link);
            include "../views/articles_admin.php";
        }
    }
}
Пример #5
0
function articles_save($id = false)
{
    global $_CLASS;
    if ($id) {
        $result = $_CLASS['core_db']->query('SELECT articles_id FROM ' . ARTICLES_TABLE . ' WHERE articles_id = ' . $id);
        $articles = $_CLASS['core_db']->fetch_row_assoc($result);
        $_CLASS['core_db']->free_result($result);
        if (!$articles) {
            redirect(generate_link('articles', array('admin' => true)));
        }
        // need to validate data with the db type
        articles_get_data($data, $error);
        if ($error) {
            return articles_edit($id, $data, $error);
        }
        $sql = 'UPDATE ' . ARTICLES_TABLE . ' SET ' . $_CLASS['core_db']->sql_build_array('UPDATE', $data) . '  WHERE articles_id = ' . $id;
        $_CLASS['core_db']->query($sql);
    } else {
        articles_get_data($data, $error);
        if ($error) {
            return articles_edit(false, $data, $error);
        }
        $data['articles_order'] = (int) 0;
        $data['articles_posted'] = (int) $_CLASS['core_user']->time;
        $data['articles_type'] = 1;
        $data['poster_id'] = $_CLASS['core_user']->data['user_id'];
        $data['poster_ip'] = $_CLASS['core_user']->ip;
        $data['poster_name'] = $_CLASS['core_user']->data['username'];
        $_CLASS['core_db']->transaction();
        $_CLASS['core_db']->query('INSERT INTO ' . ARTICLES_TABLE . ' ' . $_CLASS['core_db']->sql_build_array('INSERT', $data));
        $_CLASS['core_db']->query('UPDATE ' . ARTICLES_TABLE . ' SET articles_order = articles_order+1 WHERE articles_type=' . $data['articles_type']);
        $_CLASS['core_db']->transaction('commit');
    }
    $_CLASS['core_display']->meta_refresh('3', generate_link('articles', array('admin' => true)));
    trigger_error(sprintf($_CLASS['core_user']->get_lang('SAVED'), generate_link('articles', array('admin' => true))));
}
Пример #6
0
<?php

require_once 'startup.php';
require_once 'model.php';
//подключаемся к бд
startup();
// Определяем переменные для шаблона
$id_article = $_GET['id'];
$error = false;
$article = articles_get($id_article);
$title = $article['title'];
$content = $article['content'];
// Обработка отправки формы
if (!empty($_POST) && isset($_POST['title']) && isset($_POST['content'])) {
    // успешно данные добавлены, редирект
    if (articles_edit($id_article, $_POST['title'], $_POST['content'])) {
        die(header('Location: editor.php'));
    }
    $title = $_POST['title'];
    $content = $_POST['content'];
    $error = true;
}
// кодировку
header('Content-type: text/html; charset=utf-8');
// вывод в шаблон
include 'theme/edit.php';
Пример #7
0
//Добавление статьи
if ($action == "add") {
    if (!empty($_POST)) {
        $id_art = articles_new($link, $_POST['title'], $_POST['date'], $_POST['content'], $_GET['id_category']);
    }
    $id_category = (int) $_GET['id_category'];
    show_articles_list($link, $dir, $id_category);
} else {
    if ($action == "edit") {
        if (!isset($_GET['id'])) {
            $articles = articles_all($link);
            include $dir . "views/articles_admin.php";
        } else {
            $id = (int) $_GET['id'];
            if (!empty($_POST) && $id > 0) {
                articles_edit($link, $id, $_POST['title']);
                $articles = articles_get($link, $id);
                header("Location: articles.php?id_category=" . $articles['categories_id']);
            }
        }
    } else {
        if ($action == "edit-form") {
            $id_article = (int) $_GET['id'];
            $articles = articles_get($link, $id_article);
            $querystr = "action=edit&id=" . $id_article;
            $title_icon = '<span class="icon-bookmark banners"></span>';
            $title_form = 'Редактирование статьи:';
            require_once "../views/header.php";
            include $dir . "views/article_admin.php";
            require_once "../views/footer.php";
        } else {