$iloc = null; $newpoast = 0; if (isset($_POST['id'])) { $post = $db->selectObject('weblog_post', 'id=' . intval($_POST['id'])); $loc = unserialize($post->location_data); $iloc = exponent_core_makeLocation($loc->mod, $loc->src, $post->id); } else { $newpost = 1; } if ($post != null && exponent_permissions_check('edit', $loc) || $post == null && exponent_permissions_check('post', $loc) || $post != null && exponent_permissions_check('edit', $iloc)) { // Need to be able to update the posted date if switching from draft to non-draft. $was_draft = 0; if ($post) { $was_draft = $post->is_draft; } $post = weblog_post::update($_POST, $post); $post->location_data = serialize($loc); if (isset($post->id)) { if ($was_draft && $post->is_draft == 0) { // No longer a draft. $post->posted = time(); } else { $post->editor = $user->id; $post->edited = time(); } $db->updateObject($post, 'weblog_post'); } else { if ($newpost < 1) { if ($db->countObjects('weblog_post', "internal_name='" . $post->internal_name . "'")) { $_POST['_formError'] = 'That Internal Name is already in use. Please choose another.'; unset($_POST['internal_name']);
# # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } $post = null; $iloc = null; if (isset($_GET['id'])) { $post = $db->selectObject('weblog_post', 'id=' . intval($_GET['id'])); $loc = unserialize($post->location_data); $iloc = exponent_core_makeLocation($loc->mod, $loc->src, $post->id); } if ($post == null && exponent_permissions_check('post', $loc) || $post != null && exponent_permissions_check('edit', $loc) || $post != null && exponent_permissions_check('edit', $iloc)) { $form = weblog_post::form($post); $form->location($loc); $form->meta('action', 'post_save'); $template = new template('weblogmodule', '_form_postEdit', $loc); $template->assign('form_html', $form->toHTML()); $template->assign('is_edit', isset($_GET['id']) ? 1 : 0); $template->output(); } else { echo SITE_403_HTML; }