summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Auth.php40
-rw-r--r--app/Controller/AncestryController.php2
-rw-r--r--app/Controller/BranchesController.php8
-rw-r--r--app/Controller/DescendancyController.php4
-rw-r--r--app/Controller/FamilyController.php12
-rw-r--r--app/Controller/FanchartController.php21
-rw-r--r--app/Controller/IndividualController.php6
-rw-r--r--app/Controller/MediaController.php6
-rw-r--r--app/Controller/NoteController.php4
-rw-r--r--app/Controller/PageController.php8
-rw-r--r--app/Controller/RepositoryController.php6
-rw-r--r--app/Controller/SourceController.php6
-rw-r--r--app/Fact.php16
-rw-r--r--app/Family.php22
-rw-r--r--app/GedcomRecord.php70
-rw-r--r--app/Individual.php52
-rw-r--r--app/Media.php2
-rw-r--r--app/Module.php62
-rw-r--r--app/Module/AhnentafelReportModule.php6
-rw-r--r--app/Module/AlbumModule.php12
-rw-r--r--app/Module/BatchUpdate/BirthDeathMarriageReportModule.php6
-rw-r--r--app/Module/BirthReportModule.php6
-rw-r--r--app/Module/CemeteryReportModule.php6
-rw-r--r--app/Module/ChangeReportModule.php6
-rw-r--r--app/Module/ChartsBlockModule.php8
-rw-r--r--app/Module/ClippingsCart/ClippingsCart.php12
-rw-r--r--app/Module/ClippingsCartModule.php16
-rw-r--r--app/Module/DeathReportModule.php6
-rw-r--r--app/Module/DescendancyReportModule.php6
-rw-r--r--app/Module/FactSourcesReportModule.php6
-rw-r--r--app/Module/FamilyGroupReportModule.php6
-rw-r--r--app/Module/FamilyNavigatorModule.php2
-rw-r--r--app/Module/FamilyTreeFavoritesModule.php10
-rw-r--r--app/Module/FamilyTreeNewsModule.php8
-rw-r--r--app/Module/FamilyTreeStatisticsModule.php22
-rw-r--r--app/Module/FrequentlyAskedQuestionsModule.php5
-rw-r--r--app/Module/GoogleMapsModule.php2
-rw-r--r--app/Module/HtmlBlockModule.php14
-rw-r--r--app/Module/IndividualFamiliesReportModule.php6
-rw-r--r--app/Module/IndividualReportModule.php6
-rw-r--r--app/Module/MarriageReportModule.php6
-rw-r--r--app/Module/MediaTabModule.php10
-rw-r--r--app/Module/MissingFactsReportModuleModule.php6
-rw-r--r--app/Module/NotesTabModule.php4
-rw-r--r--app/Module/OccupationReportModule.php6
-rw-r--r--app/Module/OnThisDayModule.php4
-rw-r--r--app/Module/PageMenuModule.php4
-rw-r--r--app/Module/PedigreeReportModule.php6
-rw-r--r--app/Module/RecentChangesModule.php4
-rw-r--r--app/Module/RelatedIndividualsReportModule.php6
-rw-r--r--app/Module/RelativesTabModule.php7
-rw-r--r--app/Module/ResearchTaskModule.php4
-rw-r--r--app/Module/ReviewChangesModule.php2
-rw-r--r--app/Module/SlideShowModule.php4
-rw-r--r--app/Module/SourcesTabModule.php4
-rw-r--r--app/Module/StoriesModule.php18
-rw-r--r--app/Module/TopGivenNamesModuleModule.php2
-rw-r--r--app/Module/TopPageViewsModule.php4
-rw-r--r--app/Module/TopSurnamesModule.php2
-rw-r--r--app/Module/UpcomingAnniversariesModule.php4
-rw-r--r--app/Module/UserWelcomeModule.php9
-rw-r--r--app/Module/WelcomeBlockModule.php8
-rw-r--r--app/Module/YahrzeitModule.php4
-rw-r--r--app/Report/ReportBase.php14
-rw-r--r--app/Stats.php2
-rw-r--r--app/Theme/BaseTheme.php22
-rw-r--r--app/Tree.php16
67 files changed, 407 insertions, 299 deletions
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 . '&amp;PEDIGREE_GENERATIONS=' . $this->generations . '&amp;show_full=' . $this->showFull() . '&amp;chart_style=' . $this->chart_style . '&amp;ged=' . WT_GEDURL, $label, 3);
+ print_url_arrow('?rootid=' . $pid . '&amp;PEDIGREE_GENERATIONS=' . $this->generations . '&amp;show_full=' . $this->showFull() . '&amp;chart_style=' . $this->chart_style . '&amp;ged=' . $person->getTree()->getNameUrl(), $label, 3);
}
echo '</td>';
echo '<td class="details1">&nbsp;<span dir="ltr" class="person_box' . (($sosa == 1) ? 'NN' : (($sosa % 2) ? 'F' : '')) . '">&nbsp;', $sosa, '&nbsp;</span>&nbsp;';
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 . '&amp;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') . '&amp;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 . '&amp;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') . '&amp;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() . '&amp;generations=' . $this->generations . '&amp;chart_style=' . $this->chart_style . '&amp;show_full=' . $this->showFull() . '&amp;ged=' . WT_GEDURL, I18N::translate('Start at parents'), 2);
+ print_url_arrow('?rootid=' . $parent->getXref() . '&amp;generations=' . $this->generations . '&amp;chart_style=' . $this->chart_style . '&amp;show_full=' . $this->showFull() . '&amp;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() . '&amp;generations=' . $this->generations . '&amp;chart_style=' . $this->chart_style . '&amp;show_full=' . $this->showFull() . '&amp;ged=' . WT_GEDURL, I18N::translate('Start at parents'), 2);
+ print_url_arrow('?rootid=' . $parent->getXref() . '&amp;generations=' . $this->generations . '&amp;chart_style=' . $this->chart_style . '&amp;show_full=' . $this->showFull() . '&amp;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 . '&amp;generations=' . $this->generations . '&amp;fan_width=' . $this->fan_width . '&amp;fan_style=' . $this->fan_style . '&amp;ged=' . WT_GEDURL;
+ $tempURL = 'fanchart.php?rootid=' . $pid . '&amp;generations=' . $this->generations . '&amp;fan_width=' . $this->fan_width . '&amp;fan_style=' . $this->fan_style . '&amp;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 . '&amp;ged=' . WT_GEDURL . '" >' . I18N::translate('Pedigree') . '</a></li>';
+ $html .= '<li><a href="pedigree.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '" >' . I18N::translate('Pedigree') . '</a></li>';
if (Module::getModuleByName('googlemap')) {
- $html .= '<li><a href="module.php?mod=googlemap&amp;mod_action=pedigree_map&amp;rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '">' . I18N::translate('Pedigree map') . '</a></li>';
+ $html .= '<li><a href="module.php?mod=googlemap&amp;mod_action=pedigree_map&amp;rootid=' . $pid . '&amp;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 . '&amp;pid2=' . $pid . '&amp;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 . '&amp;pid2=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Relationship to me') . '</a></li>';
}
- $html .= '<li><a href="descendancy.php?rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '" >' . I18N::translate('Descendants') . '</a></li>';
- $html .= '<li><a href="ancestry.php?rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '">' . I18N::translate('Ancestors') . '</a></li>';
- $html .= '<li><a href="compact.php?rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '">' . I18N::translate('Compact tree') . '</a></li>';
+ $html .= '<li><a href="descendancy.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '" >' . I18N::translate('Descendants') . '</a></li>';
+ $html .= '<li><a href="ancestry.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Ancestors') . '</a></li>';
+ $html .= '<li><a href="compact.php?rootid=' . $pid . '&amp;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 . '&amp;ged=' . WT_GEDURL . '">' . I18N::translate('Hourglass chart') . '</a></li>';
+ $html .= '<li><a href="hourglass.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Hourglass chart') . '</a></li>';
if (Module::getModuleByName('tree')) {
- $html .= '<li><a href="module.php?mod=tree&amp;mod_action=treeview&amp;ged=' . WT_GEDURL . '&amp;rootid=' . $pid . '">' . I18N::translate('Interactive tree') . '</a></li>';
+ $html .= '<li><a href="module.php?mod=tree&amp;mod_action=treeview&amp;ged=' . $person->getTree()->getNameUrl() . '&amp;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&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;pid=' . $controller->getSignificantIndividual()->getXref(),
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;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&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;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&amp;mod_action=index&amp;ged=' . WT_GEDURL, 'menu-clippings');
+ $menu = new Menu($this->getTitle(), 'module.php?mod=clippings&amp;mod_action=index&amp;ged=' . $WT_TREE->getNameUrl(), 'menu-clippings');
if (isset($controller->record)) {
- $submenu = new Menu($this->getTitle(), 'module.php?mod=clippings&amp;mod_action=index&amp;ged=' . WT_GEDURL, 'menu-clippingscart');
+ $submenu = new Menu($this->getTitle(), 'module.php?mod=clippings&amp;mod_action=index&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;pid=' . $controller->getSignificantIndividual()->getXref(),
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;famid=' . $controller->getSignificantFamily()->getXref(),
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;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 . '&amp;action=deletefav&amp;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&amp;news_id=' . $news->news_id . '&amp;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&amp;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&amp;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&amp;surname_sublist=yes&amp;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&amp;surname_sublist=yes&amp;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 . "&amp;surname=" . rawurlencode($surname['name']) . '">' . $surname['name'] . '</a>';
+ $content .= '<a href="' . "indilist.php?ged=" . $WT_TREE->getNameUrl() . "&amp;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(), '&amp;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 . "&amp;mod=googlemap&amp;mod_action=pedigree_map&amp;rootid=" . $person->getXref() . "&amp;PEDIGREE_GENERATIONS={$PEDIGREE_GENERATIONS}";
+ $js .= "<a href='module.php?ged=" . $person->getTree()->getNameUrl() . "&amp;mod=googlemap&amp;mod_action=pedigree_map&amp;rootid=" . $person->getXref() . "&amp;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&amp;surname_sublist=yes&amp;ged='.WT_GEDURL . '">#totalSurnames#</a></td>
+ <td class="facts_value" align="right"><a href="indilist.php?show_all=yes&amp;surname_sublist=yes&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;pid=' . $controller->getSignificantIndividual()->getXref(),
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;pid=' . $controller->getSignificantIndividual()->getXref(),
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;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&amp;linktoid=<?php echo $controller->record->getXref(); ?>&amp;ged=<?php echo WT_GEDURL; ?>', '_blank', edit_window_specs); return false;">
+ <a href="#" onclick="window.open('addmedia.php?action=showmediaform&amp;linktoid=<?php echo $controller->record->getXref(); ?>&amp;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(); ?>&amp;ged=<?php echo WT_GEDURL; ?>&amp;linkto=person', '_blank', find_window_specs); return false;">
+ <a href="#" onclick="window.open('inverselink.php?linktoid=<?php echo $controller->record->getXref(); ?>&amp;ged=<?php echo $WT_TREE->getNameUrl(); ?>&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml',
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;pid=' . $controller->getSignificantIndividual()->getXref(),
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;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 . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;pid=' . $controller->getSignificantIndividual()->getXref(),
+ 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&amp;action=setup&amp;report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&amp;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() . '&amp;mod_action=admin_edit&amp;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() . '&amp;mod_action=admin_edit&amp;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 . '&amp;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 . '&amp;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 . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('My pedigree') . '</a></td>';
+ $content .= '<td><a href="individual.php?pid=' . $gedcomid . '&amp;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 . '&amp;ged=' . WT_GEDURL . '"><i class="icon-pedigree"></i><br>' . I18N::translate('Default chart') . '</a></td>';
- $content .= '<td><a href="individual.php?pid=' . $indi_xref . '&amp;ged=' . WT_GEDURL . '"><i class="icon-indis"></i><br>' . I18N::translate('Default individual') . '</a></td>';
+ $content .= '<td><a href="pedigree.php?rootid=' . $indi_xref . '&amp;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 . '&amp;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 . '&amp;pid2=' . $individual->getXref() . '&amp;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 . '&amp;pid2=' . $individual->getXref() . '&amp;ged=' . $this->tree_url, 'menu-chart-relationship');
} else {
return new Menu(I18N::translate('Relationships'), 'relationship.php?pid1=' . $individual->getXref() . '&amp;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 . '&amp;' . $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 . '&amp;' . $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 . '&amp;rootid=' . WT_USER_GEDCOM_ID . "&amp;show_full={$showFull}&amp;talloffset={$showLayout}",
+ 'pedigree.php?' . $this->tree_url . '&amp;rootid=' . $gedcomid . '&amp;show_full=' . $showFull . '&amp;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 . '&amp;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');