當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Artist::update_artist_user方法代碼示例

本文整理匯總了PHP中Artist::update_artist_user方法的典型用法代碼示例。如果您正苦於以下問題:PHP Artist::update_artist_user方法的具體用法?PHP Artist::update_artist_user怎麽用?PHP Artist::update_artist_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Artist的用法示例。


在下文中一共展示了Artist::update_artist_user方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: process

 public static function process()
 {
     header('Content-Type: application/json');
     ob_start();
     define('CLI', true);
     $catalog_id = AmpConfig::get('upload_catalog');
     if ($catalog_id > 0) {
         $catalog = Catalog::create_from_id($catalog_id);
         if ($catalog->catalog_type == "local") {
             $allowed = explode('|', AmpConfig::get('catalog_file_pattern'));
             if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
                 $extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);
                 if (!in_array(strtolower($extension), $allowed)) {
                     debug_event('upload', 'File extension `' . $extension . '` not allowed.', '2');
                     return self::rerror();
                 }
                 $rootdir = self::get_root($catalog);
                 $targetdir = $rootdir;
                 $folder = $_POST['folder'];
                 if ($folder == '..') {
                     $folder = '';
                 }
                 if (!empty($folder)) {
                     $targetdir .= DIRECTORY_SEPARATOR . $folder;
                 }
                 $targetdir = realpath($targetdir);
                 if (strpos($targetdir, $rootdir) === FALSE) {
                     debug_event('upload', 'Something wrong with final upload path.', '1');
                     return self::rerror();
                 }
                 $targetfile = $targetdir . DIRECTORY_SEPARATOR . time() . '_' . $_FILES['upl']['name'];
                 if (Core::is_readable($targetfile)) {
                     debug_event('upload', 'File `' . $targetfile . '` already exists.', '1');
                     return self::rerror();
                 }
                 if (move_uploaded_file($_FILES['upl']['tmp_name'], $targetfile)) {
                     debug_event('upload', 'File uploaded to `' . $targetfile . '`.', '5');
                     if (AmpConfig::get('upload_script')) {
                         chdir($targetdir);
                         exec(AmpConfig::get('upload_script'));
                     }
                     $options = array();
                     $options['user_upload'] = $GLOBALS['user']->id;
                     if (isset($_POST['license'])) {
                         $options['license'] = $_POST['license'];
                     }
                     $artist_id = intval($_REQUEST['artist']);
                     $album_id = intval($_REQUEST['album']);
                     // Override artist information with artist's user
                     if (AmpConfig::get('upload_user_artist')) {
                         $artists = $GLOBALS['user']->get_artists();
                         $artist = null;
                         // No associated artist yet, we create a default one for the user sender
                         if (count($artists) == 0) {
                             $artists[] = Artist::check($GLOBALS['user']->f_name);
                             $artist = new Artist($artists[0]);
                             $artist->update_artist_user($GLOBALS['user']->id);
                         } else {
                             $artist = new Artist($artists[0]);
                         }
                         $artist_id = $artist->id;
                     } else {
                         // Try to create a new artist
                         if (isset($_REQUEST['artist_name'])) {
                             $artist_id = Artist::check($_REQUEST['artist_name'], null, true);
                             if ($artist_id && !Access::check('interface', 50)) {
                                 debug_event('upload', 'An artist with the same name already exists, uploaded song skipped.', 3);
                                 return self::rerror($targetfile);
                             } else {
                                 $artist_id = Artist::check($_REQUEST['artist_name']);
                                 $artist = new Artist($artist_id);
                                 if (!$artist->get_user_owner()) {
                                     $artist->update_artist_user($GLOBALS['user']->id);
                                 }
                             }
                         }
                         if (!Access::check('interface', 50)) {
                             // If the user doesn't have privileges, check it is assigned to an artist he owns
                             if (!$artist_id) {
                                 debug_event('upload', 'Artist information required, uploaded song skipped.', 3);
                                 return self::rerror($targetfile);
                             }
                             $artist = new Artist($artist_id);
                             if ($artist->get_user_owner() != $GLOBALS['user']->id) {
                                 debug_event('upload', 'Artist owner doesn\'t match the current user.', 3);
                                 return self::rerror($targetfile);
                             }
                         }
                     }
                     // Try to create a new album
                     if (isset($_REQUEST['album_name'])) {
                         $album_id = Album::check($_REQUEST['album_name'], 0, 0, null, null, $artist_id);
                     }
                     if (!Access::check('interface', 50)) {
                         // If the user doesn't have privileges, check it is assigned to an album he owns
                         if (!$album_id) {
                             debug_event('upload', 'Album information required, uploaded song skipped.', 3);
                             return self::rerror($targetfile);
                         }
                         $album = new Album($album_id);
//.........這裏部分代碼省略.........
開發者ID:nioc,項目名稱:ampache,代碼行數:101,代碼來源:upload.class.php


注:本文中的Artist::update_artist_user方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。