Esempio n. 1
0
function vtws_login($username, $pwd)
{
    $user = new Users();
    $userId = $user->retrieve_user_id($username);
    if (empty($userId)) {
        throw new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, 'Given user cannot be found');
    }
    $token = vtws_getActiveToken($userId);
    if ($token == null) {
        throw new WebServiceException(WebServiceErrorCode::$INVALIDTOKEN, "Specified token is invalid or expired");
    }
    $accessKey = vtws_getUserAccessKey($userId);
    if ($accessKey == null) {
        throw new WebServiceException(WebServiceErrorCode::$ACCESSKEYUNDEFINED, "Access key for the user is undefined");
    }
    $accessCrypt = md5($token . $accessKey);
    if (strcmp($accessCrypt, $pwd) !== 0) {
        throw new WebServiceException(WebServiceErrorCode::$INVALIDUSERPWD, "Invalid username or password");
    }
    $user = $user->retrieveCurrentUserInfoFromFile($userId);
    if ($user->status != 'Inactive') {
        return $user;
    }
    throw new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, 'Given user is inactive');
}
Esempio n. 2
0
function vtws_getchallenge($username)
{
    $adb = PearDatabase::getInstance();
    $user = new Users();
    $userid = $user->retrieve_user_id($username);
    $authToken = uniqid();
    $servertime = time();
    $expireTime = time() + 60 * 5;
    $sql = "delete from vtiger_ws_userauthtoken where userid=?";
    $adb->pquery($sql, array($userid));
    $sql = "insert into vtiger_ws_userauthtoken(userid,token,expireTime) values (?,?,?)";
    $adb->pquery($sql, array($userid, $authToken, $expireTime));
    return array("token" => $authToken, "serverTime" => $servertime, "expireTime" => $expireTime);
}
Esempio n. 3
0
function vtws_getchallenge($username)
{
    global $adb;
    $user = new Users();
    $userid = $user->retrieve_user_id($username);
    if (empty($userid)) {
        throw new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, 'Given user cannot be found');
    }
    $authToken = uniqid();
    $servertime = time();
    $expireTime = time() + 60 * 5;
    $sql = "delete from vtiger_ws_userauthtoken where userid=?";
    $adb->pquery($sql, array($userid));
    $sql = "insert into vtiger_ws_userauthtoken(userid,token,expireTime) values (?,?,?)";
    $adb->pquery($sql, array($userid, $authToken, $expireTime));
    return array("token" => $authToken, "serverTime" => $servertime, "expireTime" => $expireTime);
}
Esempio n. 4
0
function vtws_loginportal($username, $password)
{
    $uname = 'portal';
    $user = new Users();
    $userId = $user->retrieve_user_id($uname);
    if (empty($userId)) {
        throw new WebServiceException(WebServiceErrorCode::$INVALIDUSERPWD, "User {$uname} does not exist");
    }
    global $adb, $log;
    $log->debug('Entering LoginPortal function with parameter username: '******'select id
			from vtiger_portalinfo
			inner join vtiger_customerdetails on vtiger_portalinfo.id=vtiger_customerdetails.customerid
			inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_portalinfo.id
			where vtiger_crmentity.deleted=0 and user_name=? and user_password=?
			  and isactive=1 and vtiger_customerdetails.portal=1', array($username, $password));
    if ($ctors and $adb->num_rows($ctors) == 1) {
        $user = $user->retrieveCurrentUserInfoFromFile($userId);
        if ($user->status != 'Inactive') {
            $result = $adb->query("SELECT id FROM vtiger_ws_entity WHERE name = 'Users'");
            $wsid = $adb->query_result($result, 0, 'id');
            $accessinfo = vtws_getchallenge($uname);
            $sessionManager = new SessionManager();
            $sid = $sessionManager->startSession(null, false);
            if (!$sid) {
                throw new WebServiceException(WebServiceErrorCode::$SESSIONIDINVALID, 'Could not create session');
            }
            $sessionManager->set("authenticatedUserId", $userId);
            $accessinfo['sessionName'] = $sessionManager->getSessionId();
            $accessinfo['user'] = array('id' => $wsid . 'x' . $userId, 'user_name' => $user->column_fields['user_name'], 'accesskey' => $user->column_fields['accesskey']);
            return $accessinfo;
        } else {
            throw new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, 'Given user is inactive');
        }
    }
    throw new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, "Given contact is inactive");
}
function CheckLeadViewPerm($user_name)
{
    global $current_user, $log;
    require_once 'modules/Users/Users.php';
    $seed_user = new Users();
    $user_id = $seed_user->retrieve_user_id($user_name);
    $current_user = $seed_user;
    $current_user->retrieve_entity_info($user_id, "Users");
    if (isPermitted("Leads", "EditView") == "yes") {
        return "allowed";
    } else {
        return "denied";
    }
}
Esempio n. 6
0
 /**
  * Function to get calendar query for outlookplugin
  * @param   string    $username     -  User name
  * @return  string    $query        -  sql query
  */
 function get_calendarsforol($user_name)
 {
     global $log, $adb, $current_user;
     $log->debug("Entering get_calendarsforol(" . $user_name . ") method ...");
     require_once "modules/Users/Users.php";
     $seed_user = new Users();
     $user_id = $seed_user->retrieve_user_id($user_name);
     $current_user = $seed_user;
     $current_user->retrieve_entity_info($user_id, 'Users');
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
         $sql1 = "select tablename,columnname from vtiger_field where tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder' and vtiger_field.presence in (0,2)";
         $params1 = array();
     } else {
         $profileList = getCurrentUserProfileList();
         $sql1 = "select tablename,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder' and vtiger_field.displaytype in (1,2,4,3) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_field.presence in (0,2)";
         $params1 = array();
         if (count($profileList) > 0) {
             $sql1 .= " and vtiger_profile2field.profileid in (" . generateQuestionMarks($profileList) . ")";
             array_push($params1, $profileList);
         }
     }
     $result1 = $adb->pquery($sql1, $params1);
     for ($i = 0; $i < $adb->num_rows($result1); $i++) {
         $permitted_lists[] = $adb->query_result($result1, $i, 'tablename');
         $permitted_lists[] = $adb->query_result($result1, $i, 'columnname');
         if ($adb->query_result($result1, $i, 'columnname') == "date_start") {
             $permitted_lists[] = 'vtiger_activity';
             $permitted_lists[] = 'time_start';
         }
         if ($adb->query_result($result1, $i, 'columnname') == "due_date") {
             $permitted_lists[] = 'vtiger_activity';
             $permitted_lists[] = 'time_end';
         }
     }
     $permitted_lists = array_chunk($permitted_lists, 2);
     $column_table_lists = array();
     for ($i = 0; $i < count($permitted_lists); $i++) {
         $column_table_lists[] = implode(".", $permitted_lists[$i]);
     }
     $query = "select vtiger_activity.activityid as clndrid, " . implode(',', $column_table_lists) . " from vtiger_activity\n\t\t\tinner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid\n\t\t\tinner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid\n\t\t\tleft join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid\n\t\t\tleft join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid\n\t\t\tleft join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid\n\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid\n\t\t\twhere vtiger_users.user_name='" . $user_name . "' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Meeting'";
     $log->debug("Exiting get_calendarsforol method ...");
     return $query;
 }
Esempio n. 7
0
function validateSession($username, $sessionid)
{
    global $adb, $current_user;
    $adb->println("Inside function validateSession({$username}, {$sessionid})");
    require_once "modules/Users/Users.php";
    $seed_user = new Users();
    $id = $seed_user->retrieve_user_id($username);
    $server_sessionid = getServerSessionId($id);
    $adb->println("Checking Server session id and customer input session id ==> {$server_sessionid} == {$sessionid}");
    if ($server_sessionid == $sessionid) {
        $adb->println("Session id match. Authenticated to do the current operation.");
        return true;
    } else {
        $adb->println("Session id does not match. Not authenticated to do the current operation.");
        return false;
    }
}
Esempio n. 8
0
 /** Function to get the Contacts associated with the particular User Name.
 *  @param varchar $user_name - User Name
 *  Returns query
 */
 function get_contactsforol($user_name)
 {
     global $log, $adb, $current_user;
     require_once "modules/Users/Users.php";
     $seed_user = new Users();
     $user_id = $seed_user->retrieve_user_id($user_name);
     $current_user = $seed_user;
     $current_user->retrieve_entity_info($user_id, 'Users');
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
         $sql1 = "select tablename,columnname from vtiger_field where tabid=4 and vtiger_field.presence in (0,2)";
         $params1 = array();
     } else {
         $profileList = getCurrentUserProfileList();
         $sql1 = "select tablename,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.displaytype in (1,2,4,3) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_field.presence in (0,2)";
         $params1 = array();
         if (count($profileList) > 0) {
             $sql1 .= " and vtiger_profile2field.profileid in (" . generateQuestionMarks($profileList) . ")";
             array_push($params1, $profileList);
         }
     }
     $result1 = $adb->pquery($sql1, $params1);
     for ($i = 0; $i < $adb->num_rows($result1); $i++) {
         $permitted_lists[] = $adb->query_result($result1, $i, 'tablename');
         $permitted_lists[] = $adb->query_result($result1, $i, 'columnname');
         if ($adb->query_result($result1, $i, 'columnname') == "accountid") {
             $permitted_lists[] = 'vtiger_account';
             $permitted_lists[] = 'accountname';
         }
     }
     $permitted_lists = array_chunk($permitted_lists, 2);
     $column_table_lists = array();
     for ($i = 0; $i < count($permitted_lists); $i++) {
         $column_table_lists[] = implode(".", $permitted_lists[$i]);
     }
     $log->debug("Entering get_contactsforol(" . $user_name . ") method ...");
     $query = "select vtiger_contactdetails.contactid as id, " . implode(',', $column_table_lists) . " from vtiger_contactdetails\n\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid\n\t\tinner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid\n\t\tleft join vtiger_customerdetails on vtiger_customerdetails.customerid=vtiger_contactdetails.contactid\n\t\tleft join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid\n\t\tleft join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid\n\t\tleft join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid\n\t\tleft join vtiger_contactscf on vtiger_contactscf.contactid = vtiger_contactdetails.contactid\n\t\tleft join vtiger_campaigncontrel on vtiger_contactdetails.contactid = vtiger_campaigncontrel.contactid\n\t\tleft join vtiger_campaignrelstatus on vtiger_campaignrelstatus.campaignrelstatusid = vtiger_campaigncontrel.campaignrelstatusid\n\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\twhere vtiger_crmentity.deleted=0 and vtiger_users.user_name='" . $user_name . "'";
     $log->debug("Exiting get_contactsforol method ...");
     return $query;
 }
Esempio n. 9
0
function webforms_init()
{
    global $defaultUserName, $defaultUserAccessKey, $defaultOwner, $adb, $enableAppKeyValidation, $application_unique_key;
    try {
        $active = vtlib_isModuleActive('Webforms');
        if ($active === false) {
            webforms_returnError(array('code' => "WEBFORMS_DISABLED", 'message' => 'Webforms module is disabled'), 'Webforms');
        }
        if ($enableAppKeyValidation == true) {
            if ($application_unique_key !== $_REQUEST['appKey']) {
                webforms_returnError(array('code' => "WEBFORMS_INVALID_APPKEY", 'message' => 'AppKey provided is invalid'), null);
                return;
            }
        }
        $module = $_REQUEST['moduleName'];
        $challengeResult = vtws_getchallenge($defaultUserName);
        $challengeToken = $challengeResult['token'];
        $user = vtws_login($defaultUserName, md5($challengeToken . $defaultUserAccessKey));
        $describeResult = vtws_describe($module, $user);
        $fields = $describeResult['fields'];
        $assignedUser = new Users();
        $ownerId = $assignedUser->retrieve_user_id($defaultOwner);
        $userData = webforms_getUserData(vtws_getId(VtigerWebserviceObject::fromName($adb, "Users")->getEntityId(), $ownerId), $fields, $_REQUEST);
        if ($userData === null) {
            webforms_returnError(array('code' => "WEBFORMS_INVALID_DATA", 'message' => 'data provided is invalid'), $module);
            return;
        }
        if (sizeof($userData) < 1) {
            webforms_returnError(array('code' => "WEBFORMS_INVALID_DATA", 'message' => 'data provided is invalid'), $module);
            return;
        }
        $createResult = vtws_create($module, $userData, $user);
        webforms_returnSuccess($createResult, $module);
    } catch (WebServiceException $e) {
        webforms_returnError($e, $module);
    }
}
Esempio n. 10
0
 function get_searchbyemailid($username, $emailaddress)
 {
     //crm-now added $adb to provide db access
     global $log, $adb;
     global $current_user;
     require_once "modules/Users/Users.php";
     $seed_user = new Users();
     $user_id = $seed_user->retrieve_user_id($username);
     $current_user = $seed_user;
     $current_user->retrieve_entity_info($user_id, 'Users');
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     $log->debug("Entering get_searchbyemailid(" . $username . "," . $emailaddress . ") Leads method ...");
     //get users group ID's
     $gquery = 'SELECT groupid FROM vtiger_users2group WHERE userid=?';
     $gresult = $adb->pquery($gquery, array($user_id));
     for ($j = 0; $j < $adb->num_rows($gresult); $j++) {
         $groupidlist .= "," . $adb->query_result($gresult, $j, 'groupid');
     }
     //crm-now changed query to search in groups too and make only owned contacts available
     $query = "SELECT vtiger_leaddetails.lastname,\n\t\t\t\t\t\tvtiger_leaddetails.firstname,\n\t\t\t\t\t\tvtiger_leaddetails.leadid, \n\t\t\t\t\t\tvtiger_leaddetails.email, \n\t\t\t\t\t\tvtiger_leaddetails.company \n\t\t\t\t\tFROM vtiger_leaddetails \n\t\t\t\t\tINNER JOIN vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid \n\t\t\t\t\tLEFT JOIN vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid  \n\t\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\t\tWHERE vtiger_crmentity.deleted=0 AND vtiger_leaddetails.converted=0";
     if (trim($emailaddress) != '') {
         $query .= " AND ((vtiger_leaddetails.email like '" . formatForSqlLike($emailaddress) . "') or vtiger_leaddetails.lastname REGEXP REPLACE('" . $emailaddress . "',' ','|') or vtiger_leaddetails.firstname REGEXP REPLACE('" . $emailaddress . "',' ','|'))  and vtiger_leaddetails.email != ''";
     } else {
         $query .= " AND (vtiger_leaddetails.email like '" . formatForSqlLike($emailaddress) . "' and vtiger_leaddetails.email != '')";
     }
     if (isset($groupidlist)) {
         $query .= " AND (vtiger_users.user_name='" . $username . "' OR vtiger_crmentity.smownerid IN (" . substr($groupidlist, 1) . "))";
     } else {
         $query .= " AND vtiger_users.user_name='" . $username . "'";
     }
     $tab_id = getTabid("Leads");
     if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) {
         $sec_parameter = getListViewSecurityParameter("Leads");
         $query .= $sec_parameter;
     }
     $log->debug("Exiting get_searchbyemailid method ...");
     return $this->plugin_process_list_query($query);
 }
Esempio n. 11
0
$account_ids = array();
$opportunity_ids = array();
$vendor_ids = array();
$contact_ids = array();
$product_ids = array();
$pricebook_ids = array();
$quote_ids = array();
$salesorder_ids = array();
$purchaseorder_ids = array();
$invoice_ids = array();
$email_ids = array();
// Assigned user for all demo data.
$assigned_user_name = "admin";
// Look up the user id for the assigned user
$seed_user = new Users();
$assigned_user_id = $seed_user->retrieve_user_id($assigned_user_name);
global $current_user;
$current_user = new Users();
$result = $current_user->retrieve_entity_info($assigned_user_id, 'Users');
$tagkey = 1;
// Get _dom arrays
$comboFieldNames = array('leadsource' => 'leadsource_dom', 'leadstatus' => 'lead_status_dom', 'industry' => 'industry_dom', 'rating' => 'rating_dom', 'opportunity_type' => 'opportunity_type_dom', 'sales_stage' => 'sales_stage_dom');
$comboFieldArray = getComboArray($comboFieldNames);
$adb->println("company_name_array");
$adb->println($company_name_array);
$cloudtag = array('SO_vendtl', 'X-CEED', 'X-CEED', 'vtiger_50usr');
for ($i = 0; $i < $company_name_count; $i++) {
    $account_name = $company_name_array[$i];
    // Create new accounts.
    $account = new Accounts();
    $account->column_fields["accountname"] = $account_name;
Esempio n. 12
0
/**	function used to get the Quotes/Invoice pdf
 *	@param int $id - id -id
 *	return string $output - pd link value
 */
function get_pdf($id, $block, $customerid, $sessionid)
{
    global $adb;
    global $current_user, $log, $default_language;
    global $currentModule, $mod_strings, $app_strings, $app_list_strings;
    $log->debug("Entering customer portal function get_pdf");
    $isPermitted = check_permission($customerid, $block, $id);
    if ($isPermitted == false) {
        return array("#NOT AUTHORIZED#");
    }
    if (!validateSession($customerid, $sessionid)) {
        return null;
    }
    require_once "modules/Users/Users.php";
    require_once "config.inc.php";
    $seed_user = new Users();
    $user_id = $seed_user->retrieve_user_id('admin');
    $current_user = $seed_user;
    $current_user->retrieveCurrentUserInfoFromFile($user_id);
    $currentModule = $block;
    $current_language = $default_language;
    $app_strings = return_application_language($current_language);
    $app_list_strings = return_app_list_strings_language($current_language);
    $mod_strings = return_module_language($current_language, $currentModule);
    $_REQUEST['record'] = $id;
    $_REQUEST['savemode'] = 'file';
    $filenamewithpath = 'test/product/' . $id . '_' . $block . '.pdf';
    if (file_exists($filenamewithpath) && filesize($filenamewithpath) != 0) {
        unlink($filenamewithpath);
    }
    checkFileAccess("modules/{$block}/CreatePDF.php");
    include "modules/{$block}/CreatePDF.php";
    if (file_exists($filenamewithpath) && filesize($filenamewithpath) != 0) {
        //we have to pass the file content
        $filecontents[] = base64_encode(file_get_contents($filenamewithpath));
        unlink($filenamewithpath);
        // TODO: Delete the file to avoid public access.
    } else {
        $filecontents = "failure";
    }
    $log->debug("Exiting customer portal function get_pdf");
    return $filecontents;
}
Esempio n. 13
0
 /**
  * Function to get calendar query for outlookplugin
  * @param   string    $username     -  User name
  * @return  string    $query        -  sql query
  */
 function get_calendarsforol($user_name)
 {
     global $log, $adb, $current_user;
     $log->debug("Entering get_calendarsforol(" . $user_name . ") method ...");
     require_once "modules/Users/Users.php";
     $seed_user = new Users();
     $user_id = $seed_user->retrieve_user_id($user_name);
     $current_user = $seed_user;
     $current_user->retrieve_entity_info($user_id, 'Users');
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     //get users group ID's
     $gquery = 'SELECT groupid FROM vtiger_users2group WHERE userid=?';
     $gresult = $adb->pquery($gquery, array($user_id));
     for ($j = 0; $j < $adb->num_rows($gresult); $j++) {
         $groupidlist .= "," . $adb->query_result($gresult, $j, 'groupid');
     }
     if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
         $sql1 = "select tablename,columnname from vtiger_field where tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder' and vtiger_field.presence in (0,2)";
         $params1 = array();
     } else {
         $profileList = getCurrentUserProfileList();
         $sql1 = "select tablename,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder' and vtiger_field.displaytype in (1,2,4,3) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_field.presence in (0,2)";
         $params1 = array();
         if (count($profileList) > 0) {
             $sql1 .= " and vtiger_profile2field.profileid in (" . generateQuestionMarks($profileList) . ")";
             array_push($params1, $profileList);
         }
     }
     $result1 = $adb->pquery($sql1, $params1);
     for ($i = 0; $i < $adb->num_rows($result1); $i++) {
         $permitted_lists[] = $adb->query_result($result1, $i, 'tablename');
         $permitted_lists[] = $adb->query_result($result1, $i, 'columnname');
         if ($adb->query_result($result1, $i, 'columnname') == "date_start") {
             $permitted_lists[] = 'vtiger_activity';
             $permitted_lists[] = 'time_start';
         }
         if ($adb->query_result($result1, $i, 'columnname') == "due_date") {
             $permitted_lists[] = 'vtiger_activity';
             $permitted_lists[] = 'time_end';
         }
     }
     $permitted_lists = array_chunk($permitted_lists, 2);
     $column_table_lists = array();
     for ($i = 0; $i < count($permitted_lists); $i++) {
         if ($permitted_lists[$i][0] != 'vtiger_activitycf') {
             $column_table_lists[] = implode(".", $permitted_lists[$i]);
         }
     }
     $query = "SELECT vtiger_activity.activityid AS clndrid, " . implode(',', $column_table_lists) . " FROM vtiger_activity \n\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_activity.activityid \n\t\t\t\tLEFT JOIN vtiger_salesmanactivityrel ON vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid \n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id=vtiger_salesmanactivityrel.smid \n\t\t\t\tLEFT JOIN vtiger_cntactivityrel ON vtiger_cntactivityrel.activityid=vtiger_activity.activityid \n\t\t\t\tLEFT JOIN vtiger_contactdetails ON vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid \n\t\t\t\tLEFT JOIN vtiger_seactivityrel ON vtiger_seactivityrel.activityid = vtiger_activity.activityid \n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid \n\t\t\t\tWHERE vtiger_crmentity.deleted=0 AND vtiger_activity.activitytype='Meeting' ";
     if (isset($groupidlist)) {
         $query .= " AND (vtiger_users.user_name='" . $user_name . "' OR vtiger_crmentity.smownerid IN (" . substr($groupidlist, 1) . "))";
     } else {
         $query .= " AND vtiger_users.user_name='" . $user_name . "'";
     }
     //crm-now added GROUP BY to prevent the same entry to appear multiple times if assigned to multiple contacts during synchronization with Outlook
     $query .= " GROUP BY clndrid";
     $log->debug("Exiting get_calendarsforol method ...");
     return $query;
 }