'; $user = new User(); $user->load((int)$uid); //header if ($_GET['tier_one']) { $main_tier = $_GET['tier_one']; //$tmp = $_GET['tier_one'].'pagedemo.php'; } else { $main_tier = 'media-gallery'; } if ($_GET['upload']==1) { $onload = "show_hide('images-upload', 'images-thumb', 'images-list'); show_hide('audios-upload', 'audios-thumb', 'audios-list'); show_hide('videos-upload', 'videos-thumb', 'videos-list');"; $show_array = array('show'=>'images-upload', 'hide1'=>'images-thumb', 'hide2'=>'images-list'); } if($_POST) { /* Function for Filtering the POST data Array */ filter_all_post(&$_POST, TRUE); } $image_extensions = array('.png', 'jpeg', '.jpg', '.gif', '.xpm', '.bmp'); // FOR IMAGE UPLOAD - START for ($k=0; $k'images-upload', 'hide1'=>'images-thumb', 'hide2'=>'images-list'); } else if ($_POST['submit'] && ($_POST['media_type'] == 'image') && (!empty($_FILES[$file_name_dynamic]['name'][$k]) || !empty($_POST['userfile_url_'.$k])) && ($_SESSION['user']['id'])) { $upload = uihelper_upload_gallery ($uid, $_POST, $_FILES, '', $k); if ($upload[3] == TRUE) { $uploaded = TRUE; $msg1 = "Images Uploaded"; } else { $msg1 = $upload[1]; //index 1 has the error message $onload = "show_hide('images-upload', 'images-thumb', 'images-list');"; $show_array = array('show'=>'images-upload', 'hide1'=>'images-thumb', 'hide2'=>'images-list'); } } else if ($_POST['submit'] && ($_POST['media_type'] == 'image') && empty($_FILES[$file_name_dynamic]['name'][$k]) && empty($_POST['userfile_url_'.$k]) && ($k==0) && ($_SESSION['user']['id']) && (($k!=0 && $no_data_filled == TRUE) || ($k==0 && $no_data_filled == FALSE))) { $upload[1] = "Select any image file to upload"; $onload = "show_hide('images-upload', 'images-thumb', 'images-list');"; $show_array = array('show'=>'images-upload', 'hide1'=>'images-thumb', 'hide2'=>'images-list'); } $upload_array[$k]=$upload; } // FOR AUDIO UPLOAD - START //print '
'; print_r($_POST); print_r($_FILES); exit;
for ($k=0; $k'audios-upload', 'hide1'=>'audios-thumb', 'hide2'=>'audios-list');
    }
  }
  else if ($_POST['submit_audio'] && ($_POST['media_type'] == 'audio') && empty($_FILES[$file_name_dynamic]['name']) && empty($_POST['userfile_audio_url_'.$k]) && ($_SESSION['user']['id']) && (($k!=0 && $no_data_filled == TRUE) || ($k==0 && $no_data_filled == FALSE))) {
    $upload[1] = "Select any audio file to upload";
    $onload = "show_hide('audios-upload', 'audios-thumb', 'audios-list');";
    $show_array = array('show'=>'audios-upload', 'hide1'=>'audios-thumb', 'hide2'=>'audios-list');
  }
  $upload_array[$k]=$upload;
}

// FOR VIDEO UPLOAD - START
//print '
'; print_r($_POST); print_r($_FILES); exit;
for ($k=0; $k'videos-upload', 'hide1'=>'videos-thumb', 'hide2'=>'videos-list');
    }
  }
  else if ($_POST['submit_video'] && ($_POST['media_type'] == 'video') && empty($_FILES[$file_name_dynamic]['name']) && empty($_POST['userfile_video_url_'.$k]) && ($_SESSION['user']['id']) && (($k!=0 && $no_data_filled == TRUE) || ($k==0 && $no_data_filled == FALSE))) {
    $upload[1] = "Select any video file to upload";
    $onload = "show_hide('videos-upload', 'videos-thumb', 'videos-list');";
    $show_array = array('show'=>'videos-upload', 'hide1'=>'videos-thumb', 'hide2'=>'videos-list');
  }
  $upload_array[$k]=$upload;
}


// deleting images
try {
  if(($_GET['action']=='delete') && ($_SESSION['user']['id'])) {

    if ($_GET['type'] == 'image') {
      foreach ($_POST as $k=>$v) {
        $delete_pics_id[] = $k;
      }
      //print_r($delete_pics_id); exit;
      array_pop($delete_pics_id);

      foreach ($delete_pics_id as $id) {
        $new_image = new Image();
        $new_image->content_id = $id;
        $new_image->delete($id);
      }
      $msg1 = "Images Deleted";
    }

    if ($_GET['type'] == 'audio') {
      foreach ($_POST as $k=>$v) {
        $delete_audios_id[] = $k;
      }
      array_pop($delete_audios_id);
      foreach ($delete_audios_id as $id) {
        $new_image = new Audio();
        $new_image->content_id = $id;
        $new_image->delete($id);
      }
      $msg1 = "Audios Deleted";
    }

    if ($_GET['type'] == 'video') {
      foreach ($_POST as $k=>$v) {
        $delete_videos_id[] = $k;
      }
      array_pop($delete_videos_id);
      foreach ($delete_videos_id as $id) {
        $new_image = new Video();
        $new_image->content_id = $id;
        $new_image->delete($id);
      }
      $msg1 = "Videos Deleted";
    }
  }
}
catch (PAException $e) {
   $msg = "$e->message";
   $error = TRUE;
}

// Loading user relations (relation ids)
$relations_ids = Relation::get_all_relations((int)$_SESSION['user']['id']);
//$relations_ids = Relation::get_all_relations((int)$_SESSION['user']['id']);

// Loading user groups (whom user is a member)
$group_ids = Group::get_user_groups ($_SESSION['user']['id']);


function setup_module($column, $moduleName, $obj) {

    global $uid, $upload_array, $show_array, $relations_ids, $user;

    switch ($column) {
    case 'left':
	if ($moduleName != 'LogoModule') {
	    $obj->block_type = HOMEPAGE;
	}
	$obj->uid = $uid;
	break;

    case 'middle':
	$obj->content_id = $_REQUEST['cid'];
	$obj->uid = $uid;
	$obj->block_type = 'media_management';
	$obj->error = $upload_array;
	$obj->upload_media_type = $_POST['media_type'];
	$obj->show_array = $show_array;
	$obj->relations_ids = $relations_ids;
	break;

    case 'right':
	if ($moduleName=='UserPhotoModule') {
	    $obj->block_type = 'UserPhotoBlock';
	    $obj->picture = $user->picture;
	}
	if ($moduleName != 'AdsByGoogleModule') {
	    $obj->block_type = HOMEPAGE;
	}
	break;
    }
}



$page = new PageRenderer("setup_module", PAGE_MEDIA_GALLERY, "Media Gallery - PeopleAggregator", "media_gallery_pa.tpl", "header.tpl", PUB, NULL, $network_info, $onload);
$page->header->set('relations_ids',$relations_ids);
// hack to reorder the middle modules depending on which we want to show first
if ($_POST['submit_audio'] || ($_GET['show_first'] == 'audio')) {
  $page->rotate_modules("middle");
}
else if ($_POST['submit_video'] || ($_GET['show_first'] == 'video')) {
  $page->rotate_modules("middle", 2);
}

if (!empty($msg1)) {
  $msg_tpl = & new Template(CURRENT_THEME_FSPATH."/display_message.tpl");
  $msg_tpl->set('message', $msg1);
  $page->add_module("middle", "top", $msg_tpl->fetch());
}

echo $page->render();

?>