Admidio API
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Packages

  • com
    • tecnick
      • tcpdf
  • None
  • PHPMailer
    • easypeasyics
  • PHPWavUtils
  • Securimage
    • classes

Classes

  • AutoLogin
  • Component
  • ComponentUpdate
  • ConditionParser
  • Database
  • DateTimeExtended
  • Email
  • Folder
  • FormValidation
  • FunctionClass
  • Htaccess
  • HtmlDiv
  • HtmlElement
  • HtmlForm
  • HtmlFormBasic
  • HtmlFormInstallation
  • HtmlList
  • HtmlNavbar
  • HtmlPage
  • HtmlTable
  • HtmlTableBasic
  • Image
  • Inventory
  • InventoryFields
  • Language
  • LanguageData
  • ListConfiguration
  • Menu
  • Message
  • ModuleAnnouncements
  • ModuleDates
  • ModuleLists
  • ModuleMenu
  • ModuleMessages
  • Modules
  • ModuleWeblinks
  • MyFiles
  • Navigation
  • ntlm_sasl_client_class
  • Organization
  • Participants
  • PasswordHash
  • PasswordHashing
  • ProfileFields
  • RoleDependency
  • RolesRights
  • RSSfeed
  • Session
  • SystemMail
  • TableAccess
  • TableAnnouncement
  • TableCategory
  • TableDate
  • TableFile
  • TableFolder
  • TableGuestbook
  • TableGuestbookComment
  • TableInventory
  • TableInventoryField
  • TableLists
  • TableMembers
  • TableMessage
  • TablePhotos
  • TableRoles
  • TableRooms
  • TableText
  • TableUserField
  • TableUsers
  • TableWeblink
  • UploadHandlerDownload
  • UploadHandlerPhoto
  • User
  • UserRegistration

Exceptions

  • AdmException
  • WavFileException
  • WavFormatException

Functions

  • admFuncAutoload
  • admFuncGeneratePagination
  • admFuncGetBytesFromSize
  • admFuncGetDirectoryEntries
  • admFuncMaxUploadSize
  • admFuncProcessableImageSize
  • admFuncShowCreateChangeInfoById
  • admFuncShowCreateChangeInfoByName
  • admFuncVariableIsValid
  • admReadTemplateFile
  • admStrIsValidFileName
  • admStrStripTagsSpecial
  • admStrToLower
  • admStrToUpper
  • bzip2Version
  • checkDatabaseVersion
  • checkPhpVersion
  • EmailAttachment
  • FileSizeNiceDisplay
  • FormattedTimeRemaining
  • FunctionIsDisabled
  • getFormerRolesFromDatabase
  • getFutureRolesFromDatabase
  • getmicrotime
  • getRoleMemberships
  • getRolesFromDatabase
  • gzipVersion
  • hasRole
  • hl_attrval
  • hl_bal
  • hl_cmtcd
  • hl_ent
  • hl_prot
  • hl_regex
  • hl_spec
  • hl_tag
  • hl_tag2
  • hl_tidy
  • hl_version
  • htmLawed
  • HTMLFilter
  • isGroupLeader
  • isMember
  • kses
  • kses_hook
  • MySQLdumpVersion
  • OutputInformation
  • SafeExec
  • showNotice
  • strAddSlashesDeep
  • strNextLetter
  • strStripSlashesDeep
  • strStripTags
  • strValidCharacters
  • tln_body2div
  • tln_casenormalize
  • tln_deent
  • tln_defang
  • tln_findnxreg
  • tln_findnxstr
  • tln_fixatts
  • tln_fixstyle
  • tln_fixurl
  • tln_getnxtag
  • tln_sanitize
  • tln_skipspace
  • tln_tagprint
  • tln_unspace
  • version_compare_replacement
  • version_compare_replacement_sub

Class User

TableAccess
Extended by User

Direct known subclasses

TableUsers, UserRegistration

Copyright: 2004-2016 The Admidio Team
License: GNU General Public License v2.0 only **********************************************************************************************
Class:

User Diese Klasse dient dazu ein Userobjekt zu erstellen. Ein User kann ueber diese Klasse in der Datenbank verwaltet werden

Beside the methods of the parent class there are the following additional methods:

deleteUserFieldData() - delete all user data of profile fields; user record will not be deleted getListViewRights() - Liefert ein Array mit allen Rollen und der Berechtigung, ob der User die Liste einsehen darf - aehnlich getProperty, allerdings suche ueber usf_id getVCard() - Es wird eine vCard des Users als String zurueckgegeben setRoleMembership($roleId, $startDate = DATE_NOW, $endDate = '9999-12-31', $leader = '') - set a role membership for the current user if memberships to this user and role exists within the period than merge them to one new membership viewProfile - Ueberprueft ob der User das Profil eines uebrgebenen Users einsehen darf viewRole - Ueberprueft ob der User eine uebergebene Rolle(Liste) einsehen darf isAdministrator() - gibt true/false zurueck, falls der User Mitglied der Rolle "Webmaster" ist


Located at user.php

Methods summary

public
# __construct( Database & $database, ProfileFields $userFields = null, integer $userId = 0 )

Constructor that will create an object of a recordset of the users table. If the id is set than this recordset will be loaded.

Constructor that will create an object of a recordset of the users table. If the id is set than this recordset will be loaded.

Parameters

$database
Object of the class Database. This should be the default global object @b $gDb.
$userFields

An object of the ProfileFields class with the profile field structure of the current organization. This could be the default object @b $gProfileFields.

$userId

The id of the user who should be loaded. If id isn't set than an empty object with no specific user is created.

Overrides

TableAccess::__construct
public
# assignDefaultRoles( )

Assign the user to all roles that have set the flag @b rol_default_registration. These flag should be set if you want that every new user should get this role.

Assign the user to all roles that have set the flag @b rol_default_registration. These flag should be set if you want that every new user should get this role.

public boolean
# checkRolesRight( string $right = null )

The method reads all roles where this user has a valid membership and checks the rights of those roles. It stores all rights that the user get at last through one role in an array. In addition the method checks which roles lists the user could see in an separate array. Also an array with all roles where the user has the right to write an email will be stored. The method considered the role leader rights of each role if this is set and the current user is a leader in a role.

The method reads all roles where this user has a valid membership and checks the rights of those roles. It stores all rights that the user get at last through one role in an array. In addition the method checks which roles lists the user could see in an separate array. Also an array with all roles where the user has the right to write an email will be stored. The method considered the role leader rights of each role if this is set and the current user is a leader in a role.

Parameters

$right

The database column name of the right that should be checked. If this param is not set then only the arrays are filled.

Returns

boolean
Return true if a special right should be checked and the user has this right.
public true|string
# checkLogin( string $password, boolean $setAutoLogin = false, boolean $updateSessionCookies = true, boolean $updateHash = true, boolean $isAdministrator = false )

Check if a valid password is set for the user and return true if the correct password was set. Optional the current session could be updated to a valid login session.

Check if a valid password is set for the user and return true if the correct password was set. Optional the current session could be updated to a valid login session.

Parameters

$password
The password for the current user. This should not be encoded.
$setAutoLogin

If set to true then this login will be stored in AutoLogin table and the user doesn't need to login another time with this browser. To use this functionality @b $updateSessionCookies must be set to true.

$updateSessionCookies

The current session will be updated to a valid login. If set to false then the login is only valid for the current script.

$updateHash

If set to true the code will check if the current password hash uses the best hashing algorithm. If not the password will be rehashed with the new algorithm. If set to false the password will not be rehashed.

$isAdministrator
If set to true the code will check if the current password hash uses

Returns

true|string

Return true if login was successful and a string with the reason why the login failed. Possible reasons: SYS_LOGIN_MAX_INVALID_LOGIN SYS_LOGIN_NOT_ACTIVATED SYS_LOGIN_USER_NO_MEMBER_IN_ORGANISATION SYS_LOGIN_USER_NO_ADMINISTRATOR SYS_LOGIN_USERNAME_PASSWORD_INCORRECT

public
# clear( )

Additional to the parent method the user profile fields and all user rights and role memberships will be initialized

Additional to the parent method the user profile fields and all user rights and role memberships will be initialized

Overrides

TableAccess::clear
public boolean
# columnsValueChanged( )

returns true if a column of user table or profile fields has changed

returns true if a column of user table or profile fields has changed

Returns

boolean
public true|
# delete( )

Deletes the selected user of the table and all the many references in other tables. After that the class will be initialize.

Deletes the selected user of the table and all the many references in other tables. After that the class will be initialize.

Returns

true|
@b true if no error occurred

Overrides

TableAccess::delete
public
# deleteUserFieldData( )

delete all user data of profile fields; user record will not be deleted

delete all user data of profile fields; user record will not be deleted

private int[]
# getAllRolesWithRight( array $rightsList )

Parameters

$rightsList

Returns

int[]
public int[]
# getAllMailRoles( )

Creates an array with all roles where the user has the right to mail them

Creates an array with all roles where the user has the right to mail them

Returns

int[]
Array with role ids where user has the right to mail them
public int[]
# getAllVisibleRoles( )

Creates an array with all roles where the user has the right to view them

Creates an array with all roles where the user has the right to view them

Returns

int[]
Array with role ids where user has the right to view them
public integer
# getOrganization( )

Returns the id of the organization this user object has been assigned. This is in the default case the default organization of the config file.

Returns the id of the organization this user object has been assigned. This is in the default case the default organization of the config file.

Returns

integer
Returns the id of the organization this user object has been assigned
public int[]
# getRoleMemberships( )

Returns an array with all role ids where the user is a member.

Returns an array with all role ids where the user is a member.

Returns

int[]
Returns an array with all role ids where the user is a member.
public int[]
# getRoleMembershipsNoLeader( )

Returns an array with all role ids where the user is a member and not a leader of the role.

Returns an array with all role ids where the user is a member and not a leader of the role.

Returns

int[]

Returns an array with all role ids where the user is a member and not a leader of the role.

public mixed
# getValue( string $columnName, string $format = '' )

Get the value of a column of the database table if the column has the praefix @b usr_ otherwise the value of the profile field of the table adm_user_data will be returned. If the value was manipulated before with @b setValue than the manipulated value is returned.

Get the value of a column of the database table if the column has the praefix @b usr_ otherwise the value of the profile field of the table adm_user_data will be returned. If the value was manipulated before with @b setValue than the manipulated value is returned.

Parameters

$columnName
The name of the database column whose value should be read or the internal unique profile field name
$format

For date or timestamp columns the format should be the date/time format e.g. @b d.m.Y = '02.04.2011'. @n For text columns the format can be @b database that would return the original database value without any transformations

Returns

mixed

Returns the value of the database column or the value of adm_user_fields If the value was manipulated before with @b setValue than the manipulated value is returned.

Code

// reads data of adm_users column $loginname = $gCurrentUser->getValue('usr_login_name'); // reads data of adm_user_fields $email = $gCurrentUser->getValue('EMAIL'); @endcode


Par

Examples

Overrides

TableAccess::getValue
public string
# getVCard( boolean $allowedToEditProfile = false )

Creates a vcard with all data of this user object @n (Windows XP address book can't process utf8, so vcard output is iso-8859-1)

Creates a vcard with all data of this user object @n (Windows XP address book can't process utf8, so vcard output is iso-8859-1)

Parameters

$allowedToEditProfile

If set to @b true than logged in user is allowed to edit profiles so he can see more data in the vcard

Returns

string
Returns the vcard as a string
public boolean
# hasRightEditProfile( User & $user, boolean $checkOwnProfile = true )

Checks if the current user is allowed to edit the profile of the user of the parameter. If will check if user can generally edit all users or if he is a group leader and can edit users of a special role where @b $user is a member or if it's the own profile and he could edit this.

Checks if the current user is allowed to edit the profile of the user of the parameter. If will check if user can generally edit all users or if he is a group leader and can edit users of a special role where @b $user is a member or if it's the own profile and he could edit this.

Parameters

$user
User object of the user that should be checked if the current user can edit his profile.
$checkOwnProfile
If set to @b false than this method don't check the role right to edit the own profile.

Returns

boolean
Return @b true if the current user is allowed to edit the profile of the user from @b $user.
private boolean
# hasRightRole( array $rightsList, string $rightName, integer $roleId )

Parameters

$rightsList
$rightName
$roleId

Returns

boolean
public boolean
# hasRightSendMailToRole( integer $roleId )

Checks if the current user has the right to send an email to the role.

Checks if the current user has the right to send an email to the role.

Parameters

$roleId
Id of the role that should be checked.

Returns

boolean
Return @b true if the user has the right to send an email to the role.
public boolean
# hasRightViewProfile( User $user )

Checks if the current user is allowed to view the profile of the user of the parameter. If will check if user has edit rights with method editProfile or if the user is a member of a role where the current user has the right to view profiles.

Checks if the current user is allowed to view the profile of the user of the parameter. If will check if user has edit rights with method editProfile or if the user is a member of a role where the current user has the right to view profiles.

Parameters

$user
User object of the user that should be checked if the current user can view his profile.

Returns

boolean
Return @b true if the current user is allowed to view the profile of the user from @b $user.
public boolean
# hasRightViewRole( integer $roleId )

Check if the user of this object has the right to view the role that is set in the parameter.

Check if the user of this object has the right to view the role that is set in the parameter.

Parameters

$roleId
The id of the role that should be checked.

Returns

boolean
Return @b true if the user has the right to view the role otherwise @b false.
public boolean
# isAdministrator( )

Checks if the user is assigned to the role @b Administrator

Checks if the user is assigned to the role @b Administrator

Returns

boolean
Returns @b true if the user is a member of the role @b Administrator
public boolean
# isLeaderOfRole( integer $roleId )

check if user is leader of a role

check if user is leader of a role

Parameters

$roleId

Returns

boolean
public boolean
# isMemberOfRole( integer $roleId )

check if user is member of a role

check if user is member of a role

Parameters

$roleId

Returns

boolean
public boolean
# isWebmaster( )

Checks if the user is assigned to the role @b Administrator

Checks if the user is assigned to the role @b Administrator

Deprecated

3.2.0:4.0.0 Use Method isAdministrator() instead

Returns

boolean
Returns @b true if the user is a member of the role @b Administrator

See

User#isAdministrator
public
# noValueCheck( )

If this method is called than all further calls of method @b setValue will not check the values. The values will be stored in database without any inspections!

If this method is called than all further calls of method @b setValue will not check the values. The values will be stored in database without any inspections!

public boolean
# readDataById( integer $userId )

Reads a user record out of the table adm_users in database selected by the unique user id. Also all profile fields of the object @b mProfileFieldsData will be read.

Reads a user record out of the table adm_users in database selected by the unique user id. Also all profile fields of the object @b mProfileFieldsData will be read.

Parameters

$userId
Unique id of the user that should be read

Returns

boolean
Returns @b true if one record is found

Overrides

TableAccess::readDataById
public
# renewRoleData( )

Initialize all rights and role membership arrays so that all rights and role memberships will be read from database if another method needs them

Initialize all rights and role membership arrays so that all rights and role memberships will be read from database if another method needs them

public boolean
# save( boolean $updateFingerPrint = true )

Save all changed columns of the recordset in table of database. Therefore the class remembers if it's a new record or if only an update is necessary. The update statement will only update the changed columns. If the table has columns for creator or editor than these column with their timestamp will be updated. First save recordset and then save all user fields. After that the session of this got a renew for the user object. If the user doesn't have the right to save data of this user than an exception will be thrown.

Save all changed columns of the recordset in table of database. Therefore the class remembers if it's a new record or if only an update is necessary. The update statement will only update the changed columns. If the table has columns for creator or editor than these column with their timestamp will be updated. First save recordset and then save all user fields. After that the session of this got a renew for the user object. If the user doesn't have the right to save data of this user than an exception will be thrown.

Parameters

$updateFingerPrint

Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed

Returns

boolean

Throws

AdmException

Overrides

TableAccess::save
public
# saveChangesWithoutRights( )

If this method is set then a user can save changes to the user if he hasn't the necessary rights

If this method is set then a user can save changes to the user if he hasn't the necessary rights

public
# setOrganization( integer $organizationId )

Set the id of the organization which should be used in this user object. The organization is used to read the rights of the user. If @b setOrganization isn't called than the default organization @b gCurrentOrganization is set for the current user object.

Set the id of the organization which should be used in this user object. The organization is used to read the rights of the user. If @b setOrganization isn't called than the default organization @b gCurrentOrganization is set for the current user object.

Parameters

$organizationId
Id of the organization
public boolean
# setPassword( string $newPassword, boolean $isNewPassword = false, boolean $doHashing = true )

Set a new value for a password column of the database table. The value is only saved in the object. You must call the method @b save to store the new value to the database

Set a new value for a password column of the database table. The value is only saved in the object. You must call the method @b save to store the new value to the database

Parameters

$newPassword
The new value that should be stored in the database field
$isNewPassword
Should the column password or new_password be set
$doHashing
Should the password get hashed before inserted. Default is true

Returns

boolean
Returns @b true if the value is stored in the current object and @b false if a check failed
private boolean
# changeRoleMembership( string $mode, integer $id, string $startDate, string $endDate, boolean $leader )

Parameters

$mode
'set' or 'edit'
$id

Id of the role for which the membership should be set, or id of the current membership that should be edited.

$startDate
New start date of the membership. Default will be @b DATE_NOW.
$endDate
New end date of the membership. Default will be @b 31.12.9999
$leader

If set to @b 1 then the member will be leader of the role and might get more rights for this role.

Returns

boolean
Return @b true if the membership was successfully added/edited.
public boolean
# setRoleMembership( integer $roleId, string $startDate = DATE_NOW, string $endDate = '9999-12-31', boolean $leader = null )

Create a new membership to a role for the current user. If the date range contains a future or past membership of the same role then the two memberships will be merged. In opposite to setRoleMembership this method can't be used to end a membership earlier!

Create a new membership to a role for the current user. If the date range contains a future or past membership of the same role then the two memberships will be merged. In opposite to setRoleMembership this method can't be used to end a membership earlier!

Parameters

$roleId
Id of the role for which the membership should be set.
$startDate
Start date of the membership. Default will be @b DATE_NOW.
$endDate
End date of the membership. Default will be @b 31.12.9999
$leader

If set to @b 1 then the member will be leader of the role and might get more rights for this role.

Returns

boolean
Return @b true if the membership was successfully added.
public boolean
# editRoleMembership( integer $memberId, string $startDate = DATE_NOW, string $endDate = '9999-12-31', boolean $leader = null )

Edit an existing role membership of the current user. If the new date range contains a future or past membership of the same role then the two memberships will be merged. In opposite to setRoleMembership this method is useful to end a membership earlier.

Edit an existing role membership of the current user. If the new date range contains a future or past membership of the same role then the two memberships will be merged. In opposite to setRoleMembership this method is useful to end a membership earlier.

Parameters

$memberId
Id of the current membership that should be edited.
$startDate
New start date of the membership. Default will be @b DATE_NOW.
$endDate
New end date of the membership. Default will be @b 9999-12-31
$leader

If set to @b 1 then the member will be leader of the role and might get more rights for this role.

Returns

boolean
Return @b true if the membership was successfully edited.
public boolean
# setValue( string $columnName, mixed $newValue, boolean $checkValue = true )

Set a new value for a column of the database table if the column has the prefix @b usr_ otherwise the value of the profile field of the table adm_user_data will set. If the user log is activated than the change of the value will be logged in @b adm_user_log. The value is only saved in the object. You must call the method @b save to store the new value to the database

Set a new value for a column of the database table if the column has the prefix @b usr_ otherwise the value of the profile field of the table adm_user_data will set. If the user log is activated than the change of the value will be logged in @b adm_user_log. The value is only saved in the object. You must call the method @b save to store the new value to the database

Parameters

$columnName

The name of the database column whose value should get a new value or the internal unique profile field name

$newValue
The new value that should be stored in the database field
$checkValue

The value will be checked if it's valid. If set to @b false than the value will not be checked.

Returns

boolean
Returns @b true if the value is stored in the current object and @b false if a check failed

Code

// set data of adm_users column $gCurrentUser->getValue('usr_login_name', 'Admidio'); // reads data of adm_user_fields $gCurrentUser->getValue('EMAIL', 'webmaster@admidio.org');


Endcode

Par

Examples

Overrides

TableAccess::setValue
public
# updateLoginData( )

Update login data for this user. These are timestamps of last login and reset count and timestamp of invalid logins.

Update login data for this user. These are timestamps of last login and reset count and timestamp of invalid logins.

public boolean
# editAnnouncements( )

Funktion prueft, ob der angemeldete User Ankuendigungen anlegen und bearbeiten darf

Funktion prueft, ob der angemeldete User Ankuendigungen anlegen und bearbeiten darf

Returns

boolean
public boolean
# approveUsers( )

Funktion prueft, ob der angemeldete User Registrierungen bearbeiten und zuordnen darf

Funktion prueft, ob der angemeldete User Registrierungen bearbeiten und zuordnen darf

Returns

boolean
public boolean
# assignRoles( )

Checks if the user has the right to assign members to at least one role.

Checks if the user has the right to assign members to at least one role.

Returns

boolean
Return @b true if the user can assign members to at least one role.
public boolean
# manageRoles( )

Checks if the user has the right to manage roles. Therefore he must be a member of a role with the right @b rol_manage_roles.

Checks if the user has the right to manage roles. Therefore he must be a member of a role with the right @b rol_manage_roles.

Returns

boolean
Return @b true if the user can manage roles.
public boolean
# editDates( )

Funktion prueft, ob der angemeldete User Termine anlegen und bearbeiten darf

Funktion prueft, ob der angemeldete User Termine anlegen und bearbeiten darf

Returns

boolean
public boolean
# editDownloadRight( )

Funktion prueft, ob der angemeldete User Downloads hochladen und verwalten darf

Funktion prueft, ob der angemeldete User Downloads hochladen und verwalten darf

Returns

boolean
public boolean
# editUsers( )

Funktion prueft, ob der angemeldete User fremde Benutzerdaten bearbeiten darf

Funktion prueft, ob der angemeldete User fremde Benutzerdaten bearbeiten darf

Returns

boolean
public boolean
# editGuestbookRight( )

Funktion prueft, ob der angemeldete User Gaestebucheintraege loeschen und editieren darf

Funktion prueft, ob der angemeldete User Gaestebucheintraege loeschen und editieren darf

Returns

boolean
public boolean
# commentGuestbookRight( )

Funktion prueft, ob der angemeldete User Gaestebucheintraege kommentieren darf

Funktion prueft, ob der angemeldete User Gaestebucheintraege kommentieren darf

Returns

boolean
public boolean
# editPhotoRight( )

Funktion prueft, ob der angemeldete User Fotos hochladen und verwalten darf

Funktion prueft, ob der angemeldete User Fotos hochladen und verwalten darf

Returns

boolean
public boolean
# editWeblinksRight( )

Funktion prueft, ob der angemeldete User Weblinks anlegen und editieren darf

Funktion prueft, ob der angemeldete User Weblinks anlegen und editieren darf

Returns

boolean
public boolean
# editInventory( )

Funktion prueft, ob der angemeldete User das Inventory verwalten darf

Funktion prueft, ob der angemeldete User das Inventory verwalten darf

Returns

boolean

Methods inherited from TableAccess

__sleep(), connectAdditionalTable(), countAllRecords(), hasColumnsValueChanged(), isNewRecord(), readData(), readDataByColumns(), setArray(), setDatabase()

Properties summary

protected $administrator
#
public $mProfileFieldsData
#
public array $roles_rights
# array()
protected array $listViewRights
# array()
protected array $listMailRights
# array()
protected array $rolesMembership
# array()
protected array $rolesMembershipLeader
# array()
protected array $rolesMembershipNoLeader
# array()
protected $organizationId
#
protected $assignRoles
#
protected $saveChangesWithoutRights
#
protected array $usersEditAllowed
# array()

Properties inherited from TableAccess

$additionalTables, $columnPrefix, $columnsInfos, $columnsValueChanged, $db, $dbColumns, $keyColumnName, $new_record, $tableName

Admidio API API documentation generated by ApiGen