Location: PHPKode > projects > NetworX - Social networking Service > video_albums.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())
{

	if (isset($_GET['action']) && $_GET['action'] == 'delete')
	{
		$video_album_for_deleting = new VideoAlbum($_GET['video_album_id']);
        if ($video_album_for_deleting->checkPermission('delete'))
        {
            $video_album_for_deleting->delete();
		}
        else
        {
            cmn_unathorized_action();
        }
    }

    $type   = $_GET['type'] ? $_GET['type'] : 'user';
    $id     = $_GET['id'] ? $_GET['id'] : $user->UserID;

	switch ($type)
	{
		case 'user':
			if ($user->UserID == $id)
			{
				$template->touchBlock('addlink');
			}
			break;

		case 'organization':
		case 'community':

			$owner = Entity::getObject($type, $id);
			if ($owner->hasMember($user->UserID))
			{
				$template->touchBlock('addlink');
			}
			break;

		case 'group':
			$owner = Entity::getObject($type, $id);
            
            if ($owner->userIsAdmin($user->UserID) || $owner->{ucfirst($type) . 'Status'} == GROUP_STATUS_PUBLIC)
            {
                if ($owner->hasMember($user->UserID))
                {
                    $template->touchBlock('addlink');
                }
            }
	}

    $template->setGlobalVariable('type', $type);
    $template->setGlobalVariable('id',   $id);
    if (strtolower($type) != 'user')
    {
        $template->setVariable('Entity', $type);
        $template->setVariable('EntityID',   $id);
        $template->parse('back_link');
    }
	$video_albums = VideoAlbum::getVideoAlbumsByType($type, $id);

	foreach ($video_albums as $video_album)
	{
        if ($video_album->checkPermission('view'))
        {
            $template->setVariable(get_object_vars($video_album));
            $template->setGlobalVariable('VideoAlbumID', $video_album->VideoAlbumID);
            $template->setVariable('VideoAlbumVideoCount', $video_album->getVideosCount());
            if ($video_album->checkPermission('edit'))
            {
                $template->parse("editlink");
            }
            $template->setVariable('VideoAlbumCoverURL', $video_album->getCover());
			$template->parse("video_album");
		}
	}

	$template->parse("addlink");

	$tab = $_GET['tab'] ? $_GET['tab'] : 0;
	$template->setVariable('tab', $tab);
}
else
{
    cmn_unathorized_action();
}
include('includes/application_bottom.php');
?>
Return current item: NetworX - Social networking Service