Skip to content

Commit

Permalink
Pico Dashboard Activity Overview
Browse files Browse the repository at this point in the history
  • Loading branch information
gigamaster committed May 13, 2024
1 parent 90f1f15 commit a69bcd0
Show file tree
Hide file tree
Showing 46 changed files with 893 additions and 624 deletions.
12 changes: 6 additions & 6 deletions xoops_trust_path/modules/pico/admin/category_access.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// independent permission update
if ( !empty( $_POST['independentpermission_update'] ) && 0 != $cat_id) {
if ( !$xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}
if ( !empty( $_POST['independentpermission'] ) ) {
// update permission_id of categories has the same permission_id and children of the category
Expand All @@ -54,15 +54,15 @@
// update permission_id of categories which permission_id is the cat_id
$db->queryF( 'UPDATE ' . $db->prefix( $mydirname . '_categories' ) . ' SET cat_permission_id=' . (int) $cat_permission_id . " WHERE cat_permission_id=$cat_id" );
}
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=category_access&cat_id=$cat_id", 3, _MD_PICO_MSG_UPDATED );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=category_access&cat_id=$cat_id", 2, _MD_PICO_MSG_UPDATED );
exit;
}


// group update
if ( !empty( $_POST['group_update'] ) ) {
if ( !$xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}
$db->queryF( 'DELETE FROM ' . $db->prefix( $mydirname . '_category_permissions' ) . " WHERE cat_id=$cat_id AND groupid>0" );
$result = $db->query( 'SELECT groupid FROM ' . $db->prefix( 'groups' ) );
Expand All @@ -75,14 +75,14 @@
$db->queryF( 'INSERT INTO ' . $db->prefix( $mydirname . '_category_permissions' ) . " (cat_id,groupid,permissions) VALUES ($cat_id,$gid," . $db->quoteString( serialize( $perms ) ) . ')' );
}
}
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=category_access&cat_id=$cat_id", 3, _MD_PICO_MSG_UPDATED );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=category_access&cat_id=$cat_id", 2, _MD_PICO_MSG_UPDATED );
exit;
}

// user update
if ( !empty( $_POST['user_update'] ) ) {
if ( !$xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}
$db->queryF( 'DELETE FROM ' . $db->prefix( $mydirname . '_category_permissions' ) . " WHERE cat_id=$cat_id AND uid>0" );

Expand Down Expand Up @@ -129,7 +129,7 @@
}
}

redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=category_access&cat_id=$cat_id", 3, _MD_PICO_MSG_UPDATED );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=category_access&cat_id=$cat_id", 2, _MD_PICO_MSG_UPDATED );
exit;
}

Expand Down
16 changes: 8 additions & 8 deletions xoops_trust_path/modules/pico/admin/contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
// contents update
if ( ! empty( $_POST['contents_update'] ) && ! empty( $_POST['weights'] ) ) {
if ( ! $xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}

$errors = [];
Expand All @@ -90,14 +90,14 @@
}
pico_sync_all( $mydirname );

redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=contents&cat_id=$cat_id", 3, $errors ? sprintf( _MD_A_PICO_MSG_FMT_DUPLICATEDVPATH, implode( ',', $errors ) ) : _MD_PICO_MSG_UPDATED );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=contents&cat_id=$cat_id", 2, $errors ? sprintf( _MD_A_PICO_MSG_FMT_DUPLICATEDVPATH, implode( ',', $errors ) ) : _MD_PICO_MSG_UPDATED );
exit;
}

// contents move
if ( ! empty( $_POST['contents_move'] ) && ! empty( $_POST['action_selects'] ) && isset( $_POST['dest_cat_id'] ) ) {
if ( ! $xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}

// cat_id check
Expand All @@ -118,14 +118,14 @@
}
pico_sync_all( $mydirname );

redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=contents&cat_id=$cat_id", 3, _MD_A_PICO_MSG_CONTENTSMOVED );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=contents&cat_id=$cat_id", 2, _MD_A_PICO_MSG_CONTENTSMOVED );
exit;
}

// contents delete
if ( ! empty( $_POST['contents_delete'] ) && ! empty( $_POST['action_selects'] ) ) {
if ( ! $xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}

foreach ( $_POST['action_selects'] as $content_id => $value ) {
Expand All @@ -137,14 +137,14 @@
}
pico_sync_all( $mydirname );

redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=contents&cat_id=$cat_id", 3, _MD_A_PICO_MSG_CONTENTSDELETED );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=contents&cat_id=$cat_id", 2, _MD_A_PICO_MSG_CONTENTSDELETED );
exit;
}

// contents export
if ( ! empty( $_POST['contents_export'] ) && ! empty( $_POST['action_selects'] ) && ! empty( $_POST['export_mid'] ) ) {
if ( ! $xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}

$export_mid = (int) @$_POST['export_mid'];
Expand All @@ -160,7 +160,7 @@
pico_import_a_content_from_pico( $export_module->getVar( 'dirname' ), $xoopsModule->getVar( 'mid' ), $content_id );
}

redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=contents&cat_id=$cat_id", 3, _MD_A_PICO_MSG_CONTENTSEXPORTED );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=contents&cat_id=$cat_id", 2, _MD_A_PICO_MSG_CONTENTSEXPORTED );
exit;
}

Expand Down
4 changes: 2 additions & 2 deletions xoops_trust_path/modules/pico/admin/extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
// extras delete
if ( ! empty( $_POST['extras_delete'] ) && ! empty( $_POST['action_selects'] ) ) {
if ( ! $xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}

foreach ( $_POST['action_selects'] as $extra_id => $value ) {
Expand All @@ -96,7 +96,7 @@
$db->query( 'DELETE FROM ' . $db->prefix( $mydirname . '_content_extras' ) . " WHERE content_extra_id=$extra_id" );
}

redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=extras", 3, _MD_A_PICO_MSG_DELETED );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=extras", 2, _MD_A_PICO_MSG_DELETED );
exit;
}

Expand Down
12 changes: 6 additions & 6 deletions xoops_trust_path/modules/pico/admin/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
@set_time_limit( 0 );

if ( ! $xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}

$import_mid = (int) @$_POST['import_mid'];
Expand All @@ -72,33 +72,33 @@
break;
}

redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=import", 3, _MD_A_PICO_MSG_IMPORTDONE );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=import", 2, _MD_A_PICO_MSG_IMPORTDONE );
exit;
}

if ( ! empty( $_POST['do_syncall'] ) ) {
@set_time_limit( 0 );

if ( ! $xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}

pico_sync_all( $mydirname );

redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=import", 3, _MD_A_PICO_MSG_SYNCALLDONE );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=import", 2, _MD_A_PICO_MSG_SYNCALLDONE );
exit;
}

if ( ! empty( $_POST['do_clearbodycache'] ) ) {
@set_time_limit( 0 );

if ( ! $xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}

pico_clear_body_cache( $mydirname );

redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=import", 3, _MD_A_PICO_MSG_CLEARBODYCACHEDONE );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=import", 2, _MD_A_PICO_MSG_CLEARBODYCACHEDONE );
exit;
}

Expand Down
132 changes: 104 additions & 28 deletions xoops_trust_path/modules/pico/admin/index.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,115 @@
<?php
/**
* CKEditor4 module for XCL
* @package CKEditor4
* Pico content management D3 module for XCL
* @package Pico
* @version XCL 2.4.0
* @author Other authors Nuno Luciano (aka gigamaster), 2020, XCL PHP7
* @author Naoki Sawada (aka nao-pon) <https://xoops.hypweb.net/>
* @copyright (c) 2005-2024 The XOOPSCube Project
* @license GPL 2.0
* @author Nuno Luciano aka Gigamaster, 2020 XCL PHP7
* @copyright (c) 2005-2024 Authors
* @license GPL v2.0
*/

require_once '../../../mainfile.php';
require_once XOOPS_ROOT_PATH . '/header.php';

// <{$mod_name|ucfirst}>
$mod_name = $xoopsModule->getVar( 'name' );

// Query Total from Multiple Tables
$query = "SELECT
(SELECT COUNT(`cat_id`) FROM " . $xoopsDB->prefix($mod_name .'_categories') ." LIMIT 1) as totalCat,
(SELECT COUNT(`content_id`) FROM " . $xoopsDB->prefix($mod_name .'_contents') ." LIMIT 1) as totalContent,
(SELECT COUNT(`content_id`) FROM " . $xoopsDB->prefix($mod_name .'_content_histories') ." LIMIT 1) as totalRevision,
(SELECT COUNT(`count`) FROM " . $xoopsDB->prefix($mod_name .'_tags') ." LIMIT 1) as totalTags,
(SELECT SUM(`comments_count`) FROM " . $xoopsDB->prefix($mod_name .'_contents') ." LIMIT 1) as totalComments,
(SELECT COUNT(`vote_id`) FROM " . $xoopsDB->prefix($mod_name .'_content_votes') ." LIMIT 1) as totalVotes,
(SELECT COUNT(`content_id`) FROM " . $xoopsDB->prefix($mod_name .'_contents') ." WHERE 'subject_waiting' IS NOT NULL
AND TRIM(subject_waiting) <> '' LIMIT 1) as totalApproval,
(SELECT COUNT(`content_extra_id`) FROM " . $xoopsDB->prefix($mod_name .'_content_extras') ." LIMIT 1) as totalExtra
";
$active = $xoopsDB->query($query);
$total = $active->fetch_array();

// QUERY SETTINGS
$items = 10; // TODO Limit of items to display and pagination
$days = 5; /* interval scheduled to expire, default 5 */

// QUERY DB
$sql = "SELECT content_id as ID,
subject as Subject,
visible as Visible,
locked as Locked,
viewed as Views,
comments_count as Comments,
expiring_time as Expire
FROM " . $xoopsDB->prefix($mod_name .'_contents'). "
WHERE expiring_time
BETWEEN (UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL $days DAY)))
AND (UNIX_TIMESTAMP(DATE_ADD(CURDATE(), INTERVAL $days DAY)))
ORDER BY expiring_time ASC LIMIT $items";

$result = $xoopsDB->query($sql);
// if no content, prevent warnings
$assignActivity = []??'';

if ($row = $result->fetch_assoc()) {

$re=1;

foreach($result as $active){
$re; // used to style interval
$id = $active['ID']??'';
$link = htmlspecialchars( XOOPS_URL.'/modules/'.$mod_name.'/index.php?content_id='.$id, ENT_QUOTES );
$edit = htmlspecialchars( XOOPS_URL.'/modules/'.$mod_name.'/index.php?page=contentmanager&content_id='.$id, ENT_QUOTES );
$subject = htmlspecialchars( $active['Subject']??'', ENT_QUOTES );
if (str_contains($active['Visible']??'', '1')) {
$visible = $active['Visible']; // icon
} else { $visible= '';}
if (str_contains($active['Locked']??'', '1')) {
$locked = $active['Locked']; // icon
} else{$locked ='';}
$comments = $active['Comments'];
$views = $active['Views'];
$expire = $active['Expire']??'';

$assignActivity[] = [
're' => $re++,
'id' => $id,
'link' => $link,
'edit' => $edit,
'subject' => $subject,
'visible' => $visible,
'locked' => $locked,
'comments' => $comments,
'views' => $views,
'expire' => $expire,
];
}
}

// RENDER
xoops_cp_header();
include __DIR__ . '/mymenu.php';
$xoopsTpl = new XoopsTpl();
$dbfile = 'db:_custom_pico_index.html';
if (file_exists($dbfile)) {
echo "The file $dbfile exists";
} else {
echo "The file $dbfile does not exist";
}
//$test = $xoopsTpl->fetch($dbIndex);

if (defined('LEGACY_BASE_VERSION')) {
$modname = $xoopsModule->getVar( 'name' ) ;
$dash = XOOPS_URL . '/admin.php';
$pref = XOOPS_MODULE_URL . '/legacy/admin/index.php?action=PreferenceEdit&amp;confmod_id=';
$help = XOOPS_MODULE_URL . '/legacy/admin/index.php?action=Help&amp;dirname=ckeditor4';
}
echo '<h3>' . $xoopsModule->getVar( 'name' ) . '</h3>';
// echo $test;
?>
<h4>HTML template</h4>
<p>echo $test;</p>
$tpl = new XoopsTpl();
$tpl->assign(
[
'mydirname' => $mod_name,
'mod_name' => $xoopsModule->getVar( 'name' ),
'mod_url' => XOOPS_URL . '/modules/' . $mod_name,
'mod_imageurl' => XOOPS_URL . '/modules/' . $mod_name . '/' . $xoopsModuleConfig['images_dir'],
'mod_config' => $xoopsModuleConfig,
'totalCat' =>$total['totalCat'],
'totalContent' =>$total['totalContent'],
'totalRevision' =>$total['totalRevision'],
'totalTags' =>$total['totalTags'],
'totalComments' =>$total['totalComments'],
'totalVotes' =>$total['totalVotes'],
'totalApproval' =>$total['totalApproval'],
'totalExtra' =>$total['totalExtra'],
'active' => $assignActivity,
'days' => $days
]
);

$tpl->display( 'db:' . $mod_name . '_admin_activity.html' );

<?php
require_once XOOPS_ROOT_PATH . "/footer.php";
?>
8 changes: 4 additions & 4 deletions xoops_trust_path/modules/pico/admin/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// tags update
if ( ! empty( $_POST['tags_update'] ) ) {
if ( ! $xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}

foreach ( array_keys( $_POST['labels'] ) as $old_label ) {
Expand Down Expand Up @@ -62,15 +62,15 @@
}
pico_sync_tags( $mydirname );

redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=tags", 3, _MD_PICO_MSG_UPDATED );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=tags", 2, _MD_PICO_MSG_UPDATED );
exit;
}


// tags delete
if ( ! empty( $_POST['tags_delete'] ) && ! empty( $_POST['action_selects'] ) ) {
if ( ! $xoopsGTicket->check( true, 'pico_admin' ) ) {
redirect_header( XOOPS_URL . '/', 3, $xoopsGTicket->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $xoopsGTicket->getErrors() );
}

foreach ( $_POST['action_selects'] as $label => $value ) {
Expand All @@ -95,7 +95,7 @@
}
pico_sync_tags( $mydirname );

redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=tags", 3, _MD_A_PICO_MSG_DELETED );
redirect_header( XOOPS_URL . "/modules/$mydirname/admin/index.php?page=tags", 2, _MD_A_PICO_MSG_DELETED );
exit;
}

Expand Down
4 changes: 4 additions & 0 deletions xoops_trust_path/modules/pico/admin_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
$constpref = '_MI_' . strtoupper( $mydirname );

$adminmenu = [
[
'title' => constant( $constpref . '_ADMENU_ACTIVITY' ),
'link' => 'admin/index.php',
],
[
'title' => constant( $constpref . '_ADMENU_CONTENTSADMIN' ),
'link' => 'admin/index.php?page=contents',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PicoControllerCopywaitingContent extends PicoControllerAbstract {
public function execute( $request ) {
// Ticket Check
if ( ! $GLOBALS['xoopsGTicket']->check( true, 'pico' ) ) {
redirect_header( XOOPS_URL . '/', 3, $GLOBALS['xoopsGTicket']->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $GLOBALS['xoopsGTicket']->getErrors() );
}

parent::execute( $request );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PicoControllerDeleteCategory extends PicoControllerAbstract {
public function execute( $request ) {
// Ticket Check
if ( ! $GLOBALS['xoopsGTicket']->check( true, 'pico' ) ) {
redirect_header( XOOPS_URL . '/', 3, $GLOBALS['xoopsGTicket']->getErrors() );
redirect_header( XOOPS_URL . '/', 2, $GLOBALS['xoopsGTicket']->getErrors() );
}

parent::execute( $request );
Expand Down
Loading

0 comments on commit a69bcd0

Please sign in to comment.