예제 #1
0
 function update($file_id, $editor_id, $title = false, $abstract = false, $category_id = false, $content = false)
 {
     // MeinBlog::log("update($file_id,$editor_id,$title=false,$abstract=false,$category_id=false,$content=false)");
     if (empty($file_id) || empty($editor_id)) {
         return false;
     }
     $this->pdo->beginTransaction();
     try {
         if ($content !== false) {
             $afx = MBFileContent::update($file_id, $content, $editor_id);
             if ($afx !== 1) {
                 throw new Exception("Error in modifying file content.", 1);
             }
         }
         $sql_set = " update_time=NOW(), main_editor_id = " . $this->pdo->quote($editor_id, PDO::PARAM_INT);
         if ($title !== false) {
             $sql_set .= ', title = ' . $this->pdo->quote($title);
         }
         if ($abstract !== false) {
             if ($abstract === null) {
                 $sql_set .= ', abstract = NULL ';
             } else {
                 $sql_set .= ', abstract = ' . $this->pdo->quote($abstract);
             }
         }
         if ($category_id !== false) {
             $sql_set .= ', category_id = ' . $this->pdo->quote($category_id, PDO::PARAM_INT);
         }
         $sql = "UPDATE mb_file_header SET {$sql_set} WHERE file_id=" . $this->pdo->quote($file_id, PDO::PARAM_INT);
         $afx = $this->pdo->exec($sql);
         if ($afx !== 1) {
             throw new Exception("Error in modifying file header.", 1);
         }
         $this->pdo->commit();
         return true;
     } catch (Exception $e) {
         $this->pdo->rollBack();
         MeinBlog::log($e->getMessage());
     }
     return false;
 }
예제 #2
0
파일: FileEdit.php 프로젝트: sinri/MeinBlog
<?php

require_once __DIR__ . '/library/MeinBlog.php';
// Start or resume one session
$sessionAgent = MeinBlogSession::sharedInstance();
$user_id = $sessionAgent->getUserId();
$user_info = $sessionAgent->getUserInfo();
$file_id = "";
$title = "";
$content = "";
$abstract = '';
$category = 'new';
$userAgent = new MBUser();
$fileAgent = new MBFileHeader();
$categoryAgent = new MBCategory();
$contentAgent = new MBFileContent();
$message = '';
if (empty($user_id)) {
    $user_id = null;
    $message = "User Session Error";
} else {
    $file_id = MeinBlog::getRequest('file_id');
    if ('edit' == MeinBlog::getRequest('act')) {
        $title = MeinBlog::getRequest('title');
        $content = MeinBlog::getRequest('content');
        $category = MeinBlog::getRequest('category');
        $abstract = MeinBlog::getRequest('abstract');
        if ($category == 'new') {
            $new_category = MeinBlog::getRequest('new_category');
            if (empty($new_category)) {
                $message .= "Please give new category name.";