From b91ce4e162976f6e4d1c308524ea1bf460430bc8 Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Thu, 14 Aug 2014 10:35:02 +0100 Subject: Import classes, per PSR autoloading standards --- library/WT/Controller/Family.php | 4 +++- library/WT/Controller/Individual.php | 9 ++++++--- library/WT/Controller/Media.php | 4 +++- library/WT/Controller/Note.php | 4 +++- library/WT/Controller/Repository.php | 4 +++- library/WT/Controller/Search.php | 4 +++- library/WT/Controller/Source.php | 4 +++- library/WT/Filter.php | 3 ++- library/WT/GedcomRecord.php | 19 +++++++++++-------- library/WT/I18N.php | 6 ++++-- library/WT/Mail.php | 15 +++++++++------ library/WT/Media.php | 16 +++++++++------- library/WT/MenuBar.php | 6 ++++-- library/WT/Module.php | 6 ++++-- library/WT/Report/PDF.php | 3 ++- library/WT/Site.php | 4 +++- library/WT/Stats.php | 36 +++++++++++++++++++----------------- library/WT/Tree.php | 12 ++++++++---- 18 files changed, 99 insertions(+), 60 deletions(-) (limited to 'library/WT') diff --git a/library/WT/Controller/Family.php b/library/WT/Controller/Family.php index d2eb2c0a02..b36b7b59cf 100644 --- a/library/WT/Controller/Family.php +++ b/library/WT/Controller/Family.php @@ -21,6 +21,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Auth; + require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; @@ -107,7 +109,7 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord { } // edit raw - if (\WT\Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { + if (Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM'), '#', 'menu-fam-editraw'); $submenu->addOnclick("return edit_raw('" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); diff --git a/library/WT/Controller/Individual.php b/library/WT/Controller/Individual.php index 5cc5069698..b8ae9fbe87 100644 --- a/library/WT/Controller/Individual.php +++ b/library/WT/Controller/Individual.php @@ -21,6 +21,9 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Auth; +use WT\User; + require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; @@ -140,8 +143,8 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord { $dummy->setPrimaryName(0); echo '
', $dummy->getFullName(); if ($this->name_count == 1) { - if (\WT\Auth::isAdmin()) { - $user = \WT\User::findByGenealogyRecord($WT_TREE, $this->record); + if (Auth::isAdmin()) { + $user = User::findByGenealogyRecord($WT_TREE, $this->record); if ($user) { echo ' - ' . WT_Filter::escapeHtml($user->getUserName()) . ''; } @@ -301,7 +304,7 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord { } // edit raw - if (\WT\Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { + if (Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM'), '#', 'menu-indi-editraw'); $submenu->addOnclick("return edit_raw('" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); diff --git a/library/WT/Controller/Media.php b/library/WT/Controller/Media.php index 1450ebffa0..dcceac8d08 100644 --- a/library/WT/Controller/Media.php +++ b/library/WT/Controller/Media.php @@ -21,6 +21,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Auth; + require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; @@ -81,7 +83,7 @@ class WT_Controller_Media extends WT_Controller_GedcomRecord { } // edit raw - if (\WT\Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { + if (Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM'), '#', 'menu-obje-editraw'); $submenu->addOnclick("return edit_raw('" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); diff --git a/library/WT/Controller/Note.php b/library/WT/Controller/Note.php index 32a0e23184..c125a1567d 100644 --- a/library/WT/Controller/Note.php +++ b/library/WT/Controller/Note.php @@ -21,6 +21,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Auth; + require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; @@ -53,7 +55,7 @@ class WT_Controller_Note extends WT_Controller_GedcomRecord { // edit raw /* Does not currently work - NOTE records do not contain nice level 1 facts - if (\WT\Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { + if (Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM'), '#', 'menu-note-editraw'); $submenu->addOnclick("return edit_raw('" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); diff --git a/library/WT/Controller/Repository.php b/library/WT/Controller/Repository.php index 61f6f8941d..3a48cdf039 100644 --- a/library/WT/Controller/Repository.php +++ b/library/WT/Controller/Repository.php @@ -21,6 +21,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Auth; + require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; @@ -66,7 +68,7 @@ class WT_Controller_Repository extends WT_Controller_GedcomRecord { } // edit raw - if (\WT\Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { + if (Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM'), '#', 'menu-repo-editraw'); $submenu->addOnclick("return edit_raw('" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); diff --git a/library/WT/Controller/Search.php b/library/WT/Controller/Search.php index b9bee174cf..cf212c5ee2 100644 --- a/library/WT/Controller/Search.php +++ b/library/WT/Controller/Search.php @@ -21,6 +21,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Log; + class WT_Controller_Search extends WT_Controller_Page { public $action; // TODO: decide if these variables are public/private/protected (or unused) @@ -381,7 +383,7 @@ class WT_Controller_Search extends WT_Controller_Page { return; } - \WT\Log::addEditLog("Search And Replace old:".$oldquery." new:".$this->replace); + Log::addEditLog("Search And Replace old:".$oldquery." new:".$this->replace); $manual_save = true; // Include edit functions. require_once WT_ROOT.'includes/functions/functions_edit.php'; diff --git a/library/WT/Controller/Source.php b/library/WT/Controller/Source.php index 5b8e3d6d04..19399bb950 100644 --- a/library/WT/Controller/Source.php +++ b/library/WT/Controller/Source.php @@ -21,6 +21,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Auth; + require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; @@ -66,7 +68,7 @@ class WT_Controller_Source extends WT_Controller_GedcomRecord { } // edit raw - if (\WT\Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { + if (Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM'), '#', 'menu-sour-editraw'); $submenu->addOnclick("return edit_raw('" . $this->record->getXref() . "');"); $menu->addSubmenu($submenu); diff --git a/library/WT/Filter.php b/library/WT/Filter.php index b93b1e961d..e039b3ccfe 100644 --- a/library/WT/Filter.php +++ b/library/WT/Filter.php @@ -19,6 +19,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA use Michelf\MarkdownExtra; +use WT\Log; class WT_Filter { // REGEX to match a URL @@ -291,7 +292,7 @@ class WT_Filter { public static function checkCsrf() { if (WT_Filter::post('csrf') !== WT_Filter::getCsrfToken()) { // Oops. Something is not quite right - \WT\Log::addAuthenticationLog('CSRF mismatch - session expired or malicious attack'); + Log::addAuthenticationLog('CSRF mismatch - session expired or malicious attack'); WT_FlashMessages::addMessage(WT_I18N::translate('This form has expired. Try again.')); return false; } diff --git a/library/WT/GedcomRecord.php b/library/WT/GedcomRecord.php index db41b4f89d..73250acdcd 100755 --- a/library/WT/GedcomRecord.php +++ b/library/WT/GedcomRecord.php @@ -21,6 +21,9 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Auth; +use WT\Log; + class WT_GedcomRecord { const RECORD_TYPE = 'UNKNOWN'; const SQL_FETCH = "SELECT o_gedcom FROM `##other` WHERE o_id=? AND o_file=?"; @@ -918,7 +921,7 @@ class WT_GedcomRecord { $this->pending = $new_gedcom; - if (\WT\Auth::user()->getSetting('auto_accept')) { + if (Auth::user()->getSetting('auto_accept')) { accept_all_changes($this->xref, $this->gedcom_id); $this->gedcom = $new_gedcom; $this->pending = null; @@ -961,14 +964,14 @@ class WT_GedcomRecord { )); // Accept this pending change - if (\WT\Auth::user()->getSetting('auto_accept')) { + if (Auth::user()->getSetting('auto_accept')) { accept_all_changes($xref, $gedcom_id); } // Clear this record from the cache self::$pending_record_cache = null; - \WT\Log::addEditLog('Create: ' . $type . ' ' . $xref); + Log::addEditLog('Create: ' . $type . ' ' . $xref); // Return the newly created record return WT_GedcomRecord::getInstance($xref); @@ -1004,7 +1007,7 @@ class WT_GedcomRecord { $this->pending = $gedcom; // Accept this pending change - if (\WT\Auth::user()->getSetting('auto_accept')) { + if (Auth::user()->getSetting('auto_accept')) { accept_all_changes($this->xref, $this->gedcom_id); $this->gedcom = $gedcom; $this->pending = null; @@ -1012,7 +1015,7 @@ class WT_GedcomRecord { $this->parseFacts(); - \WT\Log::addEditLog('Update: ' . static::RECORD_TYPE . ' ' . $this->xref); + Log::addEditLog('Update: ' . static::RECORD_TYPE . ' ' . $this->xref); } public function deleteRecord() { @@ -1023,11 +1026,11 @@ class WT_GedcomRecord { $this->gedcom_id, $this->xref, $this->getGedcom(), - \WT\Auth::id(), + Auth::id(), )); // Accept this pending change - if (\WT\Auth::user()->getSetting('auto_accept')) { + if (Auth::user()->getSetting('auto_accept')) { accept_all_changes($this->xref, $this->gedcom_id); } @@ -1035,7 +1038,7 @@ class WT_GedcomRecord { self::$gedcom_record_cache = null; self::$pending_record_cache = null; - \WT\Log::addEditLog('Delete: ' . static::RECORD_TYPE . ' ' . $this->xref); + Log::addEditLog('Delete: ' . static::RECORD_TYPE . ' ' . $this->xref); } // Remove all links from this record to $xref diff --git a/library/WT/I18N.php b/library/WT/I18N.php index 2b46bc19be..0c0cd9c3b8 100644 --- a/library/WT/I18N.php +++ b/library/WT/I18N.php @@ -25,6 +25,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Auth; + class WT_I18N { // Lookup table to convert unicode code-points into scripts. // See https://en.wikipedia.org/wiki/Unicode_block @@ -87,8 +89,8 @@ class WT_I18N { $locale = WT_Filter::get('lang'); if ($locale && array_key_exists($locale, $installed_languages)) { // Requested in the URL? - if (\WT\Auth::id()) { - \WT\Auth::user()->setSetting('language', $locale); + if (Auth::id()) { + Auth::user()->setSetting('language', $locale); } } elseif (array_key_exists($WT_SESSION->locale, $installed_languages)) { // Rembered from a previous visit? diff --git a/library/WT/Mail.php b/library/WT/Mail.php index 217d362fd2..22e70510b9 100644 --- a/library/WT/Mail.php +++ b/library/WT/Mail.php @@ -18,6 +18,9 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Log; +use WT\User; + class WT_Mail { const EOL = "
\r\n"; // End-of-line that works for both TEXT and HTML messages @@ -46,7 +49,7 @@ class WT_Mail { ->setReplyTo ($replyto_email, $replyto_name) ->send (WT_Mail::transport()); } catch (Exception $ex) { - \WT\Log::addErrorLog('Mail: ' . $ex->getMessage()); + Log::addErrorLog('Mail: ' . $ex->getMessage()); return false; } return true; @@ -55,14 +58,14 @@ class WT_Mail { /** * Send an automated system message (such as a password reminder) from a tree to a user. * - * @param WT_Tree $tree - * @param \WT\User $user - * @param string $subject - * @param string $message + * @param WT_Tree $tree + * @param User $user + * @param string $subject + * @param string $message * * @return bool */ - public static function system_message(WT_Tree $tree, \WT\User $user, $subject, $message) { + public static function system_message(WT_Tree $tree, User $user, $subject, $message) { return self::send( $tree, $user->getEmail(), $user->getRealName(), diff --git a/library/WT/Media.php b/library/WT/Media.php index 8662628a5b..9b479c6c38 100644 --- a/library/WT/Media.php +++ b/library/WT/Media.php @@ -21,6 +21,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Log; + class WT_Media extends WT_GedcomRecord { const RECORD_TYPE = 'OBJE'; const SQL_FETCH = "SELECT m_gedcom FROM `##media` WHERE m_id=? AND m_file=?"; @@ -121,13 +123,13 @@ class WT_Media extends WT_GedcomRecord { } // Does the folder exist for this thumbnail? if (!is_dir(dirname($file)) && !@mkdir(dirname($file), WT_PERM_EXE, true)) { - \WT\Log::addMediaLog('The folder ' . dirname($file) . ' could not be created for ' . $this->getXref()); + Log::addMediaLog('The folder ' . dirname($file) . ' could not be created for ' . $this->getXref()); return $file; } // Is there a corresponding main image? $main_file = WT_DATA_DIR . $MEDIA_DIRECTORY . $this->file; if (!file_exists($main_file)) { - \WT\Log::addMediaLog('The file ' . $main_file . ' does not exist for ' . $this->getXref()); + Log::addMediaLog('The file ' . $main_file . ' does not exist for ' . $this->getXref()); return $file; } // Try to create a thumbnail automatically @@ -135,7 +137,7 @@ class WT_Media extends WT_GedcomRecord { if ($imgsize[0] && $imgsize[1]) { // Image small enough to be its own thumbnail? if ($imgsize[0] < $THUMBNAIL_WIDTH) { - \WT\Log::addMediaLog('Thumbnail created for ' . $main_file . ' (copy of main image)'); + Log::addMediaLog('Thumbnail created for ' . $main_file . ' (copy of main image)'); @copy($main_file, $file); } else { if (hasMemoryForImage($main_file)) { @@ -162,12 +164,12 @@ class WT_Media extends WT_GedcomRecord { } @imagedestroy($main_image); @imagedestroy($thumb_image); - \WT\Log::addMediaLog('Thumbnail created for ' . $main_file); + Log::addMediaLog('Thumbnail created for ' . $main_file); } else { - \WT\Log::addMediaLog('Failed to create thumbnail for ' . $main_file); + Log::addMediaLog('Failed to create thumbnail for ' . $main_file); } } else { - \WT\Log::addMediaLog('Not enough memory to create thumbnail for ' . $main_file); + Log::addMediaLog('Not enough memory to create thumbnail for ' . $main_file); } } } @@ -331,7 +333,7 @@ class WT_Media extends WT_GedcomRecord { if ($this->fileExists($which)) { // alert the admin if we cannot determine the mime type of an existing file // as the media firewall will be unable to serve this file properly - \WT\Log::addMediaLog('Media Firewall error: >Unknown Mimetype< for file >' . $this->file . '<'); + Log::addMediaLog('Media Firewall error: >Unknown Mimetype< for file >' . $this->file . '<'); } } else { $imgsize['mime']=$mime[$imgsize['ext']]; diff --git a/library/WT/MenuBar.php b/library/WT/MenuBar.php index 8296721b37..08029686b5 100644 --- a/library/WT/MenuBar.php +++ b/library/WT/MenuBar.php @@ -21,6 +21,8 @@ // along with this program; if not, write to the Free Software // // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Auth; + class WT_MenuBar { public static function getGedcomMenu() { $menu = new WT_Menu(WT_I18N::translate('Home page'), 'index.php?ctype=gedcom&ged='.WT_GEDURL, 'menu-tree'); @@ -44,7 +46,7 @@ class WT_MenuBar { $showFull = ($PEDIGREE_FULL_DETAILS) ? 1 : 0; $showLayout = ($PEDIGREE_LAYOUT) ? 1 : 0; - if (!\WT\Auth::id()) { + if (!Auth::id()) { return null; } @@ -55,7 +57,7 @@ class WT_MenuBar { $submenu = new WT_Menu(WT_I18N::translate('My page'), 'index.php?ctype=user&ged='.WT_GEDURL, 'menu-mypage'); $menu->addSubmenu($submenu); //-- editaccount submenu - if (\WT\Auth::user()->getSetting('editaccount')) { + if (Auth::user()->getSetting('editaccount')) { $submenu = new WT_Menu(WT_I18N::translate('My account'), 'edituser.php', 'menu-myaccount'); $menu->addSubmenu($submenu); } diff --git a/library/WT/Module.php b/library/WT/Module.php index a9cdaff752..255f6088f7 100644 --- a/library/WT/Module.php +++ b/library/WT/Module.php @@ -18,6 +18,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Log; + abstract class WT_Module { private $_title = null; @@ -117,7 +119,7 @@ abstract class WT_Module { $modules[$module_name]=new $class(); } else { // Module has been deleted from disk? Disable it. - \WT\Log::addConfigurationLog("Module {$module_name} has been deleted from disk - disabling it"); + Log::addConfigurationLog("Module {$module_name} has been deleted from disk - disabling it"); WT_DB::prepare( "UPDATE `##module` SET status='disabled' WHERE module_name=?" )->execute(array($module_name)); @@ -147,7 +149,7 @@ abstract class WT_Module { $array[$module_name]=new $class(); } else { // Module has been deleted from disk? Disable it. - \WT\Log::addConfigurationLog("Module {$module_name} has been deleted from disk - disabling it"); + Log::addConfigurationLog("Module {$module_name} has been deleted from disk - disabling it"); WT_DB::prepare( "UPDATE `##module` SET status='disabled' WHERE module_name=?" )->execute(array($module_name)); diff --git a/library/WT/Report/PDF.php b/library/WT/Report/PDF.php index 2c48befd6c..8ed832a9f7 100644 --- a/library/WT/Report/PDF.php +++ b/library/WT/Report/PDF.php @@ -22,6 +22,7 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Auth; /** * Main WT Report Class for PDF @@ -86,7 +87,7 @@ class WT_Report_PDF extends WT_Report_Base { // Set the document information // Only admin should see the version number $appversion = WT_WEBTREES; - if (\WT\Auth::isAdmin()) { + if (Auth::isAdmin()) { $appversion .= " ".WT_VERSION; } $this->pdf->SetCreator($appversion . " (" . parent::wt_url . ")"); diff --git a/library/WT/Site.php b/library/WT/Site.php index 4c9cb76259..a1731da09a 100644 --- a/library/WT/Site.php +++ b/library/WT/Site.php @@ -18,6 +18,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Log; + class WT_Site { static $setting=null; @@ -42,7 +44,7 @@ class WT_Site { // If parameter two is specified, then SET the setting if (self::preference($setting_name)!=$setting_value) { // Audit log of changes - \WT\Log::addConfigurationLog('Site setting "' . $setting_name . '" set to "' . $setting_value . '"'); + Log::addConfigurationLog('Site setting "' . $setting_name . '" set to "' . $setting_value . '"'); } WT_DB::prepare( "REPLACE INTO `##site_setting` (setting_name, setting_value) VALUES (?, LEFT(?, 255))" diff --git a/library/WT/Stats.php b/library/WT/Stats.php index 0611e94c66..968740d568 100644 --- a/library/WT/Stats.php +++ b/library/WT/Stats.php @@ -26,6 +26,8 @@ require_once WT_ROOT.'includes/functions/functions_print_lists.php'; use Rhumsaa\Uuid\Uuid; +use WT\Auth; +use WT\User; class WT_Stats { private $_gedcom; @@ -657,19 +659,19 @@ class WT_Stats { static function totalUsers($params=null) { if (!empty($params[0])) { - $total = count(\WT\User::all()) + (int)$params[0]; + $total = count(User::all()) + (int)$params[0]; } else { - $total = count(\WT\User::all()); + $total = count(User::all()); } return WT_I18N::number($total); } static function totalAdmins() { - return WT_I18N::number(count(\WT\User::allAdmins())); + return WT_I18N::number(count(User::allAdmins())); } static function totalNonAdmins() { - return WT_I18N::number(count(\WT\User::all()) - count(\WT\User::allAdmins())); + return WT_I18N::number(count(User::all()) - count(User::allAdmins())); } function _totalMediaType($type='all') { @@ -3401,8 +3403,8 @@ class WT_Stats { // List active users $NumAnonymous = 0; $loggedusers = array (); - foreach (\WT\User::allLoggedIn() as $user) { - if (\WT\Auth::isAdmin() || $user->getSetting('visibleonline')) { + foreach (User::allLoggedIn() as $user) { + if (Auth::isAdmin() || $user->getSetting('visibleonline')) { $loggedusers[] = $user; } else { $NumAnonymous++; @@ -3430,7 +3432,7 @@ class WT_Stats { $content .= ': '; } } - if (\WT\Auth::check()) { + if (Auth::check()) { foreach ($loggedusers as $user) { if ($type == 'list') { $content .= "
  • " . WT_Filter::escapeHtml($user->getRealName()) . ' - ' . WT_Filter::escapeHtml($user->getUserName()); @@ -3458,8 +3460,8 @@ class WT_Stats { static function _usersLoggedInTotal($type='all') { $anon = 0; $visible = 0; - foreach (\WT\User::allLoggedIn() as $user) { - if (\WT\Auth::isAdmin() || $user->getSetting('visibleonline')) { + foreach (User::allLoggedIn() as $user) { + if (Auth::isAdmin() || $user->getSetting('visibleonline')) { $visible++; } else { $anon++; @@ -3482,13 +3484,13 @@ class WT_Stats { static function usersLoggedInTotalVisible() { return self::_usersLoggedInTotal('visible'); } static function userID() { - return \WT\Auth::id(); + return Auth::id(); } static function userName($params = null) { - if (\WT\Auth::check()) { - return \WT\Auth::user()->getUserName(); + if (Auth::check()) { + return Auth::user()->getUserName(); } elseif (is_array($params) && isset($params[0]) && $params[0] != '') { # if #username:visitor# was specified, then "visitor" will be returned when the user is not logged in return $params[0]; @@ -3497,7 +3499,7 @@ class WT_Stats { } } static function userFullName() { - return \WT\Auth::check() ? \WT\Auth::user()->getRealName() : ''; + return Auth::check() ? Auth::user()->getRealName() : ''; } static function _getLatestUserData($type = 'userid', $params = null) { @@ -3505,9 +3507,9 @@ class WT_Stats { static $user_id = null; if ($user_id === null) { - $user = \WT\User::findLatestToRegister(); + $user = User::findLatestToRegister(); } else { - $user = \WT\User::find($user_id); + $user = User::find($user_id); } switch($type) { @@ -3602,8 +3604,8 @@ class WT_Stats { $page_parameter='gedcom:'.get_id_from_gedcom($page_parameter ? $page_parameter : WT_GEDCOM); } elseif ($page_name=='index.php') { // index.php?ctype=user - $user = \WT\User::findByIdentifier($page_parameter); - $page_parameter='user:'.($user ? $user->getUserId() : \WT\Auth::id()); + $user = User::findByIdentifier($page_parameter); + $page_parameter='user:'.($user ? $user->getUserId() : Auth::id()); } else { // indi/fam/sour/etc. } diff --git a/library/WT/Tree.php b/library/WT/Tree.php index b89b7d0945..2c2b253beb 100644 --- a/library/WT/Tree.php +++ b/library/WT/Tree.php @@ -18,6 +18,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +use WT\Auth; +use WT\Log; +use WT\User; + class WT_Tree { // Tree attributes public $tree_id =null; // The "gedcom ID" number @@ -73,7 +77,7 @@ class WT_Tree { if ($this->preference($setting_name)!=$setting_value) { $this->preference[$setting_name]=$setting_value; // Audit log of changes - \WT\Log::addConfigurationLog('Gedcom setting "' . $setting_name . '" set to "' . $setting_value . '"'); + Log::addConfigurationLog('Gedcom setting "' . $setting_name . '" set to "' . $setting_value . '"'); } WT_DB::prepare( "REPLACE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES (?, ?, LEFT(?, 255))" @@ -103,7 +107,7 @@ class WT_Tree { // If parameter two is specified, then SET the setting. if ($this->preference($setting_name)!=$setting_value) { // Audit log of changes - \WT\Log::addConfigurationLog('Gedcom setting "'.$setting_name.'" set to "'.$setting_value.'"'); + Log::addConfigurationLog('Gedcom setting "'.$setting_name.'" set to "'.$setting_value.'"'); } WT_DB::prepare( "REPLACE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, LEFT(?, 255))" @@ -113,8 +117,8 @@ class WT_Tree { } // Can a user accept changes for this tree? - public function canAcceptChanges(\WT\User $user) { - return \WT\Auth::isModerator($this, $user); + public function canAcceptChanges(User $user) { + return Auth::isModerator($this, $user); } // Fetch all the trees that we have permission to access. -- cgit v1.3