/** * nv_set_allow() * * @param mixed $who * @param mixed $groups * @return */ function nv_faq_set_allow($who, $groups) { global $user_info; if (!$who or $who == 1 and defined('NV_IS_USER') or $who == 2 and defined('NV_IS_ADMIN')) { return true; } elseif ($who == 3 and !empty($groups) and defined('NV_IS_USER') and nv_is_in_groups($user_info['in_groups'], $groups)) { return true; } return false; }
/** * nv_setBlockAllowed() * * @param mixed $groups_view * @return */ function nv_setBlockAllowed($groups_view) { global $user_info; if (defined('NV_IS_SPADMIN')) { return true; } $groups_view = (string) $groups_view; if ($groups_view == "0" or $groups_view == "1" and defined('NV_IS_USER') or $groups_view == "2" and defined('NV_IS_MODADMIN')) { return true; } if (defined('NV_IS_USER') and nv_is_in_groups($user_info['in_groups'], $groups_view)) { return true; } return false; }
$contents = np_album_theme($home_album, ''); } } $array_cat = array(); $key = 0; foreach ($home_category as $_catid) { $func_who_view = $allcats[$_catid]['who_view']; $allowed = false; if ($func_who_view == 0) { $allowed = true; } if ($func_who_view == 1 and defined('NV_IS_USER')) { $allowed = true; } elseif ($func_who_view == 2 and defined('NV_IS_MODADMIN')) { $allowed = true; } elseif ($func_who_view == 3 and defined('NV_IS_USER') and nv_is_in_groups($user_info['in_groups'], $allalbs[$albid]['groups_view'])) { $allowed = true; } if ($allowed) { $array_cat[$key] = $allcats[$_catid]; $sql = "SELECT " . $cal_found_rows . " `pid`, `filename`, `filepath`, `thumbpath`, `catid`, `userid`, `title`, `alias`, `alt`, `img_size` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_" . $_catid . "` LIMIT " . $limit; $query = $db->sql_query($sql); if ($catid > 0) { $result_all = $db->sql_query("SELECT FOUND_ROWS()"); list($all_page) = $db->sql_fetchrow($result_all); } while ($photo = $db->sql_fetch_assoc($query)) { $array_cat[$key]['content'][] = $photo; } } ++$key;
} else { $sql = "SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "_photos` WHERE `pid`=" . intval($pid) . " LIMIT 1"; $photo_data = $db->sql_fetch_assoc($db->sql_query($sql)); if (empty($photo_data)) { $contents = np_theme_message('Ảnh bạn yêu cầu không tồn tại hoặc đã bị xóa'); } else { $func_who_view = $photo_data['who_view']; $allowed = false; if ($func_who_view == 0) { $allowed = true; } if ($func_who_view == 1 and defined('NV_IS_USER')) { $allowed = true; } elseif ($func_who_view == 2 and defined('NV_IS_MODADMIN')) { $allowed = true; } elseif ($func_who_view == 3 and defined('NV_IS_USER') and nv_is_in_groups($user_info['in_groups'], $global_array_cat[$catid]['groups_view'])) { $allowed = true; } if ($allowed) { $feature = array('cmable' => $photo_data['allowed_comm'], 'voteable' => $photo_data['allowed_rating']); $comment_array = np_comment('photos', $pid, $photo_data['allowed_comm'], 0); $comment_array['ver'] = $ver; $photo_data['comments'] = comment_theme('photos', $pid, $feature, $comment_array); $photo_data['scwidth'] = $scwidth; $photo_data['scheight'] = $scheight; $photo_data['fitwidth'] = $fitwidth; $photo_data['fitheight'] = $fitheight; $contents = np_view_photo($photo_data, $ver); } else { $msg = no_permission($func_who_view); $contents = np_theme_message($msg);
/** * nv_blocks_get_content() * * @return */ function nv_blocks_content() { global $db, $module_info, $op, $global_config, $lang_global, $module_name, $module_file, $my_head, $user_info; $__blocks = array(); $__blocks_return = array(); #dev version theme control $xml = simplexml_load_file(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/config.ini'); $content = $xml->xpath('positions'); //array $position = $content[0]->position; //object $array_position = array(); for ($i = 0; $i < count($position); $i++) { $__pos = (string) $position[$i]->tag; if (!empty($__pos)) { $array_position[] = $__pos; $__blocks_return[$__pos] = ""; } } if (!empty($array_position)) { #dev version theme control $sql_bl = "SELECT * FROM `" . NV_BLOCKS_TABLE . "` WHERE func_id='" . $module_info['funcs'][$op]['func_id'] . "' AND `theme` ='" . $global_config['module_theme'] . "' AND `active`=1 ORDER BY `weight` ASC"; $list = nv_db_cache($sql_bl, '', 'themes'); foreach ($list as $row_bl) { $__pos = $row_bl['position']; if (isset($__blocks_return[$__pos]) and ($__pos['exp_time'] == 0 or $__pos['exp_time'] > " . NV_CURRENTTIME . ")) { $groups_view = (string) $row_bl['groups_view']; $allowed = false; if ($groups_view == "0") { $allowed = true; } if ($groups_view == "1" and defined('NV_IS_USER')) { $allowed = true; } elseif ($groups_view == "2" and defined('NV_IS_MODADMIN')) { $allowed = true; } elseif (defined('NV_IS_SPADMIN')) { $allowed = true; } elseif (defined('NV_IS_USER') and nv_is_in_groups($user_info['in_groups'], $groups_view)) { $allowed = true; } if ($allowed) { $title = $row_bl['title']; if (!empty($title) and !empty($row_bl['link'])) { $title = "<a href=\"" . $row_bl['link'] . "\">" . $title . "</a>"; } # comment this line $__blocks[$__pos][] = array('bid' => $row_bl['bid'], 'weight' => $row_bl['weight'], 'func_id' => $row_bl['func_id'], 'title' => $title, 'type' => $row_bl['type'], 'file_path' => $row_bl['file_path'], 'template' => $row_bl['template']); } } } foreach (array_keys($__blocks) as $__pos) { if (!empty($__blocks[$__pos])) { foreach ($__blocks[$__pos] as $__values) { $content = ""; if ($__values['type'] == "banner") { $content = showBanners($__values['file_path']); } elseif ($__values['type'] == "html") { $content = $__values['file_path']; } elseif ($__values['type'] == "rss") { $array_rrs = explode("#@#", $__values['file_path']); $content = nv_get_rss($array_rrs[0]); } elseif (preg_match($global_config['check_block_global'], $__values['file_path']) and file_exists(NV_ROOTDIR . "/includes/blocks/" . $__values['file_path'])) { include NV_ROOTDIR . "/includes/blocks/" . $__values['file_path']; } elseif (preg_match($global_config['check_block_module'], $__values['file_path']) and file_exists(NV_ROOTDIR . "/modules/" . $module_file . "/blocks/" . $__values['file_path'])) { include NV_ROOTDIR . "/modules/" . $module_file . "/blocks/" . $__values['file_path']; } if (!empty($content) or defined('NV_IS_DRAG_BLOCK')) { $block_theme = ""; $__values['template'] = empty($__values['template']) ? "default" : $__values['template']; if (!empty($module_info['theme']) and file_exists(NV_ROOTDIR . "/themes/" . $module_info['theme'] . "/layout/block." . $__values['template'] . ".tpl")) { $block_theme = $module_info['theme']; } elseif (!empty($global_config['module_theme']) and file_exists(NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/layout/block." . $__values['template'] . ".tpl")) { $block_theme = $global_config['module_theme']; } elseif (!empty($global_config['site_theme']) and file_exists(NV_ROOTDIR . "/themes/" . $global_config['site_theme'] . "/layout/block." . $__values['template'] . ".tpl")) { $block_theme = $global_config['site_theme']; } elseif (file_exists(NV_ROOTDIR . "/themes/default/layout/block." . $__values['template'] . ".tpl")) { $block_theme = "default"; } if (!empty($block_theme) and $__values['type'] != "rss") { $xtpl = new XTemplate("block." . $__values['template'] . ".tpl", NV_ROOTDIR . "/themes/" . $block_theme . "/layout"); $xtpl->assign('BLOCK_TITLE', $__values['title']); $xtpl->assign('BLOCK_CONTENT', $content); $xtpl->parse('mainblock'); $b_content = $xtpl->text('mainblock'); } elseif (!empty($block_theme) and $__values['type'] == "rss") { $rss_setting_number = intval($array_rrs[1]); $rss_setting_description = intval($array_rrs[2]); $rss_setting_html = intval($array_rrs[3]); $rss_setting_pubdate = intval($array_rrs[4]); $rss_setting_target = intval($array_rrs[5]); $xtpl = new XTemplate("block." . $__values['template'] . ".tpl", NV_ROOTDIR . "/themes/" . $block_theme . "/layout"); $xtpl->assign('BLOCK_TITLE', $__values['title']); $a = 1; foreach ($content as $item) { if ($a <= $rss_setting_number) { $item['description'] = $rss_setting_html ? $item['description'] : strip_tags($item['description']); $item['target'] = $rss_setting_target ? " onclick=\"this.target='_blank'\" " : ""; $xtpl->assign('DATA_RSS', $item); if ($rss_setting_description) { $xtpl->parse('mainblock.looprss.description'); } if ($rss_setting_pubdate) { $xtpl->parse('mainblock.looprss.pubDate'); } $xtpl->parse('mainblock.looprss'); $a++; } else { break; } } $xtpl->parse('mainblock'); $b_content = $xtpl->text('mainblock'); } else { $b_content = $__values['title'] . "<br>" . $content . "<br>"; } if (defined('NV_IS_DRAG_BLOCK')) { $b_content = '<div class="portlet" id="bl_' . $__values['bid'] . '"> <p> <a href="javascript:void(0)" class="editblock" name="' . $__values['bid'] . '"> <img src="' . NV_BASE_SITEURL . 'images/edit.png" style="border:none"/> ' . $lang_global['edit_block'] . '</a> | <a href="javascript:void(0)" class="delblock" name="' . $__values['bid'] . '"> <img src="' . NV_BASE_SITEURL . 'images/delete.png" style="border:none"/> ' . $lang_global['delete_block'] . '</a> | <a href="javascript:void(0)" class="outgroupblock" name="' . $__values['bid'] . '"> <img src="' . NV_BASE_SITEURL . 'images/outgroup.png" style="border:none"/> ' . $lang_global['outgroup_block'] . '</a> </p> ' . $b_content . '</div>'; } $__blocks_return[$__pos] .= $b_content; } } } } } if (defined('NV_IS_DRAG_BLOCK')) { #dev version theme control foreach ($__blocks_return as $__pos => $b_content) { $__blocks_return[$__pos] = '<div class="column" id="' . preg_replace('#\\[|\\]#', '', $__pos) . '">'; $__blocks_return[$__pos] .= $b_content; $__blocks_return[$__pos] .= ' <span><a class="addblock" id="' . $__pos . '" href="javascript:void(0)"><img src="' . NV_BASE_SITEURL . 'images/add.png" style="border:none"/> ' . $lang_global['add_block'] . '</a></span>'; $__blocks_return[$__pos] .= '</div>'; } #end dev version theme control } return $__blocks_return; }