/** * Gets a gallery selection tree list, extending deeper from the given category_id, showing all sub(sub...)galleries. * * @param ?ID_TEXT The gallery we are getting the tree starting from (NULL: root) * @param string The parent tree at this point of the recursion * @param ?array The database row for the $category_id gallery (NULL: get it from the DB) * @param boolean Whether to include video/image statistics in the returned tree * @param ?string A function name to filter galleries with (NULL: no filter) * @param boolean Whether displayed galleries must support images * @param boolean Whether displayed galleries must support videos * @param boolean Whether to NOT show member galleries that do not exist yet * @param boolean Whether to get a list of child galleries (not just direct ones, recursively), instead of just IDs * @param ?integer The number of recursive levels to search (NULL: all) * @param ?MEMBER Member we are filtering for (NULL: not needed) * @param boolean Whether to only show for what may be added to by the current member * @return array The tree structure, or if $use_compound_list, the tree structure built with pairs containing the compound list in addition to the child branches */ function get_gallery_tree($category_id = 'root', $tree = '', $gallery_info = NULL, $do_stats = true, $filter = NULL, $must_accept_images = false, $must_accept_videos = false, $purity = false, $use_compound_list = false, $levels = NULL, $member_id = NULL, $addable_filter = false) { if ($levels == -1) { return $use_compound_list ? array(array(), '') : array(); } if (is_null($category_id)) { $category_id = 'root'; } if (!has_category_access(get_member(), 'galleries', $category_id)) { return $use_compound_list ? array(array(), '') : array(); } // Put our title onto our tree if (is_null($gallery_info)) { $_gallery_info = $GLOBALS['SITE_DB']->query_select('galleries', array('fullname', 'is_member_synched', 'accept_images', 'accept_videos'), array('name' => $category_id), '', 1); if (!array_key_exists(0, $_gallery_info)) { warn_exit(do_lang_tempcode('_MISSING_RESOURCE', escape_html('gallery:' . $category_id))); } $gallery_info = $_gallery_info[0]; } $title = array_key_exists('text_original', $gallery_info) ? $gallery_info['text_original'] : get_translated_text($gallery_info['fullname']); $is_member_synched = $gallery_info['is_member_synched'] == 1; $accept_images = $gallery_info['accept_images'] == 1; $accept_videos = $gallery_info['accept_videos'] == 1; $tree .= $title; $children = array(); $sub = false; $query = 'FROM ' . get_table_prefix() . 'galleries g LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND g.fullname=t.id WHERE ' . db_string_equal_to('parent_id', $category_id); if (current(current($GLOBALS['SITE_DB']->query('SELECT COUNT(*) ' . $query))) >= 300) { $rows = $GLOBALS['SITE_DB']->query('SELECT text_original,name,fullname,accept_images,accept_videos,is_member_synched,g.fullname ' . $query . ' ORDER BY add_date', 300); } else { $rows = $GLOBALS['SITE_DB']->query('SELECT text_original,name,fullname,accept_images,accept_videos,is_member_synched,g.fullname ' . $query . ' ORDER BY text_original ASC'); } if ((is_null($filter) || call_user_func_array($filter, array($category_id, $member_id, count($rows)))) && (!$must_accept_images || $accept_images && !$is_member_synched) && (!$must_accept_videos || $accept_videos && !$is_member_synched)) { // We'll be putting all children in this entire tree into a single list $children[0]['id'] = $category_id; $children[0]['tree'] = $tree; $children[0]['title'] = $title; $children[0]['accept_images'] = $gallery_info['accept_images']; $children[0]['accept_videos'] = $gallery_info['accept_videos']; $children[0]['is_member_synched'] = $gallery_info['is_member_synched']; if ($addable_filter) { $children[0]['addable'] = has_submit_permission('mid', get_member(), get_ip_address(), 'cms_galleries', array('galleries', $category_id)); } if ($do_stats) { $good_row_count = 0; foreach ($rows as $row) { if ((is_null($filter) || call_user_func_array($filter, array($row['name'], $member_id, 1))) && (!$must_accept_images || $row['accept_images'] && $row['is_member_synched'] == 0) && (!$must_accept_videos || $row['accept_videos'] && $row['is_member_synched'] == 0)) { $good_row_count++; } } $children[0]['child_count'] = $good_row_count; if ($good_row_count == 0 && !$purity && $gallery_info['is_member_synched']) { $children[0]['child_count'] = 1; } // XHTMLXHTML $children[0]['video_count'] = $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)', array('cat' => $category_id)); $children[0]['image_count'] = $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)', array('cat' => $category_id)); } $sub = true; } $can_submit = mixed(); // Children of this category $tree .= ' > '; $found_own_gallery = false; $found_member_galleries = array($GLOBALS['FORUM_DRIVER']->get_guest_id() => 1); $compound_list = $category_id . ','; foreach ($rows as $child) { if ($child['name'] == 'root') { continue; } $can_submit = can_submit_to_gallery($child['name']); if ($can_submit === false) { $can_submit = !$addable_filter; } if ($can_submit !== false && $can_submit !== true) { $found_own_gallery = true; $found_member_galleries[$can_submit] = 1; } if ($can_submit !== false && ($levels !== 0 || $use_compound_list)) { $child_id = $child['name']; // $child_title=$child['text_original']; $child_tree = $tree; $child_children = get_gallery_tree($child_id, $child_tree, $child, $do_stats, $filter, $must_accept_images, $must_accept_videos, $purity, $use_compound_list, is_null($levels) ? NULL : $levels - 1, $member_id, $addable_filter); if ($use_compound_list) { list($child_children, $_compound_list) = $child_children; $compound_list .= $_compound_list; } if ($levels !== 0) { $children = array_merge($children, $child_children); } } } if ($sub && array_key_exists(0, $children)) { $children[0]['compound_list'] = $compound_list; } $done_for_all = false; if ($is_member_synched && !$purity && $levels !== 0) { if (has_specific_permission(get_member(), 'can_submit_to_others_categories') && get_forum_type() == 'ocf') { ocf_require_all_forum_stuff(); $members = $GLOBALS['FORUM_DB']->query_select('f_members', array('id', 'm_username', 'm_primary_group'), NULL, 'ORDER BY m_username', 100); if (count($members) != 100) { $done_for_all = true; $group_membership = $GLOBALS['FORUM_DB']->query_select('f_group_members', array('gm_group_id', 'gm_member_id'), array('gm_validated' => 1)); $group_permissions = $GLOBALS['SITE_DB']->query('SELECT group_id,the_page,the_value FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'gsp WHERE ' . db_string_equal_to('specific_permission', 'have_personal_category') . ' AND (' . db_string_equal_to('the_page', '') . ' OR ' . db_string_equal_to('the_page', 'cms_galleries') . ')'); $is_super_admin = $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()); foreach ($members as $_member) { $member = $_member['id']; $username = $_member['m_username']; $this_category_id = 'member_' . strval($member) . '_' . $category_id; if ($member == get_member()) { $has_permission = true; } else { $a = in_array(array('group_id' => $member['m_primary_group'], 'the_page' => '', 'the_value' => 1), $group_permissions); $b = in_array(array('group_id' => $member['m_primary_group'], 'the_page' => 'cms_galleries', 'the_value' => 0), $group_permissions); $c = in_array(array('group_id' => $member['m_primary_group'], 'the_page' => 'cms_galleries', 'the_value' => 1), $group_permissions); $has_permission = $is_super_admin; if ($a && !$b || $c) { $has_permission = true; } if (!$has_permission) { foreach ($group_membership as $_g) { if ($_g['gm_member_id'] == $member) { $a = in_array(array('group_id' => $_g['gm_group_id'], 'the_page' => '', 'the_value' => 1), $group_permissions); $b = in_array(array('group_id' => $_g['gm_group_id'], 'the_page' => 'cms_galleries', 'the_value' => 0), $group_permissions); $c = in_array(array('group_id' => $_g['gm_group_id'], 'the_page' => 'cms_galleries', 'the_value' => 1), $group_permissions); if ($a && !$b || $c) { $has_permission = true; } break; } } } } if ($has_permission && !array_key_exists($member, $found_member_galleries) && (is_null($filter) || call_user_func_array($filter, array($this_category_id, $member_id, 0)))) { $own_gallery = array(); $own_gallery['id'] = $this_category_id; $this_title = do_lang('NEW_PERSONAL_GALLERY_OF', $username, $title); $own_gallery['tree'] = $tree . $this_title; $own_gallery['video_count'] = 0; $own_gallery['image_count'] = 0; $own_gallery['child_count'] = 0; $own_gallery['title'] = $this_title; $own_gallery['accept_images'] = $gallery_info['accept_images']; $own_gallery['accept_videos'] = $gallery_info['accept_videos']; $own_gallery['is_member_synched'] = 0; $own_gallery['compound_list'] = $compound_list; $own_gallery['addable'] = true; $children[] = $own_gallery; if ($member == get_member()) { $found_own_gallery = true; } } } } } if ((!$done_for_all || !$found_own_gallery) && !array_key_exists(get_member(), $found_member_galleries) && !is_guest() && !$purity && has_specific_permission(get_member(), 'have_personal_category')) { $this_category_id = 'member_' . strval(get_member()) . '_' . $category_id; if (is_null($filter) || call_user_func_array($filter, array($this_category_id, $member_id, 0))) { $own_gallery = array(); $own_gallery['id'] = $this_category_id; $this_title = do_lang('NEW_PERSONAL_GALLERY_OF', $GLOBALS['FORUM_DRIVER']->get_username(get_member()), $title); $own_gallery['tree'] = $tree . $this_title; $own_gallery['video_count'] = 0; $own_gallery['image_count'] = 0; $own_gallery['child_count'] = 0; $own_gallery['title'] = $this_title; $own_gallery['accept_images'] = $gallery_info['accept_images']; $own_gallery['accept_videos'] = $gallery_info['accept_videos']; $own_gallery['is_member_synched'] = 0; $own_gallery['addable'] = true; $own_gallery['compound_list'] = $compound_list; $children[] = $own_gallery; } } } return $use_compound_list ? array($children, $compound_list) : $children; }
/** * Standard aed_module edit actualiser. * * @param ID_TEXT The entry being edited */ function edit_actualisation($_id) { $id = intval($_id); $cat = post_param('cat'); if (can_submit_to_gallery($cat) === false) { access_denied('SUBMIT_HERE'); } make_member_gallery_if_needed($cat); $this->check_videos_allowed($cat); $validated = post_param_integer('validated', 0); $title = post_param('title'); $urls = get_url('url', 'file', 'uploads/galleries' . (get_value('use_gallery_subdirs') == '1' ? '/' . $cat : ''), 0, OCP_UPLOAD_VIDEO, true, 'thumb_url', 'file2'); if ($urls[0] == '') { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } $url = $urls[0]; if (!array_key_exists(1, $urls) || $urls[1] == '') { $thumb_url = ''; } else { $thumb_url = $urls[1]; } if (substr($url, 0, 8) != 'uploads/' && $url != '' && is_null(http_download_file($url, 0, false)) && !is_null($GLOBALS['HTTP_MESSAGE_B'])) { attach_message($GLOBALS['HTTP_MESSAGE_B'], 'warn'); } if ($thumb_url == '' && $url != '') { $thumb_url = create_video_thumb($url); } if ($thumb_url == '') { $rows = $GLOBALS['SITE_DB']->query_select('videos', array('url', 'thumb_url'), array('id' => $id), '', 1); $thumb_url = $rows[0]['thumb_url']; } if ($url == '' || $thumb_url == '') { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } $comments = post_param('comments'); $allow_rating = post_param_integer('allow_rating', 0); $allow_comments = post_param_integer('allow_comments', 0); $notes = post_param('notes', ''); $allow_trackbacks = post_param_integer('allow_trackbacks', 0); list($video_width, $video_height, $video_length) = $this->get_special_video_info(); $this->donext_type = $cat; if ($validated == 1 && $GLOBALS['SITE_DB']->query_value('videos', 'validated', array('id' => $id)) == 0) { $submitter = $GLOBALS['SITE_DB']->query_value('videos', 'submitter', array('id' => $id)); if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'galleries') && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'galleries', $cat)) { syndicate_described_activity($submitter != get_member() ? 'galleries:ACTIVITY_VALIDATE_VIDEO' : 'galleries:ACTIVITY_ADD_VIDEO', $title == '' ? $urls[2] : $title, '', '', '_SEARCH:galleries:video:' . strval($id), '', '', 'galleries', 1, NULL); } } edit_video($id, $title, $cat, $comments, $url, $thumb_url, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $video_length, $video_width, $video_height, post_param('meta_keywords', ''), post_param('meta_description', '')); }