Add backend site management for collective topics and topics
- Introduced new backend site management features including the ability to accept, unaccept, save, edit, and display topics and collective topics. - Added new views for editing and listing collective topics and topics. - Implemented necessary backend logic in the `BackendSites` and `factory\BackendSites` classes to handle CRUD operations for topics and collective topics. - Updated the layout to include links for accessing the new backend features based on user permissions.
This commit is contained in:
82
autoload/controls/class.BackendSites.php
Normal file
82
autoload/controls/class.BackendSites.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?
|
||||
namespace controls;
|
||||
class BackendSites
|
||||
{
|
||||
static public function topic_accept()
|
||||
{
|
||||
if ( \factory\BackendSites::topic_accept( \S::get( 'id' ) ) )
|
||||
{
|
||||
\S::alert( 'Temat został zaakceptowany' );
|
||||
header( 'Location: /backend_sites/topics/' );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
static public function topic_unaccept()
|
||||
{
|
||||
if ( \factory\BackendSites::topic_unaccept( \S::get( 'id' ) ) )
|
||||
{
|
||||
\S::alert( 'Temat został odrzucony' );
|
||||
header( 'Location: /backend_sites/topics/' );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
static public function topic_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania klienta wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
$values = \S::json_to_array( \S::get( 'values' ) );
|
||||
|
||||
$id = \factory\BackendSites::topic_save(
|
||||
(int)$values[ 'id' ], $values[ 'strona' ], $values[ 'kategoria' ], $values[ 'kategoria_id' ], $values[ 'temat' ], $values[ 'data_publikacji' ], $values[ 'opublikowany' ], $values[ 'zaakceptowany' ]
|
||||
);
|
||||
|
||||
if ( $id )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Projekt został zapisany.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function topic_edit()
|
||||
{
|
||||
return \Tpl::view( 'backend_sites/topic_edit', [
|
||||
'topic' => \factory\BackendSites::topic( (int)\S::get( 'id' ) )
|
||||
] );
|
||||
}
|
||||
|
||||
static public function topics()
|
||||
{
|
||||
return \Tpl::view( 'backend_sites/topics' );
|
||||
}
|
||||
|
||||
static public function collective_topics()
|
||||
{
|
||||
return \Tpl::view( 'backend_sites/collective_topics' );
|
||||
}
|
||||
|
||||
static public function collective_topic_edit()
|
||||
{
|
||||
return \Tpl::view( 'backend_sites/collective_topic_edit',[
|
||||
'collective_topic' => \factory\BackendSites::collective_topic( \S::get( 'id' ) ),
|
||||
] );
|
||||
}
|
||||
|
||||
static public function collective_topic_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania klienta wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
$values = \S::json_to_array( \S::get( 'values' ) );
|
||||
|
||||
$id = \factory\BackendSites::collective_topic_save(
|
||||
(int)$values[ 'id' ], $values[ 'strona' ], $values[ 'kategoria' ], $values[ 'kategoria_id' ], $values[ 'temat_ogolny' ], $values[ 'data_przetworzenia' ], $values[ 'przetworzony' ]
|
||||
);
|
||||
|
||||
if ( $id )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Projekt został zapisany.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ class Users
|
||||
$permissions[ 1 ][ 'wiki' ] = true;
|
||||
$permissions[ 1 ][ 'crm' ] = true;
|
||||
$permissions[ 1 ][ 'work_time' ] = true;
|
||||
$permissions[ 1 ][ 'zaplecze' ] = true;
|
||||
// Pyziak Grzegorz
|
||||
$permissions[ 3 ][ 'tasks' ] = true;
|
||||
$permissions[ 3 ][ 'projects' ] = true;
|
||||
@@ -20,6 +21,7 @@ class Users
|
||||
$permissions[ 3 ][ 'wiki' ] = true;
|
||||
$permissions[ 3 ][ 'crm' ] = true;
|
||||
$permissions[ 3 ][ 'work_time' ] = true;
|
||||
$permissions[ 3 ][ 'zaplecze' ] = true;
|
||||
// Roman Pyrih
|
||||
$permissions[ 5 ][ 'tasks' ] = true;
|
||||
$permissions[ 5 ][ 'projects' ] = false;
|
||||
|
||||
84
autoload/factory/class.BackendSites.php
Normal file
84
autoload/factory/class.BackendSites.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?
|
||||
namespace factory;
|
||||
class BackendSites
|
||||
{
|
||||
static public function topic_unaccept( $id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> update( 'zaplecze_tematy', [ 'zaakceptowany' => 0 ], [ 'id' => $id ] );
|
||||
}
|
||||
|
||||
static public function topic_accept( $id)
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> update( 'zaplecze_tematy', [ 'zaakceptowany' => 1 ], [ 'id' => $id ] );
|
||||
}
|
||||
|
||||
static public function topic_save( $id, $strona, $kategoria, $kategoria_id, $temat, $data_publikacji, $opublikowany, $zaakceptowany )
|
||||
{
|
||||
global $mdb;
|
||||
if ( !$id )
|
||||
{
|
||||
return $mdb -> insert( 'zaplecze_tematy', [
|
||||
'strona' => $strona,
|
||||
'kategoria' => $kategoria,
|
||||
'kategoria_id' => $kategoria_id,
|
||||
'temat' => $temat,
|
||||
'data_publikacji' => $data_publikacji,
|
||||
'opublikowany' => $opublikowany == 'on' ? 1 : 0,
|
||||
'zaakceptowany' => $zaakceptowany == 'on' ? 1 : 0,
|
||||
] );
|
||||
}
|
||||
else
|
||||
{
|
||||
return $mdb -> update( 'zaplecze_tematy', [
|
||||
'strona' => $strona,
|
||||
'kategoria' => $kategoria,
|
||||
'kategoria_id' => $kategoria_id,
|
||||
'temat' => $temat,
|
||||
'data_publikacji' => $data_publikacji,
|
||||
'opublikowany' => $opublikowany == 'on' ? 1 : 0,
|
||||
'zaakceptowany' => $zaakceptowany == 'on' ? 1 : 0,
|
||||
], [ 'id' => $id ] );
|
||||
}
|
||||
}
|
||||
|
||||
static public function topic( $id = 0 )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'zaplecze_tematy', '*', [ 'id' => $id ] );
|
||||
}
|
||||
|
||||
static public function collective_topic( $id = 0 )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'zaplecze_tematy_zbiorcze', '*', [ 'id' => $id ] );
|
||||
}
|
||||
|
||||
static public function collective_topic_save( $id, $strona, $kategoria, $kategoria_id, $temat_ogolny, $data_przetworzenia, $przetworzony )
|
||||
{
|
||||
global $mdb;
|
||||
if ( !$id )
|
||||
{
|
||||
return $mdb -> insert( 'zaplecze_tematy_zbiorcze', [
|
||||
'strona' => $strona,
|
||||
'kategoria' => $kategoria,
|
||||
'kategoria_id' => $kategoria_id,
|
||||
'temat_ogolny' => $temat_ogolny,
|
||||
'data_przetworzenia' => $data_przetworzenia,
|
||||
'przetworzony' => $przetworzony == 'on' ? 1 : 0,
|
||||
] );
|
||||
}
|
||||
else
|
||||
{
|
||||
return $mdb -> update( 'zaplecze_tematy_zbiorcze', [
|
||||
'strona' => $strona,
|
||||
'kategoria' => $kategoria,
|
||||
'kategoria_id' => $kategoria_id,
|
||||
'temat_ogolny' => $temat_ogolny,
|
||||
'data_przetworzenia' => $data_przetworzenia,
|
||||
'przetworzony' => $przetworzony == 'on' ? 1 : 0,
|
||||
], [ 'id' => $id ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user