function getWriteSharingGroupsList($module) { $log = vglobal('log'); $log->debug("Entering getWriteSharingGroupsList(" . $module . ") method ..."); $adb = PearDatabase::getInstance(); $current_user = vglobal('current_user'); $grp_array = array(); $tabid = getTabid($module); $query = "select sharedgroupid from vtiger_tmp_write_group_sharing_per where userid=? and tabid=?"; $result = $adb->pquery($query, array($current_user->id, $tabid)); $num_rows = $adb->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $grp_id = $adb->query_result($result, $i, 'sharedgroupid'); $grp_array[] = $grp_id; } $shareGrpList = constructList($grp_array, 'INTEGER'); $log->debug("Exiting getWriteSharingGroupsList method ..."); return $shareGrpList; }
function getRelCheckquery($currentmodule, $returnmodule, $recordid) { global $log; $log->debug("Entering getRelCheckquery() method ..."); global $adb; $skip_id = array(); $where_relquery = ""; $reltable = ""; if ($reltable != null) { $query = "SELECT " . $selectfield . " FROM " . $reltable . " " . $condition; } if ($query != '') { $result = $adb->query($query); if ($adb->num_rows($result) != 0) { for ($k = 0; $k < $adb->num_rows($result); $k++) { $skip_id[] = $adb->query_result($result, $k, $selectfield); } $skipids = constructList($skip_id, 'INTEGER'); $where_relquery = "and " . $table . "." . $field . " not in " . $skipids; } } $log->debug("Exiting getRelCheckquery method ..."); return $where_relquery; }
function getRelCheckquery($currentmodule, $returnmodule, $recordid) { global $log, $adb; $log->debug("Entering getRelCheckquery(" . $currentmodule . "," . $returnmodule . "," . $recordid . ") method ..."); $skip_id = array(); $where_relquery = ""; $params = array(); if ($currentmodule == "Contacts" && $returnmodule == "Potentials") { $reltable = 'vtiger_contpotentialrel'; $condition = 'WHERE potentialid = ?'; array_push($params, $recordid); $field = $selectfield = 'contactid'; $table = 'vtiger_contactdetails'; } elseif ($currentmodule == "Contacts" && $returnmodule == "Vendors") { $reltable = 'vtiger_vendorcontactrel'; $condition = 'WHERE vendorid = ?'; array_push($params, $recordid); $field = $selectfield = 'contactid'; $table = 'vtiger_contactdetails'; } elseif ($currentmodule == "Contacts" && $returnmodule == "Campaigns") { $reltable = 'vtiger_campaigncontrel'; $condition = 'WHERE campaignid = ?'; array_push($params, $recordid); $field = $selectfield = 'contactid'; $table = 'vtiger_contactdetails'; } elseif ($currentmodule == "Contacts" && $returnmodule == "Calendar") { $reltable = 'vtiger_cntactivityrel'; $condition = 'WHERE activityid = ?'; array_push($params, $recordid); $field = $selectfield = 'contactid'; $table = 'vtiger_contactdetails'; } elseif ($currentmodule == "Leads" && $returnmodule == "Campaigns") { $reltable = 'vtiger_campaignleadrel'; $condition = 'WHERE campaignid = ?'; array_push($params, $recordid); $field = $selectfield = 'leadid'; $table = 'vtiger_leaddetails'; } elseif ($currentmodule == "Users" && $returnmodule == "Calendar") { $reltable = 'vtiger_salesmanactivityrel'; $condition = 'WHERE activityid = ?'; array_push($params, $recordid); $selectfield = 'smid'; $field = 'id'; $table = 'vtiger_users'; } elseif ($currentmodule == "Campaigns" && $returnmodule == "Leads") { $reltable = 'vtiger_campaignleadrel'; $condition = 'WHERE leadid = ?'; array_push($params, $recordid); $field = $selectfield = 'campaignid'; $table = 'vtiger_campaign'; } elseif ($currentmodule == "Campaigns" && $returnmodule == "Contacts") { $reltable = 'vtiger_campaigncontrel'; $condition = 'WHERE contactid = ?'; array_push($params, $recordid); $field = $selectfield = 'campaignid'; $table = 'vtiger_campaign'; } elseif ($currentmodule == "Products" && ($returnmodule == "Potentials" || $returnmodule == "Accounts" || $returnmodule == "Contacts" || $returnmodule == "Leads")) { $reltable = 'vtiger_seproductsrel'; $condition = 'WHERE crmid = ? and setype = ?'; array_push($params, $recordid, $returnmodule); $field = $selectfield = 'productid'; $table = 'vtiger_products'; } elseif (($currentmodule == "Leads" || $currentmodule == "Accounts" || $currentmodule == "Potentials" || $currentmodule == "Contacts") && $returnmodule == "Products") { $reltable = 'vtiger_seproductsrel'; $condition = 'WHERE productid = ? and setype = ?'; array_push($params, $recordid, $currentmodule); $selectfield = 'crmid'; if ($currentmodule == "Leads") { $field = 'leadid'; $table = 'vtiger_leaddetails'; } elseif ($currentmodule == "Accounts") { $field = 'accountid'; $table = 'vtiger_account'; } elseif ($currentmodule == "Contacts") { $field = 'contactid'; $table = 'vtiger_contactdetails'; } elseif ($currentmodule == "Potentials") { $field = 'potentialid'; $table = 'vtiger_potential'; } } elseif ($currentmodule == "Products" && $returnmodule == "Vendors") { $reltable = 'vtiger_products'; $condition = 'WHERE vendor_id = ?'; array_push($params, $recordid); $field = $selectfield = 'productid'; $table = 'vtiger_products'; } elseif ($currentmodule == "Documents") { $reltable = "vtiger_senotesrel"; $selectfield = "notesid"; $condition = "where crmid = ?"; array_push($params, $recordid); $table = "vtiger_notes"; $field = "notesid"; } //end if ($reltable != null) { $query = "SELECT " . $selectfield . " FROM " . $reltable . " " . $condition; } elseif ($currentmodule != $returnmodule && $returnmodule != "") { // If none of the above relation matches, then the relation is assumed to be stored in vtiger_crmentityrel $query = "SELECT relcrmid AS relatedid FROM vtiger_crmentityrel WHERE crmid = ? and module = ? and relmodule = ?\n\t\t\t\t\tUNION SELECT crmid AS relatedid FROM vtiger_crmentityrel WHERE relcrmid = ? and relmodule = ? and module = ?"; array_push($params, $recordid, $returnmodule, $currentmodule, $recordid, $returnmodule, $currentmodule); $focus_obj = CRMEntity::getInstance($currentmodule); $field = $focus_obj->table_index; $table = $focus_obj->table_name; $selectfield = 'relatedid'; } if ($query != '') { $result = $adb->pquery($query, $params); if ($adb->num_rows($result) != 0) { for ($k = 0; $k < $adb->num_rows($result); $k++) { $skip_id[] = $adb->query_result($result, $k, $selectfield); } $skipids = implode(",", constructList($skip_id, 'INTEGER')); if (count($skipids) > 0) { $where_relquery = "and " . $table . "." . $field . " not in (" . $skipids . ")"; } } } $log->debug("Exiting getRelCheckquery method ..."); return $where_relquery; }
global $current_user; //set the return module and return action and set the return id based on return module and record $returnmodule = vtlib_purify($_REQUEST['return_module']); $returnaction = vtlib_purify($_REQUEST['return_action']); if (($returnmodule != 'Emails' || $returnmodule == 'Emails' && $_REQUEST['record'] == '') && $_REQUEST['return_id'] != '') { $returnid = vtlib_purify($_REQUEST['return_id']); } else { $returnid = $focus->id; //$_REQUEST['record']; } $adb->println("\n\nMail Sending Process has been started."); //This function call is used to send mail to the assigned to user. In this mail CC and BCC addresses will be added. if ($_REQUEST['assigntype' == 'T'] && $_REQUEST['assigned_group_id'] != '') { $grp_obj = new GetGroupUsers(); $grp_obj->getAllUsersInGroup($_REQUEST['assigned_group_id']); $users_list = constructList($grp_obj->group_users, 'INTEGER'); if (count($users_list) > 0) { $sql = "select first_name, last_name, email1, email2, yahoo_id from vtiger_users where id in (" . generateQuestionMarks($users_list) . ")"; $params = array($users_list); } else { $sql = "select first_name, last_name, email1, email2, yahoo_id from vtiger_users"; $params = array(); } $res = $adb->pquery($sql, $params); $user_email = ''; while ($user_info = $adb->fetch_array($res)) { $email = $user_info['email1']; if ($email == '' || $email == 'NULL') { $email = $user_info['email2']; if ($email == '' || $email == 'NULL') { $email = $user_info['yahoo_id'];