/** * Constructor. For the given directory open the description file and * load all the titles and descriptions. * * @param string $dir Directory where Gallery is installated * @param string $albumName Name of the album to import (this also serves * as the name of the album's directory. * @todo still need to import capture/taken dates. */ public function __construct($dir, $albumName) { // initialize gallery $initFile = realpath($dir) . DIRECTORY_SEPARATOR . 'init.php'; if (!(include_once $initFile)) { throw new Exception("The Gallery could not be loaded ({$initFile})."); } // load the album $album = new Album(); if (!$album->load($albumName)) { throw new Exception("The album '{$albumName}' could not be found."); } // photoset info $this->_setName = $album->fields['title']; $this->_setDesc = $album->fields['description']; // photos $dirAlbum = realpath($album->getAlbumDir()) . DIRECTORY_SEPARATOR; foreach ($album->photos as $item) { // only upload photos (ignore albums and movies) if (!$item->isAlbum() && !$item->isMovie()) { $file = "{$dirAlbum}{$item->image->name}.{$item->image->type}"; $this->_files[] = $file; $this->_titles[$file] = $item->getCaption(); $this->_tags[$file] = self::splitKeywords($item->getKeyWords()); if ($item->getItemCaptureDate()) { $this->_dates[$file] = $item->getItemCaptureDate(); } if ($item->isHighlight()) { $this->_setPrimary = $file; } } } }
public static function add_default_media($user_id, $type = '', $network_info = NULL) { // global var $path_prefix has been removed - please, use PA::$path static variable require_once "api/CNUser/CNUser.php"; require_once "api/CNAlbum/CNAlbum.php"; require_once "api/CNImage/CNImage.php"; require_once "api/CNAudio/CNAudio.php"; require_once "api/CNVideo/CNVideo.php"; require_once "api/CNContentCollection/CNContentCollection.php"; //$extra contains networks extra information $extra = unserialize($network_info->extra); /** setting common variables according to media type */ if ($type == '') { $net_extra_ccid_str = $extra['user_defaults']['default_image_gallery']; $alb_type = IMAGE_ALBUM; $new_img = new CNImage(); } elseif ($type == '_audio') { $net_extra_ccid_str = $extra['user_defaults']['default_audio_gallery']; $alb_type = AUDIO_ALBUM; $new_img = new CNAudio(); } elseif ($type == '_video') { $net_extra_ccid_str = $extra['user_defaults']['default_video_gallery']; $alb_type = VIDEO_ALBUM; $new_img = new CNVideo(); } /** getting array of content collection from comma separated string */ if (!empty($net_extra_ccid_str)) { $net_extra_ccid = explode(',', $net_extra_ccid_str); /** setting all content collection variables */ if (count($net_extra_ccid) >= 1) { for ($i = 0; $i < count($net_extra_ccid); $i++) { $new_im_al = new Album($alb_type); $new_im_al_default = new Album($alb_type); $new_im_al->load((int) $net_extra_ccid[$i]); $content_collection_obj = new ContentCollection(); $content_collection_obj->collection_id = $new_im_al->collection_id; $contents = $content_collection_obj->get_contents_for_collection(); $new_im_al_default->title = $new_im_al->title; $new_im_al_default->description = $new_im_al->description; $new_im_al_default->author_id = $user_id; $new_im_al_default->type = 2; // FOR ALBUM, type is 2 $new_im_al_default->save(); /** Setting content variable */ for ($j = 0; $j < count($contents); $j++) { if ($contents[$j]['type'] != 7) { // If content is not a SB content if ($alb_type == IMAGE_ALBUM) { $new_img_default = new CNImage(); $new_img_default->type = IMAGE; } elseif ($alb_type == AUDIO_ALBUM) { $new_img_default = new CNAudio(); $new_img_default->type = AUDIO; } elseif ($alb_type == VIDEO_ALBUM) { $new_img_default = new CNVideo(); $new_img_default->type = VIDEO; } $new_img->load((int) $contents[$j]['content_id']); $new_img_default->file_name = $new_img->file_name; $new_img_default->file_perm = $new_img->file_perm; $new_img_default->title = $contents[$j]['title']; $new_img_default->body = $contents[$j]['body']; $tags = Tag::load_tags_for_content($contents[$j]['content_id']); $new_img_default->allow_comments = 1; $new_img_default->author_id = $user_id; $new_img_default->parent_collection_id = $new_im_al_default->collection_id; $new_img_default->save(); if (!empty($tags)) { $tag_array = array(); if (is_array($tags)) { for ($i = 0; $i < count($tags); $i++) { $tag_array[] = $tags[$i]['name']; } } Tag::add_tags_to_content($new_img_default->content_id, $tag_array); } } else { // If content is a SB content //TODO: handling of SB content if it is in media gallery. } } } } } }
function generate_inner_html() { global $login_uid; if (!isset($_GET['gid']) || empty($_GET['gid'])) { parent::set_vars(); $frnd_list = null; if (!empty($_GET['view'])) { $frnd_list = $this->friend_list; } $sb_audios = array(); $new_album = new Album(AUDIO_ALBUM); if ($this->album_id) { $new_album = new Album(); $new_album->album_type = AUDIO_ALBUM; $new_album->load((int) $this->album_id); $audio_data['album_id'] = $new_album->collection_id; $audio_data['album_name'] = $new_album->title; } else { $new_album->collection_id = $this->default_album_id; $audio_data['album_id'] = $this->default_album_id; $audio_data['album_name'] = $this->default_album_name; } $audio_ids = $new_album->get_contents_for_collection(); if (!empty($audio_ids)) { $k = 0; $ids = array(); for ($i = 0; $i < count($audio_ids); $i++) { if ($audio_ids[$i]['type'] != 7) { // Type 7 is for SB Content $ids[$i] = $audio_ids[$i]['content_id']; } else { $tags = Tag::load_tags_for_content($audio_ids[$i]['content_id']); $tags = show_tags($tags, null); //show_tags function is defined in uihelper.php $sb_audios[] = array('content_id' => $audio_ids[$i]['content_id'], 'title' => $audio_ids[$i]['title'], 'type' => $audio_ids[$i]['type'], 'created' => $audio_ids[$i]['created'], 'tags' => $tags); } } $new_audio = new Audio(); $data = $new_audio->load_many($ids, $this->uid, $login_uid); if (count($data) > 0) { foreach ($data as $d) { $audio_data[$k]['content_id'] = $d['content_id']; $audio_data[$k]['audio_file'] = $d['audio_file']; $audio_data[$k]['audio_caption'] = $d['audio_caption']; $audio_data[$k]['title'] = $d['title']; $audio_data[$k]['body'] = $d['body']; $audio_data[$k]['created'] = $d['created']; $audio_data[$k]['tags'] = $d['tags']; $audio_data[$k]['type'] = ""; $k++; } } // Merging Media Gallery content and SB Content for ($counter = 0; $counter < count($sb_audios); $counter++) { $audio_data[$k]['content_id'] = $sb_audios[$counter]['content_id']; $audio_data[$k]['title'] = $sb_audios[$counter]['title']; $audio_data[$k]['type'] = $sb_audios[$counter]['type']; $audio_data[$k]['image_caption'] = $sb_audios[$counter]['title']; $audio_data[$k]['created'] = $sb_audios[$counter]['created']; $audio_data[$k]['tags'] = $sb_audios[$counter]['tags']; $k++; } } if (!empty($_GET['view'])) { if (empty($frnd_list)) { $audio_data = NULL; } } $inner_template = NULL; switch ($this->mode) { default: $inner_template = dirname(__FILE__) . '/center_inner_public.tpl'; } $obj_inner_template =& new Template($inner_template); $obj_inner_template->set('links', $audio_data); $obj_inner_template->set('uid', $this->uid); $obj_inner_template->set('frnd_list', $frnd_list); $obj_inner_template->set('my_all_album', $this->my_all_album); $obj_inner_template->set('show_view', $this->show_view); $inner_html = $obj_inner_template->fetch(); return $inner_html; } else { parent::set_group_media_gallery(); //------------- Handling the Groups Media gallery ----------- $group = ContentCollection::load_collection((int) $_GET['gid'], $_SESSION['user']['id']); $audio_data = Audio::load_audios_for_collection_id($_GET['gid'], $limit = 0); $audio_data['album_id'] = $group->collection_id; $audio_data['album_name'] = $group->title; $inner_template = NULL; switch ($this->mode) { default: $inner_template = dirname(__FILE__) . '/center_inner_public_groups.tpl'; } $obj_inner_template =& new Template($inner_template); $obj_inner_template->set('links', $audio_data); $obj_inner_template->set('show_view', $this->show_view); $obj_inner_template->set('my_all_groups', $this->group_ids); $inner_html = $obj_inner_template->fetch(); return $inner_html; } }
function api_validate_album_context($context, $user, $access = "write") { if (preg_match("/^group:(\\d+)\$/", $context, $m)) { // group album $collection_id = $m[1]; // load group and verify access $obj = new Group(); $obj->load($collection_id); $obj->assert_user_access($user->user_id); } elseif (preg_match("/^user:\\d+:album:(\\d+)\$/", $context, $m)) { // personal album $collection_id = $m[1]; // load album and verify access $obj = new Album(); $obj->load($collection_id); if ($access != "read") { if ($obj->author_id != $user->user_id) { throw new PAException(USER_ACCESS_DENIED, "You are not the creator of this album"); } } } else { throw new PAException(INVALID_ID, "File context must be an album or group ID"); } return array($collection_id, $obj); }
function generate_inner_html() { global $login_uid; $video_data = NULL; if (!isset($_GET['gid']) || empty($_GET['gid'])) { parent::set_vars(); $frnd_list = null; if (!empty($_GET['view'])) { $frnd_list = $this->friend_list; } $sb_videos = array(); $new_album = new Album(VIDEO_ALBUM); if ($this->album_id) { $new_album = new Album(); $new_album->album_type = VIDEO_ALBUM; $new_album->load($this->album_id); $album_data['album_id'] = $new_album->collection_id; $album_data['album_name'] = $new_album->title; } else { $new_album->collection_id = $this->default_album_id; $album_data['album_id'] = $this->default_album_id; $album_data['album_name'] = $this->default_album_name; } $params = $condition = array(); if (!empty(PA::$page_uid) || PA::$login_uid != PA::$page_uid) { $condition['M.video_perm'] = !empty($this->friend_list) && in_array(PA::$page_uid, $this->friend_list) ? array(WITH_IN_DEGREE_1, ANYONE) : ANYONE; } $condition['C.collection_id'] = $album_data['album_id']; $video_info = TekVideo::get($params, $condition); $video_ids = objtoarray($video_info); if (!empty($video_ids)) { $k = 0; $ids = array(); for ($i = 0; $i < count($video_ids); $i++) { if ($video_ids[$i]['type'] != 7) { // Type 7 is for SB Content $ids[$i] = $video_ids[$i]['content_id']; } else { $tags = Tag::load_tags_for_content($video_ids[$i]['content_id']); $tags = show_tags($tags, null); //show_tags function is defined in uihelper.php $sb_videos[] = array('content_id' => $video_ids[$i]['content_id'], 'title' => $video_ids[$i]['title'], 'type' => $video_ids[$i]['type'], 'created' => $video_ids[$i]['created'], 'tags' => $tags); } } if (count($video_ids) > 0) { $video_data = $video_ids; } // Merging Media Gallery content and SB Content for ($counter = 0; $counter < count($sb_videos); $counter++) { $video_data[$k]['content_id'] = $sb_videos[$counter]['content_id']; $video_data[$k]['title'] = $sb_videos[$counter]['title']; $video_data[$k]['type'] = $sb_videos[$counter]['type']; $video_data[$k]['video_caption'] = $sb_videos[$counter]['title']; $video_data[$k]['created'] = $sb_videos[$counter]['created']; $video_data[$k]['tags'] = $sb_videos[$counter]['tags']; $k++; } } if (!empty($_GET['view'])) { if (empty($frnd_list)) { $video_data = NULL; } } $inner_template = NULL; switch ($this->mode) { default: $inner_template = PA::$blockmodule_path . '/' . get_class($this) . '/center_inner_public.tpl'; } $obj_inner_template = new Template($inner_template); $obj_inner_template->set('links', $video_data); $obj_inner_template->set('album_data', $album_data); $obj_inner_template->set('uid', $this->uid); $obj_inner_template->set('frnd_list', $frnd_list); $obj_inner_template->set('my_all_album', $this->my_all_album); $obj_inner_template->set('show_view', $this->show_view); $inner_html = $obj_inner_template->fetch(); return $inner_html; } else { // ----- Calling parents function which set all the Require variables parent::set_group_media_gallery(); //------------- Handling the Groups Media gallery ----------- $group = ContentCollection::load_collection((int) $_GET['gid'], $_SESSION['user']['id']); $params = $condition = array(); $album_data['album_id'] = $group->collection_id; $album_data['album_name'] = $group->title; $condition['C.collection_id'] = $album_data['album_id']; $video_info = TekVideo::get($params, $condition); $video_data = objtoarray($video_info); // $video_data = Video::load_videos_for_collection_id ($_GET['gid'], $limit = 0); $i = 0; if (!empty($video_data)) { foreach ($video_data as $data) { $tags_array = Tag::load_tags_for_content($data['content_id']); $tags_string = ""; $tags_string = show_all_contents_for_tag($tags_array); $video_data[$i]['tags'] = $tags_string; $i++; } } $inner_template = NULL; switch ($this->mode) { default: $inner_template = PA::$blockmodule_path . '/' . get_class($this) . '/center_inner_public_groups.tpl'; } $obj_inner_template = new Template($inner_template); $obj_inner_template->set('links', $video_data); $obj_inner_template->set('album_data', $album_data); $obj_inner_template->set('show_view', $this->show_view); $obj_inner_template->set('my_all_groups', $this->group_ids); $inner_html = $obj_inner_template->fetch(); return $inner_html; } }
function generate_inner_html() { global $login_uid; if (!isset($_GET['gid']) || empty($_GET['gid'])) { parent::set_vars(); $frnd_list = null; if (!empty($_GET['view'])) { $frnd_list = $this->friend_list; } $sb_images = array(); $new_album = new Album(IMAGE_ALBUM); if ($this->album_id) { $new_album = new Album(); $new_album->album_type = IMAGE_ALBUM; $new_album->load($this->album_id); $image_data['album_id'] = $new_album->collection_id; $image_data['album_name'] = $new_album->title; } else { $new_album->collection_id = $this->default_album_id; $image_data['album_id'] = $this->default_album_id; $image_data['album_name'] = $this->default_album_name; } $image_ids = $new_album->get_contents_for_collection(); $k = 0; $ids = array(); if (!empty($image_ids)) { for ($i = 0; $i < count($image_ids); $i++) { if ($image_ids[$i]['type'] != 7) { // Type 7 is for SB Content $ids[$i] = $image_ids[$i]['content_id']; } else { $var = $image_ids[$i]['body']; $start = strpos($var, '<image>') + 7; if ($start > 7) { $end = strpos($var, '</image>'); $image_src = substr($var, $start, $end - $start); $tags = Tag::load_tags_for_content($image_ids[$i]['content_id']); $tags = show_tags($tags, null); //show_tags function is defined in uihelper.php $sb_images[] = array('content_id' => $image_ids[$i]['content_id'], 'title' => $image_ids[$i]['title'], 'type' => $image_ids[$i]['type'], 'created' => $image_ids[$i]['created'], 'tags' => $tags, 'image_src' => $image_src); } } } $new_image = new Image(); $data = $new_image->load_many($ids, $this->uid, $login_uid); if (count($data) > 0) { foreach ($data as $d) { $image_data[$k]['content_id'] = $d['content_id']; $image_data[$k]['image_file'] = $d['image_file']; $image_data[$k]['image_caption'] = $d['image_caption']; $image_data[$k]['title'] = $d['title']; $image_data[$k]['body'] = $d['body']; $image_data[$k]['created'] = $d['created']; $image_data[$k]['type'] = ""; $tags_array = Tag::load_tags_for_content($d['content_id']); $tags_string = ""; $tags_string = show_all_contents_for_tag($tags_array); $image_data[$k]['tags'] = $tags_string; $k++; } } // Merging Media Gallery content and SB Content for ($counter = 0; $counter < count($sb_images); $counter++) { $image_data[$k]['content_id'] = $sb_images[$counter]['content_id']; $image_data[$k]['title'] = $sb_images[$counter]['title']; $image_data[$k]['type'] = $sb_images[$counter]['type']; $image_data[$k]['image_caption'] = $sb_images[$counter]['title']; $image_data[$k]['created'] = $sb_images[$counter]['created']; $image_data[$k]['tags'] = $sb_images[$counter]['tags']; $image_data[$k]['image_src'] = $sb_images[$counter]['image_src']; $k++; } } if (!empty($_GET['view'])) { if (empty($frnd_list)) { $image_data = NULL; } } $inner_template = NULL; switch ($this->mode) { default: $inner_template = PA::$blockmodule_path . '/' . get_class($this) . '/center_inner_public.tpl'; } $obj_inner_template = new Template($inner_template); $obj_inner_template->set('links', $image_data); $obj_inner_template->set('frnd_list', $frnd_list); $obj_inner_template->set('uid', $this->uid); $obj_inner_template->set('my_all_album', $this->my_all_album); $obj_inner_template->set('show_view', $this->show_view); $inner_html = $obj_inner_template->fetch(); return $inner_html; } else { parent::set_group_media_gallery(); //------------- Handling the Groups Media gallery ----------- $group = ContentCollection::load_collection((int) $_GET['gid'], $_SESSION['user']['id']); $image_data = Image::load_images_for_collection_id($_GET['gid'], $limit = 0); $i = 0; if (!empty($image_data)) { foreach ($image_data as $data) { $tags_array = Tag::load_tags_for_content($data['content_id']); $tags_string = ""; $tags_string = show_all_contents_for_tag($tags_array); $image_data[$i]['tags'] = $tags_string; $i++; } } $image_data['album_id'] = $group->collection_id; $image_data['album_name'] = $group->title; $inner_template = NULL; switch ($this->mode) { default: $inner_template = PA::$blockmodule_path . '/' . get_class($this) . '/center_inner_public_groups.tpl'; } $obj_inner_template = new Template($inner_template); $obj_inner_template->set('links', $image_data); $obj_inner_template->set('my_all_groups', $this->group_ids); $obj_inner_template->set('show_view', $this->show_view); $inner_html = $obj_inner_template->fetch(); return $inner_html; } }