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. } } } } } }
$cid = $_GET['cid']; if ($obj_content_type->type) { switch ($obj_content_type->type) { case 'Image': $show_media = new Image(); break; case 'Audio': $show_media = new Audio(); break; case 'Video': $show_media = new Video(); break; } $show_media->load($cid); // loading tags for media $tags_array = Tag::load_tags_for_content($show_media->content_id); $tags_string = ""; if (count($tags_array) > 0) { for ($counter = 0; $counter < count($tags_array); $counter++) { $tags_string .= $tags_array[$counter]['name'] . ", "; } $tags_string = substr($tags_string, 0, strlen($tags_string) - 2); } $show_media->tags = $tags_string; // loading content's contentcollection information $cc_info = ContentCollection::load_collection($show_media->parent_collection_id, $_SESSION['user']['id']); } } if ($uid == $_SESSION['user']['id']) { global $network_info; $extra = unserialize($network_info->extra);
/** * Loads micro-content data from content,contentcollection,tags tables * @access protected * @param int content_id ID of micro-content */ protected function load($content_id) { Logger::log("Enter: Content::load() | Args: \$content_id = {$content_id}"); // get micro-content data from DB $sql = "SELECT C.content_id AS content_id, C.author_id AS author_id, C.type AS type, C.title AS title, C.body AS body, C.allow_comments AS allow_comments, C.created AS created, C.changed AS changed, C.trackbacks as trackbacks, C.is_active AS is_active, C.is_html AS is_html FROM {contents} AS C WHERE C.content_id = ? AND C.is_active <> ?"; $data = array($content_id, DELETED); $res = Dal::query($sql, $data); // fetch rows if ($res->numRows()) { $row = $res->fetchRow(DB_FETCHMODE_ASSOC); foreach ($row as $key => $value) { $this->{$key} = $value; } $res = Dal::query("SELECT collection_id FROM {contents} WHERE content_id = ?", array($this->content_id)); if ($res->numRows()) { $row = $res->fetchRow(DB_FETCHMODE_OBJECT); $this->parent_collection_id = $row->collection_id; } } else { Logger::log("No content found with content_id = {$content_id}", LOGGER_ERROR); // Throw "not found" exception throw new PAException(CONTENT_NOT_FOUND, "No such content"); } // get tags associated with micro-content $this->tags = Tag::load_tags_for_content($this->content_id); $author = new User(); $author->load((int) $this->author_id); $this->author = $author; Logger::log("Exit: Content::load()"); return; }
function uihelper_generate_center_content_permalink($cid, $show = 0) { global $app; $image_media_gallery = FALSE; $back_page = PA::$url . $app->current_route; $content = CNContent::load_content((int) $cid, (int) PA::$login_uid); // filter content fields for output $content->title = _out($content->title); $content->body = _out($content->body); if (strstr($back_page, PA_ROUTE_CONTENT) || strstr($back_page, PA_ROUTE_PERMALINK)) { if ($content->parent_collection_id > 0) { $collection = ContentCollection::load_collection((int) $content->parent_collection_id, PA::$login_uid); if ($collection->type == GROUP_COLLECTION_TYPE) { $back_page = PA::$url . PA_ROUTE_GROUP . "/gid=" . $content->parent_collection_id; } else { $back_page = PA::$url . PA_ROUTE_MEDIA_GALLEY_IMAGES . "/uid=" . $content->author_id; } // IF permalink content is a group content redirect to group homepage } else { //if coming from permalink page then redirect to user page $back_page = PA::$url . PA_ROUTE_USER_PRIVATE; } } $moderateduser = Group::is_admin((int) $content->parent_collection_id, (int) PA::$login_uid) ? 1 : 0; $back_page = urlencode($back_page); if (!$content->is_html) { $content->body = nl2br($content->body); } $media_gallery_content = NULL; $media_gallery_content = in_array(trim($content->type), array('Image', 'Audio', 'Video')); $editable = PA::$login_uid == $content->author_id || $moderateduser; $comments = Comment::get_comment_for_content($cid, '', 'ASC'); $number_of_comments = count($comments); $content->no_of_comments = $number_of_comments; $trackback = CNContent::get_trackbacks_for_content($cid); $number_of_trackbacks = count($trackback); $content->no_of_trackbacks = $number_of_trackbacks; $content->trackback_url = PA::$url . "/pa_trackback.php?cid=" . $cid; $content_user = new User(); $content_user->load((int) $content->author_id); $content->create_time = PA::date($content->changed, 'long'); // date("l, F d, Y", $content->changed); $tags = Tag::load_tags_for_content($cid); if ($tags) { $t = array(); for ($i = 0; $i < count($tags); $i++) { $name = _out($tags[$i]['name']); $uid = PA::$login_uid; $url = PA::$url . '/' . FILE_TAG_SEARCH . '?name_string=content_tag&keyword=' . $tags[$i]["name"]; $t[] = "<a href={$url}>" . $name . "</a>"; } $tag_string = "<b>Tags : </b>" . implode(", ", $t); } else { $tag_string = ""; } $content->tag_entry = $tag_string; if (property_exists($content, 'sbname')) { if (substr($content->sbname, 0, 5) == 'event') { $content->type = 'SBEvent'; } elseif (substr($content->sbname, 0, 6) == 'review') { $content->type = 'Review'; } elseif (substr($content->sbname, 0, 11) == 'media/audio') { $content->type = 'Audio'; } elseif (substr($content->sbname, 0, 11) == 'media/video') { $content->type = 'Video'; } elseif (substr($content->sbname, 0, 11) == 'media/image') { $content->type = 'Image'; } elseif (substr($content->sbname, 0, 14) == 'showcase/group') { $content->type = 'GroupShowCase'; } elseif (substr($content->sbname, 0, 15) == 'showcase/person') { $content->type = 'PersonShowCase'; } } // replace magic strings $content->replace_percent_strings(PA::$url); $type = $content->type; $type = $type . 'Permalink'; // comments $comments_list_tpl = new Template(CURRENT_THEME_FSPATH . "/cncontent_comments.php"); $comments_list_tpl->set('current_theme_path', PA::$theme_url); $comments_list_tpl->set('comments', $comments); $comments_list_tpl->set('author_id', $content->author_id); // Setting the variable for the abuse form ... $comments_list = $comments_list_tpl->fetch(); //comment form $cnform_comment_tpl = new Template(CURRENT_THEME_FSPATH . "/cnform_comment.php"); $cnform_comment_tpl->set('current_theme_path', PA::$theme_url); if (isset(PA::$login_uid)) { $user = new User(); $user->load((int) PA::$login_uid); $login_name = $user->login_name; $cnform_comment_tpl->set('name', $login_name); $cnform_comment_tpl->set('login_name', $user->login_name); } $cnform_comment_tpl->set('cid', $cid); if ($content->parent_collection_id > 0) { $cnform_comment_tpl->set('ccid', $content->parent_collection_id); } // abuse form $cnform_abuse_tpl = new Template(CURRENT_THEME_FSPATH . "/cnform_abuse.php"); /* Permalink and edit links for content */ if ($content->parent_collection_id != -1) { $perma_link = PA::$url . PA_ROUTE_PERMALINK . "/cid=" . $content->content_id . '&ccid=' . $content->parent_collection_id; } else { $perma_link = PA::$url . PA_ROUTE_PERMALINK . "/cid=" . $content->content_id; } $params = array('permissions' => 'edit_content', 'uid' => PA::$login_uid, 'cid' => $content->content_id); if (PermissionsHandler::can_user(PA::$login_uid, $params)) { if ($media_gallery_content) { $edit_link = PA::$url . '/edit_media.php?cid=' . $content->content_id; } else { $edit_link = PA::$url . "/cncontent_blog.php?cid=" . $content->content_id; } $delete_link = PA::$url . PA_ROUTE_CONTENT . "?action=deleteContent&cid=" . $content->content_id . '&back_page=' . $back_page; // handle Event separately if ($type == "EventPermalink") { $edit_link = PA::$url . '/calendar.php?cid=' . $content->content_id; $delete_link = $edit_link . "&delete=1" . '&back_page=' . $back_page; } } else { $edit_link = $delete_link = NULL; } $user_link = PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $content->author_id; /* Code for Approval and Denial links for a content */ if ($moderateduser && $content->is_active == 2) { $approval_link = PA::$url . PA_ROUTE_PERMALINK . '/cid=' . $content->content_id . '&ccid=' . $content->parent_collection_id . '&apv=1'; $denial_link = PA::$url . PA_ROUTE_PERMALINK . '/cid=' . $content->content_id . '&ccid=' . $content->parent_collection_id . '&dny=1'; } else { $approval_link = $denial_link = NULL; } // Show comments form to logged in users, only if comments enabled. global $comments_disabled; // fix by Z.Hron; if group content - only members of group can comment it $can_user_comment = true; if (isset($_GET['gid']) && isset(PA::$login_uid)) { $can_user_comment = Group::member_exists((int) $_GET['gid'], PA::$login_uid); } if (!$comments_disabled && !empty(PA::$login_uid) && $can_user_comment) { $cnform_comment = $cnform_comment_tpl->fetch(); $cnform_abuse = $cnform_abuse_tpl->fetch(); } else { $cnform_comment = $cnform_abuse = NULL; } if (getShadowedPath(CURRENT_THEME_FSPATH . "/{$type}.php")) { $middle_content = new Template(getShadowedPath(CURRENT_THEME_FSPATH . "/{$type}.php")); $middle_content->set_object('contents', $content); $middle_content->set('editable', $editable); $middle_content->set('picture_name', $content_user->picture); // to set picture name for diplaying in contets $middle_content->set('user_id', $content_user->user_id); $middle_content->set('user_name', $content_user->first_name . ' ' . $content_user->last_name); $middle_content->set('current_theme_path', PA::$theme_url); $middle_content->set('back_page', $back_page); $middle_content->set('comments', $comments_list); $middle_content->set('cnform_comment', $cnform_comment); $middle_content->set('cnform_abuse', $cnform_abuse); $middle_content->set('media_gallery_content', $media_gallery_content); if ($show == 1) { $middle_content->set('show', $show); } $middle_content->set('permalink', $perma_link); $middle_content->set('edit_link', $edit_link); $middle_content->set('approval_link', $approval_link); $middle_content->set('denial_link', $denial_link); $middle_content->set('delete_link', $delete_link); $middle_content->set('user_link', $user_link); $return_content = $middle_content->fetch(); } else { $return_content = '<p>Content does not have a display template.</p><p>Create a ' . $type . '.php file to display this content type.</p>'; } return $return_content; }
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 get_tag_string($content_id) { $tags_array = Tag::load_tags_for_content($content_id); $tags_string = ""; $count = count($tags_array); if ($count > 0) { for ($counter = 0; $counter < $count; $counter++) { $tags_string .= $tags_array[$counter]['name'] . ", "; } $tags_string = substr($tags_string, 0, strlen($tags_string) - 2); } return $tags_string; }
// *** FIXME: it looks like user::load used to take a second param // *** that determined whether it would load deleted users or not. // *** this disappeared a long time ago, though, and in the meantime // *** a new second param has appeared, that indicates the type of // *** the first param. so if anyone wants to put this back, feel // *** free... until then, the following code may not work as // *** expected: // Here second parameter of load_user_name is 0 it is is_active = 0 // (it will load all users name of People aggregator whether user // has been deleted or exist) $user1->load((int) $contents[$i]['author_id']); //, 0); $contents[$i]['author_name'] = '<a href="user.php?uid=' . $user1->user_id . '">' . $user1->first_name . '</a>'; //$contents[$i]['create_time'] = content_date($contents[$i]['changed']); $contents[$i]['trackback_url'] = "{$base_url}/pa_trackback.php?cid=" . $contents[$i]['content_id']; $tags = Tag::load_tags_for_content($contents[$i]['content_id']); if ($tags) { $t = array(); for ($j = 0; $j < count($tags); $j++) { $t_name = $tags[$j]['name']; $uid = $_SESSION['user']['id']; $t[] = "<a href=\"content_all.php?uid={$uid}&tag={$t_name}\">" . $tags[$j]['name'] . "</a>"; } $contents[$i]['tag_entry'] = "<b>Tags : </b>" . implode(", ", $t); } else { $contents[$i]['tag_entry'] = ""; } } // accessing page settings data $setting_data = ModuleSetting::load_setting(2, 1); // members
if (Group::is_admin((int) $group->collection_id, (int) $_SESSION['user']['id'])) { $is_admin = TRUE; if ($group->is_moderated || $group->reg_type == $group->REG_MODERATED) { $total_in_mod_queue = count($group->get_moderation_queue('content')) + count($group->get_moderation_queue('user')); } } $members = count($group->get_members()); $contents = $group->get_moderation_queue("content"); $mod_users = $group->get_moderation_queue("user"); $content_details = array(); $user_details = array(); if ($group->is_moderated) { $i = 0; foreach ($contents as $con) { $c = Content::load_content((int) $con, $_SESSION['user']['id']); $tags = Tag::load_tags_for_content((int) $con); if ($tags) { $t = array(); for ($j = 0; $j < count($tags); $j++) { $tid = $tags[$j]['id']; $uid = $_SESSION['user']['id']; $t[] = "<a href=\"tags.php?uid={$uid}&tagid={$tid}\">" . $tags[$j]['name'] . "</a>"; } $content_details[$i]['tag_entry'] = "<b>Tags : </b>" . implode(", ", $t); } else { $content_details[$i]['tag_entry'] = ""; } $u = new User(); $u->load((int) $c->author_id); $content_details[$i]['content_id'] = $c->content_id; $content_details[$i]['title'] = $c->title;
public function load_many($array_cids, $user_id = 0, $my_user_id = 0) { Logger::log("Enter: Image::load_many | Arg: \$content_ids = " . implode(",", $array_cids)); // TO Do: In the one query (wite query in the one string) $i = 0; foreach ($array_cids as $cid) { $sql = "SELECT * FROM {contents} AS C, {images} as I WHERE C.content_id = I.content_id AND I.content_id = ? AND C.is_active = ?"; $res = Dal::query($sql, array($cid, ACTIVE)); if ($res->numRows() > 0) { $row = $res->fetchRow(DB_FETCHMODE_OBJECT); $image[$i]['content_id'] = $row->content_id; $image[$i]['image_file'] = $row->image_file; $image[$i]['image_caption'] = $row->title; $image[$i]['title'] = $row->title; $image[$i]['body'] = $row->body; $image[$i]['created'] = $row->created; $image[$i]['collcetion_id'] = $row->collection_id; $image[$i]['perm'] = $row->image_perm; } $tags_array = Tag::load_tags_for_content($cid); $tags_string = ""; if (count($tags_array) > 0) { for ($counter = 0; $counter < count($tags_array); $counter++) { $tags_string .= $tags_array[$counter]['name'] . ", "; } $tags_string = substr($tags_string, 0, strlen($tags_string) - 2); } $image[$i]['tags'] = $tags_string; $i++; // loading tags for media } if (!empty($image) && $user_id != 0) { // getting degree 1 friendlist $relations = Relation::get_relations($user_id); if ($user_id == $my_user_id) { $user_image_data = $image; } elseif (in_array($my_user_id, $relations)) { foreach ($image as $user_data) { if ($user_data['perm'] == WITH_IN_DEGREE_1 || $user_data['perm'] == ANYONE) { $user_image_data[] = $user_data; } } } elseif ($my_user_id == 0) { foreach ($image as $user_data) { if ($user_data['perm'] == WITH_IN_DEGREE_1 || $user_data['perm'] == ANYONE) { $user_image_data[] = $user_data; } } } else { foreach ($image as $user_data) { if ($user_data['perm'] == ANYONE) { $user_image_data[] = $user_data; } } } } else { if ($user_id == $my_user_id) { $user_image_data = $image; } } Logger::log("Exit: Image::load_many()"); return $user_image_data; }
$page_content->set('header', $header); //tpl for left side bar $left_panel =& new Template(CURRENT_THEME_FSPATH . "/left_page.tpl"); $left_panel->set('img_path', $img_path); $page_content->set('left_panel', $left_panel); $comments = Comment::get_comment_for_content($cid); $number_of_comments = count($comments); $content->no_of_comments = $number_of_comments; $trackback = Content::get_trackbacks_for_content($cid); $content->trackback_url = "{$base_url}/pa_trackback.php?cid=" . $cid; $content_user = new User(); $content_user->load((int) $content->author_id); $time = content_date($content->changed); $content->author_name = '<a href="user.php?uid=' . $content_user->user_id . '">' . $content_user->first_name . '</a>'; $content->create_time = content_date($content->changed); $tags = Tag::load_tags_for_content($cid); if ($tags) { $t = array(); for ($i = 0; $i < count($tags); $i++) { $name = $tags[$i]['name']; $uid = $_SESSION['user']['id']; $t[] = "<a href=\"tags.php?uid={$uid}&tagname={$name}\">" . $tags[$i]['name'] . "</a>"; } $tag_string = "<b>Tags : </b>" . implode(", ", $t); } else { $tag_string = ""; } $content->tag_entry = $tag_string; //tpl for center content $center =& new Template(CURRENT_THEME_FSPATH . "/content.tpl"); $center->set('content_user_name', $content_user->first_name . ' ' . $content_user->last_name);
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; } }
/** * load Video data * @access public * @param $array_cids an array of Video Ids. * @param $user_id user id of the person who is accessing data * @param $my_user_id user id of the person whose data is loading * @return $video, an associative array having all data of videos */ public function load_many($array_cids, $user_id = 0, $my_user_id = 0) { Logger::log("Enter: Video::load_many | Arg: \$content_id = " . implode(",", $array_cids)); $i = 0; foreach ($array_cids as $cid) { $sql = "SELECT * FROM {contents} AS C, {videos} as V WHERE C.content_id = V.content_id AND V.content_id = ? AND C.is_active = ?"; $res = Dal::query($sql, array($cid, ACTIVE)); if ($res->numRows() > 0) { $row = $res->fetchRow(DB_FETCHMODE_OBJECT); $video[$i]['content_id'] = $row->content_id; $video[$i]['video_file'] = $row->video_file; $video[$i]['video_caption'] = $row->title; $video[$i]['title'] = $row->title; $video[$i]['body'] = $row->body; $video[$i]['created'] = $row->created; $video[$i]['perm'] = $row->video_perm; } $tags_array = Tag::load_tags_for_content($cid); $tags_string = ""; if (count($tags_array) > 0) { for ($counter = 0; $counter < count($tags_array); $counter++) { $tags_string .= $tags_array[$counter]['name'] . ", "; } $tags_string = substr($tags_string, 0, strlen($tags_string) - 2); } $video[$i]['tags'] = $tags_string; $i++; } if (!empty($video) && $user_id != 0) { // getting degree 1 friendlist $relations = Relation::get_relations($user_id); if ($user_id == $my_user_id) { $user_video_data = $video; } elseif (in_array($my_user_id, $relations)) { foreach ($video as $user_data) { if ($user_data['perm'] == WITH_IN_DEGREE_1 || $user_data['perm'] == ANYONE) { $user_video_data[] = $user_data; } } } elseif ($my_user_id == 0) { foreach ($video as $user_data) { if ($user_data['perm'] == WITH_IN_DEGREE_1 || $user_data['perm'] == ANYONE) { $user_video_data[] = $user_data; } } } else { foreach ($video as $user_data) { if ($user_data['perm'] == ANYONE) { $user_video_data[] = $user_data; } } } } else { if ($user_id == $my_user_id) { $user_video_data = $video; } } Logger::log("Exit: Video::load"); return $user_video_data; }
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; } }