mvp
This commit is contained in:
@ -41,7 +41,7 @@ class BookmarkDashboards extends DatabaseModel {
|
||||
|
||||
public function create( $title, $saved_prefs, $link_order, $description = '' ) {
|
||||
if ( ! Check::dataTitle( $title ) ) {
|
||||
Debug::info( 'Views: illegal title.' );
|
||||
Debug::info( 'Dash: illegal title.' );
|
||||
return false;
|
||||
}
|
||||
$fields = [
|
||||
@ -54,8 +54,8 @@ class BookmarkDashboards extends DatabaseModel {
|
||||
'createdAt' => time(),
|
||||
];
|
||||
if ( ! self::$db->insert( $this->tableName, $fields ) ) {
|
||||
new CustomException( 'viewCreate' );
|
||||
Debug::error( "Views: not created " . var_export($fields,true) );
|
||||
new CustomException( 'dashCreate' );
|
||||
Debug::error( "Dash: not created " . var_export($fields,true) );
|
||||
return false;
|
||||
}
|
||||
return self::$db->lastId();
|
||||
@ -63,11 +63,11 @@ class BookmarkDashboards extends DatabaseModel {
|
||||
|
||||
public function update( $id, $title, $saved_prefs, $link_order, $description = '' ) {
|
||||
if ( !Check::id( $id ) ) {
|
||||
Debug::info( 'Views: illegal ID.' );
|
||||
Debug::info( 'Dash: illegal ID.' );
|
||||
return false;
|
||||
}
|
||||
if ( !Check::dataTitle( $title ) ) {
|
||||
Debug::info( 'Views: illegal title.' );
|
||||
Debug::info( 'Dash: illegal title.' );
|
||||
return false;
|
||||
}
|
||||
$fields = [
|
||||
@ -77,8 +77,29 @@ class BookmarkDashboards extends DatabaseModel {
|
||||
'link_order' => $link_order,
|
||||
];
|
||||
if ( !self::$db->update( $this->tableName, $id, $fields ) ) {
|
||||
new CustomException( 'viewUpdate' );
|
||||
Debug::error( "Views: $id not updated" );
|
||||
new CustomException( 'dashUpdate' );
|
||||
Debug::error( "Dash: $id not updated" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updateDash( $id, $saved_prefs = '', $link_order = '' ) {
|
||||
if ( !Check::id( $id ) ) {
|
||||
Debug::info( 'Dash: illegal ID.' );
|
||||
return false;
|
||||
}
|
||||
$fields = [];
|
||||
$fields['saved_prefs'] = $saved_prefs;
|
||||
if ( ! empty( $link_order ) ) {
|
||||
$fields['link_order'] = $link_order;
|
||||
}
|
||||
if ( empty( $fields ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( !self::$db->update( $this->tableName, $id, $fields ) ) {
|
||||
new CustomException( 'dashUpdate' );
|
||||
Debug::error( "Dash: $id not updated" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user