many fixes and updates

This commit is contained in:
Joey Kimsey
2024-12-20 05:53:57 -05:00
parent e7ec79e727
commit 1496b855db
62 changed files with 1211 additions and 438 deletions

View File

@ -1,8 +1,8 @@
<?php
/**
* app/plugins/bookmarks/models/bookmarkViews.php
* app/plugins/bookmarks/models/bookmark_dashboards.php
*
* This class is used for the manipulation of the bookmark_views database table.
* This class is used for the manipulation of the bookmark_dashboards database table.
*
* @package TP Bookmarks
* @version 3.0
@ -19,26 +19,17 @@ use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters;
use TheTempusProject\Canary\Classes\CustomException;
class Bookmarkviews extends DatabaseModel {
public $tableName = 'bookmark_views';
class BookmarkDashboards extends DatabaseModel {
public $tableName = 'bookmark_dashboards';
public $databaseMatrix = [
[ 'title', 'varchar', '256' ],
[ 'saved_prefs', 'text', '' ],
[ 'link_order', 'text', '' ],
[ 'description', 'text', '' ],
[ 'privacy', 'varchar', '48' ],
[ 'createdBy', 'int', '11' ],
[ 'createdAt', 'int', '11' ],
[ 'updatedAt', 'int', '11' ],
[ 'uuid', 'text', '' ],
[ 'uuid', 'char', '36' ],
];
/**
@ -48,7 +39,7 @@ class Bookmarkviews extends DatabaseModel {
parent::__construct();
}
public function create( $title, $description = '', $privacy = 'private' ) {
public function create( $title, $saved_prefs, $link_order, $description = '' ) {
if ( ! Check::dataTitle( $title ) ) {
Debug::info( 'Views: illegal title.' );
return false;
@ -56,7 +47,8 @@ class Bookmarkviews extends DatabaseModel {
$fields = [
'title' => $title,
'description' => $description,
'privacy' => $privacy,
'saved_prefs' => $saved_prefs,
'link_order' => $link_order,
'uuid' => generateUuidV4(),
'createdBy' => App::$activeUser->ID,
'createdAt' => time(),
@ -69,7 +61,7 @@ class Bookmarkviews extends DatabaseModel {
return self::$db->lastId();
}
public function update( $id, $title, $description = '', $privacy = 'private' ) {
public function update( $id, $title, $saved_prefs, $link_order, $description = '' ) {
if ( !Check::id( $id ) ) {
Debug::info( 'Views: illegal ID.' );
return false;
@ -81,11 +73,12 @@ class Bookmarkviews extends DatabaseModel {
$fields = [
'title' => $title,
'description' => $description,
'privacy' => $privacy,
'saved_prefs' => $saved_prefs,
'link_order' => $link_order,
];
if ( !self::$db->update( $this->tableName, $id, $fields ) ) {
new CustomException( 'viewUpdate' );
Debug::error( "Views: $id not updated: $fields" );
Debug::error( "Views: $id not updated" );
return false;
}
return true;
@ -147,4 +140,16 @@ class Bookmarkviews extends DatabaseModel {
}
return $out;
}
public function findByUuid( $id ) {
$whereClause = ['uuid', '=', $id];
$dashboards = self::$db->get( $this->tableName, $whereClause );
if ( !$dashboards->count() ) {
Debug::info( 'No Dashboards found.' );
return false;
}
return $this->filter( $dashboards->first() );
}
}

View File

@ -42,7 +42,7 @@ class Bookmarks extends DatabaseModel {
[ 'hiddenAt', 'int', '11' ],
[ 'order', 'int', '11' ],
[ 'linkType', 'varchar', '32' ],
[ 'uuid', 'uuid', '36' ],
[ 'uuid', 'char', '36' ],
];
/**

View File

@ -29,7 +29,7 @@ class Folders extends DatabaseModel {
[ 'folderID', 'int', '11' ],
[ 'createdBy', 'int', '11' ],
[ 'createdAt', 'int', '11' ],
[ 'uuid', 'text', '' ],
[ 'uuid', 'char', '36' ],
];
/**