Ejemplo n.º 1
0
 /**
  * get_xml
  * This returns the xmldocument for the current rss type, it calls a sub function that gathers the data
  * and then uses the xmlDATA class to build the document
  * @return string
  */
 public function get_xml($params = null)
 {
     if ($this->type === "podcast") {
         if ($params != null && is_array($params)) {
             $object_type = $params['object_type'];
             $object_id = $params['object_id'];
             if (Core::is_library_item($object_type)) {
                 $libitem = new $object_type($object_id);
                 if ($libitem->id) {
                     $libitem->format();
                     return XML_Data::podcast($libitem);
                 }
             }
         }
     } else {
         // Function call name
         $data_function = 'load_' . $this->type;
         $pub_date_function = 'pubdate_' . $this->type;
         $data = call_user_func(array('Ampache_RSS', $data_function));
         $pub_date = null;
         if (method_exists('Ampache_RSS', $data_function)) {
             $pub_date = call_user_func(array('Ampache_RSS', $pub_date_function));
         }
         XML_Data::set_type('rss');
         $xml_document = XML_Data::rss_feed($data, $this->get_title(), $this->get_description(), $pub_date);
         return $xml_document;
     }
     return null;
 }
Ejemplo n.º 2
0
 /**
  * remove_map
  * This will only remove tag maps for the current user
  */
 public function remove_map($type, $object_id)
 {
     if (!Core::is_library_item($type)) {
         return false;
     }
     // TODO: Review the tag edition per user.
     $sql = "DELETE FROM `tag_map` WHERE `tag_id` = ? AND `object_type` = ? AND `object_id` = ? ";
     //AND `user` = ?";
     Dba::write($sql, array($this->id, $type, $object_id));
     //, $GLOBALS['user']->id));
     return true;
 }
Ejemplo n.º 3
0
 /**
  * Display an item art.
  * @param string $object_type
  * @param int $object_id
  * @param string $name
  * @param int $thumb
  * @param string $link
  * @param boolean $show_default
  * @param string $kind
  * @return boolean
  */
 public static function display($object_type, $object_id, $name, $thumb, $link = null, $show_default = true, $kind = 'default')
 {
     if (!Core::is_library_item($object_type)) {
         return false;
     }
     if (!$show_default) {
         // Don't show any image if not available
         if (!self::has_db($object_id, $object_type, $kind)) {
             return false;
         }
     }
     $size = self::get_thumb_size($thumb);
     $prettyPhoto = $link == null;
     if ($link == null) {
         $link = AmpConfig::get('web_path') . "/image.php?object_id=" . $object_id . "&object_type=" . $object_type;
         if (AmpConfig::get('use_auth') && AmpConfig::get('require_session')) {
             $link .= "&auth=" . session_id();
         }
         if ($kind != 'default') {
             $link .= '&kind=' . $kind;
         }
     }
     echo "<div class=\"item_art\">";
     echo "<a href=\"" . $link . "\" title=\"" . $name . "\"";
     if ($prettyPhoto) {
         echo " rel=\"prettyPhoto\"";
     }
     echo ">";
     $imgurl = AmpConfig::get('web_path') . "/image.php?object_id=" . $object_id . "&object_type=" . $object_type . "&thumb=" . $thumb;
     if ($kind != 'default') {
         $imgurl .= '&kind=' . $kind;
     }
     echo "<img src=\"" . $imgurl . "\" alt=\"" . $name . "\" height=\"" . $size['height'] . "\" width=\"" . $size['width'] . "\" />";
     if ($prettyPhoto) {
         if ($size['width'] >= 150) {
             echo "<div class=\"item_art_play\">";
             echo Ajax::text('?page=stream&action=directplay&object_type=' . $object_type . '&object_id=' . $object_id . '\' + getPagePlaySettings() + \'', '<span class="item_art_play_icon" title="' . T_('Play') . '" />', 'directplay_art_' . $object_type . '_' . $object_id);
             echo "</div>";
         }
         $libitem = new $object_type($object_id);
         echo "<div class=\"item_art_actions\">";
         if ($GLOBALS['user']->has_access(50) || $GLOBALS['user']->has_access(25) && $GLOBALS['user']->id == $libitem->get_user_owner()) {
             echo "<a href=\"javascript:NavigateTo('" . AmpConfig::get('web_path') . "/arts.php?action=find_art&object_type=" . $object_type . "&object_id=" . $object_id . "&burl=' + getCurrentPage());\">";
             echo UI::get_icon('edit', T_('Edit/Find Art'));
             echo "</a>";
             echo "<a href=\"javascript:NavigateTo('" . AmpConfig::get('web_path') . "/arts.php?action=clear_art&object_type=" . $object_type . "&object_id=" . $object_id . "&burl=' + getCurrentPage());\" onclick=\"return confirm('" . T_('Do you really want to reset art?') . "');\">";
             echo UI::get_icon('delete', T_('Reset Art'));
             echo "</a>";
         }
         echo "</div>";
     }
     echo "</a>\n";
     echo "</div>";
     return true;
 }
Ejemplo n.º 4
0
                $limit = $browse->get_offset();
                if ($limit > 0 && $value > 0) {
                    $total = $browse->get_total();
                    $pages = ceil($total / $limit);
                    if ($value <= $pages) {
                        $offset = ($value - 1) * $limit;
                        $browse->set_start($offset);
                    }
                }
                break;
        }
        ob_start();
        $browse->show_objects(null, $argument);
        $results[$browse->get_content_div()] = ob_get_clean();
        break;
    case 'get_share_links':
        $object_type = $_REQUEST['object_type'];
        $object_id = intval($_REQUEST['object_id']);
        if (Core::is_library_item($object_type) && $object_id > 0) {
            Share::display_ui_links($object_type, $object_id);
            exit;
        }
        break;
    default:
        $results['rfc3514'] = '0x1';
        break;
}
// switch on action;
$browse->store();
// We always do this
echo xoutput_from_array($results);
Ejemplo n.º 5
0
?>
</th>
                <th class="cel_drag essential"></th>
            </tr>
        </thead>
        <tbody id="sortableplaylist_<?php 
echo $playlist->id;
?>
">
            <?php 
foreach ($object_ids as $object) {
    if (!is_array($object)) {
        $object = (array) $object;
    }
    $object_type = $object['object_type'];
    if (Core::is_library_item($object_type)) {
        $libitem = new $object_type($object['object_id']);
        $libitem->format();
        $playlist_track = $object['track'];
        ?>
        <tr class="<?php 
        echo UI::flip_class();
        ?>
" id="track_<?php 
        echo $object['track_id'];
        ?>
">
            <?php 
        require AmpConfig::get('prefix') . UI::find_template('show_playlist_media_row.inc.php');
        ?>
        </tr>
Ejemplo n.º 6
0
    // Check to see if they've got an interface session or a valid API session, if not GTFO
    if (!Session::exists('interface', $_COOKIE[AmpConfig::get('session_name')]) && !Session::exists('api', $_REQUEST['auth'])) {
        debug_event('image', 'Access denied, checked cookie session:' . $_COOKIE[AmpConfig::get('session_name')] . ' and auth:' . $_REQUEST['auth'], 1);
        exit;
    }
}
// If we aren't resizing just trash thumb
if (!AmpConfig::get('resize_images')) {
    $_GET['thumb'] = null;
}
// FIXME: Legacy stuff - should be removed after a version or so
if (!isset($_GET['object_type'])) {
    $_GET['object_type'] = 'album';
}
$type = $_GET['object_type'];
if (!Core::is_library_item($type)) {
    exit;
}
/* Decide what size this image is */
$size = Art::get_thumb_size($_GET['thumb']);
$kind = isset($_GET['kind']) ? $_GET['kind'] : 'default';
$image = '';
$mime = '';
$filename = '';
$etag = '';
$typeManaged = false;
if (isset($_GET['type'])) {
    switch ($_GET['type']) {
        case 'popup':
            $typeManaged = true;
            require_once AmpConfig::get('prefix') . UI::find_template('show_big_art.inc.php');
Ejemplo n.º 7
0
define('AJAX_INCLUDE', '1');
require_once '../lib/init.php';
$results = '';
debug_event('edit.server.php', 'Called for action: {' . $_REQUEST['action'] . '}', '5');
// Post first
$type = $_POST['type'];
if (empty($type)) {
    $type = $_GET['type'];
}
$object_id = $_GET['id'];
if (empty($type)) {
    $object_type = $_GET['object_type'];
} else {
    $object_type = implode('_', explode('_', $type, -1));
}
if (!Core::is_library_item($object_type) && $object_type != 'share') {
    debug_event('edit.server.php', 'Type `' . $type . '` is not based on an item library.', '3');
    exit;
}
$libitem = new $object_type($object_id);
$libitem->format();
$level = '50';
if ($libitem->get_user_owner() == $GLOBALS['user']->id) {
    $level = '25';
}
if ($_REQUEST['action'] == 'show_edit_playlist') {
    $level = '25';
}
// Make sure they got them rights
if (!Access::check('interface', $level) || AmpConfig::get('demo_mode')) {
    echo xoutput_from_array(array('rfc3514' => '0x1'));
Ejemplo n.º 8
0
 /**
  * create
  * This takes a key'd array of data as input and inserts a new shoutbox entry, it returns the auto_inc id
  */
 public static function create(array $data)
 {
     if (!Core::is_library_item($data['object_type'])) {
         return false;
     }
     $sticky = isset($data['sticky']) ? 1 : 0;
     $user = intval($data['user'] ?: $GLOBALS['user']->id);
     $date = intval($data['date'] ?: time());
     $comment = strip_tags($data['comment']);
     $sql = "INSERT INTO `user_shout` (`user`,`date`,`text`,`sticky`,`object_id`,`object_type`, `data`) " . "VALUES (? , ?, ?, ?, ?, ?, ?)";
     Dba::write($sql, array($user, $date, $comment, $sticky, $data['object_id'], $data['object_type'], $data['data']));
     $insert_id = Dba::insert_id();
     // Never send email in case of user impersonation
     if (!isset($data['user']) && $insert_id) {
         $libitem = new $data['object_type']($data['object_id']);
         $item_owner_id = $libitem->get_user_owner();
         if ($item_owner_id) {
             if (Preference::get_by_user($item_owner_id, 'notify_email')) {
                 $item_owner = new User($item_owner_id);
                 if (!empty($item_owner->email)) {
                     $libitem->format();
                     $mailer = new Mailer();
                     $mailer->set_default_sender();
                     $mailer->recipient = $item_owner->email;
                     $mailer->recipient_name = $item_owner->fullname;
                     $mailer->subject = T_('New shout on your content');
                     $mailer->message = sprintf(T_("You just received a new shout from %s on your content `%s`.\n\n\n    ----------------------\n    %s\n    ----------------------\n\n    %s\n    "), $GLOBALS['user']->fullname, $libitem->get_fullname(), $comment, AmpConfig::get('web_path') . "/shout.php?action=show_add_shout&type=" . $data['object_type'] . "&id=" . $data['object_id'] . "#shout" . $insert_id);
                     $mailer->send();
                 }
             }
         }
     }
     return $insert_id;
 }
Ejemplo n.º 9
0
 public static function is_valid_type($type)
 {
     return Core::is_library_item($type) || $type == 'user';
 }
Ejemplo n.º 10
0
 public static function display_from_request()
 {
     if (!Access::check('interface', '50')) {
         UI::access_denied();
     } else {
         $user_id = $_REQUEST['user_id'];
         $object_type = $_REQUEST['object_type'];
         $object_id = $_REQUEST['object_id'];
         $end_date = $_REQUEST['end_date'] ? strtotime($_REQUEST['end_date']) : time();
         $f_end_date = date("Y-m-d H:i", $end_date);
         $start_date = $_REQUEST['start_date'] ? strtotime($_REQUEST['start_date']) : $end_date - 864000;
         $f_start_date = date("Y-m-d H:i", $start_date);
         $zoom = $_REQUEST['zoom'] ?: 'day';
         $gtypes = array();
         $gtypes[] = 'user_hits';
         if ($object_type == null || $object_type == 'song' || $object_type == 'video') {
             $gtypes[] = 'user_bandwidth';
         }
         if (!$user_id && !$object_id) {
             $gtypes[] = 'catalog_files';
             $gtypes[] = 'catalog_size';
         }
         $blink = '';
         if ($object_id) {
             if (Core::is_library_item($object_type)) {
                 $libitem = new $object_type($object_id);
                 $libitem->format();
                 if (isset($libitem->f_link)) {
                     $blink = $libitem->f_link;
                 }
             }
         } else {
             if ($user_id) {
                 $u = new User($user_id);
                 $u->format();
                 $blink = $u->f_link;
             }
         }
         require_once AmpConfig::get('prefix') . '/templates/show_graphs.inc.php';
     }
 }
Ejemplo n.º 11
0
 /**
  * show
  * Show the activity entry.
  */
 public function show()
 {
     // If user flags aren't enabled don't do anything
     if (!AmpConfig::get('userflags') || !$this->id) {
         return false;
     }
     $user = new User($this->user);
     $user->format();
     $libitem = new $this->object_type($this->object_id);
     $libitem->format();
     echo '<div>';
     $fdate = date('m/d/Y H:i:s', $this->activity_date);
     echo '<div class="shoutbox-date">';
     if ($user->f_avatar_mini) {
         echo '<a href="' . $user->link . '">' . $user->f_avatar_mini . '</a> ';
     }
     echo $fdate;
     echo '</div>';
     $descr = $user->f_link . ' ';
     switch ($this->action) {
         case 'shout':
             $descr .= T_('commented on');
             break;
         case 'upload':
             $descr .= T_('uploaded');
             break;
         case 'play':
             $descr .= T_('played');
             break;
         case 'userflag':
             $descr .= T_('favorited');
             break;
         case 'follow':
             $descr .= T_('started to follow');
             break;
         default:
             $descr .= T_('did something on');
             break;
     }
     $descr .= ' ' . $libitem->f_link;
     echo '<div>';
     echo $descr;
     if (Core::is_library_item($this->object_type)) {
         echo ' ';
         $libitem->display_art(10);
     }
     echo '</div>';
     echo '</div><br />';
 }
Ejemplo n.º 12
0
 /**
  * rate
  * This rate a library item
  * @param array $input
  */
 public static function rate($input)
 {
     ob_end_clean();
     $type = $input['type'];
     $id = $input['id'];
     $rating = $input['rating'];
     if (!Core::is_library_item($type) || !$id) {
         echo XML_Data::error('401', T_('Wrong library item type.'));
     } else {
         $item = new $type($id);
         if (!$item->id) {
             echo XML_Data::error('404', T_('Library item not found.'));
         } else {
             $r = new Rating($id, $type);
             $r->set_rating($rating);
             echo XML_Data::single_string('success');
         }
     }
 }
Ejemplo n.º 13
0
     if (!Access::check('interface', '25')) {
         UI::access_denied();
         exit;
     }
     if (!Core::form_verify('add_shout', 'post')) {
         UI::access_denied();
         exit;
     }
     // Remove unauthorized defined values from here
     if (isset($_POST['user'])) {
         unset($_POST['user']);
     }
     if (isset($_POST['date'])) {
         unset($_POST['date']);
     }
     if (!Core::is_library_item($_POST['object_type'])) {
         UI::access_denied();
         exit;
     }
     $shout_id = Shoutbox::create($_POST);
     header("Location:" . AmpConfig::get('web_path') . '/shout.php?action=show_add_shout&type=' . $_POST['object_type'] . '&id=' . intval($_POST['object_id']));
     exit;
     break;
 case 'show_add_shout':
     // Get our object first
     $object = Shoutbox::get_object($_REQUEST['type'], $_REQUEST['id']);
     if (!$object || !$object->id) {
         AmpError::add('general', T_('Invalid Object Selected'));
         AmpError::display('general');
         break;
     }