1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-18 05:09:05 +01:00

#513 Added method createUserCategory() to media_class.php for adding user-specific media-categories.

This commit is contained in:
Cameron 2014-02-09 15:44:43 -08:00
parent 39ef038062
commit fb2af5db53

View File

@ -247,6 +247,48 @@ class e_media
return e107::getDb()->db_Insert('core_media_cat', $data);
}
/**
* Create a user Media-Category.
* @param $type string image | file | video
* @param $userId int - leave empty for currently logged in user.
* @param $userName string - leave blank for currently logged in user
* @param $parms (optional) - for future use.
*/
public function createUserCategory($type='image', $userId = USERID, $userName = USERNAME, $parms=null)
{
if($type !='image' && $type='file' && $type !='video')
{
return false;
}
$cat = 'user_'.$type.'_'.intval($userId);
if(!e107::getDb()->gen('SELECT media_cat_id FROM #core_media_cat WHERE media_cat_category = "'.$cat.'" LIMIT 1'))
{
$insert = array(
'owner' => 'user',
'category' => $cat,
'title' => $userName,
'sef' => 'media-'.eHelper::title2sef($userName),
'diz' => '',
'class' => '',
'image' => '',
'order' => ''
);
return $this->createCategory($insert);
}
return false;
}
/**
* Create multiple media categories in once
* @param array $data