<?php

switch ($_REQUEST['tnb_user_action']) {
    case 'insert-musica':
        //          UPLOAD_ERR_CANT_WRITE   = 7
        //          UPLOAD_ERR_EXTENSION    = 8
        //          UPLOAD_ERR_FORM_SIZE    = 2
        //          UPLOAD_ERR_INI_SIZE     = 1
        //          UPLOAD_ERR_NO_FILE      = 4
        //          UPLOAD_ERR_NO_TMP_DIR   = 6
        //          UPLOAD_ERR_OK           = 0
        //          UPLOAD_ERR_PARTIAL      = 3
        if (isset($_FILES['music']) && $_FILES['music']['error'] == 0) {
            $gal_musica = tnb_get_artista_galeria($profileuser->ID, 'music');
            $acceptedFormats = array('audio/mpeg', 'audio/x-mpeg', 'audio/mp3', 'audio/x-mp3', 'audio/mpeg3', 'audio/x-mpeg3', 'audio/mpg', 'audio/x-mpg', 'audio/x-mpegaudio');
            if (in_array($_FILES['music']['type'], $acceptedFormats)) {
                $post = array("post_title" => $_POST['music_title'], "post_content" => $_FILES['music']['name'], "post_excerpt" => $_FILES['music']['name'], "post_author" => $profileuser->ID);
                unset($GLOBALS['post']);
                $media_id = media_handle_upload('music', $gal_musica->ID, $post);
                if ($media_id->errors) {
                    $msg['error'][] = implode(' ', $media_id->errors['upload_error']);
                }
                if (!$msg['error']) {
                    $meta = get_post_meta($media_id, '_wp_attached_file');
                    $sizes = get_media_file_sizes($upload_dir . "/" . $meta[0]);
                    $menu_order = count(tnb_get_artista_musicas($profileuser->ID));
                    $update = array('ID' => $media_id, 'menu_order' => $menu_order);
                    wp_update_post($update);
                    //$albuns = get_user_meta($current_user->ID, 'albuns');
                    update_post_meta($media_id, '_filesize', $sizes['filesize']);
                    update_post_meta($media_id, '_playtime', $sizes['playtime']);
<?php

$galeriasId['rider'] = tnb_get_artista_galeria($profileuser->ID, 'rider');
$galeriasId['mapa_palco'] = tnb_get_artista_galeria($profileuser->ID, 'mapa_palco');
?>

<button id="abrir-kit" class="config-button" >Abrir KIT</button>

<div class="tnb_modal" id="kit-artista">
    
    <h2><?php 
_e("Kit do artista", "tnb");
?>
 "<?php 
echo $curauth->display_name;
?>
"</h2>
    
    <p><em><?php 
_e('Você está vendo o KIT (Kit de Informações Técnicas) do artista. Feche essa janela para ver o perfil completo. Se quiser abrir novamente o KIT, clique no botão no topo da página', 'tnb');
?>
</em></p>

    <div class="content">
        <div class="thumbnail"><?php 
echo get_avatar($curauth->ID);
?>
</div>
        <p class="description"><?php 
echo $curauth->description;
?>
<?php

switch ($_REQUEST['tnb_user_action']) {
    case 'insert-image':
        //          UPLOAD_ERR_CANT_WRITE   = 7
        //          UPLOAD_ERR_EXTENSION    = 8
        //          UPLOAD_ERR_FORM_SIZE    = 2
        //          UPLOAD_ERR_INI_SIZE     = 1
        //          UPLOAD_ERR_NO_FILE      = 4
        //          UPLOAD_ERR_NO_TMP_DIR   = 6
        //          UPLOAD_ERR_OK           = 0
        //          UPLOAD_ERR_PARTIAL      = 3
        if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
            $gal_image = tnb_get_artista_galeria($profileuser->ID, 'images');
            $acceptedFormats = array('image/gif', 'image/png', 'image/jpeg', 'image/pjpeg', 'image/x-png');
            if (in_array($_FILES['image']['type'], $acceptedFormats)) {
                $post = array("post_title" => $_POST['image_title'], "post_content" => $_FILES['image']['name'], "post_excerpt" => $_FILES['image']['name'], "post_author" => $profileuser->ID);
                unset($GLOBALS['post']);
                $media_id = media_handle_upload('image', $gal_image->ID, $post);
                if ($media_id->errors) {
                    $msg['error'][] = implode(' ', $media_id->errors['upload_error']);
                }
                if (!$msg['error']) {
                    $menu_order = count(tnb_get_artista_fotos($profileuser->ID));
                    $update = array('ID' => $media_id, 'menu_order' => $menu_order);
                    wp_update_post($update);
                    tnb_cache_unset("ARTISTAS_FOTOS", $profileuser->ID);
                }
            } else {
                $msg['error'][] = __('Tipo de arquivo não permitido', 'tnb');
            }
    protected function __output()
    {
        $artista = get_user_by('id', $this->user_id);
        $galeriasId['rider'] = tnb_get_artista_galeria($profileuser->ID, 'rider');
        $galeriasId['mapa_palco'] = tnb_get_artista_galeria($profileuser->ID, 'mapa_palco');
        $mapa_palco = null;
        $rider = null;
        if ($this->property['exibir_mapa']) {
            $media_mp = get_posts("post_parent=" . $galeriasId['mapa_palco']->ID . "&post_type=attachment&meta_key=_media_index&meta_value=mapa_palco_1&author={$this->user_id}");
            if (isset($media_mp[0])) {
                $mapa_palco = $media_mp[0];
            }
        }
        if ($this->property['exibir_rider']) {
            $media_r = get_posts("post_parent=" . $galeriasId['rider']->ID . "&post_type=attachment&meta_key=_media_index&meta_value=rider_1&author={$this->user_id}");
            if (isset($media_r[0])) {
                $rider = $media_r[0];
            }
        }
        ?>
        <?php 
        if ($this->property['exibir_nome']) {
            ?>
            <h2> <?php 
            echo $artista->display_name;
            ?>
 </h2>
        <?php 
        }
        ?>
        
        
        <div>
            <?php 
        if ($this->property['exibir_avatar']) {
            ?>
                <?php 
            echo get_avatar($this->user_id);
            ?>
            <?php 
        }
        ?>
            
            <?php 
        if ($this->property['exibir_release']) {
            ?>
                <p class="bottom"><?php 
            echo nl2br(strip_tags($artista->description, '<p><a><img><blockquote><i><b><hr>'));
            ?>
</p>
            <?php 
        }
        ?>
            
            <?php 
        if ($this->property['exibir_integrantes']) {
            ?>
                <p class="bottom">
                    <strong><?php 
            _e('Integrantes', 'tnb');
            ?>
:</strong><br />
                    <?php 
            echo nl2br(strip_tags($artista->integrantes, '<p><a><img><blockquote><i><b><hr>'));
            ?>
                </p>
            <?php 
        }
        ?>
        </div>
        <?php 
        if ($mapa_palco || $rider) {
            ?>
        <p class="bottom">
            <strong><?php 
            _e('Downloads', 'tnb');
            ?>
:</strong>
            
            <?php 
            if ($mapa_palco) {
                ?>
            
                <a class="btn-download button" href="<?php 
                echo wp_get_attachment_url($mapa_palco->ID);
                ?>
"><?php 
                _e('Mapa do Palco', 'tnb');
                ?>
</a>
                
            <?php 
            }
            ?>
            
            <?php 
            if ($rider) {
                ?>
                
                <a class="btn-download button" href="<?php 
                echo wp_get_attachment_url($rider->ID);
                ?>
"><?php 
                _e('Rider', 'tnb');
                ?>
</a>
                
            <?php 
            }
            ?>

        </p>
        <?php 
        }
        ?>
        <?php 
        // INFORMAÇÔES RESTRITAS A PRODUTORES
        ?>
        
        <?php 
        //if (current_user_can('select_artists')):
        ?>
            <p class="bottom">
                
                <?php 
        if ($this->property['exibir_telefone'] && $artista->telefone) {
            ?>
                    <strong><?php 
            _e('Telefone', 'tnb');
            ?>
</strong>:                     
                   <?php 
            echo $artista->telefone;
            ?>
<br />
                <?php 
        }
        ?>
                                
                <?php 
        if ($this->property['exibir_email'] && $artista->email_publico) {
            ?>
                    <strong><?php 
            _e('E-mail', 'tnb');
            ?>
</strong>: 
                    <?php 
            echo $artista->email_publico;
            ?>
                <?php 
        }
        ?>
            </p>
        <?php 
        //endif; // user_can select_artists
        ?>
        
        <?php 
        if ($this->property['exibir_origem']) {
            ?>
                        
            <p class="bottom">
                <?php 
            $paises = get_paises();
            ?>
                <?php 
            if ($artista->origem_cidade || $artista->origem_estado) {
                ?>
                    <strong><?php 
                _e('Origem:', 'tnb');
                ?>
</strong>
                    <?php 
                echo $artista->origem_cidade;
                ?>
 - <?php 
                echo $artista->origem_estado;
                ?>
 (<?php 
                echo $paises[$artista->origem_pais];
                ?>
)
                <?php 
            } elseif ($this->editable()) {
                ?>
                    <strong><?php 
                _e('Origem:', 'tnb');
                ?>
</strong>
                    <a href="<?php 
                echo get_author_posts_url($this->user_id);
                ?>
/editar/banda"><?php 
                _e("adicionar esta informação.");
                ?>
</a>
                <?php 
            }
            ?>
            </p>
            
        <?php 
        }
        ?>
        
        <?php 
        if ($this->property['exibir_residencia']) {
            ?>
            <p class="bottom">
                <?php 
            if (!is_array($paises)) {
                $paises = get_paises();
            }
            ?>
                <?php 
            if ($artista->banda_cidade || $artista->banda_estado || $artista->banda_pais) {
                ?>
                    <strong><?php 
                _e('Residência:', 'tnb');
                ?>
</strong>
                    <?php 
                echo $artista->banda_cidade;
                ?>
 - <?php 
                echo $artista->banda_estado;
                ?>
 (<?php 
                echo $paises[$artista->banda_pais];
                ?>
)
                <?php 
            } elseif ($this->editable()) {
                ?>
                    <strong><?php 
                _e('Residência:', 'tnb');
                ?>
</strong>
                    <a href="<?php 
                echo get_author_posts_url($this->user_id);
                ?>
/editar/banda"><?php 
                _e("adicionar esta informação.");
                ?>
</a>
                <?php 
            }
            ?>
            </p>
        <?php 
        }
        ?>
        
        <?php 
        if ($this->property['exibir_estilo'] && $artista->estilo_musical_livre) {
            ?>
            <p class="bottom">
                <strong><?php 
            _e('Estilo', 'tnb');
            ?>
</strong><br />
                <?php 
            echo $artista->estilo_musical_livre;
            ?>
            </p>
        <?php 
        }
        ?>
        <?php 
        if ($this->property['exibir_redes_sociais']) {
            ?>
            <?php 
            if ($artista->facebook || $artista->twitter || $artista->orkut || $artista->youtube || $artista->vimeo) {
                ?>
                <p class="redes-sociais bottom">
                    <strong><?php 
                _e('Redes Sociais', 'tnb');
                ?>
 </strong><br />
                    <?php 
                if ($artista->facebook) {
                    ?>
 <a href='<?php 
                    echo $artista->facebook;
                    ?>
' target="blank"><img src="<?php 
                    bloginfo('stylesheet_directory');
                    ?>
/img/facebook.png" alt="" /></a> <?php 
                }
                ?>
 
                    <?php 
                if ($artista->twitter) {
                    ?>
 <a href='<?php 
                    echo $artista->twitter;
                    ?>
' target="blank"><img src="<?php 
                    bloginfo('stylesheet_directory');
                    ?>
/img/twitter.png" alt="" /></a> <?php 
                }
                ?>
                    <?php 
                if ($artista->orkut) {
                    ?>
 <a href='<?php 
                    echo $artista->orkut;
                    ?>
' target="blank"><img src="<?php 
                    bloginfo('stylesheet_directory');
                    ?>
/img/orkut.png" alt="" /></a> <?php 
                }
                ?>
                    <?php 
                if ($artista->youtube) {
                    ?>
 <a href='<?php 
                    echo $artista->youtube;
                    ?>
' target="blank"><img src="<?php 
                    bloginfo('stylesheet_directory');
                    ?>
/img/youtube.png" alt="" /></a> <?php 
                }
                ?>
                    <?php 
                if ($artista->vimeo) {
                    ?>
 <a href='<?php 
                    echo $artista->vimeo;
                    ?>
' target="blank"><img src="<?php 
                    bloginfo('stylesheet_directory');
                    ?>
/img/vimeo.png" alt="" /></a> <?php 
                }
                ?>
                </p>
            <?php 
            }
            ?>
        <?php 
        }
        ?>
        <?php 
    }