function get_albums() { $images = Album::load_all($_SESSION['user']['id'], IMAGE_ALBUM); $audios = Album::load_all($_SESSION['user']['id'], AUDIO_ALBUM); $videos = Album::load_all($_SESSION['user']['id'], VIDEO_ALBUM); return array('images' => $images, 'audios' => $audios, 'videos' => $videos); }
function render() { global $current_theme_path; if ($this->contentcollection_type == '1') { // if contentcolectin is group $data = $this->media_data; } else { $data = $this->media_data; if ($data->type == IMAGE) { $this->media_type = 'Image'; if (strstr($data->image_file, "http://")) { $this->image_path = $data->image_file; $this->image_show = getimagehtml($this->image_path, 300, 250, "", $this->image_path); } else { $this->image_path = "files/" . $data->image_file; } if ($this->contentcollection_type == 2) { $image_albums = Album::load_all($this->uid, IMAGE_ALBUM); $this->links = $image_albums; } } else { if ($data->type == AUDIO) { $this->media_type = 'Audio'; $this->image_path = "{$current_theme_path}/images/audio_img.jpg"; if ($this->contentcollection_type == 2) { $audio_albums = Album::load_all($this->uid, AUDIO_ALBUM); $this->links = $audio_albums; } } else { if ($data->type == VIDEO) { $this->media_type = 'Video'; $this->image_path = "{$current_theme_path}/images/video_img.jpg"; if ($this->contentcollection_type == 2) { $video_albums = Album::load_all($this->uid, VIDEO_ALBUM); $this->links = $video_albums; } } } } } if ($this->contentcollection_type == '1') { $this->inner_HTML = $this->generate_group_inner_html(); } else { $this->inner_HTML = $this->generate_inner_html(); } $content = parent::render(); return $content; }
/** !! * Figures out what type of media we're looking at, then sets a couple * internal variables, and then dispaches the flow to either * {@see generate_inner_html()} and {@see generate_group_inner_html()} * * @return string Content to be displayed. */ function render() { if ($this->contentcollection_type == '1') { // if contentcolectin is group $data = $this->media_data; } else { $data = $this->media_data; if ($data->type == IMAGE) { $this->media_type = 'Image'; $this->image_path = $data->image_file; if ($this->contentcollection_type == 2) { $image_albums = Album::load_all($this->uid, IMAGE_ALBUM); $this->links = $image_albums; } } else { if ($data->type == AUDIO) { $this->media_type = 'Audio'; $this->image_path = PA::$theme_url . "/images/audio_img.jpg"; if ($this->contentcollection_type == 2) { $audio_albums = Album::load_all($this->author_id, AUDIO_ALBUM); $this->links = $audio_albums; } } else { if ($data->type == TEK_VIDEO) { $this->media_type = 'Video'; $this->image_path = "files/" . $data->internal_thumbnail; if ($this->contentcollection_type == 2) { $video_albums = Album::load_all($this->uid, VIDEO_ALBUM); $this->links = $video_albums; } $data->file_perm = $data->video_perm; } } } } if ($this->contentcollection_type == '1') { $this->inner_HTML = $this->generate_group_inner_html(); } else { $this->inner_HTML = $this->generate_inner_html(); } $content = parent::render(); return $content; }
function generate_inner_html() { global $_PA; switch ($this->type) { case 'Videos': $alb_type = VIDEO_ALBUM; break; case 'Audios': $alb_type = AUDIO_ALBUM; break; default: // default to the image album if no type given // default to the image album if no type given case 'Images': $alb_type = IMAGE_ALBUM; break; } $all_albums = Album::load_all(PA::$login_uid, $alb_type); $default_name = $_PA->default_album_titles[$alb_type]; /* setting all the album for this page */ /* Retrive the All album of user */ $album = array(); $j = 0; if (!empty($all_albums)) { foreach ($all_albums as $alb) { $album[$j]['id'] = $alb['collection_id']; $album[$j]['name'] = $alb['description']; $j++; } $this->default_album_id = $album[0]['id']; $this->default_album_name = $album[0]['name']; } $this->my_all_album = $album; $tmp_file = dirname(__FILE__) . '/center_inner_public.tpl'; $inner_html_gen =& new Template($tmp_file); $inner_html_gen->set('my_all_album', $this->my_all_album); $inner_html_gen->set('default_name', $default_name); $inner_html_gen->set('back', $_SERVER['HTTP_REFERER']); $inner_html_gen->set('media_type', $this->type); $inner_html = $inner_html_gen->fetch(); return $inner_html; }
function generate_inner_html() { $user_id = PA::$login_uid; if (!empty($this->mode)) { $this->type = $this->mode; $user_id = !empty($this->user_id) ? $this->user_id : PA::$login_uid; } switch ($this->type) { case 'Videos': $gid = NULL; if (!empty($_GET['gid'])) { $gid = $_GET['gid']; } if (empty($this->mode)) { $TekMedia = new TekMedia(); $form_key = $TekMedia->generate_form($gid); } $alb_type = VIDEO_ALBUM; break; case 'Audios': $alb_type = AUDIO_ALBUM; break; default: // default to the image album if no type given // default to the image album if no type given case 'Images': $alb_type = IMAGE_ALBUM; break; case 'YouTube': $gid = NULL; if (!empty($_GET['gid'])) { $gid = $_GET['gid']; } if (empty($this->mode)) { $TekMedia = new TekMedia(); $form_key = $TekMedia->generate_form($gid); } $alb_type = VIDEO_ALBUM; break; } $all_albums = Album::load_all($user_id, $alb_type); $default_name = PA::$config->default_album_titles[$alb_type]; /* setting all the album for this page */ /* Retrive the All album of user */ $album = array(); $j = 0; if (!empty($all_albums)) { foreach ($all_albums as $alb) { $album[$j]['id'] = $alb['collection_id']; $album[$j]['name'] = $alb['description']; $j++; } $this->default_album_id = $album[0]['id']; $this->default_album_name = $album[0]['name']; } $this->my_all_album = $album; if ($this->mode == 'Videos') { if (@$this->view == 'remote') { $tmp_file = PA::$blockmodule_path . '/' . get_class($this) . '/ajax_form_video_upload.tpl'; } else { $tmp_file = PA::$blockmodule_path . '/' . get_class($this) . '/form_video_upload.tpl'; } $this->outer_template = 'empty_outer.tpl'; } else { $tmp_file = PA::$blockmodule_path . '/' . get_class($this) . '/center_inner_public.tpl'; } if (@$this->view == 'ajax') { switch ($this->mode) { case 'YouTube': $t = 'youtube'; break; case 'Videos': $t = 'video'; break; case 'Images': $t = 'image'; break; case 'Audios': $t = 'audio'; break; } if (!empty($t)) { $tmp_file = PA::$blockmodule_path . '/' . get_class($this) . '/ajax_' . $t . '.tpl.php'; } $this->outer_template = 'empty_outer.tpl'; } $inner_html_gen = new Template($tmp_file); $inner_html_gen->set('my_all_album', $this->my_all_album); $inner_html_gen->set('default_name', $default_name); $inner_html_gen->set('back', @$_SERVER['HTTP_REFERER']); $inner_html_gen->set('media_type', $this->type); if (!empty($form_key)) { $inner_html_gen->set('form_key', $form_key); } $inner_html = $inner_html_gen->fetch(); return $inner_html; }
function set_vars() { global $login_uid; /* For handling the Album according to thier type */ switch ($this->type) { case 'Images': $all_albums = Album::load_all($this->uid, IMAGE_ALBUM); break; case 'Videos': $all_albums = Album::load_all($this->uid, VIDEO_ALBUM); break; case 'Audios': $all_albums = Album::load_all($this->uid, AUDIO_ALBUM); break; default: // Treating Images are the default parameters break; } /* setting all the album for this page */ /* Retrive the All album of user */ $album = array(); $j = 0; if (!empty($all_albums)) { foreach ($all_albums as $alb) { $album[$j]['id'] = $alb['collection_id']; $album[$j]['name'] = $alb['title']; $j++; } $this->default_album_id = @$album[0]['id']; $this->default_album_name = @$album[0]['name']; $this->my_all_album = $album; } /* For handling Users Friend Album*/ if (isset($login_uid)) { /* Here we calculate all the relation (Friend's) Ids TODO: add a check to load it only when a user wants to see his friend's gallery */ /* $relations_ids = Relation::get_all_relations((int)$login_uid); $users = array(); $users_ids = array(); $users = Network::get_members(array('network_id'=>PA::$network_info->network_id)); if ( $users['total_users'] ) { for( $i = 0; $i < $users['total_users']; $i++) { $users_ids[] = $users['users_data'][$i]['user_id']; } } if (!empty($relations_ids)) { $cnt = count($relations_ids); for ($i = 0; $i < $cnt; $i++) { if (!in_array($relations_ids[$i]['user_id'], $users_ids)) { unset($relations_ids[$i]); } } } // extracting some name who are not member of that network ;) */ $relations_ids = Relation::get_all_relations((int) PA::$login_uid, 0, FALSE, 'ALL', 0, 'created', 'DESC', 'internal', APPROVED, PA::$network_info->network_id); /* Here varify that users has any relation or not ... as well as loads all album */ if (!empty($relations_ids)) { /* Here we get all the frnds list of login User */ $frnd_albums = array(); $i = 0; sortByFunc($relations_ids, create_function('$relations_ids', 'return $relations_ids["login_name"];')); foreach ($relations_ids as $frnd_id) { $frnd_list[$i]['name'] = $frnd_id['login_name']; $frnd_list[$i]['id'] = $frnd_id['user_id']; $i++; } } } // End of Friend Album $this->friend_list = @$frnd_list; // can be empty }
function uihelper_upload_gallery_for_group($uid, $type, $k = 0) { require_once "api/User/User.php"; require_once "api/Tag/Tag.php"; require_once "api/Album/Album.php"; require_once "api/Image/Image.php"; require_once "api/Audio/Audio.php"; require_once "api/Video/Video.php"; require_once "web/includes/classes/CNFileUploader.php"; $logged_in_user = get_login_user(); $user = new User(); $media_count_no = $k; $error_file = NULL; $uploaded = False; if ($type == '') { $file_type = "image"; $alb_type = IMAGE_ALBUM; $new_img = new Image(); $new_img->file_perm = @$_POST['image_perm']; } elseif ($type == '_audio') { $file_type = "audio"; $alb_type = AUDIO_ALBUM; $new_img = new Audio(); $new_img->file_perm = @$_POST['audio_perm']; } elseif ($type == '_video') { $file_type = "video"; $alb_type = VIDEO_ALBUM; $new_img = new Video(); $new_img->file_perm = @$_POST['video_perm']; } //file uploading start $file_name_dynamic = "userfile{$type}" . "_" . "{$k}"; $file_name_dynamic_type = $file_name_dynamic; //"$file_name_dynamic"."$type"; $newname = $_FILES[$file_name_dynamic_type]['name']; $uploadfile = PA::$upload_path . basename($_FILES[$file_name_dynamic_type]['name']); $myUploadobj = new FileUploader(); //creating instance of file. $image_type = "{$file_type}"; $value = $file_name_dynamic_type; $file = $myUploadobj->upload_file(PA::$upload_path, $value, true, true, $image_type); if ($file == false) { $msg = $myUploadobj->error; $error = TRUE; } else { $new_img->file_name = "{$file}"; $error_file = FALSE; } // file uploading end if (empty($error)) { try { $user->load((int) $uid); $action = !empty($_GET['action']) ? $_GET['action'] : 'upload'; $colls = Album::load_all($uid, $alb_type); if (isset($_POST['submit' . $type]) && $action != 'delete' && $error_file == FALSE) { $new_img->author_id = $uid; if ($type == '_audio') { $new_img->type = AUDIO; } elseif ($type == '_video') { $new_img->type = VIDEO; } else { $new_img->type = IMAGE; } if (empty($_POST['caption' . $type][$k])) { $ext = explode(".", $newname); $_POST['caption' . $type][$k] = $ext[0]; } $new_img->title = stripslashes(trim($_POST['caption' . $type][$k])); $new_img->title = strip_tags($new_img->title); $new_img->file_perm = ANYONE; $new_img->excerpt = stripslashes(trim($_POST['caption' . $type][$k])); $new_img->excerpt = strip_tags($new_img->excerpt); if (empty($_POST['body' . $type][$k])) { $new_img->body = ''; $new_img->body = strip_tags($new_img->body); } else { $new_img->body = stripslashes(trim($_POST['body' . $type][$k])); $new_img->body = strip_tags($new_img->body); } $new_img->allow_comments = 1; $new_img->parent_collection_id = $_POST['group_id']; $new_img->save(); if (!empty($_POST['tags' . $type][$media_count_no])) { $tag_array = Tag::split_tags($_POST['tags' . $type][$media_count_no]); Tag::add_tags_to_content($new_img->content_id, $tag_array); } } else { throw new CNException(USER_NOT_FOUND, 'unable to upload file.'); } if (!empty($msg)) { $uploaded = FALSE; } else { $uploaded = TRUE; if (isset($_REQUEST['gid'])) { $mail_type = "group_media_uploaded"; $new_img->group_id = $_REQUEST['gid']; } else { $mail_type = "media_uploaded"; } PANotify::send($mail_type, PA::$network_info, PA::$login_user, $new_img); } } catch (CNException $e) { $msg = "{$e->message}"; $error = TRUE; } } $array_of_error_message = array(@$error, @$msg, @$error_file, @$uploaded, 'collection_id' => $new_img->parent_collection_id, 'content_id' => $new_img->content_id); return $array_of_error_message; }
if ($_GET['status'] == 'TRUE') { $network_extra = unserialize(PA::$network_info->extra); $new_video = new TekVideo(); $new_video->file_name = $_GET['video_id']; $new_video->author_id = PA::$login_uid; $new_video->title = !empty($_GET['title']) ? $_GET['title'] : ''; $new_video->body = !empty($_GET['description']) ? $_GET['description'] : ''; $new_video->email_id = PA::$user->email; $new_video->allow_comments = 1; if (!empty($_GET['group_id'])) { $perm = 1; $album = $_GET['group_id']; } else { $perm = !empty($_GET['video_perm']) ? $_GET['video_perm'] : 1; // get the actual album for this user!!! $video_albums = Album::load_all(PA::$login_uid, VIDEO_ALBUM); if (!empty($video_albums[0])) { $album = $video_albums[0]['collection_id']; } else { // we need to create one $new_al = new Album(VIDEO_ALBUM); $new_al->author_id = PA::$login_uid; $new_al->type = 2; $new_al->description = $new_im_al->name = $new_al->title = PA::$config->default_album_titles[VIDEO_ALBUM]; $new_al->save(); $album = $new_al->collection_id; } } $new_video->video_perm = $new_video->file_perm = $perm; $new_video->parent_collection_id = $album; $new_video->save();
} } } catch (PAException $e) { $msg = "{$e->message}"; $error = TRUE; } // FOR VIDEO UPLOAD - START if ($_POST['submit_video'] && !empty($_FILES['userfile_video']['name'])) { $upload = uihelper_upload_gallery($uid, $_POST, $_FILES, '_video'); if ($upload[3] == TRUE) { $uploaded = TRUE; $msg1 = "Video Uploaded"; } } // Load Video Albums $video_albums = Album::load_all($uid, VIDEO_ALBUM); $video_data = array(); $j = 0; foreach ($video_albums as $albums) { $new_album = new Album(VIDEO_ALBUM); $video_data[$j]['album_name'] = $albums['description']; $video_data[$j]['album_id'] = $albums['collection_id']; $new_album->collection_id = $albums['collection_id']; $video_ids = $new_album->get_contents_for_collection(); if (!empty($video_ids)) { $k = 0; $ids = array(); for ($i = 0; $i < count($video_ids); $i++) { $ids[$i] = $video_ids[$i]['content_id']; } $new_video = new Video();
function get_user_albums() { switch ($this->album_type) { case IMAGE_ALBUM: $caption = 'Default Image Album'; break; case AUDIO_ALBUM: $caption = 'Default Audio Album'; break; case VIDEO_ALBUM: $caption = 'Default Video Album'; break; } $albums = Album::load_all($_SESSION['user']['id'], $this->album_type); if (count($albums) == 0) { $Album = new Album($this->album_type); $Album->author_id = $_SESSION['user']['id']; $Album->type = 2; $Album->title = $caption; $Album->name = $caption; $Album->description = $caption; $Album->save(); $albums = Album::load_all($_SESSION['user']['id'], $this->album_type); } return $albums; }
} } } catch (PAException $e) { $msg = "{$e->message}"; $error = TRUE; } // FOR AUDIO UPLOAD - START if ($_POST['submit_audio'] && !empty($_FILES['userfile_audio']['name'])) { $upload = uihelper_upload_gallery($uid, $_POST, $_FILES, '_audio'); if ($upload[3] == TRUE) { $uploaded = TRUE; $msg1 = "Image Uploaded"; } } // Load Audio Albums $audio_albums = Album::load_all($uid, AUDIO_ALBUM); $audio_data = array(); $j = 0; foreach ($audio_albums as $albums) { $new_album = new Album(AUDIO_ALBUM); $audio_data[$j]['album_name'] = $albums['description']; $audio_data[$j]['album_id'] = $albums['collection_id']; $new_album->collection_id = $albums['collection_id']; $audio_ids = $new_album->get_contents_for_collection(); if (!empty($audio_ids)) { $k = 0; $ids = array(); for ($i = 0; $i < count($audio_ids); $i++) { $ids[$i] = $audio_ids[$i]['content_id']; } $new_audio = new Audio();
function peopleaggregator_getAlbums($args) { if (!empty($args['authToken'])) { $user = User::from_auth_token($args['authToken']); $display_user_id = $auth_user_id = $user->user_id; } else { $user = $display_user_id = $auth_user_id = NULL; } $context = $args['context']; $show_personal = $show_group = FALSE; if (preg_match("/^user:(\\d+)\$/", $context, $m)) { $show_personal = TRUE; $display_user_id = (int) $m[1]; } else { if (empty($user)) { throw new PAException(OPERATION_NOT_PERMITTED, "'user', 'group' and 'all' contexts are not allowed for anonymous users"); } switch ($context) { case 'user': $show_personal = TRUE; break; case 'group': $show_group = TRUE; break; case 'all': $show_personal = $show_group = TRUE; break; default: throw new PAException(INVALID_ID, "context argument must be 'all', 'user' or 'group'"); } } $albums_out = array(); if ($show_personal) { $types_seen = array(); // get personal albums $albums = Album::load_all($display_user_id); foreach ($albums as $album) { $types_seen[(int) $album['album_type_id']] = TRUE; $albums_out[] = array('id' => "user:{$display_user_id}:album:" . $album['collection_id'], 'title' => $album['description'], 'access' => $display_user_id == $auth_user_id ? "write" : "read", 'created' => $album['created'], 'type' => array(API::$album_type_from_id[(int) $album['album_type_id']])); } if ($display_user_id == $auth_user_id) { // We don't reliably create personal albums on user creation, so add them in here if necessary... foreach (array(IMAGE_ALBUM, AUDIO_ALBUM, VIDEO_ALBUM) as $alb_type) { if (!isset($types_seen[$alb_type])) { // insert default album for this type $albums_out[] = array('id' => "user:{$user->user_id}:album:default:" . API::$album_type_from_id[$alb_type], 'title' => PA::$config->default_album_titles[$alb_type], 'access' => "write", 'type' => array(API::$album_type_from_id[$alb_type])); } } } } if ($show_group) { // get group albums $groups = Group::get_user_groups($user->user_id, FALSE); foreach ($groups as $g) { $albums_out[] = array('id' => "group:" . $g['gid'], 'title' => $g['name'], 'access' => "write", 'type' => array("image", "audio", "video")); } } return array('success' => TRUE, 'albums' => $albums_out); }
} } } catch (PAException $e) { $msg = "{$e->message}"; $error = TRUE; } // FOR IMAGE UPLOAD - START if ($_POST['submit'] && !empty($_FILES['userfile']['name'])) { $upload = uihelper_upload_gallery($uid, $_POST, $_FILES, ''); if ($upload[3] == TRUE) { $uploaded = TRUE; $msg1 = "Image Uploaded"; } } // Load Image Albums $image_albums = Album::load_all($uid, IMAGE_ALBUM); $image_data = array(); $image_ids = array(); $j = 0; foreach ($image_albums as $albums) { $new_album = new Album(IMAGE_ALBUM); $image_data[$j]['album_name'] = $albums['description']; $image_data[$j]['album_id'] = $albums['collection_id']; $new_album->collection_id = $albums['collection_id']; $image_ids = $new_album->get_contents_for_collection(); if (!empty($image_ids)) { $k = 0; $ids = array(); for ($i = 0; $i < count($image_ids); $i++) { $ids[$i] = $image_ids[$i]['content_id']; }