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