function do_save() {
	global $linkres, $dblang;

	$linkres->category=$_POST['category'];
	if (!empty($_POST['url'])) {
		$linkres->url = trim($_POST['url']);
	}
	$linkres->title = stripslashes(clean_text($_POST['title']));
	$linkres->content = stripslashes(clean_text($_POST['bodytext']));
	$linkres->tags = tags_normalize_string(stripslashes(clean_text($_POST['tags'])));
	// change the status
	if ($linkres->status != 'published' && ($_POST['status'] == 'queued' || $_POST['status'] == 'discard')) {
		$linkres->status = $_POST['status'];
	}
	if (!link_edit_errors($linkres)) {
		$linkres->store();
		tags_insert_string($linkres->id, $dblang, $linkres->tags, $linkres->date);
		echo '<div class="form-error-submit">&nbsp;&nbsp;'._("noticia actualizada").'</div>'."\n";
	} else {
		$linkres->read();
	}

	echo '<div class="formnotice">'."\n";
	$linkres->print_summary('preview');
	echo '</div>'."\n";

	echo '<form id="genericform" method="GET" action="story.php" >';
	echo '<input type="hidden" name="id" value="'.$linkres->id.'" />'."\n";
	echo '<input class="genericsubmit" type="button" onclick="window.history.go(-1)" value="'._('&#171; modificar').'">&nbsp;&nbsp;'."\n";;
	echo '<input class="genericsubmit" type="submit" value="'._('ir a la noticia').'" />'."\n";
	echo '</form>'. "\n";

}
示例#2
0
文件: editlink.php 项目: rasomu/chuza
function do_save() {
	global $linkres, $dblang, $current_user;

	$linkres->read_content_type_buttons($_POST['type']);

	$linkres->category=intval($_POST['category']);
	if ($current_user->admin) {
		if (!empty($_POST['url'])) {
			$linkres->url = clean_input_url($_POST['url']);
		}
		if ($_POST['thumb_delete']) {
			$linkres->delete_thumb();
		}
		if ($_POST['thumb_get']) {
			$linkres->get_thumb();
		}
	}
	$linkres->title = clean_text($_POST['title'], 40);
	$linkres->content = clean_text_with_tags($_POST['bodytext']);
	$linkres->tags = tags_normalize_string($_POST['tags']);
	// change the status
	if ($_POST['status'] != $linkres->status
		&& ($_POST['status'] == 'autodiscard' || $current_user->admin)
		&& preg_match('/^[a-z]{4,}$/', $_POST['status'])
		&& ( ! $linkres->is_discarded() || $current_user->admin)) {
		if (preg_match('/discard|abuse|duplicated|autodiscard/', $_POST['status'])) {
			// Insert a log entry if the link has been manually discarded
			$insert_discard_log = true;
		}
		$linkres->status = $_POST['status'];
	}

  // EVENTS
  $d = $_POST["datepicker1"];
  $linkres->start_date = substr($d,3,2).'-'.substr($d, 0, 2).'-'.substr($d,6,4);

  $d = $_POST["datepicker2"];
  $linkres->end_date = substr($d,3,2).'-'.substr($d, 0, 2).'-'.substr($d,6,4);


	if (!link_edit_errors($linkres)) {
		if (empty($linkres->uri)) $linkres->get_uri();
		$linkres->store();
		tags_insert_string($linkres->id, $dblang, $linkres->tags, $linkres->date);

		// Insert edit log/event if the link it's newer than 15 days
		if ($globals['now'] - $linkres->date < 86400*15) {
			require_once(mnminclude.'log.php');
			if ($insert_discard_log) {
				// Insert always a link and discard event if the status has been changed to discard
				log_insert('link_discard', $linkres->id, $current_user->user_id);
				if ($linkres->author == $current_user->user_id) { // Don't save edit log if it's discarded by an admin
					log_insert('link_edit', $linkres->id, $current_user->user_id);
				}
			} elseif ($linkres->votes > 0) {
				log_conditional_insert('link_edit', $linkres->id, $current_user->user_id, 60);
			}
		}

		echo '<div class="form-error-submit">&nbsp;&nbsp;'._("noticia actualizada").'</div>'."\n";
	}

	$linkres->read();

	echo '<div class="formnotice">'."\n";
	$linkres->print_summary('preview');
	echo '</div>'."\n";

	echo '<form class="note" method="GET" action="story.php" >';
	echo '<input type="hidden" name="id" value="'.$linkres->id.'" />'."\n";
	echo '<input class="button" type="button" onclick="window.history.go(-1)" value="&#171; '._('modificar').'">&nbsp;&nbsp;'."\n";;
	echo '<input class="button" type="submit" value="'._('ir a la noticia').'" />'."\n";
	echo '</form>'. "\n";
}
示例#3
0
function do_save()
{
    global $linkres, $dblang, $current_user;
    $linkres->read_content_type_buttons($_POST['type']);
    $linkres->category = intval($_POST['category']);
    if (!empty($_POST['url']) && ($current_user->user_level == 'admin' || $current_user->user_level == 'god')) {
        $linkres->url = clean_input_url($_POST['url']);
    }
    $linkres->title = clean_text($_POST['title'], 40);
    $linkres->content = clean_text($_POST['bodytext']);
    $linkres->tags = tags_normalize_string($_POST['tags']);
    // change the status
    if (($current_user->user_level == 'god' || $linkres->status != 'published') && ($_POST['status'] == 'queued' || $_POST['status'] == 'discard' || $_POST['status'] == 'abuse' || $_POST['status'] == 'autodiscard')) {
        if (!$linkres->is_discarded() && ($_POST['status'] == 'discard' || $_POST['status'] == 'abuse' || $_POST['status'] == 'autodiscard')) {
            // Insert a log entry if the link has been manually discarded
            $insert_discard_log = true;
        }
        $linkres->status = $_POST['status'];
    }
    if (!link_edit_errors($linkres)) {
        if (empty($linkres->uri)) {
            $linkres->get_uri();
        }
        $linkres->store();
        tags_insert_string($linkres->id, $dblang, $linkres->tags, $linkres->date);
        // Insert edit log/event
        require_once mnminclude . 'log.php';
        if ($insert_discard_log) {
            // Insert always a link and discard event if the status has been changed to discard
            log_insert('link_discard', $linkres->id, $current_user->user_id);
            log_insert('link_edit', $linkres->id, $current_user->user_id);
        } else {
            log_conditional_insert('link_edit', $linkres->id, $current_user->user_id, 60);
        }
        echo '<div class="form-error-submit">&nbsp;&nbsp;' . _("noticia actualizada") . '</div>' . "\n";
    }
    $linkres->read();
    echo '<div class="formnotice">' . "\n";
    $linkres->print_summary('preview');
    echo '</div>' . "\n";
    echo '<form id="genericform" method="GET" action="story.php" >';
    echo '<input type="hidden" name="id" value="' . $linkres->id . '" />' . "\n";
    echo '<input class="genericsubmit" type="button" onclick="window.history.go(-1)" value="' . _('&#171; modificar') . '">&nbsp;&nbsp;' . "\n";
    echo '<input class="genericsubmit" type="submit" value="' . _('ir a la noticia') . '" />' . "\n";
    echo '</form>' . "\n";
}
示例#4
0
function do_save($link)
{
    global $dblang, $globals, $current_user, $db;
    $link->status = $link->sub_status;
    $site_properties = SitesMgr::get_extended_properties();
    // Store previous value for the log
    $link_old = new stdClass();
    $link_old->url = $link->url;
    $link_old->title = $link->title;
    $link_old->content = $link->content;
    $link_old->tags = $link->tags;
    $link_old->status = $link->status;
    $link_old->sub_id = $link->sub_id;
    $link->read_content_type_buttons($_POST['type']);
    $link->sub_id = intval($_POST['sub_id']);
    if ($link->sub_id != $link_old->sub_id) {
        $link->sub_changed = true;
        // To force to delete old statuses with another origin
    }
    if ($current_user->admin || $current_user->user_level == 'blogger' || SitesMgr::is_owner()) {
        if (!empty($_POST['url'])) {
            $link->url = clean_input_url($_POST['url']);
        }
        if ($_POST['thumb_delete']) {
            $link->delete_thumb();
        }
        if ($_POST['uri_update']) {
            $link->get_uri();
        }
        if ($_POST['thumb_get']) {
            $link->get_thumb();
        } elseif (!empty($_POST['thumb_url'])) {
            $url = clean_input_url($_POST['thumb_url']);
            $link->get_thumb(false, $url);
        }
    }
    $link->title = $_POST['title'];
    $link->content = $_POST['bodytext'];
    $link->tags = tags_normalize_string($_POST['tags']);
    $errors = link_edit_errors($link);
    // change the status
    if ($_POST['status'] != $link->status && ($_POST['status'] == 'autodiscard' || $current_user->admin || SitesMgr::is_owner()) && preg_match('/^[a-z]{4,}$/', $_POST['status']) && (!$link->is_discarded() || $current_user->admin || SitesMgr::is_owner())) {
        if (preg_match('/discard|abuse|duplicated|autodiscard/', $_POST['status'])) {
            // Insert a log entry if the link has been manually discarded
            $insert_discard_log = true;
        }
        $link->status = $_POST['status'];
    }
    if (!$errors) {
        if (empty($link->uri)) {
            $link->get_uri();
        }
        // Check the blog_id
        $blog_id = Blog::find_blog($link->url, $link->id);
        if ($blog_id > 0 && $blog_id != $link->blog) {
            $link->blog = $blog_id;
        }
        $db->transaction();
        $link->store();
        // Disabled table tags
        // tags_insert_string($link->id, $dblang, $link->tags, $link->date);
        // Insert edit log/event if the link it's newer than 15 days
        if ($globals['now'] - $link->date < 86400 * 15) {
            if ($insert_discard_log) {
                // Insert always a link and discard event if the status has been changed to discard
                Log::insert('link_discard', $link->id, $current_user->user_id);
                if ($link->author == $current_user->user_id) {
                    // Don't save edit log if it's discarded by an admin
                    Log::insert('link_edit', $link->id, $current_user->user_id);
                }
            } elseif ($link->votes > 0) {
                Log::conditional_insert('link_edit', $link->id, $current_user->user_id, 60, serialize($link_old));
            }
        }
        // Check this one is a draft, allows the user to save and send it to the queue
        if ($link->votes == 0 && $link->status != 'queued' && $link->author == $current_user->user_id) {
            $link->enqueue();
        }
        $db->commit();
    }
    $link->read();
    $link->permalink = $link->get_permalink();
    Haanga::Load('link/edit_result.html', compact('link', 'errors'));
}