2015-05-05 01:00:01 +00:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2015-08-02 21:49:12 -03:00
|
|
|
// ============================================================================
|
|
|
|
// Check role
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-07-14 01:41:32 -03:00
|
|
|
// ============================================================================
|
|
|
|
// Functions
|
|
|
|
// ============================================================================
|
2015-05-05 01:00:01 +00:00
|
|
|
function addPost($args)
|
|
|
|
{
|
|
|
|
global $dbPosts;
|
2015-07-20 00:14:12 -03:00
|
|
|
global $Language;
|
2015-08-02 21:49:12 -03:00
|
|
|
|
2016-01-07 20:43:09 -03:00
|
|
|
// Add the page, if the $key is FALSE the creation of the post failure.
|
|
|
|
$key = $dbPosts->add($args);
|
|
|
|
|
2017-03-26 20:51:32 +02:00
|
|
|
if($key) {
|
2015-08-30 22:18:06 -03:00
|
|
|
// Reindex tags, this function is in 70.posts.php
|
|
|
|
reIndexTagsPosts();
|
2015-08-29 02:02:09 -03:00
|
|
|
|
2017-03-26 20:51:32 +02:00
|
|
|
// Re index categories
|
|
|
|
reIndexCategoriesPosts();
|
|
|
|
|
|
|
|
// Call the plugins after post creation
|
2016-01-07 20:43:09 -03:00
|
|
|
Theme::plugins('afterPostCreate');
|
|
|
|
|
|
|
|
// Alert for the user
|
2015-07-22 00:15:02 -03:00
|
|
|
Alert::set($Language->g('Post added successfully'));
|
2015-05-05 01:00:01 +00:00
|
|
|
Redirect::page('admin', 'manage-posts');
|
|
|
|
}
|
2017-03-26 20:51:32 +02:00
|
|
|
else {
|
2015-07-22 00:15:02 -03:00
|
|
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the post.');
|
2017-03-26 20:51:32 +02:00
|
|
|
Log::set(__METHOD__.LOG_SEP.'Cleaning database...');
|
|
|
|
$dbPosts->delete($key);
|
2015-05-05 01:00:01 +00:00
|
|
|
}
|
2015-08-30 22:18:06 -03:00
|
|
|
|
|
|
|
return false;
|
2015-05-05 01:00:01 +00:00
|
|
|
}
|
|
|
|
|
2015-08-02 21:49:12 -03:00
|
|
|
// ============================================================================
|
|
|
|
// Main before POST
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-07-14 01:41:32 -03:00
|
|
|
// ============================================================================
|
|
|
|
// POST Method
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-05-05 01:00:01 +00:00
|
|
|
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|
|
|
{
|
|
|
|
addPost($_POST);
|
2015-05-30 22:06:55 -03:00
|
|
|
}
|
2015-08-02 21:49:12 -03:00
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Main after POST
|
2015-11-28 11:47:03 -03:00
|
|
|
// ============================================================================
|