65 lines
2.0 KiB
PHP
65 lines
2.0 KiB
PHP
<?
|
|
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['author_position'], $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' );
|
|
}
|
|
} |