Location: PHPKode > projects > NetworX - Social networking Service > videos.php
<?php
/*
NetworX - open-source social networks platform
Copyright (C) 2009 SocialABC, Inc. http://www.socialabc.com
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program in a file called LICENSE; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ 

include('includes/application_top.php');

if ($user->isAuthorised())
{

	$video_album = new VideoAlbum($_GET['video_album_id']);

    if ($video_album->VideoAlbumID != -1 && $video_album->checkPermission('view'))
    {

        if ($video_album->GroupID != -1)
        {
            $template->setVariable('Entity', 'group');
            $template->setVariable('EntityID', $video_album->GroupID);
            $template->parse('back_link');
        }
        else if ($video_album->OrganizationID != -1)
        {
            $template->setVariable('Entity', 'organization');
            $template->setVariable('EntityID', $video_album->OrganizationID);
            $template->parse('back_link');
        }

        $template->setGlobalVariable("VideoAlbumID", $video_album->VideoAlbumID);
        $template->setVariable("VideoAlbumName", $video_album->VideoAlbumName);

        $owner = $video_album->getOwner();

        $template->setGlobalVariable('type', strtolower(get_class($owner)));
        $template->setGlobalVariable('id', $owner->{ucfirst(get_class($owner)) . 'ID'});


        $page = $_GET['page'] ? $_GET['page'] : 1;
        $first = ($page - 1) * ALBUM_VIDEOS_ON_LINE * ALBUM_LINES_ON_PAGE;
        $last  = $first + ALBUM_VIDEOS_ON_LINE * ALBUM_LINES_ON_PAGE;
        $videos = $video_album->getVideos($first, $last);

        $count = 1;
        foreach ($videos as $video)
        {
            $template->setVariable("VideoName", $video->VideoName);
            $template->setVariable("ImgURL", $video->getVideoURL());
            $template->setVariable("VideoID", $video->VideoID);
            $template->setVariable('VideoCommentsCount', $video->getVideoCommentsCount());
            $template->parse("video");
            if ($count++ == ALBUM_VIDEOS_ON_LINE)
            {
                $count = 1;
                $template->parse("videoline");
            }
        }
        if ($count > 1)
        {
            $template->parse("videoline");
        }

        $pages_count = ceil((float)$video_album->getVideosCount() / (ALBUM_LINES_ON_PAGE * ALBUM_VIDEOS_ON_LINE));
        if ($page < $pages_count)
        {
	        $template->setVariable("PageNumber_next", $page + 1);
	        $template->parse("next_link");
        }
        if ($page > 1)
        {
	        $template->setVariable("PageNumber_prev", $page - 1);
	        $template->parse("prev_link");
        }

    }
    else
    {
        cmn_unathorized_action();
    }
}
else
{
    cmn_unathorized_action();
}
include('includes/application_bottom.php');
?>
Return current item: NetworX - Social networking Service