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 session data, so release the lock 66Zend_Session::writeClose(); 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 $helpindex = 'index_portal'; 101 print_header(get_gedcom_setting(WT_GED_ID, 'title')); 102} 103 104if (WT_USE_LIGHTBOX) { 105 require WT_ROOT.'modules/lightbox/lb_defaultconfig.php'; 106 require WT_ROOT.'modules/lightbox/functions/lb_call_js.php'; 107} 108 109// TODO: these should be moved to their respective module/block 110echo WT_JS_START; 111?> 112 function refreshpage() { 113 window.location = 'index.php?ctype=<?php echo $ctype; ?>'; 114 } 115 function addnews(uname) { 116 window.open('editnews.php?username='+uname, '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1'); 117 } 118 function editnews(news_id) { 119 window.open('editnews.php?news_id='+news_id, '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1'); 120 } 121 var pastefield; 122 function paste_id(value) { 123 pastefield.value=value; 124 } 125<?php 126echo WT_JS_END; 127//-- start of main content section 128if ($ctype=='user') { 129 echo '<div align="center">'; 130 echo '<h1>', i18n::translate('My Page'), '</h1>'; 131 echo i18n::translate('My Page allows you to keep bookmarks of your favorite people, track upcoming events, and collaborate with other webtrees users.'); 132 echo '<br /><br /></div>'; 133} 134echo '<script src="js/jquery/jquery.min.js" type="text/javascript"></script>'; 135echo '<script type="text/javascript">jQuery.noConflict();</script>'; 136if ($blocks['main']) { 137 if ($blocks['side']) { 138 echo '<div id="index_main_blocks">'; 139 } else { 140 echo '<div id="index_full_blocks">'; 141 } 142 foreach ($blocks['main'] as $block_id=>$module_name) { 143 $class_name=$module_name.'_WT_Module'; 144 $module=new $class_name; 145 if ($SEARCH_SPIDER || !$module->loadAjax()) { 146 // Load the block directly 147 $module->getBlock($block_id); 148 } else { 149 // Load the block asynchronously 150 echo '<div id="block_', $block_id, '"><img src="images/loading.gif" alt="', htmlspecialchars(i18n::translate('Loading...')), '"/></div>'; 151 echo WT_JS_START, "jQuery('#block_{$block_id}').load('index.php?ctype={$ctype}&action=ajax&block_id={$block_id}');", WT_JS_END; 152 } 153 } 154 echo '</div>'; 155} 156 157if ($blocks['side']) { 158 if ($blocks['main']) { 159 echo '<div id="index_small_blocks">'; 160 } else { 161 echo '<div id="index_full_blocks">'; 162 } 163 foreach ($blocks['side'] as $block_id=>$module_name) { 164 $class_name=$module_name.'_WT_Module'; 165 $module=new $class_name; 166 if ($SEARCH_SPIDER || !$module->loadAjax()) { 167 // Load the block directly 168 $module->getBlock($block_id); 169 } else { 170 // Load the block asynchronously 171 echo '<div id="block_', $block_id, '"><img src="images/loading.gif" alt="', htmlspecialchars(i18n::translate('Loading...')), '"/></div>'; 172 echo WT_JS_START, "jQuery('#block_{$block_id}').load('index.php?ctype={$ctype}&action=ajax&block_id={$block_id}');", WT_JS_END; 173 } 174 } 175 echo '</div>'; 176} 177 178// Ensure there is always way to configure the blocks 179if ($ctype=='user' && !in_array('user_welcome', $blocks['main']) && !in_array('user_welcome', $blocks['side'])) { 180 echo '<div align="center">'; 181 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>'; 182 echo help_link('mypage_customize'); 183 echo '</div>'; 184} 185if (WT_USER_IS_ADMIN && $ctype=='gedcom' && !in_array('gedcom_block', $blocks['main']) && !in_array('gedcom_block', $blocks['side'])) { 186 echo '<div align="center">'; 187 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>'; 188 echo '</div>'; 189} 190 191print_footer(); 192