1<?php 2/** 3 * My Page page allows a logged in user the abilty 4 * to keep bookmarks, see a list of upcoming events, etc. 5 * 6 * webtrees: Web based Family History software 7 * Copyright (C) 2010 webtrees development team. 8 * 9 * Derived from PhpGedView 10 * Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. 11 * 12 * This program is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by 14 * the Free Software Foundation; either version 2 of the License, or 15 * (at your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * You should have received a copy of the GNU General Public License 23 * along with this program; if not, write to the Free Software 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * 26 * @package webtrees 27 * @subpackage Display 28 * @version $Id$ 29 */ 30 31define('WT_SCRIPT_NAME', 'index.php'); 32require './includes/session.php'; 33 34if (isset($_REQUEST['action'])) $action = $_REQUEST['action']; 35if (isset($_REQUEST['ctype'])) $ctype = $_REQUEST['ctype']; 36$news_id = safe_GET('news_id'); 37 38$time = client_time(); 39 40if (!isset($action)) $action=''; 41 42// Visitors should see any links to a user page, but they may be 43// following a link after an inactivity logout. 44if (!WT_USER_ID) { 45 if (!empty($ctype) && $ctype=='user') { 46 header('Location: login.php&url=index.php?ctype=user'); 47 exit; 48 } else { 49 $ctype = 'gedcom'; 50 } 51} 52 53if (empty($ctype)) { 54 if ($PAGE_AFTER_LOGIN == 'welcome') $ctype = 'gedcom'; 55 else $ctype = 'user'; 56} 57 58//-- get the blocks list 59if ($ctype=='user') { 60 $blocks=get_user_blocks(WT_USER_ID); 61} else { 62 $blocks=get_gedcom_blocks(WT_GED_ID); 63} 64 65// We have finished writing to $_SESSION, so release the lock 66session_write_close(); 67 68$all_blocks=WT_Module::getActiveBlocks(); 69 70// We generate individual blocks using AJAX 71if ($action=='ajax') { 72 header('Content-Type: text/html; charset=UTF-8'); 73 // Check we're displaying an allowable block. 74 $block_id=safe_GET('block_id'); 75 if (array_key_exists($block_id, $blocks['main'])) { 76 $module_name=$blocks['main'][$block_id]; 77 } elseif (array_key_exists($block_id, $blocks['side'])) { 78 $module_name=$blocks['side'][$block_id]; 79 } else { 80 exit; 81 } 82 if (array_key_exists($module_name, $all_blocks)) { 83 $class_name=$module_name.'_WT_Module'; 84 $module=new $class_name; 85 $module->getBlock($block_id); 86 } 87 if (WT_DEBUG) { 88 echo execution_stats(); 89 } 90 if (WT_DEBUG_SQL) { 91 echo WT_DB::getQueryLog(); 92 } 93 exit; 94} 95 96if ($ctype=='user') { 97 $helpindex = 'mypage_portal'; 98 print_header(i18n::translate('My Page')); 99} else { 100 print_header(get_gedcom_setting(WT_GED_ID, 'title')); 101} 102 103if (WT_USE_LIGHTBOX) { 104 require WT_ROOT.'modules/lightbox/lb_defaultconfig.php'; 105 require WT_ROOT.'modules/lightbox/functions/lb_call_js.php'; 106} 107 108// TODO: these should be moved to their respective module/block 109echo WT_JS_START; 110?> 111 function refreshpage() { 112 window.location = 'index.php?ctype=<?php echo $ctype; ?>'; 113 } 114 function addnews(uname) { 115 window.open('editnews.php?username='+uname, '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1'); 116 } 117 function editnews(news_id) { 118 window.open('editnews.php?news_id='+news_id, '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1'); 119 } 120 var pastefield; 121 function paste_id(value) { 122 pastefield.value=value; 123 } 124<?php 125echo WT_JS_END; 126//-- start of main content section 127if ($ctype=='user') { 128 echo '<div align="center">'; 129 echo '<h1>', i18n::translate('My Page'), '</h1>'; 130 echo i18n::translate('My Page allows you to keep bookmarks of your favorite people, track upcoming events, and collaborate with other webtrees users.'); 131 echo '<br /><br /></div>'; 132} 133echo '<script src="js/jquery/jquery.min.js" type="text/javascript"></script>'; 134echo '<script type="text/javascript">jQuery.noConflict();</script>'; 135if ($blocks['main']) { 136 if ($blocks['side']) { 137 echo '<div id="index_main_blocks">'; 138 } else { 139 echo '<div id="index_full_blocks">'; 140 } 141 foreach ($blocks['main'] as $block_id=>$module_name) { 142 $class_name=$module_name.'_WT_Module'; 143 $module=new $class_name; 144 if ($SEARCH_SPIDER || !$module->loadAjax()) { 145 // Load the block directly 146 $module->getBlock($block_id); 147 } else { 148 // Load the block asynchronously 149 echo '<div id="block_', $block_id, '"><img src="images/loading.gif" alt="', htmlspecialchars(i18n::translate('Loading...')), '"/></div>'; 150 echo WT_JS_START, "jQuery('#block_{$block_id}').load('index.php?ctype={$ctype}&action=ajax&block_id={$block_id}');", WT_JS_END; 151 } 152 } 153 echo '</div>'; 154} 155 156if ($blocks['side']) { 157 if ($blocks['main']) { 158 echo '<div id="index_small_blocks">'; 159 } else { 160 echo '<div id="index_full_blocks">'; 161 } 162 foreach ($blocks['side'] as $block_id=>$module_name) { 163 $class_name=$module_name.'_WT_Module'; 164 $module=new $class_name; 165 if ($SEARCH_SPIDER || !$module->loadAjax()) { 166 // Load the block directly 167 $module->getBlock($block_id); 168 } else { 169 // Load the block asynchronously 170 echo '<div id="block_', $block_id, '"><img src="images/loading.gif" alt="', htmlspecialchars(i18n::translate('Loading...')), '"/></div>'; 171 echo WT_JS_START, "jQuery('#block_{$block_id}').load('index.php?ctype={$ctype}&action=ajax&block_id={$block_id}');", WT_JS_END; 172 } 173 } 174 echo '</div>'; 175} 176 177// Ensure there is always way to configure the blocks 178if ($ctype=='user' && !in_array('user_welcome', $blocks['main']) && !in_array('user_welcome', $blocks['side'])) { 179 echo '<div align="center">'; 180 echo "<a href=\"javascript:;\" onclick=\"window.open('index_edit.php?name=".WT_USER_NAME."&ctype=user', '_blank', 'top=50,left=10,width=600,height=500,scrollbars=1,resizable=1');\">".i18n::translate('Customize My Page').'</a>'; 181 echo help_link('mypage_customize'); 182 echo '</div>'; 183} 184if (WT_USER_IS_ADMIN && $ctype=='gedcom' && !in_array('gedcom_block', $blocks['main']) && !in_array('gedcom_block', $blocks['side'])) { 185 echo '<div align="center">'; 186 echo "<a href=\"javascript:;\" onclick=\"window.open('".encode_url("index_edit.php?name={$GEDCOM}&ctype=gedcom", false)."', '_blank', 'top=50,left=10,width=600,height=500,scrollbars=1,resizable=1');\">".i18n::translate('Customize this GEDCOM Home Page').'</a>'; 187 echo '</div>'; 188} 189 190print_footer(); 191