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