diff options
102 files changed, 627 insertions, 509 deletions
diff --git a/action.php b/action.php index ed48cb8368..851816cddd 100644 --- a/action.php +++ b/action.php @@ -42,7 +42,7 @@ switch (Filter::post('action')) { case 'accept-changes': // Accept all the pending changes for a record $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF)); - if ($record && WT_USER_CAN_ACCEPT && $record->canShow() && $record->canEdit()) { + if ($record && Auth::isModerator($record->getTree()) && $record->canShow() && $record->canEdit()) { FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('The changes to “%s” have been accepted.', $record->getFullName())); accept_all_changes($record->getXref(), $record->getTree()->getTreeId()); } else { @@ -126,7 +126,7 @@ case 'delete-note': case 'delete-repository': case 'delete-source': $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF)); - if ($record && WT_USER_CAN_EDIT && $record->canShow() && $record->canEdit()) { + if ($record && Auth::isEditor($record->getTree()) && $record->canShow() && $record->canEdit()) { // Delete links to this record foreach (fetch_all_links($record->getXref(), $record->getTree()->getTreeId()) as $xref) { $linker = GedcomRecord::getInstance($xref); @@ -213,7 +213,7 @@ case 'unlink-media': case 'reject-changes': // Reject all the pending changes for a record $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF)); - if ($record && WT_USER_CAN_ACCEPT && $record->canShow() && $record->canEdit()) { + if ($record && $record->canEdit() && Auth::isModerator($record->getTree())) { FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('The changes to “%s” have been rejected.', $record->getFullName())); reject_all_changes($record->getXref(), $record->getTree()->getTreeId()); } else { diff --git a/addmedia.php b/addmedia.php index 5ecd12f4f3..038a90db2d 100644 --- a/addmedia.php +++ b/addmedia.php @@ -58,7 +58,7 @@ if ($action == 'update' || $action == 'create') { } } -if (!WT_USER_CAN_EDIT || !$disp) { +if (!Auth::isEditor($WT_TREE) || !$disp) { $controller ->pageHeader() ->addInlineJavascript('closePopupAndReloadParent();'); @@ -100,7 +100,7 @@ case 'create': // Save the information from the “showcreateform” action // Managers can create new media paths (subfolders). Users must use existing folders. if ($folderName && !is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) { - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) { FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName))); } else { @@ -261,7 +261,7 @@ case 'update': // Save the information from the “editmedia” action // Managers can create new media paths (subfolders). Users must use existing folders. if ($folderName && !is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) { - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) { FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName))); } else { @@ -442,7 +442,7 @@ if ($gedfile == 'FILE') { echo '<tr><td class="descriptionbox wrap width25">'; echo I18N::translate('Media file to upload') . '</td><td class="optionbox wrap"><input type="file" name="mediafile" onchange="updateFormat(this.value);" size="40"></td></tr>'; // Check for thumbnail generation support - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { echo '<tr><td class="descriptionbox wrap width25">'; echo I18N::translate('Thumbnail to upload') . '</td><td class="optionbox wrap"><input type="file" name="thumbnail" size="40">'; echo '<p class="sub">', I18N::translate('Choose the thumbnail image that you want to upload. Although thumbnails can be generated automatically for images, you may wish to generate your own thumbnail, especially for other media types. For example, you can provide a still image from a video, or a photograph of the individual who made an audio recording.'), '</p>'; @@ -453,7 +453,7 @@ if ($gedfile == 'FILE') { // Filename on server $isExternal = isFileExternal($gedfile); if ($gedfile == 'FILE') { - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { add_simple_tag( "1 $gedfile", '', @@ -481,7 +481,7 @@ if ($gedfile == 'FILE') { echo I18N::translate('Filename on server'), help_link('upload_server_file'); echo '</td>'; echo '<td class="optionbox wrap wrap">'; - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { echo '<input name="filename" type="text" value="' . Filter::escapeHtml($fileName) . '" size="40"'; if ($isExternal) { echo '>'; @@ -501,7 +501,7 @@ if (!$isExternal) { echo '<tr><td class="descriptionbox wrap width25">'; echo I18N::translate('Folder name on server'), '</td><td class="optionbox wrap">'; //-- don’t let regular users change the location of media items - if ($action !== 'update' || WT_USER_GEDCOM_ADMIN) { + if ($action !== 'update' || Auth::isManager($WT_TREE)) { $mediaFolders = QueryMedia::folderList(); echo '<span dir="ltr"><select name="folder_list" onchange="document.newmedia.folder.value=this.options[this.selectedIndex].value;">'; echo '<option '; diff --git a/admin_media_upload.php b/admin_media_upload.php index 55645fe1c5..a20e75f445 100644 --- a/admin_media_upload.php +++ b/admin_media_upload.php @@ -67,7 +67,7 @@ if ($action == "upload") { // Managers can create new media paths (subfolders). Users must use existing folders. if ($folderName && !is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) { - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) { FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName))); } else { @@ -212,7 +212,7 @@ for ($i = 1; $i < 6; $i++) { } echo '</td></tr>'; - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { echo '<tr><td>'; echo I18N::translate('Filename on server'); echo '</td>'; @@ -227,7 +227,7 @@ for ($i = 1; $i < 6; $i++) { echo '<tr style="display:none;"><td><input type="hidden" name="filename', $i, '" value=""></td></tr>'; } - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { echo '<tr><td>'; echo I18N::translate('Folder name on server'); echo '</td>'; diff --git a/admin_pgv_to_wt.php b/admin_pgv_to_wt.php index 4ee8b4dad1..4672935506 100644 --- a/admin_pgv_to_wt.php +++ b/admin_pgv_to_wt.php @@ -602,14 +602,14 @@ if ($PGV_SCHEMA_VERSION >= 12) { } define('PGV_PHPGEDVIEW', true); -define('PGV_PRIV_PUBLIC', WT_PRIV_PUBLIC); -define('PGV_PRIV_USER', WT_PRIV_USER); -define('PGV_PRIV_NONE', WT_PRIV_NONE); -define('PGV_PRIV_HIDE', WT_PRIV_HIDE); -$PRIV_PUBLIC = WT_PRIV_PUBLIC; -$PRIV_USER = WT_PRIV_USER; -$PRIV_NONE = WT_PRIV_NONE; -$PRIV_HIDE = WT_PRIV_HIDE; +define('PGV_PRIV_PUBLIC', Auth::PRIV_PRIVATE); +define('PGV_PRIV_USER', Auth::PRIV_USER); +define('PGV_PRIV_NONE', Auth::PRIV_NONE); +define('PGV_PRIV_HIDE', Auth::PRIV_HIDE); +$PRIV_PUBLIC = Auth::PRIV_PRIVATE; +$PRIV_USER = Auth::PRIV_USER; +$PRIV_NONE = Auth::PRIV_NONE; +$PRIV_HIDE = Auth::PRIV_HIDE; // Old versions of PGV used a $GEDCOMS[] array. // New versions used a database. diff --git a/admin_trees_config.php b/admin_trees_config.php index f5352b4dbb..46bcdf2071 100644 --- a/admin_trees_config.php +++ b/admin_trees_config.php @@ -124,10 +124,10 @@ $PRIVACY_CONSTANTS = array( ); $privacy = array( - WT_PRIV_PUBLIC => I18N::translate('Show to visitors'), - WT_PRIV_USER => I18N::translate('Show to members'), - WT_PRIV_NONE => I18N::translate('Show to managers'), - WT_PRIV_HIDE => I18N::translate('Hide from everyone'), + Auth::PRIV_PRIVATE => I18N::translate('Show to visitors'), + Auth::PRIV_USER => I18N::translate('Show to members'), + Auth::PRIV_NONE => I18N::translate('Show to managers'), + Auth::PRIV_HIDE => I18N::translate('Hide from everyone'), ); $tags = array_unique(array_merge( @@ -1062,8 +1062,8 @@ $controller <?php echo /* I18N: A configuration setting */ I18N::translate('Who can upload new media files?'); ?> </label> <div class="col-sm-9"> - <?php echo select_edit_control('MEDIA_UPLOAD', array(WT_PRIV_USER=> I18N::translate('Show to members'), - WT_PRIV_NONE=> I18N::translate('Show to managers'), WT_PRIV_HIDE=> I18N::translate('Hide from everyone')), null, $WT_TREE->getPreference('MEDIA_UPLOAD'), 'class="form-control"'); ?> + <?php echo select_edit_control('MEDIA_UPLOAD', array(Auth::PRIV_USER=> I18N::translate('Show to members'), + Auth::PRIV_NONE=> I18N::translate('Show to managers'), Auth::PRIV_HIDE=> I18N::translate('Hide from everyone')), null, $WT_TREE->getPreference('MEDIA_UPLOAD'), 'class="form-control"'); ?> <p class="small text-muted"> <?php echo /* I18N: Help text for the “Who can upload new media files?” configuration setting */ I18N::translate('If you are concerned that users might upload inappropriate images, you can restrict media uploads to managers only.'); ?> </p> diff --git a/app/Auth.php b/app/Auth.php index fb3022101a..45c43a9826 100644 --- a/app/Auth.php +++ b/app/Auth.php @@ -22,13 +22,19 @@ use Zend_Session; * Class Auth - authentication functions */ class Auth { + // Privacy constants + const PRIV_PRIVATE = 2; // Allows visitors to view the item + const PRIV_USER = 1; // Allows members to access the item + const PRIV_NONE = 0; // Allows managers to access the item + const PRIV_HIDE = -1; // Hide the item to all users + /** * Are we currently logged in? * * @return boolean */ public static function check() { - return Auth::id() !== null; + return self::id() !== null; } /** @@ -47,7 +53,7 @@ class Auth { } /** - * Is a user a manager of a tree? + * Is the specified/current user a manager of a tree? * * @param Tree $tree * @param User|null $user @@ -63,7 +69,7 @@ class Auth { } /** - * Is a user a moderator of a tree? + * Is the specified/current user a moderator of a tree? * * @param Tree $tree * @param User|null $user @@ -79,7 +85,7 @@ class Auth { } /** - * Is a user an editor of a tree? + * Is the specified/current user an editor of a tree? * * @param Tree $tree * @param User|null $user @@ -96,7 +102,7 @@ class Auth { } /** - * Is a user a member of a tree? + * Is the specified/current user a member of a tree? * * @param Tree $tree * @param User|null $user @@ -112,6 +118,28 @@ class Auth { } /** + * What is the specified/current user's access level within a tree? + * + * @param Tree $tree + * @param User|null $user + * + * @return boolean + */ + public static function accessLevel(Tree $tree, User $user = null) { + if ($user === null) { + $user = self::user(); + } + + if (self::isManager($tree, $user)) { + return self::PRIV_NONE; + } elseif (self::isMember($tree, $user)) { + return self::PRIV_USER; + } else { + return self::PRIV_PRIVATE; + } + } + + /** * Is the current visitor a search engine? The global is set in session.php * * @return boolean @@ -139,7 +167,7 @@ class Auth { * @return User */ public static function user() { - $user = User::find(Auth::id()); + $user = User::find(self::id()); if ($user === null) { $visitor = new \stdClass; $visitor->user_id = ''; diff --git a/app/Controller/AncestryController.php b/app/Controller/AncestryController.php index e743e5e8b2..8ebc074477 100644 --- a/app/Controller/AncestryController.php +++ b/app/Controller/AncestryController.php @@ -83,7 +83,7 @@ class AncestryController extends ChartController { echo '</td>'; echo '<td>'; if ($sosa > 1) { - print_url_arrow('?rootid=' . $pid . '&PEDIGREE_GENERATIONS=' . $this->generations . '&show_full=' . $this->showFull() . '&chart_style=' . $this->chart_style . '&ged=' . WT_GEDURL, $label, 3); + print_url_arrow('?rootid=' . $pid . '&PEDIGREE_GENERATIONS=' . $this->generations . '&show_full=' . $this->showFull() . '&chart_style=' . $this->chart_style . '&ged=' . $person->getTree()->getNameUrl(), $label, 3); } echo '</td>'; echo '<td class="details1"> <span dir="ltr" class="person_box' . (($sosa == 1) ? 'NN' : (($sosa % 2) ? 'F' : '')) . '"> ', $sosa, ' </span> '; diff --git a/app/Controller/BranchesController.php b/app/Controller/BranchesController.php index 96c67ee76f..b04db7b3c9 100644 --- a/app/Controller/BranchesController.php +++ b/app/Controller/BranchesController.php @@ -39,6 +39,8 @@ class BranchesController extends PageController { * Create a branches list controller */ public function __construct() { + global $WT_TREE; + parent::__construct(); $this->surname = Filter::get('surname'); @@ -49,7 +51,7 @@ class BranchesController extends PageController { $this->setPageTitle(/* I18N: %s is a surname */ I18N::translate('Branches of the %s family', Filter::escapeHtml($this->surname))); $this->loadIndividuals(); - $self = Individual::getInstance(WT_USER_GEDCOM_ID); + $self = Individual::getInstance($WT_TREE->getUserPreference(Auth::user(), 'gedcomid')); if ($self) { $this->loadAncestors($self, 1); } @@ -198,7 +200,7 @@ class BranchesController extends PageController { $sosa = array_search($individual, $this->ancestors, true); if ($sosa) { $sosa_class = 'search_hit'; - $sosa_html = ' <a class="details1 ' . $individual->getBoxStyle() . '" title="' . I18N::translate('Sosa') . '" href="relationship.php?pid2=' . WT_USER_ROOT_ID . '&pid1=' . $individual->getXref() . '">' . $sosa . '</a>' . self::sosaGeneration($sosa); + $sosa_html = ' <a class="details1 ' . $individual->getBoxStyle() . '" title="' . I18N::translate('Sosa') . '" href="relationship.php?pid2=' . $WT_TREE->getUserPreference(Auth::user(), 'rootid') . '&pid1=' . $individual->getXref() . '">' . $sosa . '</a>' . self::sosaGeneration($sosa); } else { $sosa_class = ''; $sosa_html = ''; @@ -234,7 +236,7 @@ class BranchesController extends PageController { $sosa = array_search($spouse, $this->ancestors, true); if ($sosa) { $sosa_class = 'search_hit'; - $sosa_html = ' <a class="details1 ' . $spouse->getBoxStyle() . '" title="' . I18N::translate('Sosa') . '" href="relationship.php?pid2=' . WT_USER_ROOT_ID . '&pid1=' . $spouse->getXref() . '"> ' . $sosa . ' </a>' . self::sosaGeneration($sosa); + $sosa_html = ' <a class="details1 ' . $spouse->getBoxStyle() . '" title="' . I18N::translate('Sosa') . '" href="relationship.php?pid2=' . $WT_TREE->getUserPreference(Auth::user(), 'rootid') . '&pid1=' . $spouse->getXref() . '"> ' . $sosa . ' </a>' . self::sosaGeneration($sosa); } else { $sosa_class = ''; $sosa_html = ''; diff --git a/app/Controller/DescendancyController.php b/app/Controller/DescendancyController.php index e4d71c39e2..4a634d8892 100644 --- a/app/Controller/DescendancyController.php +++ b/app/Controller/DescendancyController.php @@ -107,7 +107,7 @@ class DescendancyController extends ChartController { echo '<td>'; foreach ($person->getChildFamilies() as $cfamily) { foreach ($cfamily->getSpouses() as $parent) { - print_url_arrow('?rootid=' . $parent->getXref() . '&generations=' . $this->generations . '&chart_style=' . $this->chart_style . '&show_full=' . $this->showFull() . '&ged=' . WT_GEDURL, I18N::translate('Start at parents'), 2); + print_url_arrow('?rootid=' . $parent->getXref() . '&generations=' . $this->generations . '&chart_style=' . $this->chart_style . '&show_full=' . $this->showFull() . '&ged=' . $parent->getTree()->getNameUrl(), I18N::translate('Start at parents'), 2); // only show the arrow for one of the parents break; } @@ -186,7 +186,7 @@ class DescendancyController extends ChartController { if ($spouse) { foreach ($spouse->getChildFamilies() as $cfamily) { foreach ($cfamily->getSpouses() as $parent) { - print_url_arrow('?rootid=' . $parent->getXref() . '&generations=' . $this->generations . '&chart_style=' . $this->chart_style . '&show_full=' . $this->showFull() . '&ged=' . WT_GEDURL, I18N::translate('Start at parents'), 2); + print_url_arrow('?rootid=' . $parent->getXref() . '&generations=' . $this->generations . '&chart_style=' . $this->chart_style . '&show_full=' . $this->showFull() . '&ged=' . $parent->getTree()->getNameUrl(), I18N::translate('Start at parents'), 2); // only show the arrow for one of the parents break; } diff --git a/app/Controller/FamilyController.php b/app/Controller/FamilyController.php index 5f9504ea39..c78db3aa1d 100644 --- a/app/Controller/FamilyController.php +++ b/app/Controller/FamilyController.php @@ -86,7 +86,7 @@ class FamilyController extends GedcomRecordController { // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-fam'); - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { // edit_fam / members $submenu = new Menu(I18N::translate('Change family members'), '#', 'menu-fam-change'); $submenu->setOnclick("return change_family_members('" . $this->record->getXref() . "');"); @@ -106,14 +106,14 @@ class FamilyController extends GedcomRecordController { } // delete - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { $submenu = new Menu(I18N::translate('Delete'), '#', 'menu-fam-del'); $submenu->setOnclick("return delete_family('" . I18N::translate('Deleting the family will unlink all of the individuals from each other but will leave the individuals in place. Are you sure you want to delete this family?') . "', '" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); } // edit raw - if (Auth::isAdmin() || WT_USER_CAN_EDIT && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { + if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $submenu = new Menu(I18N::translate('Edit raw GEDCOM'), '#', 'menu-fam-editraw'); $submenu->setOnclick("return edit_raw('" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); @@ -159,7 +159,7 @@ class FamilyController extends GedcomRecordController { * Print the facts */ public function printFamilyFacts() { - global $linkToID, $WT_TREE; + global $linkToID; $linkToID = $this->record->getXref(); // -- Tell addmedia.php what to link to @@ -173,7 +173,7 @@ class FamilyController extends GedcomRecordController { echo '<tr><td class="messagebox" colspan="2">', I18N::translate('No facts for this family.'), '</td></tr>'; } - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { print_add_new_fact($this->record->getXref(), $indifacts, 'FAM'); echo '<tr><td class="descriptionbox">'; @@ -188,7 +188,7 @@ class FamilyController extends GedcomRecordController { echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','SHARED_NOTE');\">", I18N::translate('Add a new shared note'), '</a>'; echo '</td></tr>'; - if ($WT_TREE->getPreference('MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { + if ($this->record->getTree()->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($this->record->getTree())) { echo '<tr><td class="descriptionbox">'; echo I18N::translate('Media object'); echo '</td><td class="optionbox">'; diff --git a/app/Controller/FanchartController.php b/app/Controller/FanchartController.php index 4ef7da9f34..62bca2d628 100644 --- a/app/Controller/FanchartController.php +++ b/app/Controller/FanchartController.php @@ -335,7 +335,7 @@ class FanchartController extends ChartController { // add action url $pid = $person->getXref(); $imagemap .= '" href="#' . $pid . '"'; - $tempURL = 'fanchart.php?rootid=' . $pid . '&generations=' . $this->generations . '&fan_width=' . $this->fan_width . '&fan_style=' . $this->fan_style . '&ged=' . WT_GEDURL; + $tempURL = 'fanchart.php?rootid=' . $pid . '&generations=' . $this->generations . '&fan_width=' . $this->fan_width . '&fan_style=' . $this->fan_style . '&ged=' . $person->getTree()->getNameUrl(); $html .= '<div id="' . $pid . '" class="fan_chart_menu">'; $html .= '<div class="person_box"><div class="details1">'; $html .= '<a href="' . $person->getHtmlUrl() . '" class="name1">' . $name; @@ -344,20 +344,21 @@ class FanchartController extends ChartController { } $html .= '</a>'; $html .= '<ul class="charts">'; - $html .= '<li><a href="pedigree.php?rootid=' . $pid . '&ged=' . WT_GEDURL . '" >' . I18N::translate('Pedigree') . '</a></li>'; + $html .= '<li><a href="pedigree.php?rootid=' . $pid . '&ged=' . $person->getTree()->getNameUrl() . '" >' . I18N::translate('Pedigree') . '</a></li>'; if (Module::getModuleByName('googlemap')) { - $html .= '<li><a href="module.php?mod=googlemap&mod_action=pedigree_map&rootid=' . $pid . '&ged=' . WT_GEDURL . '">' . I18N::translate('Pedigree map') . '</a></li>'; + $html .= '<li><a href="module.php?mod=googlemap&mod_action=pedigree_map&rootid=' . $pid . '&ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Pedigree map') . '</a></li>'; } - if (WT_USER_GEDCOM_ID && WT_USER_GEDCOM_ID != $pid) { - $html .= '<li><a href="relationship.php?pid1=' . WT_USER_GEDCOM_ID . '&pid2=' . $pid . '&ged=' . WT_GEDURL . '">' . I18N::translate('Relationship to me') . '</a></li>'; + $gedcomid = $person->getTree()->getUserPreference(Auth::user(), 'gedcomid'); + if ($gedcomid && $gedcomid != $pid) { + $html .= '<li><a href="relationship.php?pid1=' . $gedcomid . '&pid2=' . $pid . '&ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Relationship to me') . '</a></li>'; } - $html .= '<li><a href="descendancy.php?rootid=' . $pid . '&ged=' . WT_GEDURL . '" >' . I18N::translate('Descendants') . '</a></li>'; - $html .= '<li><a href="ancestry.php?rootid=' . $pid . '&ged=' . WT_GEDURL . '">' . I18N::translate('Ancestors') . '</a></li>'; - $html .= '<li><a href="compact.php?rootid=' . $pid . '&ged=' . WT_GEDURL . '">' . I18N::translate('Compact tree') . '</a></li>'; + $html .= '<li><a href="descendancy.php?rootid=' . $pid . '&ged=' . $person->getTree()->getNameUrl() . '" >' . I18N::translate('Descendants') . '</a></li>'; + $html .= '<li><a href="ancestry.php?rootid=' . $pid . '&ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Ancestors') . '</a></li>'; + $html .= '<li><a href="compact.php?rootid=' . $pid . '&ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Compact tree') . '</a></li>'; $html .= '<li><a href="' . $tempURL . '">' . I18N::translate('Fan chart') . '</a></li>'; - $html .= '<li><a href="hourglass.php?rootid=' . $pid . '&ged=' . WT_GEDURL . '">' . I18N::translate('Hourglass chart') . '</a></li>'; + $html .= '<li><a href="hourglass.php?rootid=' . $pid . '&ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Hourglass chart') . '</a></li>'; if (Module::getModuleByName('tree')) { - $html .= '<li><a href="module.php?mod=tree&mod_action=treeview&ged=' . WT_GEDURL . '&rootid=' . $pid . '">' . I18N::translate('Interactive tree') . '</a></li>'; + $html .= '<li><a href="module.php?mod=tree&mod_action=treeview&ged=' . $person->getTree()->getNameUrl() . '&rootid=' . $pid . '">' . I18N::translate('Interactive tree') . '</a></li>'; } $html .= '</ul>'; // spouse(s) and children diff --git a/app/Controller/IndividualController.php b/app/Controller/IndividualController.php index e9f4ac29de..583a1d3be5 100644 --- a/app/Controller/IndividualController.php +++ b/app/Controller/IndividualController.php @@ -269,7 +269,7 @@ class IndividualController extends GedcomRecordController { // will copy the first submenu - which may be edit-raw or delete. // As a temporary solution, make it edit the name $menu->setOnclick("return false;"); - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { foreach ($this->record->getFacts() as $fact) { if ($fact->getTag() === 'NAME' && $fact->canEdit()) { $menu->setOnclick("return edit_name('" . $this->record->getXref() . "', '" . $fact->getFactId() . "');"); @@ -303,14 +303,14 @@ class IndividualController extends GedcomRecordController { } // delete - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { $submenu = new Menu(I18N::translate('Delete'), '#', 'menu-indi-del'); $submenu->setOnclick("return delete_individual('" . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJS(Filter::unescapeHtml($this->record->getFullName()))) . "', '" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); } // edit raw - if (Auth::isAdmin() || WT_USER_CAN_EDIT && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { + if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $submenu = new Menu(I18N::translate('Edit raw GEDCOM'), '#', 'menu-indi-editraw'); $submenu->setOnclick("return edit_raw('" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); diff --git a/app/Controller/MediaController.php b/app/Controller/MediaController.php index cb2713a545..cad29e5b42 100644 --- a/app/Controller/MediaController.php +++ b/app/Controller/MediaController.php @@ -41,7 +41,7 @@ class MediaController extends GedcomRecordController { // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-obje'); - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { $submenu = new Menu(I18N::translate('Edit media object'), '#', 'menu-obje-edit'); $submenu->setOnclick("window.open('addmedia.php?action=editmedia&pid={$this->record->getXref()}', '_blank', edit_window_specs)"); $menu->addSubmenu($submenu); @@ -67,14 +67,14 @@ class MediaController extends GedcomRecordController { } // delete - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { $submenu = new Menu(I18N::translate('Delete'), '#', 'menu-obje-del'); $submenu->setOnclick("return delete_media('" . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJS(Filter::unescapeHtml($this->record->getFullName()))) . "', '" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); } // edit raw - if (Auth::isAdmin() || WT_USER_CAN_EDIT && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { + if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $submenu = new Menu(I18N::translate('Edit raw GEDCOM'), '#', 'menu-obje-editraw'); $submenu->setOnclick("return edit_raw('" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); diff --git a/app/Controller/NoteController.php b/app/Controller/NoteController.php index 3e4d643581..ab83d482e0 100644 --- a/app/Controller/NoteController.php +++ b/app/Controller/NoteController.php @@ -41,14 +41,14 @@ class NoteController extends GedcomRecordController { // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-note'); - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { $submenu = new Menu(I18N::translate('Edit note'), '#', 'menu-note-edit'); $submenu->setOnclick('return edit_note(\'' . $this->record->getXref() . '\');'); $menu->addSubmenu($submenu); } // delete - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { $submenu = new Menu(I18N::translate('Delete'), '#', 'menu-note-del'); $submenu->setOnclick("return delete_note('" . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJS(Filter::unescapeHtml($this->record->getFullName()))) . "', '" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); diff --git a/app/Controller/PageController.php b/app/Controller/PageController.php index 99af6abc16..fff0fda65f 100644 --- a/app/Controller/PageController.php +++ b/app/Controller/PageController.php @@ -217,11 +217,11 @@ class PageController extends BaseController { static $individual; // Only query the DB once. - if (!$individual && WT_USER_ROOT_ID) { - $individual = Individual::getInstance(WT_USER_ROOT_ID); + if (!$individual && $WT_TREE->getUserPreference(Auth::user(), 'rootid')) { + $individual = Individual::getInstance($WT_TREE->getUserPreference(Auth::user(), 'rootid')); } - if (!$individual && WT_USER_GEDCOM_ID) { - $individual = Individual::getInstance(WT_USER_GEDCOM_ID); + if (!$individual && $WT_TREE->getUserPreference(Auth::user(), 'gedcomid')) { + $individual = Individual::getInstance($WT_TREE->getUserPreference(Auth::user(), 'gedcomid')); } if (!$individual) { $individual = Individual::getInstance($WT_TREE->getPreference('PEDIGREE_ROOT_ID')); diff --git a/app/Controller/RepositoryController.php b/app/Controller/RepositoryController.php index 736aec1faa..e9573d9828 100644 --- a/app/Controller/RepositoryController.php +++ b/app/Controller/RepositoryController.php @@ -41,7 +41,7 @@ class RepositoryController extends GedcomRecordController { // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-repo'); - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { $fact = $this->record->getFirstFact('NAME'); $submenu = new Menu(I18N::translate('Edit repository'), '#', 'menu-repo-edit'); if ($fact) { @@ -55,14 +55,14 @@ class RepositoryController extends GedcomRecordController { } // delete - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { $submenu = new Menu(I18N::translate('Delete'), '#', 'menu-repo-del'); $submenu->setOnclick("return delete_repository('" . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJS(Filter::unescapeHtml($this->record->getFullName()))) . "', '" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); } // edit raw - if (Auth::isAdmin() || WT_USER_CAN_EDIT && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { + if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $submenu = new Menu(I18N::translate('Edit raw GEDCOM'), '#', 'menu-repo-editraw'); $submenu->setOnclick("return edit_raw('" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); diff --git a/app/Controller/SourceController.php b/app/Controller/SourceController.php index 3d513ccb1d..916d188547 100644 --- a/app/Controller/SourceController.php +++ b/app/Controller/SourceController.php @@ -41,7 +41,7 @@ class SourceController extends GedcomRecordController { // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-sour'); - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { $fact = $this->record->getFirstFact('TITL'); $submenu = new Menu(I18N::translate('Edit source'), '#', 'menu-sour-edit'); if ($fact) { @@ -55,14 +55,14 @@ class SourceController extends GedcomRecordController { } // delete - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->record->getTree())) { $submenu = new Menu(I18N::translate('Delete'), '#', 'menu-sour-del'); $submenu->setOnclick("return delete_source('" . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJS(Filter::unescapeHtml($this->record->getFullName()))) . "', '" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); } // edit raw - if (Auth::isAdmin() || WT_USER_CAN_EDIT && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { + if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $submenu = new Menu(I18N::translate('Edit raw GEDCOM'), '#', 'menu-sour-editraw'); $submenu->setOnclick("return edit_raw('" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); diff --git a/app/Fact.php b/app/Fact.php index 6be581e2b4..833e48b97a 100644 --- a/app/Fact.php +++ b/app/Fact.php @@ -129,17 +129,21 @@ class Fact { /** * Do the privacy rules allow us to display this fact to the current user * - * @param integer $access_level + * @param integer|null $access_level * * @return boolean */ - public function canShow($access_level = WT_USER_ACCESS_LEVEL) { + public function canShow($access_level = null) { + if ($access_level === null) { + $access_level = Auth::accessLevel($this->getParent()->getTree()); + } + // Does this record have an explicit RESN? if (strpos($this->gedcom, "\n2 RESN confidential")) { - return WT_PRIV_NONE >= $access_level; + return Auth::PRIV_NONE >= $access_level; } if (strpos($this->gedcom, "\n2 RESN privacy")) { - return WT_PRIV_USER >= $access_level; + return Auth::PRIV_USER >= $access_level; } if (strpos($this->gedcom, "\n2 RESN none")) { return true; @@ -170,8 +174,8 @@ class Fact { // Members cannot edit RESN, CHAN and locked records return $this->parent->canEdit() && !$this->isPendingDeletion() && ( - WT_USER_GEDCOM_ADMIN || - WT_USER_CAN_EDIT && strpos($this->gedcom, "\n2 RESN locked") === false && $this->getTag() != 'RESN' && $this->getTag() != 'CHAN' + Auth::isManager($this->parent->getTree()) || + Auth::isEditor($this->parent->getTree()) && strpos($this->gedcom, "\n2 RESN locked") === false && $this->getTag() != 'RESN' && $this->getTag() != 'CHAN' ); } diff --git a/app/Family.php b/app/Family.php index f94aac005d..daf33c778b 100644 --- a/app/Family.php +++ b/app/Family.php @@ -137,7 +137,11 @@ class Family extends GedcomRecord { } /** {@inheritdoc} */ - public function canShowName($access_level = WT_USER_ACCESS_LEVEL) { + public function canShowName($access_level = null) { + if ($access_level === null) { + $access_level = Auth::accessLevel($this->tree); + } + // We can always see the name (Husband-name + Wife-name), however, // the name will often be "private + private" return true; @@ -161,11 +165,15 @@ class Family extends GedcomRecord { /** * Get the (zero, one or two) spouses from this family. * - * @param integer $access_level + * @param integer|null $access_level * * @return Individual[] */ - function getSpouses($access_level = WT_USER_ACCESS_LEVEL) { + function getSpouses($access_level = null) { + if ($access_level === null) { + $access_level = Auth::accessLevel($this->tree); + } + $spouses = array(); if ($this->husb && $this->husb->canShowName($access_level)) { $spouses[] = $this->husb; @@ -180,11 +188,15 @@ class Family extends GedcomRecord { /** * Get a list of this family’s children. * - * @param integer $access_level + * @param integer|null $access_level * * @return Individual[] */ - function getChildren($access_level = WT_USER_ACCESS_LEVEL) { + function getChildren($access_level = null) { + if ($access_level === null) { + $access_level = Auth::accessLevel($this->tree); + } + $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); $children = array(); diff --git a/app/GedcomRecord.php b/app/GedcomRecord.php index d8d8e95012..d62f694524 100644 --- a/app/GedcomRecord.php +++ b/app/GedcomRecord.php @@ -38,13 +38,13 @@ class GedcomRecord { /** @var Fact[] facts extracted from $gedcom/$pending */ protected $facts; - /** @var boolean Can we display details of this record to WT_PRIV_PUBLIC */ + /** @var boolean Can we display details of this record to Auth::PRIV_PRIVATE */ private $disp_public; - /** @var boolean Can we display details of this record to WT_PRIV_USER */ + /** @var boolean Can we display details of this record to Auth::PRIV_USER */ private $disp_user; - /** @var boolean Can we display details of this record to WT_PRIV_NONE */ + /** @var boolean Can we display details of this record to Auth::PRIV_NONE */ private $disp_none; /** @var string[][] All the names of this individual */ @@ -140,7 +140,7 @@ class GedcomRecord { } // If we can edit, then we also need to be able to see pending records. - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor(Tree::findById($gedcom_id))) { if (!isset(self::$pending_record_cache[$gedcom_id])) { // Fetch all pending records in one database query self::$pending_record_cache[$gedcom_id] = array(); @@ -359,16 +359,16 @@ class GedcomRecord { } // We should always be able to see our own record (unless an admin is applying download restrictions) - if ($this->getXref() === WT_USER_GEDCOM_ID && $this->tree->getTreeId() === WT_GED_ID && $access_level === WT_USER_ACCESS_LEVEL) { + if ($this->getXref() === $this->tree->getUserPreference(Auth::user(), 'gedcomid') && $access_level === Auth::accessLevel($this->tree)) { return true; } // Does this record have a RESN? if (strpos($this->gedcom, "\n1 RESN confidential")) { - return WT_PRIV_NONE >= $access_level; + return Auth::PRIV_NONE >= $access_level; } if (strpos($this->gedcom, "\n1 RESN privacy")) { - return WT_PRIV_USER >= $access_level; + return Auth::PRIV_USER >= $access_level; } if (strpos($this->gedcom, "\n1 RESN none")) { return true; @@ -381,7 +381,7 @@ class GedcomRecord { } // Privacy rules do not apply to admins - if (WT_PRIV_NONE >= $access_level) { + if (Auth::PRIV_NONE >= $access_level) { return true; } @@ -411,30 +411,34 @@ class GedcomRecord { /** * Can the details of this record be shown? * - * @param integer $access_level + * @param integer|null $access_level * * @return boolean */ - public function canShow($access_level = WT_USER_ACCESS_LEVEL) { - // CACHING: this function can take three different parameters, + public function canShow($access_level = null) { + if ($access_level === null) { + $access_level = Auth::accessLevel($this->tree); + } + +// CACHING: this function can take three different parameters, // and therefore needs three different caches for the result. switch ($access_level) { - case WT_PRIV_PUBLIC: // visitor + case Auth::PRIV_PRIVATE: // visitor if ($this->disp_public === null) { - $this->disp_public = $this->canShowRecord(WT_PRIV_PUBLIC); + $this->disp_public = $this->canShowRecord(Auth::PRIV_PRIVATE); } return $this->disp_public; - case WT_PRIV_USER: // member + case Auth::PRIV_USER: // member if ($this->disp_user === null) { - $this->disp_user = $this->canShowRecord(WT_PRIV_USER); + $this->disp_user = $this->canShowRecord(Auth::PRIV_USER); } return $this->disp_user; - case WT_PRIV_NONE: // admin + case Auth::PRIV_NONE: // admin if ($this->disp_none === null) { - $this->disp_none = $this->canShowRecord(WT_PRIV_NONE); + $this->disp_none = $this->canShowRecord(Auth::PRIV_NONE); } return $this->disp_none; - case WT_PRIV_HIDE: // hidden from admins + case Auth::PRIV_HIDE: // hidden from admins // We use this value to bypass privacy checks. For example, // when downloading data or when calculating privacy itself. return true; @@ -447,11 +451,15 @@ class GedcomRecord { /** * Can the name of this record be shown? * - * @param integer $access_level + * @param integer|null $access_level * * @return boolean */ - public function canShowName($access_level = WT_USER_ACCESS_LEVEL) { + public function canShowName($access_level = null) { + if ($access_level === null) { + $access_level = Auth::accessLevel($this->tree); + } + return $this->canShow($access_level); } @@ -461,7 +469,7 @@ class GedcomRecord { * @return boolean */ public function canEdit() { - return WT_USER_GEDCOM_ADMIN || WT_USER_CAN_EDIT && strpos($this->gedcom, "\n1 RESN locked") === false; + return Auth::isManager($this->tree) || Auth::isEditor($this->tree) && strpos($this->gedcom, "\n1 RESN locked") === false; } /** @@ -473,7 +481,7 @@ class GedcomRecord { * @return string */ public function privatizeGedcom($access_level) { - if ($access_level == WT_PRIV_HIDE) { + if ($access_level == Auth::PRIV_HIDE) { // We may need the original record, for example when downloading a GEDCOM or clippings cart return $this->gedcom; } elseif ($this->canShow($access_level)) { @@ -1010,15 +1018,19 @@ class GedcomRecord { /** * The facts and events for this record. * - * @param string $filter - * @param boolean $sort - * @param integer $access_level - * @param boolean $override Include private records, to allow us to implement $SHOW_PRIVATE_RELATIONSHIPS and $SHOW_LIVING_NAMES. + * @param string $filter + * @param boolean $sort + * @param integer|null $access_level + * @param boolean $override Include private records, to allow us to implement $SHOW_PRIVATE_RELATIONSHIPS and $SHOW_LIVING_NAMES. * * @return Fact[] */ - public function getFacts($filter = null, $sort = false, $access_level = WT_USER_ACCESS_LEVEL, $override = false) { - $facts = array(); + public function getFacts($filter = null, $sort = false, $access_level = null, $override = false) { + if ($access_level === null) { + $access_level = Auth::accessLevel($this->tree); + } + + $facts = array(); if ($this->canShow($access_level) || $override) { foreach ($this->facts as $fact) { if (($filter == null || preg_match('/^' . $filter . '$/', $fact->getTag())) && $fact->canShow($access_level)) { @@ -1139,7 +1151,7 @@ class GedcomRecord { list($new_gedcom) = explode("\n", $old_gedcom, 2); // Replacing (or deleting) an existing fact - foreach ($this->getFacts(null, false, WT_PRIV_HIDE) as $fact) { + foreach ($this->getFacts(null, false, Auth::PRIV_HIDE) as $fact) { if (!$fact->isPendingDeletion()) { if ($fact->getFactId() === $fact_id) { if ($gedcom) { diff --git a/app/Individual.php b/app/Individual.php index 7ec02fb24c..4df0a2feb7 100644 --- a/app/Individual.php +++ b/app/Individual.php @@ -59,7 +59,11 @@ class Individual extends GedcomRecord { * * {@inheritdoc} */ - public function canShowName($access_level = WT_USER_ACCESS_LEVEL) { + public function canShowName($access_level = null) { + if ($access_level === null) { + $access_level = Auth::accessLevel($this->tree); + } + return $this->tree->getPreference('SHOW_LIVING_NAMES') >= $access_level || $this->canShow($access_level); } @@ -99,12 +103,14 @@ class Individual extends GedcomRecord { } } // Consider relationship privacy (unless an admin is applying download restrictions) - if (WT_USER_GEDCOM_ID && WT_USER_PATH_LENGTH && $this->tree->getTreeId() == WT_GED_ID && $access_level = WT_USER_ACCESS_LEVEL) { - return self::isRelated($this, WT_USER_PATH_LENGTH); + $user_path_length = $this->tree->getUserPreference(Auth::user(), 'RELATIONSHIP_PATH_LENGTH'); + $gedcomid = $this->tree->getUserPreference(Auth::user(), 'gedcomid'); + if ($gedcomid && $user_path_length && $this->tree->getTreeId() == WT_GED_ID && $access_level = Auth::accessLevel($this->tree)) { + return self::isRelated($this, $user_path_length); } // No restriction found - show living people to members only: - return WT_PRIV_USER >= $access_level; + return Auth::PRIV_USER >= $access_level; } /** @@ -118,14 +124,14 @@ class Individual extends GedcomRecord { private static function isRelated(Individual $target, $distance) { static $cache = null; - $user_individual = Individual::getInstance(WT_USER_GEDCOM_ID); + $user_individual = Individual::getInstance($target->tree->getUserPreference(Auth::user(), 'gedcomid')); if ($user_individual) { if (!$cache) { $cache = array( 0 => array($user_individual), 1 => array(), ); - foreach ($user_individual->getFacts('FAM[CS]', false, WT_PRIV_HIDE) as $fact) { + foreach ($user_individual->getFacts('FAM[CS]', false, Auth::PRIV_HIDE) as $fact) { $family = $fact->getTarget(); if ($family) { $cache[1][] = $family; @@ -153,7 +159,7 @@ class Individual extends GedcomRecord { if ($n % 2 == 0) { // Add FAM->INDI links foreach ($cache[$n - 1] as $family) { - foreach ($family->getFacts('HUSB|WIFE|CHIL', false, WT_PRIV_HIDE) as $fact) { + foreach ($family->getFacts('HUSB|WIFE|CHIL', false, Auth::PRIV_HIDE) as $fact) { $individual = $fact->getTarget(); // Don’t backtrack if ($individual && !in_array($individual, $cache[$n - 2], true)) { @@ -167,7 +173,7 @@ class Individual extends GedcomRecord { } else { // Add INDI->FAM links foreach ($cache[$n - 1] as $individual) { - foreach ($individual->getFacts('FAM[CS]', false, WT_PRIV_HIDE) as $fact) { + foreach ($individual->getFacts('FAM[CS]', false, Auth::PRIV_HIDE) as $fact) { $family = $fact->getTarget(); // Don’t backtrack if ($family && !in_array($family, $cache[$n - 2], true)) { @@ -276,8 +282,8 @@ class Individual extends GedcomRecord { // If we found no conclusive dates then check the dates of close relatives. // Check parents (birth and adopted) - foreach ($this->getChildFamilies(WT_PRIV_HIDE) as $family) { - foreach ($family->getSpouses(WT_PRIV_HIDE) as $parent) { + foreach ($this->getChildFamilies(Auth::PRIV_HIDE) as $family) { + foreach ($family->getSpouses(Auth::PRIV_HIDE) as $parent) { // Assume parents are no more than 45 years older than their children preg_match_all('/\n2 DATE (.+)/', $parent->gedcom, $date_matches); foreach ($date_matches[1] as $date_match) { @@ -290,7 +296,7 @@ class Individual extends GedcomRecord { } // Check spouses - foreach ($this->getSpouseFamilies(WT_PRIV_HIDE) as $family) { + foreach ($this->getSpouseFamilies(Auth::PRIV_HIDE) as $family) { preg_match_all('/\n2 DATE (.+)/', $family->gedcom, $date_matches); foreach ($date_matches[1] as $date_match) { $date = new Date($date_match); @@ -312,7 +318,7 @@ class Individual extends GedcomRecord { } } // Check child dates - foreach ($family->getChildren(WT_PRIV_HIDE) as $child) { + foreach ($family->getChildren(Auth::PRIV_HIDE) as $child) { preg_match_all('/\n2 DATE (.+)/', $child->gedcom, $date_matches); // Assume children born after age of 15 foreach ($date_matches[1] as $date_match) { @@ -322,8 +328,8 @@ class Individual extends GedcomRecord { } } // Check grandchildren - foreach ($child->getSpouseFamilies(WT_PRIV_HIDE) as $child_family) { - foreach ($child_family->getChildren(WT_PRIV_HIDE) as $grandchild) { + foreach ($child->getSpouseFamilies(Auth::PRIV_HIDE) as $child_family) { + foreach ($child_family->getChildren(Auth::PRIV_HIDE) as $grandchild) { preg_match_all('/\n2 DATE (.+)/', $grandchild->gedcom, $date_matches); // Assume grandchildren born after age of 30 foreach ($date_matches[1] as $date_match) { @@ -740,11 +746,15 @@ class Individual extends GedcomRecord { /** * Get a list of this individual’s spouse families * - * @param integer $access_level + * @param integer|null $access_level * * @return Family[] */ - public function getSpouseFamilies($access_level = WT_USER_ACCESS_LEVEL) { + public function getSpouseFamilies($access_level = null) { + if ($access_level === null) { + $access_level = Auth::accessLevel($this->tree); + } + $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); $families = array(); @@ -799,11 +809,15 @@ class Individual extends GedcomRecord { /** * Get a list of this individual’s child families (i.e. their parents). * - * @param integer $access_level + * @param integer|null $access_level * * @return Family[] */ - public function getChildFamilies($access_level = WT_USER_ACCESS_LEVEL) { + public function getChildFamilies($access_level = null) { + if ($access_level === null) { + $access_level = Auth::accessLevel($this->tree); + } + $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); $families = array(); @@ -1244,7 +1258,7 @@ class Individual extends GedcomRecord { * Get an array of structures containing all the names in the record */ public function extractNames() { - $this->extractNamesFromFacts(1, 'NAME', $this->getFacts('NAME', false, WT_USER_ACCESS_LEVEL, $this->canShowName())); + $this->extractNamesFromFacts(1, 'NAME', $this->getFacts('NAME', false, Auth::accessLevel($this->tree), $this->canShowName())); } /** diff --git a/app/Media.php b/app/Media.php index b255c50518..e240c20861 100644 --- a/app/Media.php +++ b/app/Media.php @@ -314,7 +314,7 @@ class Media extends GedcomRecord { return ''; } - $etag_string = basename($this->getServerFilename($which)) . $this->getFiletime($which) . WT_GEDCOM . WT_USER_ACCESS_LEVEL . $this->tree->getPreference('SHOW_NO_WATERMARK'); + $etag_string = basename($this->getServerFilename($which)) . $this->getFiletime($which) . WT_GEDCOM . Auth::accessLevel($this->tree) . $this->tree->getPreference('SHOW_NO_WATERMARK'); $etag_string = dechex(crc32($etag_string)); return $etag_string; diff --git a/app/Module.php b/app/Module.php index 2f51cb2f50..3e484903d8 100644 --- a/app/Module.php +++ b/app/Module.php @@ -62,8 +62,8 @@ abstract class Module { * @return integer */ public function defaultAccessLevel() { - // Returns one of: WT_PRIV_HIDE, WT_PRIV_PUBLIC, WT_PRIV_USER, WT_PRIV_ADMIN - return WT_PRIV_PUBLIC; + // Returns one of: Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_USER, WT_PRIV_ADMIN + return Auth::PRIV_PRIVATE; } /** @@ -218,13 +218,12 @@ abstract class Module { * We cannot currently use auto-loading for modules, as there may be user-defined * modules about which the auto-loader knows nothing. * - * @param Tree $tree - * @param string $component The type of module, such as "tab", "report" or "menu" - * @param integer $access_level + * @param Tree $tree + * @param string $component The type of module, such as "tab", "report" or "menu" * * @return Module[] */ - private static function getActiveModulesByComponent(Tree $tree, $component, $access_level) { + private static function getActiveModulesByComponent(Tree $tree, $component) { $module_names = Database::prepare( "SELECT SQL_CACHE module_name" . " FROM `##module`" . @@ -234,7 +233,7 @@ abstract class Module { )->execute(array( 'tree_id' => $tree->getTreeId(), 'component' => $component, - 'access_level' => $access_level, + 'access_level' => Auth::accessLevel($tree), ))->fetchOneColumn(); $array = array(); @@ -259,85 +258,78 @@ abstract class Module { /** * Get a list of modules which (a) provide a block and (b) we have permission to see. * - * @param Tree $tree - * @param integer $access_level + * @param Tree $tree * * @return ModuleBlockInterface[] */ - public static function getActiveBlocks(Tree $tree, $access_level = WT_USER_ACCESS_LEVEL) { - return self::getActiveModulesByComponent($tree, 'block', $access_level); + public static function getActiveBlocks(Tree $tree) { + return self::getActiveModulesByComponent($tree, 'block'); } /** * Get a list of modules which (a) provide a chart and (b) we have permission to see. * - * @param Tree $tree - * @param integer $access_level + * @param Tree $tree * * @return ModuleChartInterface[] */ - public static function getActiveCharts(Tree $tree, $access_level = WT_USER_ACCESS_LEVEL) { - return self::getActiveModulesByComponent($tree, 'chart', $access_level); + public static function getActiveCharts(Tree $tree) { + return self::getActiveModulesByComponent($tree, 'chart'); } /** * Get a list of modules which (a) provide a menu and (b) we have permission to see. * - * @param Tree $tree - * @param integer $access_level + * @param Tree $tree * * @return ModuleMenuInterface[] */ - public static function getActiveMenus(Tree $tree, $access_level = WT_USER_ACCESS_LEVEL) { - return self::getActiveModulesByComponent($tree, 'menu', $access_level); + public static function getActiveMenus(Tree $tree) { + return self::getActiveModulesByComponent($tree, 'menu'); } /** * Get a list of modules which (a) provide a report and (b) we have permission to see. * - * @param Tree $tree - * @param integer $access_level + * @param Tree $tree * * @return ModuleReportInterface[] */ - public static function getActiveReports(Tree $tree, $access_level = WT_USER_ACCESS_LEVEL) { - return self::getActiveModulesByComponent($tree, 'report', $access_level); + public static function getActiveReports(Tree $tree) { + return self::getActiveModulesByComponent($tree, 'report'); } /** * Get a list of modules which (a) provide a sidebar and (b) we have permission to see. * - * @param Tree $tree - * @param integer $access_level + * @param Tree $tree * * @return ModuleSidebarInterface[] */ - public static function getActiveSidebars(Tree $tree, $access_level = WT_USER_ACCESS_LEVEL) { - return self::getActiveModulesByComponent($tree, 'sidebar', $access_level); + public static function getActiveSidebars(Tree $tree) { + return self::getActiveModulesByComponent($tree, 'sidebar'); } /** * Get a list of modules which (a) provide a tab and (b) we have permission to see. * - * @param Tree $tree - * @param integer $access_level + * @param Tree $tree * * @return ModuleTabInterface[] */ - public static function getActiveTabs(Tree $tree, $access_level = WT_USER_ACCESS_LEVEL) { - return self::getActiveModulesByComponent($tree, 'tab', $access_level); + public static function getActiveTabs(Tree $tree) { + return self::getActiveModulesByComponent($tree, 'tab'); } /** * Get a list of modules which (a) provide a theme and (b) we have permission to see. * - * @param Tree $tree - * @param integer $access_level + * @param Tree $tree * * @return ModuleThemeInterface[] */ - public static function getActiveThemes(Tree $tree, $access_level = WT_USER_ACCESS_LEVEL) { - return self::getActiveModulesByComponent($tree, 'theme', $access_level); + public static function getActiveThemes(Tree $tree) { + return self::getActiveModulesByComponent($tree, 'theme'); } /** diff --git a/app/Module/AhnentafelReportModule.php b/app/Module/AhnentafelReportModule.php index c24aa44f9e..a931e8b1d9 100644 --- a/app/Module/AhnentafelReportModule.php +++ b/app/Module/AhnentafelReportModule.php @@ -34,17 +34,17 @@ class AhnentafelReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_PUBLIC; + return Auth::PRIV_PRIVATE; } /** {@inheritdoc} */ public function getReportMenus() { - global $controller; + global $controller, $WT_TREE; $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/AlbumModule.php b/app/Module/AlbumModule.php index 691bc36e88..bd34ee1f7b 100644 --- a/app/Module/AlbumModule.php +++ b/app/Module/AlbumModule.php @@ -39,7 +39,9 @@ class AlbumModule extends Module implements ModuleTabInterface { /** {@inheritdoc} */ public function hasTabContent() { - return WT_USER_CAN_EDIT || $this->getMedia(); + global $WT_TREE; + + return Auth::isEditor($WT_TREE) || $this->getMedia(); } @@ -54,10 +56,10 @@ class AlbumModule extends Module implements ModuleTabInterface { $html = '<div id="' . $this->getName() . '_content">'; //Show Lightbox-Album header Links - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($WT_TREE)) { $html .= '<table class="facts_table"><tr><td class="descriptionbox rela">'; // Add a new media object - if ($WT_TREE->getPreference('MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { + if ($WT_TREE->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($WT_TREE)) { $html .= '<span><a href="#" onclick="window.open(\'addmedia.php?action=showmediaform&linktoid=' . $controller->record->getXref() . '\', \'_blank\', \'resizable=1,scrollbars=1,top=50,height=780,width=600\');return false;">'; $html .= '<img src="' . Theme::theme()->assetUrl() . 'images/image_add.png" id="head_icon" class="icon" title="' . I18N::translate('Add a new media object') . '" alt="' . I18N::translate('Add a new media object') . '">'; $html .= I18N::translate('Add a new media object'); @@ -68,7 +70,7 @@ class AlbumModule extends Module implements ModuleTabInterface { $html .= I18N::translate('Link to an existing media object'); $html .= '</a></span>'; } - if (WT_USER_GEDCOM_ADMIN && $this->getMedia()) { + if (Auth::isManager($WT_TREE) && $this->getMedia()) { // Popup Reorder Media $html .= '<span><a href="#" onclick="reorder_media(\'' . $controller->record->getXref() . '\')">'; $html .= '<img src="' . Theme::theme()->assetUrl() . 'images/images.png" id="head_icon" class="icon" title="' . I18N::translate('Re-order media') . '" alt="' . I18N::translate('Re-order media') . '">'; @@ -118,7 +120,7 @@ class AlbumModule extends Module implements ModuleTabInterface { } } - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($media->getTree())) { // Edit Media $submenu = new Menu(I18N::translate('Edit media')); $submenu->setOnclick("return window.open('addmedia.php?action=editmedia&pid=" . $media->getXref() . "', '_blank', edit_window_specs);"); diff --git a/app/Module/BatchUpdate/BirthDeathMarriageReportModule.php b/app/Module/BatchUpdate/BirthDeathMarriageReportModule.php index 4364a60a01..27e0b6c946 100644 --- a/app/Module/BatchUpdate/BirthDeathMarriageReportModule.php +++ b/app/Module/BatchUpdate/BirthDeathMarriageReportModule.php @@ -34,15 +34,17 @@ class BirthDeathMarriageReportModule extends Module implements ModuleReportInter /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_PUBLIC; + return Auth::PRIV_PRIVATE; } /** {@inheritdoc} */ public function getReportMenus() { + global $WT_TREE; + $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/BirthReportModule.php b/app/Module/BirthReportModule.php index b094b677c2..c7253d19e6 100644 --- a/app/Module/BirthReportModule.php +++ b/app/Module/BirthReportModule.php @@ -34,15 +34,17 @@ class BirthReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_PUBLIC; + return Auth::PRIV_PRIVATE; } /** {@inheritdoc} */ public function getReportMenus() { + global $WT_TREE; + $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/CemeteryReportModule.php b/app/Module/CemeteryReportModule.php index 352d28955e..69ad22dbdf 100644 --- a/app/Module/CemeteryReportModule.php +++ b/app/Module/CemeteryReportModule.php @@ -34,15 +34,17 @@ class CemeteryReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_PUBLIC; + return Auth::PRIV_PRIVATE; } /** {@inheritdoc} */ public function getReportMenus() { + global $WT_TREE; + $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/ChangeReportModule.php b/app/Module/ChangeReportModule.php index a39016bd2c..8b84fc5faf 100644 --- a/app/Module/ChangeReportModule.php +++ b/app/Module/ChangeReportModule.php @@ -34,15 +34,17 @@ class ChangeReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_USER; + return Auth::PRIV_USER; } /** {@inheritdoc} */ public function getReportMenus() { + global $WT_TREE; + $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/ChartsBlockModule.php b/app/Module/ChartsBlockModule.php index d53fba7f89..721972f488 100644 --- a/app/Module/ChartsBlockModule.php +++ b/app/Module/ChartsBlockModule.php @@ -35,10 +35,11 @@ class ChartsBlockModule extends Module implements ModuleBlockInterface { global $WT_TREE, $ctype, $controller; $PEDIGREE_ROOT_ID = $WT_TREE->getPreference('PEDIGREE_ROOT_ID'); + $gedcomid = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid'); $details = get_block_setting($block_id, 'details', '0'); $type = get_block_setting($block_id, 'type', 'pedigree'); - $pid = get_block_setting($block_id, 'pid', Auth::check() ? (WT_USER_GEDCOM_ID ? WT_USER_GEDCOM_ID : $PEDIGREE_ROOT_ID) : $PEDIGREE_ROOT_ID); + $pid = get_block_setting($block_id, 'pid', Auth::check() ? ($gedcomid ? $gedcomid : $PEDIGREE_ROOT_ID) : $PEDIGREE_ROOT_ID); if ($cfg) { foreach (array('details', 'type', 'pid', 'block') as $name) { @@ -57,7 +58,7 @@ class ChartsBlockModule extends Module implements ModuleBlockInterface { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && Auth::check()) { + if ($ctype == 'gedcom' && Auth::isManager($WT_TREE) || $ctype == 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; @@ -150,6 +151,7 @@ class ChartsBlockModule extends Module implements ModuleBlockInterface { global $WT_TREE, $controller; $PEDIGREE_ROOT_ID = $WT_TREE->getPreference('PEDIGREE_ROOT_ID'); + $gedcomid = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid'); if (Filter::postBool('save') && Filter::checkCsrf()) { set_block_setting($block_id, 'details', Filter::postBool('details')); @@ -159,7 +161,7 @@ class ChartsBlockModule extends Module implements ModuleBlockInterface { $details = get_block_setting($block_id, 'details', '0'); $type = get_block_setting($block_id, 'type', 'pedigree'); - $pid = get_block_setting($block_id, 'pid', Auth::check() ? (WT_USER_GEDCOM_ID ? WT_USER_GEDCOM_ID : $PEDIGREE_ROOT_ID) : $PEDIGREE_ROOT_ID); + $pid = get_block_setting($block_id, 'pid', Auth::check() ? ($gedcomid ? $gedcomid : $PEDIGREE_ROOT_ID) : $PEDIGREE_ROOT_ID); $controller ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) diff --git a/app/Module/ClippingsCart/ClippingsCart.php b/app/Module/ClippingsCart/ClippingsCart.php index cbf71d208e..2d2fa00895 100644 --- a/app/Module/ClippingsCart/ClippingsCart.php +++ b/app/Module/ClippingsCart/ClippingsCart.php @@ -83,10 +83,10 @@ class ClippingsCart { $others = Filter::get('others'); $this->type = Filter::get('type'); - if (($this->privatize_export === 'none' || $this->privatize_export === 'none') && !WT_USER_GEDCOM_ADMIN) { + if (($this->privatize_export === 'none' || $this->privatize_export === 'none') && !Auth::isManager($WT_TREE)) { $this->privatize_export = 'visitor'; } - if ($this->privatize_export === 'user' && !WT_USER_CAN_ACCESS) { + if ($this->privatize_export === 'user' && !Auth::isMember($WT_TREE)) { $this->privatize_export = 'visitor'; } @@ -181,16 +181,16 @@ class ClippingsCart { switch ($this->privatize_export) { case 'gedadmin': - $access_level = WT_PRIV_NONE; + $access_level = Auth::PRIV_NONE; break; case 'user': - $access_level = WT_PRIV_USER; + $access_level = Auth::PRIV_USER; break; case 'visitor': - $access_level = WT_PRIV_PUBLIC; + $access_level = Auth::PRIV_PRIVATE; break; case 'none': - $access_level = WT_PRIV_HIDE; + $access_level = Auth::PRIV_HIDE; break; } diff --git a/app/Module/ClippingsCartModule.php b/app/Module/ClippingsCartModule.php index cde06851df..00350cd1a4 100644 --- a/app/Module/ClippingsCartModule.php +++ b/app/Module/ClippingsCartModule.php @@ -35,7 +35,7 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_USER; + return Auth::PRIV_USER; } /** {@inheritdoc} */ @@ -190,7 +190,7 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS </td> <td class="optionbox"><input type="checkbox" name="IncludeMedia" value="yes"></td></tr> - <?php if (WT_USER_GEDCOM_ADMIN) { ?> + <?php if (Auth::isManager($WT_TREE)) { ?> <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Apply privacy settings'), help_link('apply_privacy'); ?></td> <td class="optionbox"> <input type="radio" name="privatize_export" value="none" checked> <?php echo I18N::translate('None'); ?><br> @@ -198,7 +198,7 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS <input type="radio" name="privatize_export" value="user"> <?php echo I18N::translate('Member'); ?><br> <input type="radio" name="privatize_export" value="visitor"> <?php echo I18N::translate('Visitor'); ?> </td></tr> - <?php } elseif (WT_USER_CAN_ACCESS) { ?> + <?php } elseif (Auth::isMember($WT_TREE)) { ?> <tr><td class="descriptionbox width50 wrap"><?php echo I18N::translate('Apply privacy settings'), help_link('apply_privacy'); ?></td> <td class="optionbox"> <input type="radio" name="privatize_export" value="user" checked> <?php echo I18N::translate('Member'); ?><br> @@ -306,15 +306,15 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS /** {@inheritdoc} */ public function getMenu() { - global $controller; + global $controller, $WT_TREE; if (Auth::isSearchEngine()) { return null; } //-- main clippings menu item - $menu = new Menu($this->getTitle(), 'module.php?mod=clippings&mod_action=index&ged=' . WT_GEDURL, 'menu-clippings'); + $menu = new Menu($this->getTitle(), 'module.php?mod=clippings&mod_action=index&ged=' . $WT_TREE->getNameUrl(), 'menu-clippings'); if (isset($controller->record)) { - $submenu = new Menu($this->getTitle(), 'module.php?mod=clippings&mod_action=index&ged=' . WT_GEDURL, 'menu-clippingscart'); + $submenu = new Menu($this->getTitle(), 'module.php?mod=clippings&mod_action=index&ged=' . $WT_TREE->getNameUrl(), 'menu-clippingscart'); $menu->addSubmenu($submenu); } if (!empty($controller->record) && $controller->record->canShow()) { @@ -578,7 +578,7 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS <td class="optionbox"><input type="checkbox" name="IncludeMedia" value="yes" checked></td></tr> '; - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { $out .= '<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . help_link('apply_privacy') . '</td>' . '<td class="optionbox">' . @@ -587,7 +587,7 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS ' <input type="radio" name="privatize_export" value="user"> ' . I18N::translate('Member') . '<br>' . ' <input type="radio" name="privatize_export" value="visitor"> ' . I18N::translate('Visitor') . '</td></tr>'; - } elseif (WT_USER_CAN_ACCESS) { + } elseif (Auth::isMember($WT_TREE)) { $out .= '<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . help_link('apply_privacy') . '</td>' . '<td class="list_value">' . diff --git a/app/Module/DeathReportModule.php b/app/Module/DeathReportModule.php index c2f3a7fd0d..2123796a68 100644 --- a/app/Module/DeathReportModule.php +++ b/app/Module/DeathReportModule.php @@ -34,15 +34,17 @@ class DeathReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_PUBLIC; + return Auth::PRIV_PRIVATE; } /** {@inheritdoc} */ public function getReportMenus() { + global $WT_TREE; + $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/DescendancyReportModule.php b/app/Module/DescendancyReportModule.php index ce0daa2362..f3e0086ddb 100644 --- a/app/Module/DescendancyReportModule.php +++ b/app/Module/DescendancyReportModule.php @@ -34,17 +34,17 @@ class DescendancyReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_PUBLIC; + return Auth::PRIV_PRIVATE; } /** {@inheritdoc} */ public function getReportMenus() { - global $controller; + global $controller, $WT_TREE; $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/FactSourcesReportModule.php b/app/Module/FactSourcesReportModule.php index d9cd7011b9..24c9200ea0 100644 --- a/app/Module/FactSourcesReportModule.php +++ b/app/Module/FactSourcesReportModule.php @@ -34,15 +34,17 @@ class FactSourcesReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_USER; + return Auth::PRIV_USER; } /** {@inheritdoc} */ public function getReportMenus() { + global $WT_TREE; + $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/FamilyGroupReportModule.php b/app/Module/FamilyGroupReportModule.php index a0877c15b7..e8ea1c79d3 100644 --- a/app/Module/FamilyGroupReportModule.php +++ b/app/Module/FamilyGroupReportModule.php @@ -34,17 +34,17 @@ class FamilyGroupReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_PUBLIC; + return Auth::PRIV_PRIVATE; } /** {@inheritdoc} */ public function getReportMenus() { - global $controller; + global $controller, $WT_TREE; $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&famid=' . $controller->getSignificantFamily()->getXref(), + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&famid=' . $controller->getSignificantFamily()->getXref(), 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/FamilyNavigatorModule.php b/app/Module/FamilyNavigatorModule.php index 697c688531..c31626d149 100644 --- a/app/Module/FamilyNavigatorModule.php +++ b/app/Module/FamilyNavigatorModule.php @@ -112,7 +112,7 @@ class FamilyNavigatorModule extends Module implements ModuleSidebarInterface { </td> </tr> <?php - $access_level = $SHOW_PRIVATE_RELATIONSHIPS ? WT_PRIV_HIDE : WT_USER_ACCESS_LEVEL; + $access_level = $SHOW_PRIVATE_RELATIONSHIPS ? Auth::PRIV_HIDE : Auth::accessLevel($family->getTree()); $facts = array_merge($family->getFacts('HUSB', false, $access_level), $family->getFacts('WIFE', false, $access_level)); foreach ($facts as $fact) { $spouse = $fact->getTarget(); diff --git a/app/Module/FamilyTreeFavoritesModule.php b/app/Module/FamilyTreeFavoritesModule.php index 961904d202..260b09845f 100644 --- a/app/Module/FamilyTreeFavoritesModule.php +++ b/app/Module/FamilyTreeFavoritesModule.php @@ -39,7 +39,7 @@ class FamilyTreeFavoritesModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { - global $ctype, $controller; + global $ctype, $controller, $WT_TREE; self::updateSchema(); // make sure the favorites table has been created @@ -118,7 +118,7 @@ class FamilyTreeFavoritesModule extends Module implements ModuleBlockInterface { $removeFavourite = '<a class="font9" href="index.php?ctype=' . $ctype . '&action=deletefav&favorite_id=' . $key . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to remove this item from your list of favorites?') . '\');">' . I18N::translate('Remove') . '</a> '; if ($favorite['type'] == 'URL') { $content .= '<div id="boxurl' . $key . '.0" class="person_box">'; - if ($ctype == 'user' || WT_USER_GEDCOM_ADMIN) { + if ($ctype == 'user' || Auth::isManager($WT_TREE)) { $content .= $removeFavourite; } $content .= '<a href="' . $favorite['url'] . '"><b>' . $favorite['title'] . '</b></a>'; @@ -140,7 +140,7 @@ class FamilyTreeFavoritesModule extends Module implements ModuleBlockInterface { break; } $content .= '">'; - if ($ctype == "user" || WT_USER_GEDCOM_ADMIN) { + if ($ctype == "user" || Auth::isManager($WT_TREE)) { $content .= $removeFavourite; } $content .= Theme::theme()->individualBoxLarge($record); @@ -148,7 +148,7 @@ class FamilyTreeFavoritesModule extends Module implements ModuleBlockInterface { $content .= '</div>'; } else { $content .= '<div id="box' . $favorite['gid'] . '.0" class="person_box">'; - if ($ctype == 'user' || WT_USER_GEDCOM_ADMIN) { + if ($ctype == 'user' || Auth::isManager($WT_TREE)) { $content .= $removeFavourite; } $content .= $record->formatList('span'); @@ -159,7 +159,7 @@ class FamilyTreeFavoritesModule extends Module implements ModuleBlockInterface { } } } - if ($ctype == 'user' || WT_USER_GEDCOM_ADMIN) { + if ($ctype == 'user' || Auth::isManager($WT_TREE)) { $uniqueID = Uuid::uuid4(); // This block can theoretically appear multiple times, so use a unique ID. $content .= '<div class="add_fav_head">'; $content .= '<a href="#" onclick="return expand_layer(\'add_fav' . $uniqueID . '\');">' . I18N::translate('Add a new favorite') . '<i id="add_fav' . $uniqueID . '_img" class="icon-plus"></i></a>'; diff --git a/app/Module/FamilyTreeNewsModule.php b/app/Module/FamilyTreeNewsModule.php index 49fc52f688..c14b35ab0e 100644 --- a/app/Module/FamilyTreeNewsModule.php +++ b/app/Module/FamilyTreeNewsModule.php @@ -32,7 +32,7 @@ class FamilyTreeNewsModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { - global $ctype; + global $ctype, $WT_TREE; switch (Filter::get('action')) { case 'deletenews': @@ -67,7 +67,7 @@ class FamilyTreeNewsModule extends Module implements ModuleBlockInterface { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; @@ -99,13 +99,13 @@ class FamilyTreeNewsModule extends Module implements ModuleBlockInterface { } $content .= $news->body; // Print Admin options for this News item - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { $content .= '<hr>' . '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $news->news_id . ', \'_blank\', news_window_specs); return false;">' . I18N::translate('Edit') . '</a> | ' . '<a href="index.php?action=deletenews&news_id=' . $news->news_id . '&ctype=' . $ctype . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete this news article?') . "');\">" . I18N::translate('Delete') . '</a><br>'; } $content .= '</div>'; } $printedAddLink = false; - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { $content .= "<a href=\"#\" onclick=\"window.open('editnews.php?gedcom_id='+WT_GED_ID, '_blank', news_window_specs); return false;\">" . I18N::translate('Add a news article') . "</a>"; $printedAddLink = true; } diff --git a/app/Module/FamilyTreeStatisticsModule.php b/app/Module/FamilyTreeStatisticsModule.php index 138b761956..be34e44207 100644 --- a/app/Module/FamilyTreeStatisticsModule.php +++ b/app/Module/FamilyTreeStatisticsModule.php @@ -67,7 +67,7 @@ class FamilyTreeStatisticsModule extends Module implements ModuleBlockInterface $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; @@ -76,7 +76,7 @@ class FamilyTreeStatisticsModule extends Module implements ModuleBlockInterface $stats = new Stats($WT_TREE); - $content = '<b>' . WT_TREE_TITLE . '</b><br>'; + $content = '<b>' . $WT_TREE->getTitleHtml() . '</b><br>'; if ($show_last_update) { $content .= '<div>' . /* I18N: %s is a date */ I18N::translate('This family tree was last updated on %s.', strip_tags($stats->gedcomUpdated())) . '</div>'; @@ -85,31 +85,31 @@ class FamilyTreeStatisticsModule extends Module implements ModuleBlockInterface $content .= '<div class="stat-table1">'; if ($stat_indi) { - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individuals') . '</div><div class="facts_value stats_value stat-cell"><a href="' . "indilist.php?surname_sublist=no&ged=" . WT_GEDURL . '">' . $stats->totalIndividuals() . '</a></div></div>'; + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individuals') . '</div><div class="facts_value stats_value stat-cell"><a href="' . "indilist.php?surname_sublist=no&ged=" . $WT_TREE->getNameUrl() . '">' . $stats->totalIndividuals() . '</a></div></div>'; $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Males') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexMales() . '<br>' . $stats->totalSexMalesPercentage() . '</a></div></div>'; $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Females') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexFemales() . '<br>' . $stats->totalSexFemalesPercentage() . '</a></div></div>'; } if ($stat_surname) { - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total surnames') . '</div><div class="facts_value stats_value stat-cell"><a href="indilist.php?show_all=yes&surname_sublist=yes&ged=' . WT_GEDURL . '">' . $stats->totalSurnames() . '</a></div></div>'; + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total surnames') . '</div><div class="facts_value stats_value stat-cell"><a href="indilist.php?show_all=yes&surname_sublist=yes&ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSurnames() . '</a></div></div>'; } if ($stat_fam) { - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Families') . '</div><div class="facts_value stats_value stat-cell"><a href="famlist.php?ged=' . WT_GEDURL . '">' . $stats->totalFamilies() . '</a></div></div>'; + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Families') . '</div><div class="facts_value stats_value stat-cell"><a href="famlist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalFamilies() . '</a></div></div>'; } if ($stat_sour) { - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Sources') . '</div><div class="facts_value stats_value stat-cell"><a href="sourcelist.php?ged=' . WT_GEDURL . '">' . $stats->totalSources() . '</a></div></div>'; + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Sources') . '</div><div class="facts_value stats_value stat-cell"><a href="sourcelist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSources() . '</a></div></div>'; } if ($stat_media) { - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Media objects') . '</div><div class="facts_value stats_value stat-cell"><a href="medialist.php?ged=' . WT_GEDURL . '">' . $stats->totalMedia() . '</a></div></div>'; + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Media objects') . '</div><div class="facts_value stats_value stat-cell"><a href="medialist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalMedia() . '</a></div></div>'; } if ($stat_repo) { - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Repositories') . '</div><div class="facts_value stats_value stat-cell"><a href="repolist.php?ged=' . WT_GEDURL . '">' . $stats->totalRepositories() . '</a></div></div>'; + $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Repositories') . '</div><div class="facts_value stats_value stat-cell"><a href="repolist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalRepositories() . '</a></div></div>'; } if ($stat_events) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total events') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalEvents() . '</div></div>'; } if ($stat_users) { $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total users') . '</div><div class="facts_value stats_value stat-cell">'; - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { $content .= '<a href="admin_users.php">' . $stats->totalUsers() . '</a>'; } else { $content .= $stats->totalUsers(); @@ -178,7 +178,7 @@ class FamilyTreeStatisticsModule extends Module implements ModuleBlockInterface $content .= '</div>'; } if ($stat_link) { - $content .= '</div><div class="clearfloat"><a href="statistics.php?ged=' . WT_GEDURL . '"><b>' . I18N::translate('View statistics as graphs') . '</b></a></div>'; + $content .= '</div><div class="clearfloat"><a href="statistics.php?ged=' . $WT_TREE->getNameUrl() . '"><b>' . I18N::translate('View statistics as graphs') . '</b></a></div>'; } // NOTE: Print the most common surnames if ($show_common_surnames) { @@ -192,7 +192,7 @@ class FamilyTreeStatisticsModule extends Module implements ModuleBlockInterface if ($i > 0) { $content .= ', '; } - $content .= '<a href="' . "indilist.php?ged=" . WT_GEDURL . "&surname=" . rawurlencode($surname['name']) . '">' . $surname['name'] . '</a>'; + $content .= '<a href="' . "indilist.php?ged=" . $WT_TREE->getNameUrl() . "&surname=" . rawurlencode($surname['name']) . '">' . $surname['name'] . '</a>'; $i++; } } diff --git a/app/Module/FrequentlyAskedQuestionsModule.php b/app/Module/FrequentlyAskedQuestionsModule.php index 9e6adcce4d..39f01f4da3 100644 --- a/app/Module/FrequentlyAskedQuestionsModule.php +++ b/app/Module/FrequentlyAskedQuestionsModule.php @@ -262,7 +262,8 @@ class FrequentlyAskedQuestionsModule extends Module implements ModuleMenuInterfa * Show a list of FAQs */ private function show() { - global $controller; + global $controller, $WT_TREE; + $controller = new PageController; $controller ->setPageTitle(I18N::translate('Frequently asked questions')) @@ -290,7 +291,7 @@ class FrequentlyAskedQuestionsModule extends Module implements ModuleMenuInterfa echo '<h2 class="center">', I18N::translate('Frequently asked questions'), '</h2>'; // Instructions echo '<div class="faq_italic">', I18N::translate('Click on a title to go straight to it, or scroll down to read them all'); - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { echo '<div class="faq_edit"><a href="module.php?mod=', $this->getName(), '&mod_action=admin_config">', I18N::translate('Click here to add, edit, or delete'), '</a></div>'; } echo '</div>'; diff --git a/app/Module/GoogleMapsModule.php b/app/Module/GoogleMapsModule.php index 93d1971fde..7e1a15d1e9 100644 --- a/app/Module/GoogleMapsModule.php +++ b/app/Module/GoogleMapsModule.php @@ -1372,7 +1372,7 @@ class GoogleMapsModule extends Module implements ModuleConfigInterface, ModuleTa $js .= 'var point = new google.maps.LatLng(' . $lat[$i] . ',' . $lon[$i] . ');'; $js .= "var marker = createMarker(point, \"" . Filter::escapeJs($name) . "\",\"<div>" . $dataleft . $datamid . $dataright . "</div>\", \""; $js .= "<div class='iwstyle'>"; - $js .= "<a href='module.php?ged=" . WT_GEDURL . "&mod=googlemap&mod_action=pedigree_map&rootid=" . $person->getXref() . "&PEDIGREE_GENERATIONS={$PEDIGREE_GENERATIONS}"; + $js .= "<a href='module.php?ged=" . $person->getTree()->getNameUrl() . "&mod=googlemap&mod_action=pedigree_map&rootid=" . $person->getXref() . "&PEDIGREE_GENERATIONS={$PEDIGREE_GENERATIONS}"; $js .= "' title='" . I18N::translate('Pedigree map') . "'>" . $dataleft . "</a>" . $datamid . $dataright . "</div>\", \"" . $marker_number . "\");"; // Construct the polygon lines $to_child = (intval(($i - 1) / 2)); // Draw a line from parent to child diff --git a/app/Module/HtmlBlockModule.php b/app/Module/HtmlBlockModule.php index 82fe3bafe8..f99abc0321 100644 --- a/app/Module/HtmlBlockModule.php +++ b/app/Module/HtmlBlockModule.php @@ -83,7 +83,7 @@ class HtmlBlockModule extends Module implements ModuleBlockInterface { */ $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>' . $title; } @@ -117,6 +117,8 @@ class HtmlBlockModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function configureBlock($block_id) { + global $WT_TREE; + if (Filter::postBool('save') && Filter::checkCsrf()) { set_block_setting($block_id, 'gedcom', Filter::post('gedcom')); set_block_setting($block_id, 'title', Filter::post('title')); @@ -156,23 +158,23 @@ class HtmlBlockModule extends Module implements ModuleBlockInterface { </tr> <tr> <td class="facts_label">'. I18N::translate('Total surnames') . '</td> - <td class="facts_value" align="right"><a href="indilist.php?show_all=yes&surname_sublist=yes&ged='.WT_GEDURL . '">#totalSurnames#</a></td> + <td class="facts_value" align="right"><a href="indilist.php?show_all=yes&surname_sublist=yes&ged='. $WT_TREE->getNameUrl() . '">#totalSurnames#</a></td> </tr> <tr> <td class="facts_label">'. I18N::translate('Families') . '</td> - <td class="facts_value" align="right"><a href="famlist.php?ged='.WT_GEDURL . '">#totalFamilies#</a></td> + <td class="facts_value" align="right"><a href="famlist.php?ged='. $WT_TREE->getNameUrl() . '">#totalFamilies#</a></td> </tr> <tr> <td class="facts_label">'. I18N::translate('Sources') . '</td> - <td class="facts_value" align="right"><a href="sourcelist.php?ged='.WT_GEDURL . '">#totalSources#</a></td> + <td class="facts_value" align="right"><a href="sourcelist.php?ged='. $WT_TREE->getNameUrl() . '">#totalSources#</a></td> </tr> <tr> <td class="facts_label">'. I18N::translate('Media objects') . '</td> - <td class="facts_value" align="right"><a href="medialist.php?ged='.WT_GEDURL . '">#totalMedia#</a></td> + <td class="facts_value" align="right"><a href="medialist.php?ged='. $WT_TREE->getNameUrl() . '">#totalMedia#</a></td> </tr> <tr> <td class="facts_label">'. I18N::translate('Repositories') . '</td> - <td class="facts_value" align="right"><a href="repolist.php?ged='.WT_GEDURL . '">#totalRepositories#</a></td> + <td class="facts_value" align="right"><a href="repolist.php?ged='. $WT_TREE->getNameUrl() . '">#totalRepositories#</a></td> </tr> <tr> <td class="facts_label">'. I18N::translate('Total events') . '</td> diff --git a/app/Module/IndividualFamiliesReportModule.php b/app/Module/IndividualFamiliesReportModule.php index 0db386d8ed..70088554c5 100644 --- a/app/Module/IndividualFamiliesReportModule.php +++ b/app/Module/IndividualFamiliesReportModule.php @@ -34,17 +34,17 @@ class IndividualFamiliesReportModule extends Module implements ModuleReportInter /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_USER; + return Auth::PRIV_USER; } /** {@inheritdoc} */ public function getReportMenus() { - global $controller; + global $controller, $WT_TREE; $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/IndividualReportModule.php b/app/Module/IndividualReportModule.php index f82a6d9040..31833b2bf5 100644 --- a/app/Module/IndividualReportModule.php +++ b/app/Module/IndividualReportModule.php @@ -34,17 +34,17 @@ class IndividualReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_PUBLIC; + return Auth::PRIV_PRIVATE; } /** {@inheritdoc} */ public function getReportMenus() { - global $controller; + global $controller, $WT_TREE; $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/MarriageReportModule.php b/app/Module/MarriageReportModule.php index d8aa244af7..3217509a7b 100644 --- a/app/Module/MarriageReportModule.php +++ b/app/Module/MarriageReportModule.php @@ -34,15 +34,17 @@ class MarriageReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_PUBLIC; + return Auth::PRIV_PRIVATE; } /** {@inheritdoc} */ public function getReportMenus() { + global $WT_TREE; + $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/MediaTabModule.php b/app/Module/MediaTabModule.php index 2c46034f56..a98e852ef2 100644 --- a/app/Module/MediaTabModule.php +++ b/app/Module/MediaTabModule.php @@ -39,7 +39,9 @@ class MediaTabModule extends Module implements ModuleTabInterface { /** {@inheritdoc} */ public function hasTabContent() { - return WT_USER_CAN_EDIT || $this->getFactsWithMedia(); + global $WT_TREE; + + return Auth::isEditor($WT_TREE) || $this->getFactsWithMedia(); } /** {@inheritdoc} */ @@ -66,19 +68,19 @@ class MediaTabModule extends Module implements ModuleTabInterface { echo '<tr><td id="no_tab4" colspan="2" class="facts_value">', I18N::translate('There are no media objects for this individual.'), '</td></tr>'; } // New media link - if ($controller->record->canEdit() && $WT_TREE->getPreference('MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { + if ($controller->record->canEdit() && $WT_TREE->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($controller->record->getTree())) { ?> <tr> <td class="facts_label"> <?php echo GedcomTag::getLabel('OBJE'); ?> </td> <td class="facts_value"> - <a href="#" onclick="window.open('addmedia.php?action=showmediaform&linktoid=<?php echo $controller->record->getXref(); ?>&ged=<?php echo WT_GEDURL; ?>', '_blank', edit_window_specs); return false;"> + <a href="#" onclick="window.open('addmedia.php?action=showmediaform&linktoid=<?php echo $controller->record->getXref(); ?>&ged=<?php echo $controller->record->getTree()->getNameUrl(); ?>', '_blank', edit_window_specs); return false;"> <?php echo I18N::translate('Add a new media object'); ?> </a> <?php echo help_link('OBJE'); ?> <br> - <a href="#" onclick="window.open('inverselink.php?linktoid=<?php echo $controller->record->getXref(); ?>&ged=<?php echo WT_GEDURL; ?>&linkto=person', '_blank', find_window_specs); return false;"> + <a href="#" onclick="window.open('inverselink.php?linktoid=<?php echo $controller->record->getXref(); ?>&ged=<?php echo $WT_TREE->getNameUrl(); ?>&linkto=person', '_blank', find_window_specs); return false;"> <?php echo I18N::translate('Link to an existing media object'); ?> </a> </td> diff --git a/app/Module/MissingFactsReportModuleModule.php b/app/Module/MissingFactsReportModuleModule.php index 46f38d8da6..144b2d9438 100644 --- a/app/Module/MissingFactsReportModuleModule.php +++ b/app/Module/MissingFactsReportModuleModule.php @@ -34,15 +34,17 @@ class MissingFactsReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_USER; + return Auth::PRIV_USER; } /** {@inheritdoc} */ public function getReportMenus() { + global $WT_TREE; + $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/NotesTabModule.php b/app/Module/NotesTabModule.php index 0860bb30fb..13df84f60e 100644 --- a/app/Module/NotesTabModule.php +++ b/app/Module/NotesTabModule.php @@ -39,7 +39,9 @@ class NotesTabModule extends Module implements ModuleTabInterface { /** {@inheritdoc} */ public function hasTabContent() { - return WT_USER_CAN_EDIT || $this->getFactsWithNotes(); + global $WT_TREE; + + return Auth::isEditor($WT_TREE) || $this->getFactsWithNotes(); } /** {@inheritdoc} */ diff --git a/app/Module/OccupationReportModule.php b/app/Module/OccupationReportModule.php index e977013d5c..ecf63f1e69 100644 --- a/app/Module/OccupationReportModule.php +++ b/app/Module/OccupationReportModule.php @@ -34,15 +34,17 @@ class OccupationReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_USER; + return Auth::PRIV_USER; } /** {@inheritdoc} */ public function getReportMenus() { + global $WT_TREE; + $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/OnThisDayModule.php b/app/Module/OnThisDayModule.php index 8d9aea343d..c9460d903c 100644 --- a/app/Module/OnThisDayModule.php +++ b/app/Module/OnThisDayModule.php @@ -32,7 +32,7 @@ class OnThisDayModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { - global $ctype; + global $ctype, $WT_TREE; $filter = get_block_setting($block_id, 'filter', '1'); $onlyBDM = get_block_setting($block_id, 'onlyBDM', '1'); @@ -52,7 +52,7 @@ class OnThisDayModule extends Module implements ModuleBlockInterface { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; diff --git a/app/Module/PageMenuModule.php b/app/Module/PageMenuModule.php index 77022642ca..fe793d4b90 100644 --- a/app/Module/PageMenuModule.php +++ b/app/Module/PageMenuModule.php @@ -37,14 +37,14 @@ class PageMenuModule extends Module implements ModuleMenuInterface { /** {@inheritdoc} */ public function getMenu() { - global $controller; + global $controller, $WT_TREE; $menu = null; if (empty($controller)) { return null; } - if (WT_USER_CAN_EDIT && method_exists($controller, 'getEditMenu')) { + if (Auth::isEditor($WT_TREE) && method_exists($controller, 'getEditMenu')) { $menu = $controller->getEditMenu(); } return $menu; diff --git a/app/Module/PedigreeReportModule.php b/app/Module/PedigreeReportModule.php index 5139595244..a968c4d1d8 100644 --- a/app/Module/PedigreeReportModule.php +++ b/app/Module/PedigreeReportModule.php @@ -34,17 +34,17 @@ class PedigreeReportModule extends Module implements ModuleReportInterface { /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_PUBLIC; + return Auth::PRIV_PRIVATE; } /** {@inheritdoc} */ public function getReportMenus() { - global $controller; + global $controller, $WT_TREE; $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/RecentChangesModule.php b/app/Module/RecentChangesModule.php index 0279b842fe..3670cdedea 100644 --- a/app/Module/RecentChangesModule.php +++ b/app/Module/RecentChangesModule.php @@ -35,7 +35,7 @@ class RecentChangesModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { - global $ctype; + global $ctype, $WT_TREE; $days = get_block_setting($block_id, 'days', self::DEFAULT_DAYS); $infoStyle = get_block_setting($block_id, 'infoStyle', 'table'); @@ -60,7 +60,7 @@ class RecentChangesModule extends Module implements ModuleBlockInterface { // Print block header $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; diff --git a/app/Module/RelatedIndividualsReportModule.php b/app/Module/RelatedIndividualsReportModule.php index 604696b19b..1f3a52cb44 100644 --- a/app/Module/RelatedIndividualsReportModule.php +++ b/app/Module/RelatedIndividualsReportModule.php @@ -34,17 +34,17 @@ class RelatedIndividualsReportModule extends Module implements ModuleReportInter /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_PUBLIC; + return Auth::PRIV_PRIVATE; } /** {@inheritdoc} */ public function getReportMenus() { - global $controller; + global $controller, $WT_TREE; $menus = array(); $menu = new Menu( $this->getTitle(), - 'reportengine.php?ged=' . WT_GEDURL . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), 'menu-report-' . $this->getName() ); $menus[] = $menu; diff --git a/app/Module/RelativesTabModule.php b/app/Module/RelativesTabModule.php index 24f74ee42b..28228e1e23 100644 --- a/app/Module/RelativesTabModule.php +++ b/app/Module/RelativesTabModule.php @@ -75,12 +75,11 @@ class RelativesTabModule extends Module implements ModuleTabInterface { */ function printFamily(Family $family, $type, $label) { global $controller; - global $SHOW_PRIVATE_RELATIONSHIPS; - if ($SHOW_PRIVATE_RELATIONSHIPS) { - $access_level = WT_PRIV_HIDE; + if ($family->getTree()->getPreference('SHOW_PRIVATE_RELATIONSHIPS')) { + $access_level = Auth::PRIV_HIDE; } else { - $access_level = WT_USER_ACCESS_LEVEL; + $access_level = Auth::accessLevel($family->getTree()); } ?> diff --git a/app/Module/ResearchTaskModule.php b/app/Module/ResearchTaskModule.php index 07aecbaf77..7b6c3e1eb3 100644 --- a/app/Module/ResearchTaskModule.php +++ b/app/Module/ResearchTaskModule.php @@ -34,7 +34,7 @@ class ResearchTaskModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { - global $ctype, $controller; + global $ctype, $controller, $WT_TREE; $show_other = get_block_setting($block_id, 'show_other', '1'); $show_unassigned = get_block_setting($block_id, 'show_unassigned', '1'); @@ -51,7 +51,7 @@ class ResearchTaskModule extends Module implements ModuleBlockInterface { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; diff --git a/app/Module/ReviewChangesModule.php b/app/Module/ReviewChangesModule.php index 3529d11d45..922262475c 100644 --- a/app/Module/ReviewChangesModule.php +++ b/app/Module/ReviewChangesModule.php @@ -68,7 +68,7 @@ class ReviewChangesModule extends Module implements ModuleBlockInterface { I18N::translate('Pending changes'), I18N::translate('There are pending changes for you to moderate.') . Mail::EOL . Mail::EOL . - '<a href="' . WT_BASE_URL . 'index.php?ged=' . WT_GEDURL . '">' . WT_BASE_URL . 'index.php?ged=' . WT_GEDURL . '</a>' + '<a href="' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '</a>' ); I18N::init(WT_LOCALE); } diff --git a/app/Module/SlideShowModule.php b/app/Module/SlideShowModule.php index 9d4e1462c4..7e6526ff00 100644 --- a/app/Module/SlideShowModule.php +++ b/app/Module/SlideShowModule.php @@ -32,7 +32,7 @@ class SlideShowModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { - global $ctype; + global $ctype, $WT_TREE; $filter = get_block_setting($block_id, 'filter', 'all'); $controls = get_block_setting($block_id, 'controls', '1'); @@ -103,7 +103,7 @@ class SlideShowModule extends Module implements ModuleBlockInterface { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; diff --git a/app/Module/SourcesTabModule.php b/app/Module/SourcesTabModule.php index b12fac059f..e531a47e7f 100644 --- a/app/Module/SourcesTabModule.php +++ b/app/Module/SourcesTabModule.php @@ -39,7 +39,9 @@ class SourcesTabModule extends Module implements ModuleTabInterface { /** {@inheritdoc} */ public function hasTabContent() { - return WT_USER_CAN_EDIT || $this->getFactsWithSources(); + global $WT_TREE; + + return Auth::isEditor($WT_TREE) || $this->getFactsWithSources(); } /** {@inheritdoc} */ diff --git a/app/Module/StoriesModule.php b/app/Module/StoriesModule.php index f97765cb02..036d8fbb50 100644 --- a/app/Module/StoriesModule.php +++ b/app/Module/StoriesModule.php @@ -63,7 +63,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn /** {@inheritdoc} */ public function getTabContent() { - global $controller; + global $controller, $WT_TREE; $block_ids = Database::prepare( @@ -85,13 +85,13 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn if (!$languages || in_array(WT_LOCALE, explode(',', $languages))) { $html .= '<div class="story_title descriptionbox center rela">' . get_block_setting($block_id, 'title') . '</div>'; $html .= '<div class="story_body optionbox">' . get_block_setting($block_id, 'story_body') . '</div>'; - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($WT_TREE)) { $html .= '<div class="story_edit"><a href="module.php?mod=' . $this->getName() . '&mod_action=admin_edit&block_id=' . $block_id . '">'; $html .= I18N::translate('Edit story') . '</a></div>'; } } } - if (WT_USER_GEDCOM_ADMIN && !$html) { + if (Auth::isManager($WT_TREE) && !$html) { $html .= '<div class="news_title center">' . $this->getTitle() . '</div>'; $html .= '<div><a href="module.php?mod=' . $this->getName() . '&mod_action=admin_edit&xref=' . $controller->record->getXref() . '">'; $html .= I18N::translate('Add a story') . '</a></div><br>'; @@ -139,7 +139,9 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn * Show and process a form to edit a story. */ private function edit() { - if (WT_USER_CAN_EDIT) { + global $WT_TREE; + + if (Auth::isEditor($WT_TREE)) { if (Filter::postBool('save') && Filter::checkCsrf()) { $block_id = Filter::postInteger('block_id'); if ($block_id) { @@ -245,7 +247,9 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn * Respond to a request to delete a story. */ private function delete() { - if (WT_USER_CAN_EDIT) { + global $WT_TREE; + + if (Auth::isEditor($WT_TREE)) { $block_id = Filter::getInteger('block_id'); Database::prepare( @@ -267,7 +271,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn private function config() { $controller = new PageController; $controller - ->restrictAccess(WT_USER_GEDCOM_ADMIN) + ->restrictAccess(Auth::isAdmin()) ->setPageTitle($this->getTitle()) ->pageHeader() ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) @@ -440,7 +444,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn /** {@inheritdoc} */ public function defaultAccessLevel() { - return WT_PRIV_HIDE; + return Auth::PRIV_HIDE; } /** {@inheritdoc} */ diff --git a/app/Module/TopGivenNamesModuleModule.php b/app/Module/TopGivenNamesModuleModule.php index 2f33f0f5c6..c4bc8bf4de 100644 --- a/app/Module/TopGivenNamesModuleModule.php +++ b/app/Module/TopGivenNamesModuleModule.php @@ -50,7 +50,7 @@ class TopGivenNamesModule extends Module implements ModuleBlockInterface { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; diff --git a/app/Module/TopPageViewsModule.php b/app/Module/TopPageViewsModule.php index 0ba6070a71..eb7deee3af 100644 --- a/app/Module/TopPageViewsModule.php +++ b/app/Module/TopPageViewsModule.php @@ -32,7 +32,7 @@ class TopPageViewsModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { - global $ctype; + global $ctype, $WT_TREE; $num = get_block_setting($block_id, 'num', '10'); $count_placement = get_block_setting($block_id, 'count_placement', 'before'); @@ -48,7 +48,7 @@ class TopPageViewsModule extends Module implements ModuleBlockInterface { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; diff --git a/app/Module/TopSurnamesModule.php b/app/Module/TopSurnamesModule.php index b9cbd28b77..0de0b21ef1 100644 --- a/app/Module/TopSurnamesModule.php +++ b/app/Module/TopSurnamesModule.php @@ -73,7 +73,7 @@ class TopSurnamesModule extends Module implements ModuleBlockInterface { } $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; diff --git a/app/Module/UpcomingAnniversariesModule.php b/app/Module/UpcomingAnniversariesModule.php index 708cb6686b..6743219503 100644 --- a/app/Module/UpcomingAnniversariesModule.php +++ b/app/Module/UpcomingAnniversariesModule.php @@ -32,7 +32,7 @@ class UpcomingAnniversariesModule extends Module implements ModuleBlockInterface /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { - global $ctype; + global $ctype, $WT_TREE; $days = get_block_setting($block_id, 'days', '7'); $filter = get_block_setting($block_id, 'filter', '1'); @@ -54,7 +54,7 @@ class UpcomingAnniversariesModule extends Module implements ModuleBlockInterface $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; diff --git a/app/Module/UserWelcomeModule.php b/app/Module/UserWelcomeModule.php index d2c24bd220..a7fc42bf66 100644 --- a/app/Module/UserWelcomeModule.php +++ b/app/Module/UserWelcomeModule.php @@ -32,15 +32,18 @@ class UserWelcomeModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { + global $WT_TREE; + $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; $title = '<span dir="auto">' . /* I18N: A greeting; %s is the user’s name */ I18N::translate('Welcome %s', Auth::user()->getRealNameHtml()) . '</span>'; $content = '<table><tr>'; $content .= '<td><a href="edituser.php"><i class="icon-mypage"></i><br>' . I18N::translate('My account') . '</a></td>'; - if (WT_USER_GEDCOM_ID) { - $content .= '<td><a href="pedigree.php?rootid=' . WT_USER_GEDCOM_ID . '&ged=' . WT_GEDURL . '"><i class="icon-pedigree"></i><br>' . I18N::translate('My pedigree') . '</a></td>'; - $content .= '<td><a href="individual.php?pid=' . WT_USER_GEDCOM_ID . '&ged=' . WT_GEDURL . '"><i class="icon-indis"></i><br>' . I18N::translate('My individual record') . '</a></td>'; + $gedcomid = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid'); + if ($gedcomid) { + $content .= '<td><a href="pedigree.php?rootid=' . $gedcomid . '&ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('My pedigree') . '</a></td>'; + $content .= '<td><a href="individual.php?pid=' . $gedcomid . '&ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-indis"></i><br>' . I18N::translate('My individual record') . '</a></td>'; } $content .= '</tr></table>'; diff --git a/app/Module/WelcomeBlockModule.php b/app/Module/WelcomeBlockModule.php index 79ad927162..f0e36d5ec7 100644 --- a/app/Module/WelcomeBlockModule.php +++ b/app/Module/WelcomeBlockModule.php @@ -32,15 +32,15 @@ class WelcomeBlockModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { - global $controller; + global $controller, $WT_TREE; $indi_xref = $controller->getSignificantIndividual()->getXref(); $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - $title = '<span dir="auto">' . WT_TREE_TITLE . '</span>'; + $title = '<span dir="auto">' . $WT_TREE->getTitleHtml() . '</span>'; $content = '<table><tr>'; - $content .= '<td><a href="pedigree.php?rootid=' . $indi_xref . '&ged=' . WT_GEDURL . '"><i class="icon-pedigree"></i><br>' . I18N::translate('Default chart') . '</a></td>'; - $content .= '<td><a href="individual.php?pid=' . $indi_xref . '&ged=' . WT_GEDURL . '"><i class="icon-indis"></i><br>' . I18N::translate('Default individual') . '</a></td>'; + $content .= '<td><a href="pedigree.php?rootid=' . $indi_xref . '&ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('Default chart') . '</a></td>'; + $content .= '<td><a href="individual.php?pid=' . $indi_xref . '&ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-indis"></i><br>' . I18N::translate('Default individual') . '</a></td>'; if (Site::getPreference('USE_REGISTRATION_MODULE') && !Auth::check()) { $content .= '<td><a href="' . WT_LOGIN_URL . '?action=register"><i class="icon-user_add"></i><br>' . I18N::translate('Request new user account') . '</a></td>'; } diff --git a/app/Module/YahrzeitModule.php b/app/Module/YahrzeitModule.php index 6d0b2874e0..34afad1313 100644 --- a/app/Module/YahrzeitModule.php +++ b/app/Module/YahrzeitModule.php @@ -35,7 +35,7 @@ class YahrzeitModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { - global $ctype, $controller; + global $ctype, $controller, $WT_TREE; $days = get_block_setting($block_id, 'days', '7'); $infoStyle = get_block_setting($block_id, 'infoStyle', 'table'); @@ -55,7 +55,7 @@ class YahrzeitModule extends Module implements ModuleBlockInterface { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; - if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) { + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<i class="icon-admin" title="' . I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; diff --git a/app/Report/ReportBase.php b/app/Report/ReportBase.php index a5227922b4..ebbbe2e5e1 100644 --- a/app/Report/ReportBase.php +++ b/app/Report/ReportBase.php @@ -966,7 +966,7 @@ function gedcomStartHandler($attrs) { $newgedrec = ''; if (count($tags) < 2) { $tmp = GedcomRecord::getInstance($attrs['id']); - $newgedrec = $tmp ? $tmp->privatizeGedcom(WT_USER_ACCESS_LEVEL) : ''; + $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($WT_TREE)) : ''; } if (empty($newgedrec)) { $tgedrec = $gedrec; @@ -977,14 +977,14 @@ function gedcomStartHandler($attrs) { $newgedrec = $vars[$match[1]]['gedcom']; } else { $tmp = GedcomRecord::getInstance($match[1]); - $newgedrec = $tmp ? $tmp->privatizeGedcom(WT_USER_ACCESS_LEVEL) : ''; + $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($WT_TREE)) : ''; } } else { if (preg_match("/@(.+)/", $tag, $match)) { $gmatch = array(); if (preg_match("/\d $match[1] @([^@]+)@/", $tgedrec, $gmatch)) { $tmp = GedcomRecord::getInstance($gmatch[1]); - $newgedrec = $tmp ? $tmp->privatizeGedcom(WT_USER_ACCESS_LEVEL) : ''; + $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($WT_TREE)) : ''; $tgedrec = $newgedrec; } else { $newgedrec = ''; @@ -2536,7 +2536,7 @@ function listStartHandler($attrs) { if ($filters) { foreach ($list as $key => $record) { foreach ($filters as $filter) { - if (!preg_match("/" . $filter . "/i", $record->privatizeGedcom(WT_USER_ACCESS_LEVEL))) { + if (!preg_match("/" . $filter . "/i", $record->privatizeGedcom(Auth::accessLevel($WT_TREE)))) { unset($list[$key]); break; } @@ -2547,7 +2547,7 @@ function listStartHandler($attrs) { $mylist = array(); foreach ($list as $indi) { $key = $indi->getXref(); - $grec = $indi->privatizeGedcom(WT_USER_ACCESS_LEVEL); + $grec = $indi->privatizeGedcom(Auth::accessLevel($WT_TREE)); $keep = true; foreach ($filters2 as $filter) { if ($keep) { @@ -2680,7 +2680,7 @@ function listEndHandler() { $list_private = 0; foreach ($list as $record) { if ($record->canShow()) { - $gedrec = $record->privatizeGedcom(WT_USER_ACCESS_LEVEL); + $gedrec = $record->privatizeGedcom(Auth::accessLevel($WT_TREE)); //-- start the sax parser $repeat_parser = xml_parser_create(); $parser = $repeat_parser; @@ -2924,7 +2924,7 @@ function relativesEndHandler() { $generation = $value->generation; } $tmp = GedcomRecord::getInstance($key); - $gedrec = $tmp->privatizeGedcom(WT_USER_ACCESS_LEVEL); + $gedrec = $tmp->privatizeGedcom(Auth::accessLevel($WT_TREE)); //-- start the sax parser $repeat_parser = xml_parser_create(); $parser = $repeat_parser; diff --git a/app/Stats.php b/app/Stats.php index dde00ac605..74fc020722 100644 --- a/app/Stats.php +++ b/app/Stats.php @@ -2134,7 +2134,7 @@ class Stats { * @return string */ private function topTenOldestAliveQuery($type = 'list', $sex = 'BOTH', $params = array()) { - if (!WT_USER_CAN_ACCESS) { + if (!Auth::isMember($this->tree)) { return I18N::translate('This information is private and cannot be shown.'); } if ($sex == 'F') { diff --git a/app/Theme/BaseTheme.php b/app/Theme/BaseTheme.php index b2cbdaf218..63b48bfff6 100644 --- a/app/Theme/BaseTheme.php +++ b/app/Theme/BaseTheme.php @@ -1161,8 +1161,10 @@ abstract class BaseTheme { * @return Menu */ protected function menuChartRelationship(Individual $individual) { - if (WT_USER_GEDCOM_ID && $individual->getXref()) { - return new Menu(I18N::translate('Relationship to me'), 'relationship.php?pid1=' . WT_USER_GEDCOM_ID . '&pid2=' . $individual->getXref() . '&ged=' . $this->tree_url, 'menu-chart-relationship'); + $gedcomid = $this->tree->getUserPreference(Auth::user(), 'gedcomid'); + + if ($gedcomid && $individual->getXref()) { + return new Menu(I18N::translate('Relationship to me'), 'relationship.php?pid1=' . $gedcomid . '&pid2=' . $individual->getXref() . '&ged=' . $this->tree_url, 'menu-chart-relationship'); } else { return new Menu(I18N::translate('Relationships'), 'relationship.php?pid1=' . $individual->getXref() . '&ged=' . $this->tree_url, 'menu-chart-relationship'); } @@ -1194,7 +1196,7 @@ abstract class BaseTheme { * @return Menu|null */ protected function menuControlPanel() { - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($this->tree)) { return new Menu(I18N::translate('Control panel'), 'admin.php', 'menu-admin'); } else { return null; @@ -1498,8 +1500,10 @@ abstract class BaseTheme { * @return Menu|null */ protected function menuMyIndividualRecord() { - if (WT_USER_GEDCOM_ID) { - return new Menu(I18N::translate('My individual record'), 'individual.php?pid=' . WT_USER_GEDCOM_ID . '&' . $this->tree_url, 'menu-myrecord'); + $gedcomid = $this->tree->getUserPreference(Auth::user(), 'gedcomid'); + + if ($gedcomid) { + return new Menu(I18N::translate('My individual record'), 'individual.php?pid=' . $gedcomid . '&' . $this->tree_url, 'menu-myrecord'); } else { return null; } @@ -1538,13 +1542,15 @@ abstract class BaseTheme { * @return Menu|null */ protected function menuMyPedigree() { - if (WT_USER_GEDCOM_ID) { + $gedcomid = $this->tree->getUserPreference(Auth::user(), 'gedcomid'); + + if ($gedcomid) { $showFull = $this->tree->getPreference('PEDIGREE_FULL_DETAILS') ? 1 : 0; $showLayout = $this->tree->getPreference('PEDIGREE_LAYOUT') ? 1 : 0; return new Menu( I18N::translate('My pedigree'), - 'pedigree.php?' . $this->tree_url . '&rootid=' . WT_USER_GEDCOM_ID . "&show_full={$showFull}&talloffset={$showLayout}", + 'pedigree.php?' . $this->tree_url . '&rootid=' . $gedcomid . '&show_full=' . $showFull . '&talloffset=' . $showLayout, 'menu-mypedigree' ); } else { @@ -1608,7 +1614,7 @@ abstract class BaseTheme { $submenu = new Menu(I18N::translate('Advanced search'), 'search_advanced.php?' . $this->tree_url, 'menu-search-advanced'); $menu->addSubmenu($submenu); //-- search_replace sub menu - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($this->tree)) { $submenu = new Menu(I18N::translate('Search and replace'), 'search.php?' . $this->tree_url . '&action=replace', 'menu-search-replace'); $menu->addSubmenu($submenu); } diff --git a/app/Tree.php b/app/Tree.php index 2d96a00473..56f425005d 100644 --- a/app/Tree.php +++ b/app/Tree.php @@ -70,10 +70,10 @@ class Tree { "SELECT SQL_CACHE xref, tag_type, CASE resn WHEN 'none' THEN :priv_public WHEN 'privacy' THEN :priv_user WHEN 'confidential' THEN :priv_none WHEN 'hidden' THEN :priv_hide END AS resn" . " FROM `##default_resn` WHERE gedcom_id = :tree_id" )->execute(array( - 'priv_public' => WT_PRIV_PUBLIC, - 'priv_user' => WT_PRIV_USER, - 'priv_none' => WT_PRIV_NONE, - 'priv_hide' => WT_PRIV_HIDE, + 'priv_public' => Auth::PRIV_PRIVATE, + 'priv_user' => Auth::PRIV_USER, + 'priv_none' => Auth::PRIV_NONE, + 'priv_hide' => Auth::PRIV_HIDE, 'tree_id' => $this->tree_id ))->fetchAll(); @@ -497,7 +497,7 @@ class Tree { $tree->setPreference('MAX_PEDIGREE_GENERATIONS', '10'); $tree->setPreference('MEDIA_DIRECTORY', 'media/'); $tree->setPreference('MEDIA_ID_PREFIX', 'M'); - $tree->setPreference('MEDIA_UPLOAD', WT_PRIV_USER); + $tree->setPreference('MEDIA_UPLOAD', Auth::PRIV_USER); $tree->setPreference('META_DESCRIPTION', ''); $tree->setPreference('META_TITLE', WT_WEBTREES); $tree->setPreference('NOTE_FACTS_ADD', 'SOUR,RESN'); @@ -521,16 +521,16 @@ class Tree { $tree->setPreference('SAVE_WATERMARK_THUMB', '0'); $tree->setPreference('SHOW_AGE_DIFF', '0'); $tree->setPreference('SHOW_COUNTER', '1'); - $tree->setPreference('SHOW_DEAD_PEOPLE', WT_PRIV_PUBLIC); + $tree->setPreference('SHOW_DEAD_PEOPLE', Auth::PRIV_PRIVATE); $tree->setPreference('SHOW_EST_LIST_DATES', '0'); $tree->setPreference('SHOW_FACT_ICONS', '1'); $tree->setPreference('SHOW_GEDCOM_RECORD', '0'); $tree->setPreference('SHOW_HIGHLIGHT_IMAGES', '1'); $tree->setPreference('SHOW_LDS_AT_GLANCE', '0'); $tree->setPreference('SHOW_LEVEL2_NOTES', '1'); - $tree->setPreference('SHOW_LIVING_NAMES', WT_PRIV_USER); + $tree->setPreference('SHOW_LIVING_NAMES', Auth::PRIV_USER); $tree->setPreference('SHOW_MEDIA_DOWNLOAD', '0'); - $tree->setPreference('SHOW_NO_WATERMARK', WT_PRIV_USER); + $tree->setPreference('SHOW_NO_WATERMARK', Auth::PRIV_USER); $tree->setPreference('SHOW_PARENTS_AGE', '1'); $tree->setPreference('SHOW_PEDIGREE_PLACES', '9'); $tree->setPreference('SHOW_PEDIGREE_PLACES_SUFFIX', '0'); diff --git a/edit_interface.php b/edit_interface.php index f38581c41a..41079af5b5 100644 --- a/edit_interface.php +++ b/edit_interface.php @@ -116,7 +116,7 @@ case 'updateraw': $gedcom = '0 @' . $record->getXref() . '@ ' . $record::RECORD_TYPE; // Retain any private facts - foreach ($record->getFacts(null, false, WT_PRIV_HIDE) as $fact) { + foreach ($record->getFacts(null, false, Auth::PRIV_HIDE) as $fact) { if (!in_array($fact->getFactId(), $fact_ids)) { $gedcom .= "\n" . $fact->getGedcom(); } @@ -317,7 +317,7 @@ case 'edit': } if (Auth::isAdmin() || $WT_TREE->getPreference('SHOW_GEDCOM_RECORD')) { echo - '<br><br><a href="edit_interface.php?action=editrawfact&xref=', $xref, '&fact_id=', $fact_id, '&ged=', WT_GEDURL, '">', + '<br><br><a href="edit_interface.php?action=editrawfact&xref=', $xref, '&fact_id=', $fact_id, '&ged=', $WT_TREE->getNameUrl(), '">', I18N::translate('Edit raw GEDCOM'), '</a>'; } @@ -2797,7 +2797,7 @@ function print_indi_form($nextaction, Individual $person = null, Family $family // If we are editing an existing name, allow raw GEDCOM editing if ($name_fact && (Auth::isAdmin() || $WT_TREE->getPreference('SHOW_GEDCOM_RECORD'))) { echo - '<br><br><a href="edit_interface.php?action=editrawfact&xref=', $xref, '&fact_id=', $name_fact->getFactId(), '&ged=', WT_GEDURL, '">', + '<br><br><a href="edit_interface.php?action=editrawfact&xref=', $xref, '&fact_id=', $name_fact->getFactId(), '&ged=', $WT_TREE->getNameUrl(), '">', I18N::translate('Edit raw GEDCOM'), '</a>'; } diff --git a/edituser.php b/edituser.php index 9bf9162fc0..e5596a7c6e 100644 --- a/edituser.php +++ b/edituser.php @@ -105,8 +105,8 @@ $controller ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) ->addInlineJavascript('autocomplete();'); -$my_individual_record = Individual::getInstance(WT_USER_GEDCOM_ID); -$default_individual = Individual::getInstance(WT_USER_ROOT_ID); +$my_individual_record = Individual::getInstance($WT_TREE->getUserPreference(Auth::user(), 'gedcomid')); +$default_individual = Individual::getInstance($WT_TREE->getUserPreference(Auth::user(), 'rootid')); // Form validation ?> @@ -186,7 +186,7 @@ function checkform(frm) { </label> </div> <div class="value"> - <input data-autocomplete-type="INDI" type="text" name="form_rootid" id="form_rootid" value="<?php WT_USER_ROOT_ID; ?>"> + <input data-autocomplete-type="INDI" type="text" name="form_rootid" id="form_rootid" value="<?php $WT_TREE->getUserPreference(Auth::user(), 'rootid'); ?>"> <?php echo print_findindi_link('form_rootid'); ?> <br> <?php if ($default_individual): ?> diff --git a/family.php b/family.php index 036ae6b8c4..932f74beb6 100644 --- a/family.php +++ b/family.php @@ -31,7 +31,7 @@ $controller = new FamilyController; if ($controller->record && $controller->record->canShow()) { $controller->pageHeader(); if ($controller->record->isPendingDeletion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -41,7 +41,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This family has been deleted. The deletion will need to be reviewed by a moderator.'), @@ -49,7 +49,7 @@ if ($controller->record && $controller->record->canShow()) { '</p>'; } } elseif ($controller->record->isPendingAddtion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -59,7 +59,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This family has been edited. The changes need to be reviewed by a moderator.'), @@ -98,7 +98,7 @@ if ($controller->record && $controller->record->canShow()) { <td colspan="2"> <?php print_family_parents($controller->record); - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($controller->record->getTree())) { $husb = $controller->record->getHusband(); if (!$husb) { echo '<a href="#" onclick="return add_spouse_to_family(\'', $controller->record->getXref(), '\', \'HUSB\');">', I18N::translate('Add a new father'), '</a><br>'; diff --git a/famlist.php b/famlist.php index 3b8ddcd350..fdce15aa76 100644 --- a/famlist.php +++ b/famlist.php @@ -60,19 +60,19 @@ if ($show_all === 'yes') { $alpha = ''; $surname = ''; $legend = I18N::translate('All'); - $url = WT_SCRIPT_NAME . '?show_all=yes&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?show_all=yes&ged=' . $WT_TREE->getNameUrl(); $show = 'indi'; } elseif ($falpha) { $alpha = ''; $surname = ''; $legend = I18N::translate('All') . ', ' . Filter::escapeHtml($falpha) . '…'; - $url = WT_SCRIPT_NAME . '?show_all=yes&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?show_all=yes&ged=' . $WT_TREE->getNameUrl(); $show = 'indi'; } else { $alpha = ''; $surname = ''; $legend = I18N::translate('All'); - $url = WT_SCRIPT_NAME . '?show_all=yes' . '&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?show_all=yes' . '&ged=' . $WT_TREE->getNameUrl(); $show = Filter::get('show', 'surn|indi', 'surn'); } } elseif ($surname) { @@ -83,39 +83,39 @@ if ($show_all === 'yes') { } else { $legend = Filter::escapeHtml($surname); } - $url = WT_SCRIPT_NAME . '?surname=' . rawurlencode($surname) . '&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?surname=' . rawurlencode($surname) . '&ged=' . $WT_TREE->getNameUrl(); switch ($falpha) { case '': break; case '@': $legend .= ', ' . $UNKNOWN_PN; - $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . WT_GEDURL; + $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . $WT_TREE->getNameUrl(); break; default: $legend .= ', ' . Filter::escapeHtml($falpha) . '…'; - $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . WT_GEDURL; + $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . $WT_TREE->getNameUrl(); break; } $show = 'indi'; // SURN list makes no sense here } elseif ($alpha === '@') { $show_all = 'no'; $legend = $UNKNOWN_NN; - $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . $WT_TREE->getNameUrl(); $show = 'indi'; // SURN list makes no sense here } elseif ($alpha === ',') { $show_all = 'no'; $legend = I18N::translate('None'); - $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . $WT_TREE->getNameUrl(); $show = 'indi'; // SURN list makes no sense here } elseif ($alpha) { $show_all = 'no'; $legend = Filter::escapeHtml($alpha) . '…'; - $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . $WT_TREE->getNameUrl(); $show = Filter::get('show', 'surn|indi', 'surn'); } else { $show_all = 'no'; $legend = '…'; - $url = WT_SCRIPT_NAME . '?ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?ged=' . $WT_TREE->getNameUrl(); $show = 'none'; // Don't show lists until something is chosen } $legend = '<span dir="auto">' . $legend . '</span>'; @@ -142,9 +142,9 @@ foreach (QueryName::surnameAlpha($show_marnm === 'yes', true, WT_GED_ID) as $let } if ($count) { if ($letter == $alpha) { - $list[] = '<a href="' . WT_SCRIPT_NAME . '?alpha=' . rawurlencode($letter) . '&ged=' . WT_GEDURL . '" class="warning" title="' . I18N::number($count) . '">' . $html . '</a>'; + $list[] = '<a href="' . WT_SCRIPT_NAME . '?alpha=' . rawurlencode($letter) . '&ged=' . $WT_TREE->getNameUrl() . '" class="warning" title="' . I18N::number($count) . '">' . $html . '</a>'; } else { - $list[] = '<a href="' . WT_SCRIPT_NAME . '?alpha=' . rawurlencode($letter) . '&ged=' . WT_GEDURL . '" title="' . I18N::number($count) . '">' . $html . '</a>'; + $list[] = '<a href="' . WT_SCRIPT_NAME . '?alpha=' . rawurlencode($letter) . '&ged=' . $WT_TREE->getNameUrl() . '" title="' . I18N::number($count) . '">' . $html . '</a>'; } } else { $list[] = $html; @@ -156,7 +156,7 @@ if (!Auth::isSearchEngine()) { if ($show_all === 'yes') { $list[] = '<span class="warning">' . I18N::translate('All') . '</span>'; } else { - $list[] = '<a href="' . WT_SCRIPT_NAME . '?show_all=yes' . '&ged=' . WT_GEDURL . '">' . I18N::translate('All') . '</a>'; + $list[] = '<a href="' . WT_SCRIPT_NAME . '?show_all=yes' . '&ged=' . $WT_TREE->getNameUrl() . '">' . I18N::translate('All') . '</a>'; } } echo '<p class="center alpha_index">', join(' | ', $list), '</p>'; diff --git a/includes/functions/functions.php b/includes/functions/functions.php index ee51161571..9c0673dc09 100644 --- a/includes/functions/functions.php +++ b/includes/functions/functions.php @@ -345,9 +345,9 @@ function get_relationship(Individual $person1, Individual $person2, $maxlength = if ($maxlength == 0 || count($node['path']) <= $maxlength) { $indi = $node['indi']; //-- check all parents and siblings of this node - foreach ($indi->getChildFamilies(WT_PRIV_HIDE) as $family) { + foreach ($indi->getChildFamilies(Auth::PRIV_HIDE) as $family) { $visited[$family->getXref()] = true; - foreach ($family->getSpouses(WT_PRIV_HIDE) as $spouse) { + foreach ($family->getSpouses(Auth::PRIV_HIDE) as $spouse) { if (!isset($visited[$spouse->getXref()])) { $node1 = $node; $node1['length']++; @@ -363,7 +363,7 @@ function get_relationship(Individual $person1, Individual $person2, $maxlength = } } } - foreach ($family->getChildren(WT_PRIV_HIDE) as $child) { + foreach ($family->getChildren(Auth::PRIV_HIDE) as $child) { if (!isset($visited[$child->getXref()])) { $node1 = $node; $node1['length']++; @@ -381,9 +381,9 @@ function get_relationship(Individual $person1, Individual $person2, $maxlength = } } //-- check all spouses and children of this node - foreach ($indi->getSpouseFamilies(WT_PRIV_HIDE) as $family) { + foreach ($indi->getSpouseFamilies(Auth::PRIV_HIDE) as $family) { $visited[$family->getXref()] = true; - foreach ($family->getSpouses(WT_PRIV_HIDE) as $spouse) { + foreach ($family->getSpouses(Auth::PRIV_HIDE) as $spouse) { if (!in_array($spouse->getXref(), $node1) || !isset($visited[$spouse->getXref()])) { $node1 = $node; $node1['length']++; @@ -399,7 +399,7 @@ function get_relationship(Individual $person1, Individual $person2, $maxlength = } } } - foreach ($family->getChildren(WT_PRIV_HIDE) as $child) { + foreach ($family->getChildren(Auth::PRIV_HIDE) as $child) { if (!isset($visited[$child->getXref()])) { $node1 = $node; $node1['length']++; diff --git a/includes/functions/functions_charts.php b/includes/functions/functions_charts.php index 68f17415f4..b7a8ea6368 100644 --- a/includes/functions/functions_charts.php +++ b/includes/functions/functions_charts.php @@ -141,7 +141,7 @@ function print_family_parents(Family $family, $sosa = 0, $label = '', $parid = ' } if ($hfam && ($sosa != -1)) { echo '<td valign="middle" rowspan="2">'; - print_url_arrow(($sosa == 0 ? '?famid=' . $hfam->getXref() . '&ged=' . WT_GEDURL : '#' . $hfam->getXref()), $hfam->getXref(), 1); + print_url_arrow(($sosa == 0 ? '?famid=' . $hfam->getXref() . '&ged=' . $hfam->getTree()->getNameUrl() : '#' . $hfam->getXref()), $hfam->getXref(), 1); echo '</td>'; } if ($hfam) { @@ -232,7 +232,7 @@ function print_family_parents(Family $family, $sosa = 0, $label = '', $parid = ' } if ($hfam && ($sosa != -1)) { echo '<td valign="middle" rowspan="2">'; - print_url_arrow(($sosa == 0 ? '?famid=' . $hfam->getXref() . '&ged=' . WT_GEDURL : '#' . $hfam->getXref()), $hfam->getXref(), 1); + print_url_arrow(($sosa == 0 ? '?famid=' . $hfam->getXref() . '&ged=' . $hfam->getTree()->getNameUrl() : '#' . $hfam->getXref()), $hfam->getXref(), 1); echo '</td>'; } if ($hfam) { @@ -296,7 +296,7 @@ function print_family_children(Family $family, $childid = '', $sosa = 0, $label } echo '</span>'; - if ($sosa == 0 && WT_USER_CAN_EDIT) { + if ($sosa == 0 && Auth::isEditor($family->getTree())) { echo '<br>'; echo "<a href=\"#\" onclick=\"return add_child_to_family('", $family->getXref(), "', 'U');\">" . I18N::translate('Add a child to this family') . "</a>"; echo ' <a class="icon-sex_m_15x15" href="#" onclick="return add_child_to_family(\'', $family->getXref(), '\', \'M\');" title="', I18N::translate('son'), '"></a>'; diff --git a/includes/functions/functions_db.php b/includes/functions/functions_db.php index f145738384..6647e67259 100644 --- a/includes/functions/functions_db.php +++ b/includes/functions/functions_db.php @@ -1055,6 +1055,8 @@ function get_id_from_gedcom($ged_name) { * @return string[][] */ function get_user_blocks($user_id) { + global $WT_TREE; + $blocks = array('main'=>array(), 'side'=>array()); $rows = Database::prepare( "SELECT SQL_CACHE location, block_id, module_name" . @@ -1066,7 +1068,7 @@ function get_user_blocks($user_id) { " AND `##module_privacy`.gedcom_id=?" . " AND access_level>=?" . " ORDER BY location, block_order" - )->execute(array($user_id, WT_GED_ID, WT_USER_ACCESS_LEVEL))->fetchAll(); + )->execute(array($user_id, $WT_TREE->getTreeId(), Auth::accessLevel($WT_TREE)))->fetchAll(); foreach ($rows as $row) { $blocks[$row->location][$row->block_id] = $row->module_name; } @@ -1075,8 +1077,8 @@ function get_user_blocks($user_id) { /** * NOTE - this function is only correct when $gedcom_id==WT_GED_ID - * since the privacy depends on WT_USER_ACCESS_LEVEL, which depends - * on WT_GED_ID "SELECT SQL_CACHE location, block_id, module_name". + * since the privacy depends on the user access level, which depends + * on the tree. * * @param integer $gedcom_id * @@ -1093,7 +1095,7 @@ function get_gedcom_blocks($gedcom_id) { " AND status='enabled'" . " AND access_level>=?" . " ORDER BY location, block_order" - )->execute(array($gedcom_id, WT_USER_ACCESS_LEVEL))->fetchAll(); + )->execute(array($gedcom_id, Auth::accessLevel(Tree::findById($gedcom_id))))->fetchAll(); foreach ($rows as $row) { $blocks[$row->location][$row->block_id] = $row->module_name; } diff --git a/includes/functions/functions_edit.php b/includes/functions/functions_edit.php index 1a220a7dea..367fc7eea4 100644 --- a/includes/functions/functions_edit.php +++ b/includes/functions/functions_edit.php @@ -171,10 +171,10 @@ function edit_language_checkboxes($parameter_name, $accepted_languages) { */ function edit_field_access_level($name, $selected = '', $extra = '') { $ACCESS_LEVEL = array( - WT_PRIV_PUBLIC=> I18N::translate('Show to visitors'), - WT_PRIV_USER => I18N::translate('Show to members'), - WT_PRIV_NONE => I18N::translate('Show to managers'), - WT_PRIV_HIDE => I18N::translate('Hide from everyone') + Auth::PRIV_PRIVATE=> I18N::translate('Show to visitors'), + Auth::PRIV_USER => I18N::translate('Show to members'), + Auth::PRIV_NONE => I18N::translate('Show to managers'), + Auth::PRIV_HIDE => I18N::translate('Hide from everyone') ); return select_edit_control($name, $ACCESS_LEVEL, null, $selected, $extra); } @@ -1007,7 +1007,7 @@ function print_add_layer($tag, $level = 2) { break; case 'OBJE': - if ($WT_TREE->getPreference('MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { + if ($WT_TREE->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($WT_TREE)) { echo "<a href=\"#\" onclick=\"return expand_layer('newobje');\"><i id=\"newobje_img\" class=\"icon-plus\"></i> ", I18N::translate('Add a new media object'), '</a>'; echo help_link('OBJE'); echo '<br>'; diff --git a/includes/functions/functions_export.php b/includes/functions/functions_export.php index 73407edfce..d2389066ba 100644 --- a/includes/functions/functions_export.php +++ b/includes/functions/functions_export.php @@ -174,16 +174,16 @@ function export_gedcom($gedcom, $gedout, $exportOptions) { switch ($exportOptions['privatize']) { case 'gedadmin': - $access_level = WT_PRIV_NONE; + $access_level = Auth::PRIV_NONE; break; case 'user': - $access_level = WT_PRIV_USER; + $access_level = Auth::PRIV_USER; break; case 'visitor': - $access_level = WT_PRIV_PUBLIC; + $access_level = Auth::PRIV_PRIVATE; break; case 'none': - $access_level = WT_PRIV_HIDE; + $access_level = Auth::PRIV_HIDE; break; } diff --git a/includes/functions/functions_print.php b/includes/functions/functions_print.php index 94b500e897..5a8b86f456 100644 --- a/includes/functions/functions_print.php +++ b/includes/functions/functions_print.php @@ -263,7 +263,7 @@ function format_asso_rela_record(Fact $event) { $relationship_name .= $associate->getSexImage(); } - $values[] = '<a href="relationship.php?pid1=' . $associate->getXref() . '&pid2=' . $person->getXref() . '&ged=' . WT_GEDURL . '">' . $relationship_name . '</a>'; + $values[] = '<a href="relationship.php?pid1=' . $associate->getXref() . '&pid2=' . $person->getXref() . '&ged=' . $associate->getTree()->getNameUrl() . '">' . $relationship_name . '</a>'; } } $value = implode(' — ', $values); diff --git a/includes/functions/functions_print_facts.php b/includes/functions/functions_print_facts.php index 32701bb2a6..935c37a96a 100644 --- a/includes/functions/functions_print_facts.php +++ b/includes/functions/functions_print_facts.php @@ -226,7 +226,7 @@ function print_fact(Fact $fact, GedcomRecord $record) { echo '<div class="field"><a href="mailto:', Filter::escapeHtml($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>'; break; case 'FILE': - if (WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT) { + if (Auth::isEditor($fact->getParent()->getTree())) { echo '<div class="field">', Filter::escapeHtml($fact->getValue()), '</div>'; } break; @@ -580,13 +580,9 @@ function print_media_links($factrec, $level) { } echo '<div class="media-display"><div class="media-display-image">'; echo $media->displayImage(); - echo '</div>'; // close div "media-display-image" + echo '</div>'; echo '<div class="media-display-title">'; - if (Auth::isSearchEngine()) { - echo $media->getFullName(); - } else { - echo '<a href="mediaviewer.php?mid=', $media->getXref(), '&ged=', WT_GEDURL, '">', $media->getFullName(), '</a>'; - } + echo '<a href="', $media->getHtmlUrl(), '">', $media->getFullName(), '</a>'; // NOTE: echo the notes of the media echo '<p>'; echo print_fact_notes($media->getGedcom(), 1); diff --git a/includes/functions/functions_print_lists.php b/includes/functions/functions_print_lists.php index 15ae9d089a..62946e09db 100644 --- a/includes/functions/functions_print_lists.php +++ b/includes/functions/functions_print_lists.php @@ -1042,7 +1042,7 @@ function format_sour_table($datalist) { /* 10 #NOTE */ { type: "num", visible: false }, /* 11 CHAN */ { dataSort: 12, visible: ' . ($WT_TREE->getPreference('SHOW_LAST_CHANGE') ? 'true' : 'false') . ' }, /* 12 CHAN_sort */ { visible: false }, - /* 13 DELETE */ { visible: ' . (WT_USER_GEDCOM_ADMIN ? 'true' : 'false') . ', sortable: false } + /* 13 DELETE */ { visible: ' . (Auth::isManager($WT_TREE) ? 'true' : 'false') . ', sortable: false } ], displayLength: 20, pagingType: "full_numbers" @@ -1135,7 +1135,7 @@ function format_sour_table($datalist) { $html .= '<td></td>'; } //-- Delete - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { $html .= '<td><div title="' . I18N::translate('Delete') . '" class="deleteicon" onclick="return delete_source(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($source->getFullName()))) . "', '" . $source->getXref() . '\');"><span class="link_text">' . I18N::translate('Delete') . '</span></div></td>'; } else { $html .= '<td></td>'; @@ -1182,7 +1182,7 @@ function format_note_table($datalist) { /* 8 #SOUR */ { type: "num", visible: false }, /* 9 CHAN */ { dataSort: 10, visible: ' . ($WT_TREE->getPreference('SHOW_LAST_CHANGE') ? 'true' : 'false') . ' }, /* 10 CHAN_sort */ { visible: false }, - /* 11 DELETE */ { visible: ' . (WT_USER_GEDCOM_ADMIN ? 'true' : 'false') . ', sortable: false } + /* 11 DELETE */ { visible: ' . (Auth::isManager($WT_TREE) ? 'true' : 'false') . ', sortable: false } ], displayLength: 20, pagingType: "full_numbers" @@ -1250,7 +1250,7 @@ function format_note_table($datalist) { $html .= '<td></td>'; } //-- Delete - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { $html .= '<td><div title="' . I18N::translate('Delete') . '" class="deleteicon" onclick="return delete_note(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($note->getFullName()))) . "', '" . $note->getXref() . '\');"><span class="link_text">' . I18N::translate('Delete') . '</span></div></td>'; } else { $html .= '<td></td>'; @@ -1298,7 +1298,7 @@ function format_repo_table($repositories) { /* 2 #SOUR */ { type: "num", visible: false }, /* 3 CHAN */ { dataSort: 4, visible: ' . ($WT_TREE->getPreference('SHOW_LAST_CHANGE') ? 'true' : 'false') . ' }, /* 4 CHAN_sort */ { visible: false }, - /* 5 DELETE */ { visible: ' . (WT_USER_GEDCOM_ADMIN ? 'true' : 'false') . ', sortable: false } + /* 5 DELETE */ { visible: ' . (Auth::isManager($WT_TREE) ? 'true' : 'false') . ', sortable: false } ], displayLength: 20, pagingType: "full_numbers" @@ -1364,7 +1364,7 @@ function format_repo_table($repositories) { $html .= '<td></td>'; } //-- Delete - if (WT_USER_GEDCOM_ADMIN) { + if (Auth::isManager($WT_TREE)) { $html .= '<td><div title="' . I18N::translate('Delete') . '" class="deleteicon" onclick="return delete_repository(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($repository->getFullName()))) . "', '" . $repository->getXref() . '\');"><span class="link_text">' . I18N::translate('Delete') . '</span></div></td>'; } else { $html .= '<td></td>'; @@ -1454,7 +1454,7 @@ function format_media_table($media_objects) { $html .= '<td>'; $html .= '<a href="' . $media_object->getHtmlUrl() . '" class="list_item name2">'; $html .= highlight_search_hits($name) . '</a>'; - if (WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT) { + if (Auth::isEditor($media_object->getTree())) { $html .= '<br><a href="' . $media_object->getHtmlUrl() . '">' . basename($media_object->getFilename()) . '</a>'; } $html .= '</td>'; @@ -1497,7 +1497,8 @@ function format_media_table($media_objects) { * @return string */ function format_surname_table($surnames, $script) { - global $controller; + global $controller, $WT_TREE; + $html = ''; $controller ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) @@ -1537,9 +1538,9 @@ function format_surname_table($surnames, $script) { foreach ($surnames as $surn => $surns) { // Each surname links back to the indi/fam surname list if ($surn) { - $url = $script . '?surname=' . rawurlencode($surn) . '&ged=' . WT_GEDURL; + $url = $script . '?surname=' . rawurlencode($surn) . '&ged=' . $WT_TREE->getNameUrl(); } else { - $url = $script . '?alpha=,&ged=' . WT_GEDURL; + $url = $script . '?alpha=,&ged=' . $WT_TREE->getNameUrl(); } // Row counter $html .= '<tr>'; @@ -1587,6 +1588,8 @@ function format_surname_table($surnames, $script) { * @return string */ function format_surname_tagcloud($surnames, $script, $totals) { + global $WT_TREE; + $cloud = new Zend_Tag_Cloud( array( 'tagDecorator' => array( @@ -1617,7 +1620,7 @@ function format_surname_tagcloud($surnames, $script, $totals) { 'weight' => count($indis), 'params' => array( 'url' => $surn ? - $script . '?surname=' . urlencode($surn) . '&ged=' . WT_GEDURL : $script . '?alpha=,&ged=' . WT_GEDURL + $script . '?surname=' . urlencode($surn) . '&ged=' . $WT_TREE->getNameUrl() : $script . '?alpha=,&ged=' . $WT_TREE->getNameUrl() ) )); } diff --git a/includes/reportheader.php b/includes/reportheader.php index c6de16d628..18d767cd34 100644 --- a/includes/reportheader.php +++ b/includes/reportheader.php @@ -90,7 +90,7 @@ function characterData($parser, $data) { function reportStartHandler($attrs) { global $report_array; - $access = WT_PRIV_PUBLIC; + $access = Auth::PRIV_PRIVATE; if (isset($attrs["access"])) { if (isset($$attrs["access"])) { $access = $$attrs["access"]; diff --git a/includes/session.php b/includes/session.php index 9ef6935193..15fb6606cf 100644 --- a/includes/session.php +++ b/includes/session.php @@ -146,12 +146,6 @@ define('WT_GEDCOM_LINE_LENGTH', 255 - strlen(WT_EOL)); // Characters, not bytes // Used in Google charts define('WT_GOOGLE_CHART_ENCODING', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.'); -// Privacy constants -define('WT_PRIV_PUBLIC', 2); // Allows visitors to view the marked information -define('WT_PRIV_USER', 1); // Allows members to access the marked information -define('WT_PRIV_NONE', 0); // Allows managers to access the marked information -define('WT_PRIV_HIDE', -1); // Hide the item to all users - // For performance, it is quicker to refer to files using absolute paths define('WT_ROOT', realpath(dirname(__DIR__)) . DIRECTORY_SEPARATOR); @@ -456,35 +450,9 @@ if (!$WT_TREE) { if ($WT_TREE) { define('WT_GEDCOM', $WT_TREE->getName()); define('WT_GED_ID', $WT_TREE->getTreeId()); - define('WT_GEDURL', $WT_TREE->getNameUrl()); - define('WT_TREE_TITLE', $WT_TREE->getTitleHtml()); - define('WT_USER_GEDCOM_ADMIN', Auth::isManager($WT_TREE)); - define('WT_USER_CAN_ACCEPT', Auth::isModerator($WT_TREE)); - define('WT_USER_CAN_EDIT', Auth::isEditor($WT_TREE)); - define('WT_USER_CAN_ACCESS', Auth::isMember($WT_TREE)); - define('WT_USER_GEDCOM_ID', $WT_TREE->getUserPreference(Auth::user(), 'gedcomid')); - define('WT_USER_ROOT_ID', $WT_TREE->getUserPreference(Auth::user(), 'rootid') ? $WT_TREE->getUserPreference(Auth::user(), 'rootid') : WT_USER_GEDCOM_ID); - define('WT_USER_PATH_LENGTH', $WT_TREE->getUserPreference(Auth::user(), 'RELATIONSHIP_PATH_LENGTH')); - if (WT_USER_GEDCOM_ADMIN) { - define('WT_USER_ACCESS_LEVEL', WT_PRIV_NONE); - } elseif (WT_USER_CAN_ACCESS) { - define('WT_USER_ACCESS_LEVEL', WT_PRIV_USER); - } else { - define('WT_USER_ACCESS_LEVEL', WT_PRIV_PUBLIC); - } } else { define('WT_GEDCOM', ''); define('WT_GED_ID', null); - define('WT_GEDURL', ''); - define('WT_TREE_TITLE', WT_WEBTREES); - define('WT_USER_GEDCOM_ADMIN', false); - define('WT_USER_CAN_ACCEPT', false); - define('WT_USER_CAN_EDIT', false); - define('WT_USER_CAN_ACCESS', false); - define('WT_USER_GEDCOM_ID', ''); - define('WT_USER_ROOT_ID', ''); - define('WT_USER_PATH_LENGTH', 0); - define('WT_USER_ACCESS_LEVEL', WT_PRIV_PUBLIC); } // With no parameters, init() looks to the environment to choose a language @@ -74,7 +74,7 @@ if ($ctype === 'user') { $controller->restrictAccess(Auth::check()); } $controller - ->setPageTitle($ctype === 'user' ? I18N::translate('My page') : WT_TREE_TITLE) + ->setPageTitle($ctype === 'user' ? I18N::translate('My page') : $WT_TREE->getTitle()) ->setMetaRobots('index,follow') ->setCanonicalUrl(WT_SCRIPT_NAME . '?ctype=' . $ctype . '&ged=' . WT_GEDCOM) ->pageHeader() @@ -136,7 +136,7 @@ echo '<div id="link_change_blocks">'; if ($ctype === 'user') { echo '<a href="index_edit.php?user_id=' . Auth::id() . '">', I18N::translate('Change the blocks on this page'), '</a>'; -} elseif ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN) { +} elseif ($ctype === 'gedcom' && Auth::isManager($WT_TREE)) { echo '<a href="index_edit.php?gedcom_id=' . WT_GED_ID . '">', I18N::translate('Change the blocks on this page'), '</a>'; } diff --git a/indilist.php b/indilist.php index 9949f426ba..d99088dbc2 100644 --- a/indilist.php +++ b/indilist.php @@ -60,19 +60,19 @@ if ($show_all === 'yes') { $alpha = ''; $surname = ''; $legend = I18N::translate('All'); - $url = WT_SCRIPT_NAME . '?show_all=yes&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?show_all=yes&ged=' . $WT_TREE->getNameUrl(); $show = 'indi'; } elseif ($falpha) { $alpha = ''; $surname = ''; $legend = I18N::translate('All') . ', ' . Filter::escapeHtml($falpha) . '…'; - $url = WT_SCRIPT_NAME . '?show_all=yes&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?show_all=yes&ged=' . $WT_TREE->getNameUrl(); $show = 'indi'; } else { $alpha = ''; $surname = ''; $legend = I18N::translate('All'); - $url = WT_SCRIPT_NAME . '?show_all=yes' . '&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?show_all=yes' . '&ged=' . $WT_TREE->getNameUrl(); $show = Filter::get('show', 'surn|indi', 'surn'); } } elseif ($surname) { @@ -83,39 +83,39 @@ if ($show_all === 'yes') { } else { $legend = Filter::escapeHtml($surname); } - $url = WT_SCRIPT_NAME . '?surname=' . rawurlencode($surname) . '&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?surname=' . rawurlencode($surname) . '&ged=' . $WT_TREE->getNameUrl(); switch ($falpha) { case '': break; case '@': $legend .= ', ' . $UNKNOWN_PN; - $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . WT_GEDURL; + $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . $WT_TREE->getNameUrl(); break; default: $legend .= ', ' . Filter::escapeHtml($falpha) . '…'; - $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . WT_GEDURL; + $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . $WT_TREE->getNameUrl(); break; } $show = 'indi'; // SURN list makes no sense here } elseif ($alpha === '@') { $show_all = 'no'; $legend = $UNKNOWN_NN; - $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . $WT_TREE->getNameUrl(); $show = 'indi'; // SURN list makes no sense here } elseif ($alpha === ',') { $show_all = 'no'; $legend = I18N::translate('None'); - $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . $WT_TREE->getNameUrl(); $show = 'indi'; // SURN list makes no sense here } elseif ($alpha) { $show_all = 'no'; $legend = Filter::escapeHtml($alpha) . '…'; - $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?alpha=' . rawurlencode($alpha) . '&ged=' . $WT_TREE->getNameUrl(); $show = Filter::get('show', 'surn|indi', 'surn'); } else { $show_all = 'no'; $legend = '…'; - $url = WT_SCRIPT_NAME . '?ged=' . WT_GEDURL; + $url = WT_SCRIPT_NAME . '?ged=' . $WT_TREE->getNameUrl(); $show = 'none'; // Don't show lists until something is chosen } $legend = '<span dir="auto">' . $legend . '</span>'; @@ -142,9 +142,9 @@ foreach (QueryName::surnameAlpha($show_marnm === 'yes', false, WT_GED_ID) as $le } if ($count) { if ($letter == $alpha) { - $list[] = '<a href="' . WT_SCRIPT_NAME . '?alpha=' . rawurlencode($letter) . '&ged=' . WT_GEDURL . '" class="warning" title="' . I18N::number($count) . '">' . $html . '</a>'; + $list[] = '<a href="' . WT_SCRIPT_NAME . '?alpha=' . rawurlencode($letter) . '&ged=' . $WT_TREE->getNameUrl() . '" class="warning" title="' . I18N::number($count) . '">' . $html . '</a>'; } else { - $list[] = '<a href="' . WT_SCRIPT_NAME . '?alpha=' . rawurlencode($letter) . '&ged=' . WT_GEDURL . '" title="' . I18N::number($count) . '">' . $html . '</a>'; + $list[] = '<a href="' . WT_SCRIPT_NAME . '?alpha=' . rawurlencode($letter) . '&ged=' . $WT_TREE->getNameUrl() . '" title="' . I18N::number($count) . '">' . $html . '</a>'; } } else { $list[] = $html; @@ -156,7 +156,7 @@ if (!Auth::isSearchEngine()) { if ($show_all === 'yes') { $list[] = '<span class="warning">' . I18N::translate('All') . '</span>'; } else { - $list[] = '<a href="' . WT_SCRIPT_NAME . '?show_all=yes' . '&ged=' . WT_GEDURL . '">' . I18N::translate('All') . '</a>'; + $list[] = '<a href="' . WT_SCRIPT_NAME . '?show_all=yes' . '&ged=' . $WT_TREE->getNameUrl() . '">' . I18N::translate('All') . '</a>'; } } echo '<p class="center alpha_index">', join(' | ', $list), '</p>'; diff --git a/individual.php b/individual.php index bb65688261..deb4a96650 100644 --- a/individual.php +++ b/individual.php @@ -16,6 +16,13 @@ namespace Fisharebest\Webtrees; * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/** + * Defined in session.php + * + * @global Tree $WT_TREE + */ +global $WT_TREE; + define('WT_SCRIPT_NAME', 'individual.php'); require './includes/session.php'; $controller = new IndividualController; @@ -34,7 +41,7 @@ if ($controller->record && $controller->record->canShow()) { $controller->pageHeader(); if ($controller->record->isPendingDeletion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -44,7 +51,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This individual has been deleted. The deletion will need to be reviewed by a moderator.'), @@ -52,7 +59,7 @@ if ($controller->record && $controller->record->canShow()) { '</p>'; } } elseif ($controller->record->isPendingAddtion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -62,7 +69,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This individual has been edited. The changes need to be reviewed by a moderator.'), @@ -253,7 +253,7 @@ case 'requestpw': I18N::translate('Username') . ": " . Filter::escapeHtml($user->getUserName()) . Mail::EOL . I18N::translate('Password') . ": " . $user_new_pw . Mail::EOL . Mail::EOL . I18N::translate('After you have logged in, select the “My account” link under the “My page” menu and fill in the password fields to change your password.') . Mail::EOL . Mail::EOL . - '<a href="' . WT_BASE_URL . 'login.php?ged=' . WT_GEDURL . '">' . WT_BASE_URL . 'login.php?ged=' . WT_GEDURL . '</a>' + '<a href="' . WT_BASE_URL . 'login.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'login.php?ged=' . $WT_TREE->getNameUrl() . '</a>' ); } // Show a success message, even if the user account does not exist. diff --git a/mediafirewall.php b/mediafirewall.php index eac5063e4d..28999898c6 100644 --- a/mediafirewall.php +++ b/mediafirewall.php @@ -60,12 +60,13 @@ function send404AsImage() { * before returning it back to the media firewall * * @param resource $im + * @param Tree $tree * * @return resource */ -function applyWatermark($im) { +function applyWatermark($im, Tree $tree) { // text to watermark with - $word1_text = WT_TREE_TITLE; + $word1_text = $tree->getTitle(); // maximum font size for “word1” ; will be automaticaly reduced to fit in the image $word1_maxsize = 100; // rgb color codes for text @@ -308,7 +309,7 @@ if ($type) { // if this is not a thumbnail, or WATERMARK_THUMB is true if (($which === 'main') || $WT_TREE->getPreference('WATERMARK_THUMB')) { // if the user’s priv’s justify it... - if (WT_USER_ACCESS_LEVEL > $WT_TREE->getPreference('SHOW_NO_WATERMARK')) { + if (Auth::accessLevel($WT_TREE) > $WT_TREE->getPreference('SHOW_NO_WATERMARK')) { // add a watermark $usewatermark = true; } @@ -389,7 +390,7 @@ if ($generatewatermark) { if (function_exists($imCreateFunc) && function_exists($imSendFunc)) { $im = $imCreateFunc($serverFilename); - $im = applyWatermark($im); + $im = applyWatermark($im, $WT_TREE); // save the image, if preferences allow if ($which === 'thumb' && $WT_TREE->getPreference('SAVE_WATERMARK_THUMB') || $which === 'main' && $WT_TREE->getPreference('SAVE_WATERMARK_IMAGE')) { diff --git a/medialist.php b/medialist.php index e611841fcc..6d76396f88 100644 --- a/medialist.php +++ b/medialist.php @@ -16,6 +16,13 @@ namespace Fisharebest\Webtrees; * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/** + * Defined in session.php + * + * @global Tree $WT_TREE + */ +global $WT_TREE; + define('WT_SCRIPT_NAME', 'medialist.php'); require './includes/session.php'; @@ -26,7 +33,7 @@ $controller $search = Filter::get('search'); $sortby = Filter::get('sortby', 'file|title', 'title'); -if (!WT_USER_CAN_EDIT && !WT_USER_CAN_ACCEPT) { +if (!Auth::isEditor($WT_TREE)) { $sortby = 'title'; } $start = Filter::getInteger('start'); @@ -75,7 +82,7 @@ $medialist = QueryMedia::mediaList( <td class="optionbox wrap"> <?php echo select_edit_control('folder', $folders, null, $folder); ?> </td> - <?php if (WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT): ?> + <?php if (Auth::isEditor($WT_TREE)): ?> <td class="descriptionbox wrap"> <?php echo I18N::translate('Sort order'); ?> </td> @@ -255,7 +262,7 @@ if ($search) { echo '<table><tr><td class="media-image">'; echo $mediaobject->displayImage(); echo '</td><td class="media-col list_value_wrap">'; - if (WT_USER_CAN_EDIT) { + if (Auth::isEditor($WT_TREE)) { echo MediaController::getMediaListMenu($mediaobject); } // If sorting by title, highlight the title. If sorting by filename, highlight the filename @@ -274,7 +281,7 @@ if ($search) { echo GedcomTag::getLabelValue('URL', $mediaobject->getFilename()); } else { if ($mediaobject->fileExists()) { - if (WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT) { + if (Auth::isEditor($WT_TREE)) { echo GedcomTag::getLabelValue('FILE', $mediaobject->getFilename()); } echo GedcomTag::getLabelValue('FORM', $mediaobject->mimeType()); diff --git a/mediaviewer.php b/mediaviewer.php index c3fb126614..846830d636 100644 --- a/mediaviewer.php +++ b/mediaviewer.php @@ -16,6 +16,13 @@ namespace Fisharebest\Webtrees; * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/** + * Defined in session.php + * + * @global Tree $WT_TREE + */ +global $WT_TREE; + define('WT_SCRIPT_NAME', 'mediaviewer.php'); require './includes/session.php'; @@ -24,7 +31,7 @@ $controller = new MediaController; if ($controller->record && $controller->record->canShow()) { $controller->pageHeader(); if ($controller->record->isPendingDeletion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -34,7 +41,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This media object has been deleted. The deletion will need to be reviewed by a moderator.'), @@ -42,7 +49,7 @@ if ($controller->record && $controller->record->canShow()) { '</p>'; } } elseif ($controller->record->isPendingAddtion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -52,7 +59,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This media object has been edited. The changes need to be reviewed by a moderator.'), diff --git a/modules_v3/GEDFact_assistant/_CENS/census_3_search_add.php b/modules_v3/GEDFact_assistant/_CENS/census_3_search_add.php index 7ab5c8359c..f40dfc1114 100644 --- a/modules_v3/GEDFact_assistant/_CENS/census_3_search_add.php +++ b/modules_v3/GEDFact_assistant/_CENS/census_3_search_add.php @@ -127,7 +127,7 @@ namespace Fisharebest\Webtrees; </td> <td align="left" class="facts_value" style="text-decoration:none;" > <?php - echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . WT_GEDURL . "\">"; + echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . $gparent->getTree()->getNameUrl() . "\">"; echo $headImg2; echo "</a>"; ?> @@ -205,7 +205,7 @@ namespace Fisharebest\Webtrees; </td> <td align="left" class="facts_value"> <?php - echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . WT_GEDURL . "\">"; + echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . $gparent->getTree()->getNameUrl() . "\">"; echo $headImg2; echo "</a>"; ?> @@ -291,7 +291,7 @@ namespace Fisharebest\Webtrees; </td> <td align="left" class="facts_value"> <?php - echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $child->getXref() . "&gedcom=" . WT_GEDURL . "\">"; + echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $child->getXref() . "&gedcom=" . $child->getTree()->getNameUrl() . "\">"; echo $headImg2; echo "</a>"; ?> @@ -396,7 +396,7 @@ namespace Fisharebest\Webtrees; </td> <td align="left" class="facts_value"> <?php - echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . WT_GEDURL . "\">"; + echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . $gparent->getTree()->getNameUrl() . "\">"; echo $headImg2; echo "</a>"; ?> @@ -475,7 +475,7 @@ namespace Fisharebest\Webtrees; </td> <td align="left" class="facts_value"> <?php - echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . WT_GEDURL . "\">"; + echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . $gparent->getTree()->getNameUrl() . "\">"; echo $headImg2; echo "</a>"; ?> @@ -563,7 +563,7 @@ namespace Fisharebest\Webtrees; </td> <td align="left" class="facts_value"> <?php - echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $child->getXref() . "&gedcom=" . WT_GEDURL . "\">"; + echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $child->getXref() . "&gedcom=" . $child->getTree()->getNameUrl() . "\">"; echo $headImg2; echo "</a>"; ?> @@ -672,7 +672,7 @@ namespace Fisharebest\Webtrees; </td> <td align="left" class="facts_value"> <?php - echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . WT_GEDURL . "\">"; + echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . $gparent->getTree()->getNameUrl() . "\">"; echo $headImg2; echo "</a>"; ?> @@ -762,7 +762,7 @@ namespace Fisharebest\Webtrees; </td> <td align="left" class="facts_value"> <?php - echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . WT_GEDURL . "\">"; + echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $gparent->getXref() . "&gedcom=" . $gparent->getTree()->getNameUrl() . "\">"; echo $headImg2; echo "</a>"; ?> @@ -848,7 +848,7 @@ namespace Fisharebest\Webtrees; </td> <td align="left" class="facts_value"> <?php - echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $child->getXref() . "&gedcom=" . WT_GEDURL . "\">"; + echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $child->getXref() . "&gedcom=" . $child->getTree()->getNameUrl() . "\">"; echo $headImg2; echo "</a>"; ?> diff --git a/modules_v3/GEDFact_assistant/_MEDIA/media_1_ctrl.php b/modules_v3/GEDFact_assistant/_MEDIA/media_1_ctrl.php index 6451c5f179..ff48db0a3a 100644 --- a/modules_v3/GEDFact_assistant/_MEDIA/media_1_ctrl.php +++ b/modules_v3/GEDFact_assistant/_MEDIA/media_1_ctrl.php @@ -108,7 +108,7 @@ if ($pid == "") { // Husband ------------------- if ($people["husb"]) { $fulln = strip_tags($people['husb']->getFullName()); - $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people["husb"]->getXref() . "&gedcom=" . WT_GEDURL); + $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people['husb']->getXref() . "&gedcom=" . $people['husb']->getTree()->getNameUrl()); print_pedigree_person_nav_media($people["husb"]->getXref()); $slabel = $parentlinks; $submenu = new Menu($slabel); @@ -145,7 +145,7 @@ if ($pid == "") { if ($people["wife"]) { $fulln = strip_tags($people['wife']->getFullName()); - $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people["wife"]->getXref() . "&gedcom=" . WT_GEDURL); + $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people['wife']->getXref() . "&gedcom=" . $people['wife']->getTree()->getNameUrl()); print_pedigree_person_nav_media($people["wife"]->getXref()); $slabel = $parentlinks; $submenu = new Menu($slabel); @@ -182,7 +182,7 @@ if ($pid == "") { $elderdate = $family->getMarriageDate(); foreach ($people["children"] as $key=>$child) { $fulln = strip_tags($child->getFullName()); - $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $child->getXref() . "&gedcom=" . WT_GEDURL); + $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $child->getXref() . "&gedcom=" . $child->getTree()->getNameUrl()); print_pedigree_person_nav_media($child->getXref()); $slabel = $spouselinks; $submenu = new Menu($slabel); @@ -241,7 +241,7 @@ if ($pid == "") { $elderdate = ""; if ($people["husb"]) { $fulln = strip_tags($people['husb']->getFullName()); - $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people["husb"]->getXref() . "&gedcom=" . WT_GEDURL); + $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people['husb']->getXref() . "&gedcom=" . $people['husb']->getTree()->getNameUrl()); print_pedigree_person_nav_media($people["husb"]->getXref()); $slabel = $parentlinks; $submenu = new Menu($slabel); @@ -279,7 +279,7 @@ if ($pid == "") { // Wife ------------------- if ($people["wife"]) { $fulln = strip_tags($people['wife']->getFullName()); - $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people["wife"]->getXref() . "&gedcom=" . WT_GEDURL); + $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people["wife"]->getXref() . "&gedcom=" . $people['wife']->getTree()->getNameUrl()); print_pedigree_person_nav_media($people["wife"]->getXref()); $slabel = $parentlinks; $submenu = new Menu($slabel); @@ -319,7 +319,7 @@ if ($pid == "") { $elderdate = $family->getMarriageDate(); foreach ($people["children"] as $key=>$child) { $fulln = strip_tags($child->getFullName()); - $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $child->getXref() . "&gedcom=" . WT_GEDURL); + $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $child->getXref() . "&gedcom=" . $child->getTree()->getNameUrl()); print_pedigree_person_nav_media($child->getXref()); $slabel = $spouselinks; $submenu = new Menu($slabel); @@ -372,7 +372,7 @@ if ($pid == "") { // Husband ------------------- if ($people["husb"]) { $fulln = strip_tags($people['husb']->getFullName()); - $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people["husb"]->getXref() . "&gedcom=" . WT_GEDURL); + $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people['husb']->getXref() . "&gedcom=" . $people['husb']->getTree()->getNameUrl()); print_pedigree_person_nav_media($people["husb"]->getXref()); $slabel = $parentlinks; $submenu = new Menu($slabel); @@ -411,7 +411,7 @@ if ($pid == "") { // Wife ------------------- if ($people["wife"]) { $fulln = strip_tags($people['wife']->getFullName()); - $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people["wife"]->getXref() . "&gedcom=" . WT_GEDURL); + $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $people['wife']->getXref() . "&gedcom=" . $people['wife']->getTree()->getNameUrl()); print_pedigree_person_nav_media($people["wife"]->getXref()); $slabel = $parentlinks; $submenu = new Menu($slabel); @@ -448,7 +448,7 @@ if ($pid == "") { // Children foreach ($people["children"] as $key=>$child) { $fulln = strip_tags($child->getFullName()); - $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $child->getXref() . "&gedcom=" . WT_GEDURL); + $menu = new Menu($headImg, "edit_interface.php?action=addmedia_links&noteid=newnote&pid=" . $child->getXref() . "&gedcom=" . $child->getTree()->getNameUrl()); print_pedigree_person_nav_media($child->getXref()); $slabel = $spouselinks; $submenu = new Menu($slabel); @@ -610,9 +610,7 @@ function print_pedigree_person_nav_media($pid) { //-- Step Husband Details ------------------------------ $person_step = 'Yes'; if ($husb->canShowName()) { - $parentlinks .= "<a href=\"individual.php?pid=" . $husb->getXref() . "&&gedcom=" . WT_GEDURL . "\">"; - $parentlinks .= $husb->getFullName(); - $parentlinks .= "</a>"; + $parentlinks .= '<a href="' . $husb->getHtmlUrl() . '">' . $husb->getFullName() . '</a>'; } else { $parentlinks .= I18N::translate('Private'); } @@ -630,7 +628,7 @@ function print_pedigree_person_nav_media($pid) { // Step Wife Details $person_step = 'Yes'; if ($wife->canShowName()) { - $parentlinks .= '<a href="individual.php?pid=' . $wife->getXref() . '&gedcom=' . WT_GEDURL . '">' . $wife->getFullName() . '</a>'; + $parentlinks .= '<a href="' . $wife->getHtmlUrl() . '">' . $wife->getFullName() . '</a>'; } else { $parentlinks .= I18N::translate('Private'); } @@ -16,6 +16,13 @@ namespace Fisharebest\Webtrees; * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/** + * Defined in session.php + * + * @global Tree $WT_TREE + */ +global $WT_TREE; + define('WT_SCRIPT_NAME', 'note.php'); require './includes/session.php'; @@ -24,7 +31,7 @@ $controller = new NoteController; if ($controller->record && $controller->record->canShow()) { $controller->pageHeader(); if ($controller->record->isPendingDeletion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -34,7 +41,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This note has been deleted. The deletion will need to be reviewed by a moderator.'), @@ -42,7 +49,7 @@ if ($controller->record && $controller->record->canShow()) { '</p>'; } } elseif ($controller->record->isPendingAddtion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -52,7 +59,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This note has been edited. The changes need to be reviewed by a moderator.'), @@ -139,7 +146,7 @@ if (Module::getModuleByName('GEDFact_assistant')) { <table class="facts_table"> <tr> <td class="descriptionbox"> - <?php if (WT_USER_CAN_EDIT) { ?> + <?php if (Auth::isEditor($controller->record->getTree())) { ?> <a href="#" onclick="return edit_note('<?php echo $controller->record->getXref(); ?>')" title="<?php echo I18N::translate('Edit'); ?>"> <i class="icon-note"></i> <?php echo I18N::translate('Shared note'); ?> </a> @@ -16,6 +16,13 @@ namespace Fisharebest\Webtrees; * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/** + * Defined in session.php + * + * @global Tree $WT_TREE + */ +global $WT_TREE; + define('WT_SCRIPT_NAME', 'repo.php'); require './includes/session.php'; @@ -24,7 +31,7 @@ $controller = new RepositoryController; if ($controller->record && $controller->record->canShow()) { $controller->pageHeader(); if ($controller->record->isPendingDeletion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -34,7 +41,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This repository has been deleted. The deletion will need to be reviewed by a moderator.'), @@ -42,7 +49,7 @@ if ($controller->record && $controller->record->canShow()) { '</p>'; } } elseif ($controller->record->isPendingAddtion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -52,7 +59,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This repository has been edited. The changes need to be reviewed by a moderator.'), diff --git a/reportengine.php b/reportengine.php index 0af3f0e083..3c18fe71ea 100644 --- a/reportengine.php +++ b/reportengine.php @@ -55,7 +55,7 @@ foreach ($vars as $name => $var) { case 'INDI': $record = Individual::getInstance($var); if ($record && $record->canShowName()) { - $newvars[$name]['gedcom'] = $record->privatizeGedcom(WT_USER_ACCESS_LEVEL); + $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE)); } else { $action = 'setup'; } @@ -63,7 +63,7 @@ foreach ($vars as $name => $var) { case 'FAM': $record = Family::getInstance($var); if ($record && $record->canShowName()) { - $newvars[$name]['gedcom'] = $record->privatizeGedcom(WT_USER_ACCESS_LEVEL); + $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE)); } else { $action = 'setup'; } @@ -71,7 +71,7 @@ foreach ($vars as $name => $var) { case 'SOUR': $record = Source::getInstance($var); if ($record && $record->canShowName()) { - $newvars[$name]['gedcom'] = $record->privatizeGedcom(WT_USER_ACCESS_LEVEL); + $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE)); } else { $action = 'setup'; } @@ -46,10 +46,10 @@ define('WT_REQUIRED_PHP_VERSION', '5.3.2'); define('WT_MODULES_DIR', 'modules_v3/'); define('WT_ROOT', ''); define('WT_GED_ID', null); -define('WT_PRIV_PUBLIC', 2); -define('WT_PRIV_USER', 1); -define('WT_PRIV_NONE', 0); -define('WT_PRIV_HIDE', -1); +define('Auth::PRIV_PRIVATE', 2); +define('Auth::PRIV_USER', 1); +define('Auth::PRIV_NONE', 0); +define('Auth::PRIV_HIDE', -1); if (file_exists(WT_DATA_DIR . WT_CONFIG_FILE)) { header('Location: index.php'); diff --git a/source.php b/source.php index 07e292112d..841af20f1d 100644 --- a/source.php +++ b/source.php @@ -16,6 +16,13 @@ namespace Fisharebest\Webtrees; * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/** + * Defined in session.php + * + * @global Tree $WT_TREE + */ +global $WT_TREE; + define('WT_SCRIPT_NAME', 'source.php'); require './includes/session.php'; @@ -24,7 +31,7 @@ $controller = new SourceController; if ($controller->record && $controller->record->canShow()) { $controller->pageHeader(); if ($controller->record->isPendingDeletion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -34,7 +41,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This source has been deleted. The deletion will need to be reviewed by a moderator.'), @@ -42,7 +49,7 @@ if ($controller->record && $controller->record->canShow()) { '</p>'; } } elseif ($controller->record->isPendingAddtion()) { - if (WT_USER_CAN_ACCEPT) { + if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( @@ -52,7 +59,7 @@ if ($controller->record && $controller->record->canShow()) { ), ' ', help_link('pending_changes'), '</p>'; - } elseif (WT_USER_CAN_EDIT) { + } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This source has been edited. The changes need to be reviewed by a moderator.'), @@ -141,7 +148,7 @@ echo '<div id="source-tabs"> if ($controller->record->canEdit()) { print_add_new_fact($controller->record->getXref(), $facts, 'SOUR'); // new media - if ($controller->record->getTree()->getPreference('MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { + if ($controller->record->getTree()->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($WT_TREE)) { echo '<tr><td class="descriptionbox">'; echo GedcomTag::getLabel('OBJE'); echo '</td><td class="optionbox">'; diff --git a/statistics.php b/statistics.php index c26ede7320..b15b4fe088 100644 --- a/statistics.php +++ b/statistics.php @@ -63,13 +63,13 @@ if (!$ajax) { echo '<div id="statistics-page"><h2>', I18N::translate('Statistics'), '</h2>', '<div id="statistics_chart">', '<ul>', - '<li><a href="statistics.php?ged=', WT_GEDURL, '&ajax=1&tab=0">', + '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=0">', '<span id="stats-indi">', I18N::translate('Individuals'), '</span></a></li>', - '<li><a href="statistics.php?ged=', WT_GEDURL, '&ajax=1&tab=1">', + '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=1">', '<span id="stats-fam">', I18N::translate('Families'), '</span></a></li>', - '<li><a href="statistics.php?ged=', WT_GEDURL, '&ajax=1&tab=2">', + '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=2">', '<span id="stats-other">', I18N::translate('Others'), '</span></a></li>', - '<li><a href="statistics.php?ged=', WT_GEDURL, '&ajax=1&tab=3">', + '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=3">', '<span id="stats-own">', I18N::translate('Own charts'), '</span></a></li>', '</ul>', '<div id="loading-indicator" style="margin:auto;width:100%;"></div>', diff --git a/timeline.php b/timeline.php index a1dd6312c9..2f008d3121 100644 --- a/timeline.php +++ b/timeline.php @@ -273,7 +273,7 @@ document.onmouseup = function () { <?php echo $indi->getAddName(); ?><br> </a> <input type="hidden" name="pids[<?php echo $p; ?>]" value="<?php echo Filter::escapeHtml($pid); ?>"> - <a href="timeline.php?<?php echo $controller->pidlinks; ?>&scale=<?php echo $controller->scale; ?>&remove=<?php echo $pid; ?>&ged=<?php echo WT_GEDURL; ?>" > + <a href="timeline.php?<?php echo $controller->pidlinks; ?>&scale=<?php echo $controller->scale; ?>&remove=<?php echo $pid; ?>&ged=<?php echo $WT_TREE->getNameUrl(); ?>" > <span class="details1"><?php echo I18N::translate('Remove individual'); ?></span></a> <?php if (!empty($controller->birthyears[$pid])) { ?> <span class="details1"><br> @@ -288,7 +288,7 @@ document.onmouseup = function () { ?> <input type="hidden" name="pids[<?php echo $p; ?>]" value="<?php echo Filter::escapeHtml($pid); ?>"> <br> - <a href="timeline.php?<?php echo $controller->pidlinks; ?>&scale=<?php echo $controller->scale; ?>&remove=<?php echo $pid; ?>&ged=<?php echo WT_GEDURL; ?>" > + <a href="timeline.php?<?php echo $controller->pidlinks; ?>&scale=<?php echo $controller->scale; ?>&remove=<?php echo $pid; ?>&ged=<?php echo $WT_TREE->getNameUrl(); ?>" > <span class="details1"><?php echo I18N::translate('Remove individual'); ?></span></a> <br> <?php } ?> @@ -308,14 +308,14 @@ document.onmouseup = function () { $scalemod = round($controller->scale * .2) + 1; ?> <td class="list_value" style="padding: 5px;"> - <a href="<?php echo WT_SCRIPT_NAME . "?" . $controller->pidlinks . "scale=" . ($controller->scale + $scalemod); ?>&ged=<?php echo WT_GEDURL; ?>" class="icon-zoomin" title="<?php echo I18N::translate('Zoom in'); ?>"></a><br> - <a href="<?php echo WT_SCRIPT_NAME . "?" . $controller->pidlinks . "scale=" . ($controller->scale - $scalemod); ?>&ged=<?php echo WT_GEDURL; ?>" class="icon-zoomout" title="<?php echo I18N::translate('Zoom out'); ?>"></a><br> - <input type="button" value="<?php echo I18N::translate('Clear chart'); ?>" onclick="window.location = 'timeline.php?ged=<?php echo WT_GEDURL; ?>';"> + <a href="<?php echo WT_SCRIPT_NAME . "?" . $controller->pidlinks . "scale=" . ($controller->scale + $scalemod); ?>&ged=<?php echo $WT_TREE->getNameUrl(); ?>" class="icon-zoomin" title="<?php echo I18N::translate('Zoom in'); ?>"></a><br> + <a href="<?php echo WT_SCRIPT_NAME . "?" . $controller->pidlinks . "scale=" . ($controller->scale - $scalemod); ?>&ged=<?php echo $WT_TREE->getNameUrl(); ?>" class="icon-zoomout" title="<?php echo I18N::translate('Zoom out'); ?>"></a><br> + <input type="button" value="<?php echo I18N::translate('Clear chart'); ?>" onclick="window.location = 'timeline.php?ged=<?php echo $WT_TREE->getNameUrl(); ?>';"> </td> <?php } ?> </tr> </table> - <br><a href="lifespan.php?ged=<?php echo WT_GEDURL; ?>"><b><?php echo I18N::translate('Show lifespans'); ?></b></a> + <br><a href="lifespan.php?ged=<?php echo $WT_TREE->getNameUrl(); ?>"><b><?php echo I18N::translate('Show lifespans'); ?></b></a> </form> <?php if (count($controller->people) > 0) { |
