plugin fixes
This commit is contained in:
@ -38,7 +38,10 @@ class Folders extends DatabaseModel {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function create( $title, $folderID = 0, $description = '', $color = 'default', $privacy = 'private' ) {
|
||||
public function create( $title, $folderID = 0, $description = '', $color = 'default', $privacy = 'private', $user = null ) {
|
||||
if ( empty( $user ) ) {
|
||||
$user = App::$activeUser->ID;
|
||||
}
|
||||
if ( ! Check::dataTitle( $title ) ) {
|
||||
Debug::info( 'Folders: illegal title.' );
|
||||
return false;
|
||||
@ -48,9 +51,10 @@ class Folders extends DatabaseModel {
|
||||
'description' => $description,
|
||||
'color' => $color,
|
||||
'privacy' => $privacy,
|
||||
'createdBy' => App::$activeUser->ID,
|
||||
'createdBy' => $user,
|
||||
'createdAt' => time(),
|
||||
];
|
||||
|
||||
if ( !empty( $folderID ) ) {
|
||||
$fields['folderID'] = $folderID;
|
||||
}
|
||||
@ -102,6 +106,20 @@ class Folders extends DatabaseModel {
|
||||
return $this->filter( $folders->results() );
|
||||
}
|
||||
|
||||
public function bySpecificUser( $userID, $limit = null ) {
|
||||
$whereClause = ['createdBy', '=', $userID];
|
||||
if ( empty( $limit ) ) {
|
||||
$folders = self::$db->get( $this->tableName, $whereClause );
|
||||
} else {
|
||||
$folders = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] );
|
||||
}
|
||||
if ( !$folders->count() ) {
|
||||
Debug::info( 'No Folders found.' );
|
||||
return false;
|
||||
}
|
||||
return $this->filter( $folders->results() );
|
||||
}
|
||||
|
||||
public function getName( $id ) {
|
||||
$folder = self::findById( $id );
|
||||
if (false == $folder) {
|
||||
|
Reference in New Issue
Block a user