Skip to content
Snippets Groups Projects
Commit 269ee954 authored by Johannes Goderbauer's avatar Johannes Goderbauer Committed by Johannes Goderbauer
Browse files

added comments to IncomingCallExecutor_lib

(cherry picked from commit 4c7cc7d6)
parent 3c5c8c2d
No related branches found
No related tags found
No related merge requests found
......@@ -10,8 +10,6 @@ import("Sql_lib");
import("system.cti");
import("system.indexsearch");
//TODO: comment library completely
/**
* object for processing cti-calls
* Within the constructor, data is collected but not further processed. To perform operations, different methods are provide (lke the .execute-function)
......@@ -205,6 +203,30 @@ IncomingCallExecutor._callstateToText = function(pCallstate)
return callstateName;
};
/**
* helper function to load a contact by a given number (or contactId) as they are required for formatting of a callers name for example
* will use the index for a fast phone number search; will load the actual data from the database
*
* either the number or contactIds have to be given to the function. you can specify both if you want to extent the search
* (look for the phoneNumber XXX and also look for those YYY contactIds; Note that this is an extension and not a an addtional filter and therefor
* will result in an SQL-OR-condtion)
*
* @param {String} pNumber phone number that shall be searched, formatting is ignored for searching
* @param {Array} pContactIds additional contactIds to load
*
* @return {Array} array of contacts where each element is an object with these properites
* <ul>
* <li>CONTACTID</li>
* <li>ORGANISATION_ID</li>
* <li>ORGANISATION_NAME</li>
* <li>PERSON_ID</li>
* <li>LANGUAGE</li>
* <li>PERSON_FULL_NAME</li>
* </ul>
*
* @private
* @static
*/
IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds)
{
var phoneNumber = pNumber;
......@@ -269,12 +291,28 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds)
ORGANISATION_ID: e[1],
ORGANISATION_NAME: e[2].trim(),
PERSON_ID: e[3],
LANGUAGE: e[4],
ISOLANGUAGE: e[4],
PERSON_FULL_NAME: e.slice(5).join(" ").trim() //quick solution until the ticket above (#1047680) is solved
};
});
};
/**
* helper function to load user data models by given contacts as they are returned in IncomingCallExecutor._getContactsFromNumber
* the CONTACTID-property of the contact will be used to search within the users
* Only active users are returned
*
* either the number or contactIds have to be given to the function. you can specify both if you want to extent the search
* (look for the phoneNumber XXX and also look for those YYY contactIds; Note that this is an extension and not a an addtional filter and therefor
* will result in an SQL-OR-condtion)
*
* @param {Array} pContacts contacts as they are returned in IncomingCallExecutor._getContactsFromNumber(...)
*
* @return {Array} array of user data models (PROFILE_DEFAULT)
*
* @private
* @static
*/
IncomingCallExecutor._getUsersFromContacts = function (pContacts)
{
var users = tools.getUsersByAttribute(tools.CONTACTID, pContacts.map(function(e){
......@@ -286,6 +324,16 @@ IncomingCallExecutor._getUsersFromContacts = function (pContacts)
return users;
};
/**
* will search within the contacts for a given user and then return the contacts language
* The CONTACTID of the user is used for finding the matching contact
*
* @param {Object} pUserObject user data model whose contact shall be searched
*
* @return {String} language as isocode of the contact or null if no language is set/the user was not found in the "contactsLocal" property
*
* @private
*/
IncomingCallExecutor.prototype.getLocaleFromUser = function(pUserObject)
{
var contactId = pUserObject[tools.CONTACTID];
......@@ -293,7 +341,7 @@ IncomingCallExecutor.prototype.getLocaleFromUser = function(pUserObject)
return e.CONTACTID == contactId;
});
//language for output like notifications, this is most likely used within the callback-functions (action handlers):
if (contact && contact.LANGUAGE)
if (contact && contact.ISOLANGUAGE)
return contact.ISOLANGUAGE;
else
return null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment