Skip to content

Users & Rights

User lookups, access rights and role checks.

18 functions. All require apis/main_webservices.php to be included.


On this page: getEmailAddr ยท getMobileNo ยท getOwnerEmail ยท getUserChildList ยท getUserEmail ยท getUserFullname ยท getUserIdFromName ยท getUserMobileno ยท getUserNameFromID ยท getUsersHavingRights ยท hasUserAccess ยท hasUserMenuAccess ยท isUserAdmin ยท isUserExtranet ยท isUserMerciAdmin ยท isUserSOPC ยท isUserSysAdmin ยท notifyUser


getEmailAddr()

Prototype

getEmailAddr( $cTable, $id, $cField )

Description

  • Returns an email address resolved through field mapping for a table row and field.
  • Email counterpart of getMobileNo() for linked-master contacts.

Parameters

  • $cTable โ€” table name
  • $id โ€” id of table
  • $cField โ€” Field name of table.

Returns

  • String โ€” the mapped email address for that row/field.

Return example

$em = getEmailAddr('trn_salesorder', 1024, 'customer');
// e.g. 'buyer@acme.com'

Usage example

$mobile = GetEmailAddr( 'trn_sales', 1222, 'party' )
returns: 'no-reply@merciglobal.com'

:material-file-code: Source: apis/core2_a.php


getMobileNo()

Prototype

getMobileNo( $cTable, $id, $cField )

Description

  • Returns a mobile number resolved through field mapping โ€” given a table, row id and field it follows the configured mapping to the actual phone column.
  • Use when the contact number lives on a linked master rather than the row itself.

Parameters

  • $cTable โ€” table name
  • $id โ€” id of table
  • $cField โ€” Field name of table.

Returns

  • String โ€” the mapped mobile number for that row/field.

Return example

$mob = getMobileNo('trn_salesorder', 1024, 'customer');
// e.g. '9825012345'

Usage example

$mobile = GetMobileNo( 'trn_sales', 1222, 'party' )
returns: 9898098980

:material-file-code: Source: apis/core2_a.php


getOwnerEmail()

Prototype

getOwnerEmail()

Description

  • Returns the owner/director's email address for the project.
  • Use for escalations and high-level notifications.

Returns

  • String โ€” owner/director email address.

Return example

$em = getOwnerEmail();
// e.g. 'director@company.com'

Usage example

$email = GetOwnerEmail();

:material-file-code: Source: apis/core2_a.php


getUserChildList()

Prototype

getUserChildList( $CurrentUserId=0 )

Description

  • Returns the list of users that sit below a given user in the reporting hierarchy.
  • Defaults to the current user when no id is passed.
  • Use to scope dashboards/approvals to a manager's subordinates.

Parameters

  • $CurrentUserId โ€” User ID. Defaults to Current User ID.

Returns

  • Array โ€” user ids (and/or names) reporting under the given/current user.

Return example

$team = getUserChildList();
// e.g. [44, 51, 63]

Usage example

$userChildren = getUserChildList();   Will return eg. array( 32, 40, 41, 44 );

Where 32 is current user, and 40, 41, 44 are children users under user id 32

:material-file-code: Source: apis/core2_a.php


getUserEmail()

Prototype

GetUserEmail( $userid=0 )

Description

  • Returns the email address of a user by id.
  • Defaults to the current user when no id is supplied.

Parameters

  • $userid โ€” numeric user id. Defaults ot Current User ID

Returns

  • String โ€” the user's email address.

Return example

$em = getUserEmail(42);
// e.g. 'rajesh@company.com'

Usage example

$mobile = GetUserMobileNo( 2 ); //where 2 is the userid
returns: 'x@xyz.com'

:material-file-code: Source: apis/core2_a.php


getUserFullname()

Prototype

GetUserFullname($name)

Description

  • Returns a user's full display name from their login name.
  • Use in greetings, signatures and people pickers.

Parameters

  • <$name>: Name of the user

Returns

  • String โ€” the user's full name.

Return example

$fn = getUserFullname('rajesh');
// e.g. 'Rajesh Kumar Shah'

Usage example

$user = GetUserIdFromName(12);

:material-file-code: Source: apis/core2_a.php


getUserIdFromName()

Prototype

GetUserIdFromName($name)

Description

  • Resolves a login name to its numeric user id.
  • Use when input arrives as a name but you need the id for joins.

Parameters

  • <$name>: Name of the user

Returns

  • Integer โ€” the user id for the given name.

Return example

$id = getUserIdFromName('rajesh');
// e.g. 42

Usage example

$user = GetUserIdFromName(12);

:material-file-code: Source: apis/core2_a.php


getUserMobileno()

Prototype

GetUserMobileNo( $username='' )

Description

  • Returns the mobile number registered for a user.
  • Defaults to the current user when $username is empty.

Parameters

  • $username โ€” string name of user. Defaults to current user name

Returns

  • String โ€” the user's mobile number from the users table.

Return example

$mob = getUserMobileno('rajesh');
// e.g. '9825012345'

Usage example

$mobile = GetUserMobileNo( 'ANTONY' );
returns: 9898098980

:material-file-code: Source: apis/core2_a.php


getUserNameFromID()

Prototype

GetUserNameFromID( $id=-1 )

Description

  • Resolves a user id to its login name.
  • Inverse of getUserIdFromName(); handy for displaying audit/ownership ids.

Parameters

  • [$id]: ID of the user. Defaults to Current User

Returns

  • String โ€” the login name for the given user id.

Return example

$name = getUserNameFromID(42);
// e.g. 'rajesh'

Usage example

$user = GetUserNameFromID(12);

:material-file-code: Source: apis/core2_a.php


getUsersHavingRights()

Prototype

getUsersHavingRights($rights_key='')

Description

  • Returns every user that holds a specific access-rights key.
  • Use to fan out notifications/approvals to all authorised users for an action.

Parameters

  • $rights_key โ€” ACCESS KEY. Defaults to BLANK ('')

Returns

  • Array โ€” user ids that have the given ACCESS KEY.

Return example

$approvers = getUsersHavingRights('APPROVE_PO');
// e.g. [12, 42, 77]

Usage example

$users = getUsersHavingRights('trn_sales')

:material-file-code: Source: apis/core2_a.php


hasUserAccess()

Prototype

HasUserAccess( $cTable, $cAccess )

Description

  • Checks the logged-in user's permission for a table and a specific action (add/edit/delete/etc.).
  • Call before rendering action buttons or executing privileged operations.

Parameters

  • $cTable โ€” Table name for which access has to be checked.
  • $cAccess โ€” Access Code. A for Add, E for Edit, D for Delete, L for List, P for Print/Export.

Returns

  • Boolean โ€” true if the current user is allowed the action on that table.

Return example

if (hasUserAccess('trn_salesorder', 'DELETE')) {
    // show delete button
}
// returns: true | false

Usage example

if (hasUserAccess( 'trn_sales', 'E' ){
   ...
   ...
}

:material-file-code: Source: apis/core2_a.php


hasUserMenuAccess()

Prototype

HasUserMenuAccess( $cAccessName )

Description

  • Checks whether the current user can access a given menu access key.
  • Use to hide/show menu items and guard direct page access.

Parameters

  • $cAccessName

Returns

  • Boolean โ€” true if the user has access to the menu key.

Return example

if (hasUserMenuAccess('REPORTS_GST')) {
    // allow opening GST reports
}
// returns: true | false

Usage example

$access = HasUserMenuAccess( 'trn_sales' );

:material-file-code: Source: apis/core2_a.php


isUserAdmin()

Prototype

isUserAdmin()

Description

  • Tells whether the current user is a Client-side Administrator.
  • The customer's own admin role, below Merci/SysAdmin.

Returns

  • Boolean โ€” true if the user is the client admin.

Return example

if (isUserAdmin()) { /* client admin features */ }
// returns: true | false

Usage example

if (isUserAdmin()){

    ...

 }

:material-file-code: Source: apis/core2_a.php


isUserExtranet()

Prototype

isUserExtranet()

Description

  • Tells whether the logged-in session is an extranet (customer/vendor) user rather than internal staff.
  • Use to restrict internal-only data and features.

Returns

  • Boolean โ€” true for extranet users, false for internal users.

Return example

if (isUserExtranet()) {
    // limit to the customer's own records
}
// returns: true | false

Usage example

if (isUserExtranet()){

   ...

}

:material-file-code: Source: apis/core2_a.php


isUserMerciAdmin()

Prototype

isUserMerciAdmin()

Description

  • Tells whether the current user is a Merci (vendor-side) Admin.
  • Used for Merciglobal support/maintenance-level access.

Returns

  • Boolean โ€” true if the user is a Merci Admin.

Return example

if (isUserMerciAdmin()) { /* support tools */ }
// returns: true | false

Usage example

if (isUserMerciAdmin()){

    ...

 }

:material-file-code: Source: apis/core2_a.php


isUserSOPC()

Prototype

isUserSOPC()

Description

  • Tells whether the current user holds the SOPC role.
  • Use to enable SOPC-specific screens and approvals.

Returns

  • Boolean โ€” true if the user is SOPC.

Return example

if (isUserSOPC()) { /* SOPC actions */ }
// returns: true | false

Usage example

if (isUserSOPC()){

    ...

 }

:material-file-code: Source: apis/core2_a.php


isUserSysAdmin()

Prototype

isUserSysAdmin()

Description

  • Tells whether the current user is a System Administrator.
  • Highest internal privilege tier; gate sensitive configuration behind it.

Returns

  • Boolean โ€” true if the current user is SysAdmin.

Return example

if (isUserSysAdmin()) { /* allow config */ }
// returns: true | false

Usage example

if (isUserSysAdmin()){

    ...

 }

:material-file-code: Source: apis/core2_a.php


notifyUser()

Prototype

notifyUser( $title, $msg='' )

Description

  • Pushes a runtime alert/notification to the user (rendered via ksa.php).
  • Use to surface a title + message banner during an action.

Parameters

  • $title โ€” Title of Alert
  • $msg โ€” HTML / Text Message to be displayed in the Alert Box

Returns

  • Nothing โ€” performs the notification as a side effect.

Return example

notifyUser('Saved', 'Order #1024 created');
// (no return value)

Usage example

notifyUser('Warning','Disk space is full!');

:material-file-code: Source: apis/core4.php