Show / Hide Table of Contents

Class User

Class for representing a user.

Syntax
Examples
User u;

u.load(2); // Loads user with id = 2
print(u.getValue("username"));
u.setValue("email", "bob@example.com");
u.setValue("language", "en"); // "no" or "en"
u.setValue("status", "1"); // 1 is Active, 2 is Not Present, 3 is deleted
print(u.isLoggedIn(2).toString()); // 2 = web pages, 1 = soap interface

Constructors

User()

Class for representing a user.

Declaration
User
Examples
User u;

u.load(2); // Loads user with id = 2
print(u.getValue("username"));
u.setValue("email", "bob@example.com");
u.setValue("language", "en"); // "no" or "en"
u.setValue("status", "1"); // 1 is Active, 2 is Not Present, 3 is deleted
print(u.isLoggedIn(2).toString()); // 2 = web pages, 1 = soap interface

Methods

getValue(String)

Gets the value of a given column.

Declaration
String getValue(String colName)
Parameters
Type Name Description
String colName

String with column name.

Returns
Type Description
String

Returns a string with value in given column.

Remarks

Possible values:

ValueTypeDescription
idIntegerThe primary key (auto-incremented)
loginnameStringThe unique loginname for this user.
usernameStringThe unique username for this user.
passwordStringThe encrypted password for this user.
firstnameStringThe firstname for this user.
middlenameStringThe middlename for this user.
lastnameStringThe lastname for this user.
emailStringThe email address for this user.
statusIntegerThe status (enum) for this user. 1 is Active; 2 is Not Present; 3 is deleted
signatureStringThe users signature.
languageStringA string indicating the user's language. See list below for values.
flagsIntegerA bitmask indicating flags for this entry.
lastCategoryIntegerThe last chosen category for this user when posting tickets. category.id
pictureIdIntegerThe attachment ID of the picture for this user.
defaultUserIntegerThe default user to set on new tickets in this category (1=automatically; 2=unassigned; 3=the owner)
initialsStringObsolete field. Cannot be removed because of not null error on older systems
groupIntegerThe group ID of the primary group which this user belongs to
roleIntegerThe role ID of the role this user belongs to
associateIdIntegerThe corresponding associate id for this user
ownerCompanyIntegerthe contact ID of the owning company of the users' connected person entity.
x_* The extrafield with the given database field name.

Language values:

ValueDescription
0Norwegian
1English
2German
3Swedish
4Danish
5Dutch
6French
7Spanish
8Italian
9Czech
10Finnish
11Polish
12Russian
13Ukrainian

Status: (Indicated by enums):

FlagValue
StatusNone0
StatusNormal1
StatusNotAvailable2
StatusDeleted3
StatusReadOnly4
StatusSpm5
StatusSystem127

The different notify masks: (Indicated by bit enums):

FlagValue
NewTicket1
NewTicketMessage2
TicketEscalated3
TicketActivated4
ActiveTickets5 //only used as a filter (ejuser)
TicketTakeOver6
Hotlist9 //only used as a filter (ejuser)
Custom10

Access flags:

FlagValue
AccessNone0 (value 0)
AccessListOthers0 bit number 1)
AccessReadOthers1
AccessEditOthers 2
AccessEditOwnPref 3
AccessCategoryAdministration4
AccessUserAdministration5
AccessEjournalAdministration6
AccessStatistics 7
AccessDocuments8
AccessJustCategory9 //obsolete
AccessEditProfile10
AccessListOnlyOwn11
AccessReadOnlyOwn12
AccessEditOnlyOwn13
AccessChat14
AccessChatAdmin15
AccessSpm16
AccessEditFaq17
AccessFaqAdmin18
AccessListExtraTablesContent19
AccessEditExtraTablesContent20
AccessReadSelections21
AccessEditSelections22
AccessPostToFacebook23

User flags:

FlagValue
None0
UseLastCategory1
DefaultTicketClose2
DefaultMessageClose3
SortDesc4
PreviewImages5
OnlyOwnCategories6
SmallFonts7
InsertLastMessage8
ShowQuickSearch9
Use24HrsClock10
AddMessageNewWindow11
OnlyShowOpenTicketsInHotlist12
UseLocalClock13
HighlightActiveScreenElement14
DisplayOwnCategories15
SuppressWarnOnNavigate16
SuppressPreviewWarning17
PlainTextEditor18
FckEditorSingleLineBreak19
CustomDateFormat20
SundayFirstDayInWeek21
OldScreensOnEditTicket22
KeepFormattingOnPaste23
DisplayCheckboxLeft24
ShowMessagesAsPlainText25
HasSOWinLicense26
HasSOWebLicense27
HasSpmCal28
HasMailMergeCal29
HasChatCal30
Examples
User u;

u.load(2); // Loads user with id = 2
print(u.getValue("username"));
u.setValue("email", "bob@example.com");
u.setValue("language", "en"); // "no" or "en"
u.setValue("status", "1"); // 1 is Active, 2 is Not Present, 3 is deleted
print(u.isLoggedIn(2).toString()); // 2 = web pages, 1 = soap interface

hasTicketAccess(Integer,Integer)

Returns true if the user have at least the given access to the given ticket id.

Declaration
Bool hasTicketAccess(Integer ticketId, Integer accessLevel)
Parameters
Type Name Description
Integer ticketId
Integer accessLevel

AccessLevel is 0 for listing tickets, 1 for reading tickets and 2 for editing tickets.

Returns
Type Description
Examples
User u;

u.load(2); // Loads user with id = 2
print(u.getValue("username"));
u.setValue("email", "bob@example.com");
u.setValue("language", "en"); // "no" or "en"
u.setValue("status", "1"); // 1 is Active, 2 is Not Present, 3 is deleted
print(u.isLoggedIn(2).toString()); // 2 = web pages, 1 = soap interface

isAdministrator()

Returns true if the user is an administrator, false if not.

Declaration
Bool isAdministrator()
Returns
Type Description
Examples
User u;

u.load(2); // Loads user with id = 2
print(u.getValue("username"));
u.setValue("email", "bob@example.com");
u.setValue("language", "en"); // "no" or "en"
u.setValue("status", "1"); // 1 is Active, 2 is Not Present, 3 is deleted
print(u.isLoggedIn(2).toString()); // 2 = web pages, 1 = soap interface

isLoggedIn(Integer)

Checks if a user is logged in or not.

Declaration
Bool isLoggedIn(Integer origin)
Parameters
Type Name Description
Integer origin

2 = web pages, 1 = soap interface.

Returns
Type Description
Examples
User u;

u.load(2); // Loads user with id = 2
print(u.getValue("username"));
u.setValue("email", "bob@example.com");
u.setValue("language", "en"); // "no" or "en"
u.setValue("status", "1"); // 1 is Active, 2 is Not Present, 3 is deleted
print(u.isLoggedIn(2).toString()); // 2 = web pages, 1 = soap interface

load(Integer)

Loads a user from the database

Declaration
Bool load(Integer p_id)
Parameters
Type Name Description
Integer p_id

The user Id.

Returns
Type Description

True if the user is loaded successfully.

Examples
User u;

u.load(2); // Loads user with id = 2
print(u.getValue("username"));
u.setValue("email", "bob@example.com");
u.setValue("language", "en"); // "no" or "en"
u.setValue("status", "1"); // 1 is Active, 2 is Not Present, 3 is deleted
print(u.isLoggedIn(2).toString()); // 2 = web pages, 1 = soap interface

loadFromAgentAndKey(Integer,String)

Loads a user from an Agent with userId and the Agent's key.

Declaration
Bool loadFromAgentAndKey(Integer id, String Key)
Parameters
Type Name Description
Integer id

ID of the user

String Key

Key of the agent.

Returns
Type Description

True if the user is loaded successfully.

Examples
User u;

u.load(2); // Loads user with id = 2
print(u.getValue("username"));
u.setValue("email", "bob@example.com");
u.setValue("language", "en"); // "no" or "en"
u.setValue("status", "1"); // 1 is Active, 2 is Not Present, 3 is deleted
print(u.isLoggedIn(2).toString()); // 2 = web pages, 1 = soap interface

save()

Saves a user object to the database, returns the ID of the user.

Declaration
Integer save()
Returns
Type Description
Integer

Returns the ID of the user.

Examples
User u;

u.load(2); // Loads user with id = 2
print(u.getValue("username"));
u.setValue("email", "bob@example.com");
u.setValue("language", "en"); // "no" or "en"
u.setValue("status", "1"); // 1 is Active, 2 is Not Present, 3 is deleted
print(u.isLoggedIn(2).toString()); // 2 = web pages, 1 = soap interface

setValue(String,String,String)

Sets a value in a given column.

Declaration
Void setValue(String column, String value)
Parameters
Type Name Description
String column
String value
String columns

String with column name.

Returns
Type Description
Void
Remarks

Possible values:

ValueTypeDescription
idIntegerThe primary key (auto-incremented)
loginnameStringThe unique loginname for this user.
usernameStringThe unique username for this user.
passwordStringThe encrypted password for this user.
firstnameStringThe firstname for this user.
middlenameStringThe middlename for this user.
lastnameStringThe lastname for this user.
emailStringThe email address for this user.
statusIntegerThe status (enum) for this user. 1 is Active; 2 is Not Present; 3 is deleted
signatureStringThe users signature.
languageStringA string indicating the user's language. See list below for values.
flagsIntegerA bitmask indicating flags for this entry.
lastCategoryIntegerThe last chosen category for this user when posting tickets. category.id
pictureIdIntegerThe attachment ID of the picture for this user.
defaultUserIntegerThe default user to set on new tickets in this category (1=automatically; 2=unassigned; 3=the owner)
initialsStringObsolete field. Cannot be removed because of not null error on older systems.
groupIntegerThe group ID of the primary group which this user belongs to
roleIntegerThe role ID of the role this user belongs to
associateIdIntegerThe corresponding associate id for this user
ownerCompanyIntegerthe contact ID of the owning company of the users' connected person entity.
x_* The extrafield with the given database field name.

Language values:

ValueDescription
0Norwegian
1English
2German
3Swedish
4Danish
5Dutch
6French
7Spanish
8Italian
9Czech
10Finnish
11Polish
12Russian
13Ukrainian

Status: (Indicated by enums):

FlagValue
StatusNone0
StatusNormal1
StatusNotAvailable2
StatusDeleted3
StatusReadOnly4
StatusSpm5
StatusSystem127

The different notify masks: (Indicated by bit enums):

FlagValue
NewTicket1
NewTicketMessage2
TicketEscalated3
TicketActivated4
ActiveTickets5 //only used as a filter (ejuser)
TicketTakeOver6
Hotlist9 //only used as a filter (ejuser)
Custom10

Access flags:

FlagValue
AccessNone0 (value 0)
AccessListOthers0 bit number 1)
AccessReadOthers1
AccessEditOthers 2
AccessEditOwnPref 3
AccessCategoryAdministration4
AccessUserAdministration5
AccessEjournalAdministration6
AccessStatistics 7
AccessDocuments8
AccessJustCategory9 //obsolete
AccessEditProfile10
AccessListOnlyOwn11
AccessReadOnlyOwn12
AccessEditOnlyOwn13
AccessChat14
AccessChatAdmin15
AccessSpm16
AccessEditFaq17
AccessFaqAdmin18
AccessListExtraTablesContent19
AccessEditExtraTablesContent20
AccessReadSelections21
AccessEditSelections22
AccessPostToFacebook23

User flags:

FlagValue
None0
UseLastCategory1
DefaultTicketClose2
DefaultMessageClose3
SortDesc4
PreviewImages5
OnlyOwnCategories6
SmallFonts7
InsertLastMessage8
ShowQuickSearch9
Use24HrsClock10
AddMessageNewWindow11
OnlyShowOpenTicketsInHotlist12
UseLocalClock13
HighlightActiveScreenElement14
DisplayOwnCategories15
SuppressWarnOnNavigate16
SuppressPreviewWarning17
PlainTextEditor18
FckEditorSingleLineBreak19
CustomDateFormat20
SundayFirstDayInWeek21
OldScreensOnEditTicket22
KeepFormattingOnPaste23
DisplayCheckboxLeft24
ShowMessagesAsPlainText25
HasSOWinLicense26
HasSOWebLicense27
HasSpmCal28
HasMailMergeCal29
HasChatCal30
Examples
User u;

u.load(2); // Loads user with id = 2
print(u.getValue("username"));
u.setValue("email", "bob@example.com");
u.setValue("language", "en"); // "no" or "en"
u.setValue("status", "1"); // 1 is Active, 2 is Not Present, 3 is deleted
print(u.isLoggedIn(2).toString()); // 2 = web pages, 1 = soap interface

toParser(Parser)

Loads a user and returns it to a given Parser.

Declaration
Void toParser(Parser parser)
Parameters
Type Name Description
Parser parser

Parser the user should be loaded to.

Returns
Type Description
Void
Examples
User u;

u.load(2); // Loads user with id = 2
print(u.getValue("username"));
u.setValue("email", "bob@example.com");
u.setValue("language", "en"); // "no" or "en"
u.setValue("status", "1"); // 1 is Active, 2 is Not Present, 3 is deleted
print(u.isLoggedIn(2).toString()); // 2 = web pages, 1 = soap interface
In This Article
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top