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'; 33require_once WT_ROOT.'includes/index_cache.php'; 34 35if (isset($_REQUEST['action'])) $action = $_REQUEST['action']; 36if (isset($_REQUEST['ctype'])) $ctype = $_REQUEST['ctype']; 37$news_id = safe_GET('news_id'); 38 39$time = client_time(); 40 41if (!isset($action)) $action=''; 42 43// Visitors should see any links to a user page, but they may be 44// following a link after an inactivity logout. 45if (!WT_USER_ID) { 46 if (!empty($ctype) && $ctype=='user') { 47 header('Location: login.php&url=index.php?ctype=user'); 48 exit; 49 } else { 50 $ctype = 'gedcom'; 51 } 52} 53 54if (empty($ctype)) { 55 if ($PAGE_AFTER_LOGIN == 'welcome') $ctype = 'gedcom'; 56 else $ctype = 'user'; 57} 58 59//-- get the blocks list 60if ($ctype=='user') { 61 $blocks=get_user_blocks(WT_USER_ID); 62} else { 63 $blocks=get_gedcom_blocks(WT_GED_ID); 64} 65 66//-- clear the GEDCOM cache files 67if (!empty($_SESSION['clearcache'])) { 68 $_SESSION['clearcache'] = false; 69 clearCache(); 70} 71 72// We have finished writing to $_SESSION, so release the lock 73session_write_close(); 74 75$all_blocks=WT_Module::getActiveBlocks(); 76 77// We generate individual blocks using AJAX 78if ($action=='ajax') { 79 header('Content-Type: text/html; charset=UTF-8'); 80 // Check we're displaying an allowable block. 81 $block_id=safe_GET('block_id'); 82 if (array_key_exists($block_id, $blocks['main'])) { 83 $module_name=$blocks['main'][$block_id]; 84 } elseif (array_key_exists($block_id, $blocks['side'])) { 85 $module_name=$blocks['side'][$block_id]; 86 } else { 87 exit; 88 } 89 if (array_key_exists($module_name, $all_blocks)) { 90 $class_name=$module_name.'_WT_Module'; 91 $module=new $class_name; 92 $module->getBlock($block_id); 93 } 94 if (WT_DEBUG) { 95 echo execution_stats(); 96 } 97 if (WT_DEBUG_SQL) { 98 echo WT_DB::getQueryLog(); 99 } 100 exit; 101} 102 103if ($ctype=='user') { 104 $helpindex = 'index_myged_help'; 105 print_header(i18n::translate('My Page')); 106} else { 107 print_header(get_gedcom_setting(WT_GED_ID, 'title')); 108} 109 110if (WT_USE_LIGHTBOX) { 111 require WT_ROOT.'modules/lightbox/lb_defaultconfig.php'; 112 require WT_ROOT.'modules/lightbox/functions/lb_call_js.php'; 113} 114 115// TODO: these should be moved to their respective module/block 116echo WT_JS_START; 117?> 118 function refreshpage() { 119 window.location = 'index.php?ctype=<?php echo $ctype; ?>'; 120 } 121 function addnews(uname) { 122 window.open('editnews.php?username='+uname, '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1'); 123 } 124 function editnews(news_id) { 125 window.open('editnews.php?news_id='+news_id, '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1'); 126 } 127 var pastefield; 128 function paste_id(value) { 129 pastefield.value=value; 130 } 131<?php 132echo WT_JS_END; 133//-- start of main content section 134if ($ctype=='user') { 135 echo '<div align="center">'; 136 echo '<h1>', i18n::translate('My Page'), '</h1>'; 137 echo i18n::translate('My Page allows you to keep bookmarks of your favorite people, track upcoming events, and collaborate with other webtrees users.'); 138 echo '<br /><br /></div>'; 139} 140echo '<script src="js/jquery/jquery.min.js" type="text/javascript"></script>'; 141echo '<script type="text/javascript">jQuery.noConflict();</script>'; 142if ($blocks['main']) { 143 if ($blocks['side']) { 144 echo '<div id="index_main_blocks">'; 145 } else { 146 echo '<div id="index_full_blocks">'; 147 } 148 foreach ($blocks['main'] as $block_id=>$module_name) { 149 $class_name=$module_name.'_WT_Module'; 150 $module=new $class_name; 151 if ($SEARCH_SPIDER || !$module->loadAjax()) { 152 // Load the block directly 153 $module->getBlock($block_id); 154 } else { 155 // Load the block asynchronously 156 echo '<div id="block_', $block_id, '"><img src="images/loading.gif" alt="', htmlspecialchars(i18n::translate('Loading...')), '"/></div>'; 157 echo WT_JS_START, "jQuery('#block_{$block_id}').load('index.php?ctype={$ctype}&action=ajax&block_id={$block_id}');", WT_JS_END; 158 } 159 } 160 echo '</div>'; 161} 162 163if ($blocks['side']) { 164 if ($blocks['main']) { 165 echo '<div id="index_small_blocks">'; 166 } else { 167 echo '<div id="index_full_blocks">'; 168 } 169 foreach ($blocks['side'] as $block_id=>$module_name) { 170 $class_name=$module_name.'_WT_Module'; 171 $module=new $class_name; 172 if ($SEARCH_SPIDER || !$module->loadAjax()) { 173 // Load the block directly 174 $module->getBlock($block_id); 175 } else { 176 // Load the block asynchronously 177 echo '<div id="block_', $block_id, '"><img src="images/loading.gif" alt="', htmlspecialchars(i18n::translate('Loading...')), '"/></div>'; 178 echo WT_JS_START, "jQuery('#block_{$block_id}').load('index.php?ctype={$ctype}&action=ajax&block_id={$block_id}');", WT_JS_END; 179 } 180 } 181 echo '</div>'; 182} 183 184// Ensure there is always way to configure the blocks 185if ($ctype=='user' && !in_array('user_welcome', $blocks['main']) && !in_array('user_welcome', $blocks['side'])) { 186 echo '<div align="center">'; 187 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>'; 188 echo help_link('mygedview_customize'); 189 echo '</div>'; 190} 191if (WT_USER_IS_ADMIN && $ctype=='gedcom' && !in_array('gedcom_block', $blocks['main']) && !in_array('gedcom_block', $blocks['side'])) { 192 echo '<div align="center">'; 193 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>'; 194 echo '</div>'; 195} 196 197print_footer(); 198