bludit/bl-kernel/admin/controllers/content.php

59 lines
2.0 KiB
PHP
Raw Normal View History

2015-11-27 17:03:42 +01:00
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// ============================================================================
2019-05-13 18:26:35 +02:00
checkRole(array('admin', 'editor', 'author'));
2018-05-20 21:48:43 +02:00
2015-11-27 17:03:42 +01:00
// ============================================================================
// Functions
// ============================================================================
// Returns the content belongs to the current user if the user has the role Editor
function filterContentOwner($list) {
global $login;
global $pages;
$tmp = array();
foreach ($list as $pageKey) {
if ($pages->db[$pageKey]['username']==$login->username()) {
array_push($tmp, $pageKey);
}
}
return $tmp;
}
2015-11-27 17:03:42 +01:00
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main after POST
// ============================================================================
$published = $pages->getList($url->pageNumber(), ITEMS_PER_PAGE_ADMIN);
$drafts = $pages->getDraftDB(true);
$scheduled = $pages->getScheduledDB(true);
$static = $pages->getStaticDB(true);
$sticky = $pages->getStickyDB(true);
2019-05-13 18:26:35 +02:00
// If the user is an Author filter the content he/she can edit
if (checkRole(array('author'), false)) {
$published = filterContentOwner($published);
$drafts = filterContentOwner($drafts);
$scheduled = filterContentOwner($scheduled);
$static = filterContentOwner($static);
$sticky = filterContentOwner($sticky);
}
// Check if out of range the pageNumber
if (empty($published) && $url->pageNumber()>1) {
2017-10-02 22:42:18 +02:00
Redirect::page('content');
}
// Title of the page
$layout['title'] .= ' - '.$L->g('Manage content');