Overview

Namespaces

  • None
  • PHP

Classes

  • Breadcrumb
  • Breadcrumbs
  • CacheFile
  • Comment
  • CommentArray
  • CommentFilter
  • CommentForm
  • CommentList
  • Config
  • Database
  • DatabaseQuery
  • DatabaseQuerySelect
  • DatabaseQuerySelectFulltext
  • DatabaseStopwords
  • Debug
  • Field
  • Fieldgroup
  • Fieldgroups
  • FieldgroupsArray
  • Fields
  • FieldsArray
  • Fieldtype
  • FieldtypeMulti
  • Fieldtypes
  • FileLog
  • FilenameArray
  • Fuel
  • HookEvent
  • ImageSizer
  • Inputfield
  • InputfieldsArray
  • InputfieldWrapper
  • Language
  • LanguageParser
  • Languages
  • LanguagesPageFieldValue
  • LanguageSupportInstall
  • LanguageTranslator
  • Markdown_Parser
  • MarkdownExtra_Parser
  • ModuleJS
  • ModulePlaceholder
  • Modules
  • Notice
  • NoticeError
  • NoticeMessage
  • Notices
  • NullPage
  • Page
  • PageArray
  • Pagefile
  • Pagefiles
  • PagefilesManager
  • PageFinder
  • Pageimage
  • Pageimages
  • PagerNav
  • PagerNavItem
  • Pages
  • PagesAccess
  • PagesSortfields
  • PagesType
  • Paths
  • Permission
  • Permissions
  • Process
  • ProcessController
  • ProcessWire
  • Role
  • Roles
  • Sanitizer
  • Selector
  • SelectorBitwiseAnd
  • SelectorContains
  • SelectorContainsLike
  • SelectorContainsWords
  • SelectorEnds
  • SelectorEqual
  • SelectorGreaterThan
  • SelectorGreaterThanEqual
  • SelectorLessThan
  • SelectorLessThanEqual
  • SelectorNotEqual
  • Selectors
  • SelectorStarts
  • Session
  • SessionCSRF
  • SmartyPants_Parser
  • SmartyPantsTypographer_Parser
  • SystemUpdate1
  • Template
  • TemplateFile
  • Templates
  • TemplatesArray
  • Textformatter
  • Textile
  • User
  • Users
  • Wire
  • WireArray
  • WireData
  • WireInput
  • WireInputData
  • WireSaveableItems
  • WireSaveableItemsLookup
  • WireUpload

Interfaces

  • CommentFormInterface
  • CommentListInterface
  • ConfigurableModule
  • FieldtypeLanguageInterface
  • FieldtypePageTitleCompatible
  • HasLookupItems
  • HasRoles
  • InputfieldHasArrayValue
  • Module
  • Saveable
  • TrackChanges

Exceptions

  • ProcessController404Exception
  • ProcessControllerPermissionException
  • Wire404Exception
  • WireDatabaseException
  • WireException
  • WirePermissionException

Functions

  • __
  • _n
  • _x
  • fuel
  • identify_modifier_markdown
  • Markdown
  • mdwp_add_p
  • mdwp_hide_tags
  • mdwp_show_tags
  • mdwp_strip_p
  • ProcessWireClassLoader
  • ProcessWireHostSiteConfig
  • ProcessWireShutdown
  • removeNewlines
  • SmartDashes
  • SmartEllipsis
  • SmartQuotes
  • smarty_modifier_markdown
  • smarty_modifier_smartypants
  • SmartyPants
  • tabIndent
  • unregisterGLOBALS
  • wire
  • wireDecodeJSON
  • wireEncodeJSON
  • wireMkdir
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
 1: <?php
 2: 
 3: class Users extends PagesType {
 4: 
 5:     protected $currentUser = null; 
 6:     protected $guestUser = null; 
 7: 
 8:     public function setCurrentUser(User $user) {
 9:         if(!$user->roles->has("id=" . $this->fuel('config')->guestUserRolePageID)) {
10:             $guestRole = $this->fuel('roles')->getGuestRole();
11:             $user->roles->add($guestRole);
12:         }
13:         $this->currentUser = $user; 
14:         Wire::setFuel('user', $user); 
15:     }
16: 
17:     /**
18:      * Ensure that every user loaded has at least the 'guest' role
19:      *
20:      */
21:     protected function loaded(Page $page) {
22:         static $guestID  = null;
23:         if(is_null($guestID)) $guestID = $this->fuel('config')->guestUserRolePageID; 
24:         if(!$page->roles->has("id=$guestID")) $page->roles->add($this->fuel('roles')->getGuestRole());
25:     }
26: 
27:     /**
28:      * Returns the current user object
29:      *
30:      * @return User
31:      *
32:      */
33:     public function getCurrentUser() {
34:         if($this->currentUser) return $this->currentUser; 
35:         return $this->getGuestUser();
36:     }
37: 
38:     /**
39:      * Get the 'guest' user account
40:      *
41:      * @return User
42:      *
43:      */
44:     public function getGuestUser() {
45:         if($this->guestUser) return $this->guestUser; 
46:         $this->guestUser = $this->get($this->config->guestUserPageID); 
47:         if(defined("PROCESSWIRE_UPGRADE") && !$this->guestUser || !$this->guestUser->id) $this->guestUser = new User(); // needed during upgrade
48:         return $this->guestUser; 
49:     }
50: 
51: }
52: 
ProcessWire API documentation generated by ApiGen 2.6.0