Add author management functionality and update routing rules
- Updated .htaccess rules to allow trailing slashes for specific routes. - Introduced a new .gitignore file to exclude the cache directory. - Created project configuration file for Serena with language and tool settings. - Implemented Authors class for managing author data, including methods for saving, deleting, and editing authors. - Added factory class for Authors to handle database interactions related to authors. - Developed Article class to manage article data and interactions, including fetching articles and updating views. - Created Page class with a placeholder method for sorting pages. - Added front factory class for fetching author details with caching.
This commit is contained in:
65
autoload/admin/controls/class.Authors.php
Normal file
65
autoload/admin/controls/class.Authors.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?
|
||||
namespace admin\controls;
|
||||
class Authors
|
||||
{
|
||||
// usunięcie autora
|
||||
static public function delete()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
|
||||
return \S::alert( 'Nie masz uprawnień' );
|
||||
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas usuwania autora wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = \S::json_to_array( \S::get( 'values' ) );
|
||||
|
||||
if ( \admin\factory\Authors::delete_author( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Autor został usunięty.' );
|
||||
|
||||
header( 'Location: /admin/authors/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// zapis autora
|
||||
static public function save()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
|
||||
return \S::alert( 'Nie masz uprawnień' );
|
||||
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania autora wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = \S::json_to_array( \S::get( 'values' ) );
|
||||
|
||||
if ( $author_id = \admin\factory\Authors::save_author( $values['id'], $values['author'], $values['image'], $values['description'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Autor został zapisany.', 'id' => $author_id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// edycja autora
|
||||
static public function edit()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
|
||||
return \S::alert( 'Nie masz uprawnień' );
|
||||
|
||||
return \Tpl::view( 'authors/author-edit', [
|
||||
'author' => \admin\factory\Authors::get_single_author( \S::get( 'id' ) ),
|
||||
'languages' => \admin\factory\Languages::languages_list()
|
||||
] );
|
||||
}
|
||||
|
||||
//autorzy artykułów
|
||||
static public function view_list()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
|
||||
return \S::alert( 'Nie masz uprawnień' );
|
||||
|
||||
return \Tpl::view( 'authors/view-list' );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user