当前位置: 首页>>代码示例>>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;未经允许,请勿转载。