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:
| Value | Type | Description |
|---|---|---|
| id | Integer | The primary key (auto-incremented) |
| loginname | String | The unique loginname for this user. |
| username | String | The unique username for this user. |
| password | String | The encrypted password for this user. |
| firstname | String | The firstname for this user. |
| middlename | String | The middlename for this user. |
| lastname | String | The lastname for this user. |
| String | The email address for this user. | |
| status | Integer | The status (enum) for this user. 1 is Active; 2 is Not Present; 3 is deleted |
| signature | String | The users signature. |
| language | String | A string indicating the user's language. See list below for values. |
| flags | Integer | A bitmask indicating flags for this entry. |
| lastCategory | Integer | The last chosen category for this user when posting tickets. category.id |
| pictureId | Integer | The attachment ID of the picture for this user. |
| defaultUser | Integer | The default user to set on new tickets in this category (1=automatically; 2=unassigned; 3=the owner) |
| initials | String | Obsolete field. Cannot be removed because of not null error on older systems |
| group | Integer | The group ID of the primary group which this user belongs to |
| role | Integer | The role ID of the role this user belongs to |
| associateId | Integer | The corresponding associate id for this user |
| ownerCompany | Integer | the contact ID of the owning company of the users' connected person entity. |
| x_* | The extrafield with the given database field name. |
Language values:
| Value | Description |
|---|---|
| 0 | Norwegian |
| 1 | English |
| 2 | German |
| 3 | Swedish |
| 4 | Danish |
| 5 | Dutch |
| 6 | French |
| 7 | Spanish |
| 8 | Italian |
| 9 | Czech |
| 10 | Finnish |
| 11 | Polish |
| 12 | Russian |
| 13 | Ukrainian |
Status: (Indicated by enums):
| Flag | Value |
|---|---|
| StatusNone | 0 |
| StatusNormal | 1 |
| StatusNotAvailable | 2 |
| StatusDeleted | 3 |
| StatusReadOnly | 4 |
| StatusSpm | 5 |
| StatusSystem | 127 |
The different notify masks: (Indicated by bit enums):
| Flag | Value |
|---|---|
| NewTicket | 1 |
| NewTicketMessage | 2 |
| TicketEscalated | 3 |
| TicketActivated | 4 |
| ActiveTickets | 5 //only used as a filter (ejuser) |
| TicketTakeOver | 6 |
| Hotlist | 9 //only used as a filter (ejuser) |
| Custom | 10 |
Access flags:
| Flag | Value |
|---|---|
| AccessNone | 0 (value 0) |
| AccessListOthers | 0 bit number 1) |
| AccessReadOthers | 1 |
| AccessEditOthers | 2 |
| AccessEditOwnPref | 3 |
| AccessCategoryAdministration | 4 |
| AccessUserAdministration | 5 |
| AccessEjournalAdministration | 6 |
| AccessStatistics | 7 |
| AccessDocuments | 8 |
| AccessJustCategory | 9 //obsolete |
| AccessEditProfile | 10 |
| AccessListOnlyOwn | 11 |
| AccessReadOnlyOwn | 12 |
| AccessEditOnlyOwn | 13 |
| AccessChat | 14 |
| AccessChatAdmin | 15 |
| AccessSpm | 16 |
| AccessEditFaq | 17 |
| AccessFaqAdmin | 18 |
| AccessListExtraTablesContent | 19 |
| AccessEditExtraTablesContent | 20 |
| AccessReadSelections | 21 |
| AccessEditSelections | 22 |
| AccessPostToFacebook | 23 |
User flags:
| Flag | Value |
|---|---|
| None | 0 |
| UseLastCategory | 1 |
| DefaultTicketClose | 2 |
| DefaultMessageClose | 3 |
| SortDesc | 4 |
| PreviewImages | 5 |
| OnlyOwnCategories | 6 |
| SmallFonts | 7 |
| InsertLastMessage | 8 |
| ShowQuickSearch | 9 |
| Use24HrsClock | 10 |
| AddMessageNewWindow | 11 |
| OnlyShowOpenTicketsInHotlist | 12 |
| UseLocalClock | 13 |
| HighlightActiveScreenElement | 14 |
| DisplayOwnCategories | 15 |
| SuppressWarnOnNavigate | 16 |
| SuppressPreviewWarning | 17 |
| PlainTextEditor | 18 |
| FckEditorSingleLineBreak | 19 |
| CustomDateFormat | 20 |
| SundayFirstDayInWeek | 21 |
| OldScreensOnEditTicket | 22 |
| KeepFormattingOnPaste | 23 |
| DisplayCheckboxLeft | 24 |
| ShowMessagesAsPlainText | 25 |
| HasSOWinLicense | 26 |
| HasSOWebLicense | 27 |
| HasSpmCal | 28 |
| HasMailMergeCal | 29 |
| HasChatCal | 30 |
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:
| Value | Type | Description |
|---|---|---|
| id | Integer | The primary key (auto-incremented) |
| loginname | String | The unique loginname for this user. |
| username | String | The unique username for this user. |
| password | String | The encrypted password for this user. |
| firstname | String | The firstname for this user. |
| middlename | String | The middlename for this user. |
| lastname | String | The lastname for this user. |
| String | The email address for this user. | |
| status | Integer | The status (enum) for this user. 1 is Active; 2 is Not Present; 3 is deleted |
| signature | String | The users signature. |
| language | String | A string indicating the user's language. See list below for values. |
| flags | Integer | A bitmask indicating flags for this entry. |
| lastCategory | Integer | The last chosen category for this user when posting tickets. category.id |
| pictureId | Integer | The attachment ID of the picture for this user. |
| defaultUser | Integer | The default user to set on new tickets in this category (1=automatically; 2=unassigned; 3=the owner) |
| initials | String | Obsolete field. Cannot be removed because of not null error on older systems. |
| group | Integer | The group ID of the primary group which this user belongs to |
| role | Integer | The role ID of the role this user belongs to |
| associateId | Integer | The corresponding associate id for this user |
| ownerCompany | Integer | the contact ID of the owning company of the users' connected person entity. |
| x_* | The extrafield with the given database field name. |
Language values:
| Value | Description |
|---|---|
| 0 | Norwegian |
| 1 | English |
| 2 | German |
| 3 | Swedish |
| 4 | Danish |
| 5 | Dutch |
| 6 | French |
| 7 | Spanish |
| 8 | Italian |
| 9 | Czech |
| 10 | Finnish |
| 11 | Polish |
| 12 | Russian |
| 13 | Ukrainian |
Status: (Indicated by enums):
| Flag | Value |
|---|---|
| StatusNone | 0 |
| StatusNormal | 1 |
| StatusNotAvailable | 2 |
| StatusDeleted | 3 |
| StatusReadOnly | 4 |
| StatusSpm | 5 |
| StatusSystem | 127 |
The different notify masks: (Indicated by bit enums):
| Flag | Value |
|---|---|
| NewTicket | 1 |
| NewTicketMessage | 2 |
| TicketEscalated | 3 |
| TicketActivated | 4 |
| ActiveTickets | 5 //only used as a filter (ejuser) |
| TicketTakeOver | 6 |
| Hotlist | 9 //only used as a filter (ejuser) |
| Custom | 10 |
Access flags:
| Flag | Value |
|---|---|
| AccessNone | 0 (value 0) |
| AccessListOthers | 0 bit number 1) |
| AccessReadOthers | 1 |
| AccessEditOthers | 2 |
| AccessEditOwnPref | 3 |
| AccessCategoryAdministration | 4 |
| AccessUserAdministration | 5 |
| AccessEjournalAdministration | 6 |
| AccessStatistics | 7 |
| AccessDocuments | 8 |
| AccessJustCategory | 9 //obsolete |
| AccessEditProfile | 10 |
| AccessListOnlyOwn | 11 |
| AccessReadOnlyOwn | 12 |
| AccessEditOnlyOwn | 13 |
| AccessChat | 14 |
| AccessChatAdmin | 15 |
| AccessSpm | 16 |
| AccessEditFaq | 17 |
| AccessFaqAdmin | 18 |
| AccessListExtraTablesContent | 19 |
| AccessEditExtraTablesContent | 20 |
| AccessReadSelections | 21 |
| AccessEditSelections | 22 |
| AccessPostToFacebook | 23 |
User flags:
| Flag | Value |
|---|---|
| None | 0 |
| UseLastCategory | 1 |
| DefaultTicketClose | 2 |
| DefaultMessageClose | 3 |
| SortDesc | 4 |
| PreviewImages | 5 |
| OnlyOwnCategories | 6 |
| SmallFonts | 7 |
| InsertLastMessage | 8 |
| ShowQuickSearch | 9 |
| Use24HrsClock | 10 |
| AddMessageNewWindow | 11 |
| OnlyShowOpenTicketsInHotlist | 12 |
| UseLocalClock | 13 |
| HighlightActiveScreenElement | 14 |
| DisplayOwnCategories | 15 |
| SuppressWarnOnNavigate | 16 |
| SuppressPreviewWarning | 17 |
| PlainTextEditor | 18 |
| FckEditorSingleLineBreak | 19 |
| CustomDateFormat | 20 |
| SundayFirstDayInWeek | 21 |
| OldScreensOnEditTicket | 22 |
| KeepFormattingOnPaste | 23 |
| DisplayCheckboxLeft | 24 |
| ShowMessagesAsPlainText | 25 |
| HasSOWinLicense | 26 |
| HasSOWebLicense | 27 |
| HasSpmCal | 28 |
| HasMailMergeCal | 29 |
| HasChatCal | 30 |
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