/** Returns a list of the associated opportunities */ function get_opportunities($id, $cur_tab_id, $rel_tab_id, $actions = false) { global $log, $singlepane_view, $currentModule, $current_user, $adb; $log->debug("Entering get_opportunities(" . $id . ") method ..."); $this_module = $currentModule; $related_module = vtlib_getModuleNameById($rel_tab_id); require_once "modules/{$related_module}/{$related_module}.php"; $other = new $related_module(); vtlib_setup_modulevars($related_module, $other); $singular_modname = vtlib_toSingular($related_module); $parenttab = getParentTab(); if ($singlepane_view == 'true') { $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; } else { $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; } $button = ''; if ($actions) { if (is_string($actions)) { $actions = explode(',', strtoupper($actions)); } if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}&parenttab={$parenttab}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> "; } if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') { $wfs = new VTWorkflowManager($adb); $racbr = $wfs->getRACRuleForRecord($currentModule, $id); if (!$racbr or $racbr->hasRelatedListPermissionTo('create', $related_module)) { $button .= "<input title='" . getTranslatedString('LBL_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\";' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'> "; } } } $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query = 'select case when (vtiger_users.user_name not like "") then ' . $userNameSql . ' else vtiger_groups.groupname end as user_name, vtiger_contactdetails.accountid, vtiger_contactdetails.contactid , vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_potential.potentialtype, vtiger_potential.sales_stage, vtiger_potential.amount, vtiger_potential.closingdate, vtiger_potential.related_to, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_account.accountname from vtiger_contactdetails left join vtiger_contpotentialrel on vtiger_contpotentialrel.contactid=vtiger_contactdetails.contactid left join vtiger_potential on (vtiger_potential.potentialid = vtiger_contpotentialrel.potentialid or vtiger_potential.related_to=vtiger_contactdetails.contactid) inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_contactdetails.contactid =' . $id . ' and (vtiger_contactdetails.accountid = vtiger_potential.related_to or vtiger_contactdetails.contactid=vtiger_potential.related_to) and vtiger_crmentity.deleted=0'; $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); if ($return_value == null) { $return_value = array(); } $return_value['CUSTOM_BUTTON'] = $button; $log->debug("Exiting get_opportunities method ..."); return $return_value; }
/** * Default (generic) function to handle the dependents list for the module. * NOTE: UI type '10' is used to stored the references to other modules for a given record. * These dependent records can be retrieved through this function. * For eg: A trouble ticket can be related to an Account or a Contact. * From a given Contact/Account if we need to fetch all such dependent trouble tickets, get_dependents_list function can be used. */ function get_dependents_list($id, $cur_tab_id, $rel_tab_id, $actions = false) { global $currentModule, $app_strings, $singlepane_view, $current_user, $adb; $parenttab = getParentTab(); $related_module = vtlib_getModuleNameById($rel_tab_id); $other = CRMEntity::getInstance($related_module); // Some standard module class doesn't have required variables // that are used in the query, they are defined in this generic API vtlib_setup_modulevars($currentModule, $this); vtlib_setup_modulevars($related_module, $other); $singular_modname = 'SINGLE_' . $related_module; $button = ''; // To make the edit or del link actions to return back to same view. if ($singlepane_view == 'true') { $returnset = "&return_module={$currentModule}&return_action=DetailView&return_id={$id}"; } else { $returnset = "&return_module={$currentModule}&return_action=CallRelatedList&return_id={$id}"; } $return_value = null; $dependentFieldSql = $this->db->pquery("SELECT tabid, tablename, fieldname, columnname FROM vtiger_field WHERE uitype='10' AND" . " fieldid IN (SELECT fieldid FROM vtiger_fieldmodulerel WHERE relmodule=? AND module=?)", array($currentModule, $related_module)); $numOfFields = $this->db->num_rows($dependentFieldSql); if ($numOfFields > 0) { $relconds = array(); while ($depflds = $this->db->fetch_array($dependentFieldSql)) { $dependentTable = $depflds['tablename']; if ($dependentTable != $other->table_name and !in_array($dependentTable, $other->related_tables)) { $relidx = isset($other->tab_name_index[$dependentTable]) ? $other->tab_name_index[$dependentTable] : $other->table_index; $other->related_tables[$dependentTable] = array($relidx, $other->table_name, $other->table_index); } $dependentColumn = $depflds['columnname']; $dependentField = $depflds['fieldname']; $relconds[] = "{$this->table_name}.{$this->table_index} = {$dependentTable}.{$dependentColumn}"; $button .= '<input type="hidden" name="' . $dependentColumn . '" id="' . $dependentColumn . '" value="' . $id . '">'; $button .= '<input type="hidden" name="' . $dependentColumn . '_type" id="' . $dependentColumn . '_type" value="' . $currentModule . '">'; } $relationconditions = '(' . implode(' or ', $relconds) . ')'; if ($actions) { if (is_string($actions)) { $actions = explode(',', strtoupper($actions)); } $wfs = ''; if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes' && getFieldVisibilityPermission($related_module, $current_user->id, $dependentField, 'readwrite') == '0') { $wfs = new VTWorkflowManager($adb); $racbr = $wfs->getRACRuleForRecord($currentModule, $id); if (!$racbr or $racbr->hasRelatedListPermissionTo('create', $related_module)) { $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $related_module) . "'> "; } } } $query = "SELECT vtiger_crmentity.*, {$other->table_name}.*"; $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query .= ", CASE WHEN (vtiger_users.user_name NOT LIKE '') THEN {$userNameSql} ELSE vtiger_groups.groupname END AS user_name"; $more_relation = ''; if (!empty($other->related_tables)) { foreach ($other->related_tables as $tname => $relmap) { $query .= ", {$tname}.*"; // Setup the default JOIN conditions if not specified if (empty($relmap[1])) { $relmap[1] = $other->table_name; } if (empty($relmap[2])) { $relmap[2] = $relmap[0]; } $more_relation .= " LEFT JOIN {$tname} ON {$tname}.{$relmap['0']} = {$relmap['1']}.{$relmap['2']}"; } } $query .= " FROM {$other->table_name}"; $query .= " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = {$other->table_name}.{$other->table_index}"; $query .= $more_relation; $query .= " INNER JOIN {$this->table_name} ON {$relationconditions}"; $query .= " LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid"; $query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid"; $query .= " WHERE vtiger_crmentity.deleted = 0 AND {$this->table_name}.{$this->table_index} = {$id}"; $return_value = GetRelatedList($currentModule, $related_module, $other, $query, $button, $returnset); } if ($return_value == null) { $return_value = array(); } $return_value['CUSTOM_BUTTON'] = $button; return $return_value; }
function getListViewEntries($focus, $module, $result, $navigationInfo, $skipActions = false) { require 'user_privileges/user_privileges_' . $this->user->id . '.php'; global $listview_max_textlength, $theme, $default_charset, $current_user, $currentModule, $adb; $fields = $this->queryGenerator->getFields(); $whereFields = $this->queryGenerator->getWhereFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $meta->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); if ($this->queryGenerator->getReferenceFieldInfoList()) { $accessibleFieldList = array_merge($this->queryGenerator->getReferenceFieldNameList(), $accessibleFieldList); } $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $listviewcolumns = $db->getFieldsArray($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } $fldcolname = $field->getColumnName(); $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $fldcolname); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!isset($this->ownerNameList[$fieldName]) or !is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { $newOwnerList = getOwnerNameList($idList); $this->ownerNameList[$fieldName] = $this->ownerNameList[$fieldName] + $newOwnerList; } } } } foreach ($listViewFields as $fieldName) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } $idList = array(); if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $modrel = getTabModuleName($field->getTabId()); $fldcolname = 'smowner' . strtolower($modrel); $j = $rowCount * $k; $k++; for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $fldcolname); if (!isset($this->ownerNameListrel[$fieldName][$id])) { $idList[$j] = $id; $j++; } } } else { if (getTabid($currentModule) != $field->getTabId() && $field->getFieldDataType() == 'reference') { $this->fetchNameList($field, $result, 1); } } if (count($idList) > 0) { if (!isset($this->ownerNameListrel[$fieldName]) or !is_array($this->ownerNameListrel[$fieldName])) { $this->ownerNameListrel[$fieldName] = getOwnerNameList($idList); } else { $newOwnerList = getOwnerNameList($idList); $this->ownerNameListrel[$fieldName] = $this->ownerNameListrel[$fieldName] + $newOwnerList; } } } $useAsterisk = get_use_asterisk($this->user->id); $wfs = new VTWorkflowManager($adb); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); $ownerId = $db->query_result($result, $i, "smownerid"); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } $uitype = $field->getUIType(); if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $modrel = getTabModuleName($field->getTabId()); $rawValue = $this->db->query_result($result, $i, "smowner" . strtolower($modrel)); } else { if (getTabid($currentModule) != $field->getTabId()) { $modrel = getTabModuleName($field->getTabId()); $relfieldname = strtolower($modrel) . $field->getColumnName(); if (in_array($relfieldname, $listviewcolumns)) { $rawValue = $this->db->query_result($result, $i, $relfieldname); } else { $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); } } else { $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); } } if ($module == 'Calendar') { $activityType = $this->db->query_result($result, $i, 'activitytype'); } if ($uitype != 8) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename') { $downloadtype = $db->query_result($result, $i, 'filelocationtype'); if ($downloadtype == 'I') { $ext = substr($value, strrpos($value, ".") + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $value = '--'; $fileicon = ''; } } else { $value = ' --'; $fileicon = ''; } $fileName = $db->query_result($result, $i, 'filename'); $downloadType = $db->query_result($result, $i, 'filelocationtype'); $status = $db->query_result($result, $i, 'filestatus'); $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($recordId)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($fileName != '' && $status == 1) { if ($downloadType == 'I') { $value = "<a href='index.php?module=uploads&action=downloadfile&" . "entityid={$recordId}&fileid={$fileId}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$recordId});'>" . textlength_check($value) . "</a>"; } elseif ($downloadType == 'E') { $value = "<a target='_blank' href='{$fileName}' onclick='javascript:" . "dldCntIncrease({$recordId});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . textlength_check($value) . "</a>"; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } elseif ($field->getFieldDataType() == 'picklist') { if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName])) { $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; } else { $value = getTranslatedString($value, $module); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); if ($field->getFieldDataType() == 'datetime') { $value .= ' ' . $date->getDisplayTime(); } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = number_format($value, 2, '.', ''); $currencyValue = CurrencyField::convertToUserFormat($value, null, true); $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol); } else { //changes made to remove vtiger_currency symbol in front of each potential amount if ($value != 0) { $value = CurrencyField::convertToUserFormat($value); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { if ($_SESSION['internal_mailer'] == 1) { //check added for email link in user detailview $fieldId = $field->getFieldId(); $value = "<a href=\"javascript:InternalMailer({$recordId},{$fieldId}," . "'{$fieldName}','{$module}','record_id');\">" . textlength_check($value) . "</a>"; } else { $value = '<a href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=' . 'Settings&roleid=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getUIType() == 69) { if ($module == 'Products') { $queryPrdt = 'SELECT vtiger_attachments.path,vtiger_attachments.attachmentsid,vtiger_attachments.`name` FROM vtiger_attachments INNER JOIN vtiger_seattachmentsrel ON vtiger_attachments.attachmentsid = vtiger_seattachmentsrel.attachmentsid INNER JOIN vtiger_products ON vtiger_seattachmentsrel.crmid = vtiger_products.productid where vtiger_seattachmentsrel.crmid=?'; $resultprdt = $this->db->pquery($queryPrdt, array($recordId)); if ($resultprdt and $this->db->num_rows($resultprdt) > 0) { $imgpath = $this->db->query_result($resultprdt, 0, 'path'); $attid = $this->db->query_result($resultprdt, 0, 'attachmentsid'); $imgfilename = $this->db->query_result($resultprdt, 0, 'name'); $value = "<div style='text-align:center;width:100%;'><img src='./" . $imgpath . $attid . '_' . $imgfilename . "' height='50'></div>"; } else { $value = ''; } } else { if ($module == 'Contacts') { $imageattachment = 'Image'; } else { $imageattachment = 'Attachment'; } //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t\t\t\t from vtiger_attachments\n\t\t\t\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t\t\t\t and vtiger_attachments.name = ?\n\t\t\t\t\t\t and vtiger_seattachmentsrel.crmid=?"; $image_res = $this->db->pquery($sql, array(str_replace(' ', '_', $value), $recordId)); $image_id = $this->db->query_result($image_res, 0, 'attachmentsid'); $image_path = $this->db->query_result($image_res, 0, 'path'); $image_name = urlencode(decode_html($this->db->query_result($image_res, 0, 'name'))); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { $ftype = $this->db->query_result($image_res, 0, 'type'); $isimage = stripos($ftype, 'image') !== false; if ($isimage) { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image'); $value = '<div style="width:100%;text-align:center;"><img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 50px;"></div>'; } else { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents'); $value = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>'; } } else { $value = ''; } } } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim(decode_html($val)), $this->picklistValueMap[$fieldName])) { $tmpArray[] = $notaccess; $tmp .= ', ' . $notaccess; } else { $tmpArray[] = $val; $tmp .= ', ' . $val; } } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getUIType() == 1024) { $content = array(); if ($value != '') { $arr_evo_actions = explode(' |##| ', $value); for ($fvalues = 0; $fvalues < sizeof($arr_evo_actions); $fvalues++) { $roleid = $arr_evo_actions[$fvalues]; $rolename = getRoleName($roleid); $content[$fvalues] = $rolename; } } $value = textlength_check(implode(', ', $content)); } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getFieldDataType() == 'phone') { if ($useAsterisk == 'true') { $value = "<a href='javascript:;' onclick='startCall("{$value}", " . ""{$recordId}")'>" . textlength_check($value) . "</a>"; } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); if (getTabid($currentModule) != $field->getTabId()) { $modrel = getTabModuleName($field->getTabId()); $fieldName = str_replace($modrel . '.', "", $fieldName); } $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = $moduleList[0]; } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a href='index.php?module={$parentModule}&action=DetailView&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; $modMetaInfo = getEntityFieldNames($parentModule); $fieldName = is_array($modMetaInfo['fieldname']) ? $modMetaInfo['fieldname'][0] : $modMetaInfo['fieldname']; // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$rawValue}' vtfieldname=" . "'{$fieldName}' vtmodule='{$parentModule}' style='display:none;'></span>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $value = textlength_check($this->ownerNameListrel[$fieldName][$value]); } else { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } elseif ($field->getUIType() == 55) { $value = getTranslatedString($value, $currentModule); } else { $value = textlength_check($value); } if ($field->getFieldDataType() != 'reference') { $parenttab = getParentTab(); $nameFields = $this->queryGenerator->getModuleNameFields($module); $nameFieldList = explode(',', $nameFields); if (in_array($fieldName, $nameFieldList) && $module != 'Emails') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } elseif ($fieldName == $focus->list_link_field && $module != 'Emails') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=" . "'{$fieldName}' vtmodule='{$module}' style='display:none;'></span>"; // END } $row[] = $value; } //Added for Actions ie., edit and delete links in listview $actionLinkInfo = ""; if (isPermitted($module, "EditView", "") == 'yes') { $racbr = $wfs->getRACRuleForRecord($currentModule, $recordId); if (!$racbr or $racbr->hasListViewPermissionTo('edit')) { $edit_link = $this->getListViewEditLink($module, $recordId); if (isset($navigationInfo['start']) && $navigationInfo['start'] > 1 && $module != 'Emails') { $actionLinkInfo .= "<a href=\"{$edit_link}&start=" . $navigationInfo['start'] . "\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } else { $actionLinkInfo .= "<a href=\"{$edit_link}\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } } } if (isPermitted($module, "Delete", "") == 'yes') { $racbr = $wfs->getRACRuleForRecord($currentModule, $recordId); if (!$racbr or $racbr->hasListViewPermissionTo('delete')) { $del_link = $this->getListViewDeleteLink($module, $recordId); if ($actionLinkInfo != "" && $del_link != "") { $actionLinkInfo .= ' | '; } if ($del_link != "") { $actionLinkInfo .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . getTranslatedString('LNK_DELETE', $module) . '</a>'; } } } // Record Change Notification if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) { if (!$focus->isViewed($recordId)) { $actionLinkInfo .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>"; } } // END if ($actionLinkInfo != "" && !$skipActions) { $row[] = $actionLinkInfo; } list($row, $unused, $unused2) = cbEventHandler::do_filter('corebos.filter.listview.render', array($row, $this->db->query_result_rowdata($result, $i), $recordId)); $data[$recordId] = $row; } return $data; }
/** Function to check if the currently logged in user is permitted to perform the specified action * @param $module -- Module Name:: Type varchar * @param $actionname -- Action Name:: Type varchar * @param $recordid -- Record Id:: Type integer * @returns yes or no. If Yes means this action is allowed for the currently logged in user. If no means this action is not allowed for the currently logged in user */ function _vtisPermitted($module, $actionname, $record_id = '') { global $log, $adb, $current_user, $seclog; $log->debug("Entering isPermitted(" . $module . "," . $actionname . "," . $record_id . ") method ..."); if (strpos($record_id, 'x') > 0) { // is webserviceid list($void, $record_id) = explode('x', $record_id); } require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; $parenttab = empty($_REQUEST['parenttab']) ? '' : vtlib_purify($_REQUEST['parenttab']); $permission = "no"; if (($module == 'Users' || $module == 'Home' || $module == 'uploads') && $parenttab != 'Settings') { //These modules dont have security right now $permission = "yes"; $log->debug("Exiting isPermitted method ..."); return $permission; } //Checking the Access for the Settings Module if ($module == 'Settings' || $module == 'Administration' || $parenttab == 'Settings') { if (!$is_admin) { $permission = "no"; } else { $permission = "yes"; } $log->debug("Exiting isPermitted method ..."); return $permission; } //Checking whether the user is admin if ($is_admin) { $permission = "yes"; $log->debug("Exiting isPermitted method ..."); return $permission; } //Retreiving the Tabid and Action Id $tabid = getTabid($module); $actionid = getActionid($actionname); //If no actionid, then allow action is vtiger_tab permission is available if ($actionid === '') { if ($profileTabsPermission[$tabid] == 0) { $permission = "yes"; $log->debug("Exiting isPermitted method ..."); } else { $permission = "no"; } return $permission; } $action = getActionname($actionid); //Checking for view all permission if ($profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { if ($actionid == 3 || $actionid == 4) { $permission = "yes"; $log->debug("Exiting isPermitted method ..."); return $permission; } } //Checking for edit all permission if ($profileGlobalPermission[2] == 0) { if ($actionid == 3 || $actionid == 4 || $actionid == 0 || $actionid == 1) { $permission = "yes"; $log->debug("Exiting isPermitted method ..."); return $permission; } } //Checking for vtiger_tab permission if ($profileTabsPermission[$tabid] != 0) { $permission = "no"; $log->debug("Exiting isPermitted method ..."); return $permission; } if (!isset($profileActionPermission[$tabid][$actionid]) && ($action == 'Export' || $action == 'Import')) { return "no"; } //Checking for Action Permission if (strlen($profileActionPermission[$tabid][$actionid]) < 1 && $profileActionPermission[$tabid][$actionid] == '') { $permission = "yes"; $log->debug("Exiting isPermitted method ..."); return $permission; } if ($profileActionPermission[$tabid][$actionid] != 0 && $profileActionPermission[$tabid][$actionid] != '') { $permission = "no"; $log->debug("Exiting isPermitted method ..."); return $permission; } //Checking and returning true if recorid is null if ($record_id == '') { $permission = "yes"; $log->debug("Exiting isPermitted method ..."); return $permission; } //If modules is Faq or PriceBook then no sharing if ($record_id != '') { if (getTabOwnedBy($module) == 1) { $permission = "yes"; $log->debug("Exiting isPermitted method ..."); return $permission; } } //Retreiving the RecordOwnerId $recOwnType = ''; $recOwnId = ''; $recordOwnerArr = getRecordOwnerId($record_id); foreach ($recordOwnerArr as $type => $id) { $recOwnType = $type; $recOwnId = $id; } //Retreiving the default Organisation sharing Access $others_permission_id = $defaultOrgSharingPermission[$tabid]; if ($recOwnType == 'Users') { $wfs = new VTWorkflowManager($adb); $racbr = $wfs->getRACRuleForRecord($module, $record_id); //Checking if the Record Owner is the current User if ($current_user->id == $recOwnId) { if ($actionname != 'EditView' and $actionname != 'Delete' and $actionname != 'DetailView' and $actionname != 'CreateView' or (!$racbr or $racbr->hasDetailViewPermissionTo($actionname, true))) { $permission = 'yes'; } else { $permission = 'no'; } $log->debug("Exiting isPermitted method ..."); return $permission; } //Checking if the Record Owner is the Subordinate User foreach ($subordinate_roles_users as $roleid => $userids) { if (in_array($recOwnId, $userids)) { $permission = 'yes'; $log->debug("Exiting isPermitted method ..."); return $permission; } } if ($racbr !== false and $racbr->hasDetailViewPermissionTo($actionname, false)) { $log->debug("Exiting isPermitted method via RAC User..."); return 'yes'; } } elseif ($recOwnType == 'Groups') { //Checking if the record owner is the current user's group if (in_array($recOwnId, $current_user_groups)) { $wfs = new VTWorkflowManager($adb); $racbr = $wfs->getRACRuleForRecord($module, $record_id); if ($actionname != 'EditView' and $actionname != 'Delete' and $actionname != 'DetailView' and $actionname != 'CreateView' or (!$racbr or $racbr->hasDetailViewPermissionTo($actionname))) { $permission = 'yes'; } else { $permission = 'no'; } $log->debug("Exiting isPermitted method ..."); return $permission; } } //Checking for Default Org Sharing permission if ($others_permission_id == 0) { if ($actionid == 1 || $actionid == 0) { if ($module == 'Calendar') { if ($recOwnType == 'Users') { $permission = isCalendarPermittedBySharing($record_id); } else { $permission = 'no'; } } else { $permission = isReadWritePermittedBySharing($module, $tabid, $actionid, $record_id); } $log->debug("Exiting isPermitted method ..."); return $permission; } elseif ($actionid == 2) { $permission = "no"; $log->debug("Exiting isPermitted method ..."); return $permission; } else { $permission = "yes"; $log->debug("Exiting isPermitted method ..."); return $permission; } } elseif ($others_permission_id == 1) { if ($actionid == 2) { $permission = "no"; $log->debug("Exiting isPermitted method ..."); return $permission; } else { $permission = "yes"; $log->debug("Exiting isPermitted method ..."); return $permission; } } elseif ($others_permission_id == 2) { $wfs = new VTWorkflowManager($adb); $racbr = $wfs->getRACRuleForRecord($module, $record_id); if ($actionname != 'EditView' and $actionname != 'Delete' and $actionname != 'DetailView' and $actionname != 'CreateView' or (!$racbr or $racbr->hasDetailViewPermissionTo($actionname))) { $permission = "yes"; $log->debug("Exiting isPermitted method ..."); return $permission; } } elseif ($others_permission_id == 3) { if ($actionid == 3 || $actionid == 4) { if ($module == 'Calendar') { if ($recOwnType == 'Users') { $permission = isCalendarPermittedBySharing($record_id); } else { $permission = 'no'; } } else { $wfs = new VTWorkflowManager($adb); $racbr = $wfs->getRACRuleForRecord($module, $record_id); if ($racbr) { if ($actionid == 3 and !$racbr->hasListViewPermissionTo('retrieve')) { return 'no'; } elseif ($actionid == 4 and !$racbr->hasDetailViewPermissionTo('retrieve')) { return 'no'; } } $permission = isReadPermittedBySharing($module, $tabid, $actionid, $record_id); } $log->debug("Exiting isPermitted method ..."); return $permission; } elseif ($actionid == 0 || $actionid == 1) { if ($module == 'Calendar') { $permission = 'no'; } else { $wfs = new VTWorkflowManager($adb); $racbr = $wfs->getRACRuleForRecord($module, $record_id); if ($racbr) { if ($actionid == 0 and !$racbr->hasDetailViewPermissionTo('create')) { return 'no'; } elseif ($actionid == 1 and !$racbr->hasDetailViewPermissionTo('update')) { return 'no'; } } $permission = isReadWritePermittedBySharing($module, $tabid, $actionid, $record_id); } $log->debug("Exiting isPermitted method ..."); return $permission; } elseif ($actionid == 2) { $permission = "no"; return $permission; } else { $permission = "yes"; $log->debug("Exiting isPermitted method ..."); return $permission; } } else { $permission = "yes"; } $log->debug("Exiting isPermitted method ..."); return $permission; }
function getListViewEntries($focus, $module, $list_result, $navigation_array, $relatedlist = '', $returnset = '', $edit_action = 'EditView', $del_action = 'Delete', $oCv = '', $page = '', $selectedfields = '', $contRelatedfields = '', $skipActions = false) { global $log, $mod_strings, $adb, $current_user, $app_strings, $theme; $log->debug("Entering getListViewEntries(" . get_class($focus) . "," . $module . "," . $list_result . "," . $relatedlist . "," . $returnset . "," . $edit_action . "," . $del_action . "," . (is_object($oCv) ? get_class($oCv) : $oCv) . ") method ..."); $tabname = getParentTab(); $noofrows = $adb->num_rows($list_result); $list_block = array(); $evt_status = ''; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $tabid = getTabid($module); $bmapname = $module . '_ListColumns'; $cbMapid = GlobalVariable::getVariable('BusinessMapping_' . $bmapname, cbMap::getMapIdByName($bmapname)); if ($cbMapid) { $cbMap = cbMap::getMapByID($cbMapid); $cbMapLC = $cbMap->ListColumns(); $parentmodule = vtlib_purify($_REQUEST['module']); $focus->list_fields = $cbMapLC->getListFieldsFor($parentmodule); $focus->list_fields_name = $cbMapLC->getListFieldsNameFor($parentmodule); $focus->list_link_field = $cbMapLC->getListLinkFor($parentmodule); if ($parentmodule == 'Home' and $cbMapLC->issetListFieldsMappingFor('Home')) { $oCv->list_fields = $focus->list_fields; $oCv->list_fields_name = $focus->list_fields_name; } } if ($oCv) { if (isset($oCv->list_fields)) { $focus->list_fields = $oCv->list_fields; } } if (is_array($selectedfields) && $selectedfields != '') { $focus->list_fields = $selectedfields; } // Remove fields which are made inactive $focus->filterInactiveFields($module); //Added to reduce the no. of queries logging for non-admin user -- by minnie-start $field_list = array(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; foreach ($focus->list_fields as $name => $tableinfo) { $fieldname = $focus->list_fields_name[$name]; if ($oCv) { if (isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; } } if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } array_push($field_list, $fieldname); } $field = array(); if ($is_admin == false) { if ($module == 'Emails') { $query = "SELECT fieldname FROM vtiger_field WHERE tabid = ? and vtiger_field.presence in (0,2)"; $params = array($tabid); } else { $profileList = getCurrentUserProfileList(); $params = array(); $query = "SELECT DISTINCT vtiger_field.fieldname\n\t\t\t\tFROM vtiger_field\n\t\t\t\tINNER JOIN vtiger_profile2field\n\t\t\t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid"; if ($module == "Calendar") { $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)"; } else { $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)"; array_push($params, $tabid); } $query .= " AND vtiger_profile2field.visible = 0\n\t\t\t\t\tAND vtiger_profile2field.visible = 0\n\t\t\t\t\tAND vtiger_def_org_field.visible = 0\n\t\t\t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\n\t\t\t\t\tAND vtiger_field.fieldname IN (" . generateQuestionMarks($field_list) . ")"; array_push($params, $profileList, $field_list); } $result = $adb->pquery($query, $params); for ($k = 0; $k < $adb->num_rows($result); $k++) { $field[] = $adb->query_result($result, $k, "fieldname"); } } //constructing the uitype and columnname array $ui_col_array = array(); $params = array(); $query = "SELECT uitype, columnname, fieldname FROM vtiger_field "; if ($module == "Calendar") { $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)"; } else { $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)"; array_push($params, $tabid); } $query .= " AND fieldname IN (" . generateQuestionMarks($field_list) . ") "; array_push($params, $field_list); $result = $adb->pquery($query, $params); $num_rows = $adb->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $tempArr = array(); $uitype = $adb->query_result($result, $i, 'uitype'); $columnname = $adb->query_result($result, $i, 'columnname'); $field_name = $adb->query_result($result, $i, 'fieldname'); $tempArr[$uitype] = $columnname; $ui_col_array[$field_name] = $tempArr; } //end if (is_array($navigation_array) && isset($navigation_array['start']) && $navigation_array['start'] > 1 && $module != 'Emails') { $linkstart = '&start=' . $navigation_array['start']; } elseif (isset($_REQUEST['start']) && $_REQUEST['start'] > 1 && $module != 'Emails') { $linkstart = '&start=' . vtlib_purify($_REQUEST['start']); } else { $linkstart = ''; } $wfs = new VTWorkflowManager($adb); if ($navigation_array['start'] != 0) { for ($i = 1; $i <= $noofrows; $i++) { $list_header = array(); //Getting the entityid if ($module != 'Users') { $entity_id = $adb->query_result($list_result, $i - 1, "crmid"); $owner_id = $adb->query_result($list_result, $i - 1, "smownerid"); } else { $entity_id = $adb->query_result($list_result, $i - 1, "id"); } foreach ($focus->list_fields as $name => $tableinfo) { $fieldname = $focus->list_fields_name[$name]; //added for vtiger_customview 27/5 if ($oCv) { if (isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } } else { $fieldname = $focus->list_fields_name[$name]; } } else { $fieldname = $focus->list_fields_name[$name]; if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } } if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || in_array($fieldname, $field) || $fieldname == '' || $name == 'Close' && $module == 'Calendar') { if ($fieldname == '') { $table_name = ''; $column_name = ''; foreach ($tableinfo as $tablename => $colname) { $table_name = $tablename; $column_name = $colname; } $value = $adb->query_result($list_result, $i - 1, $colname); } else { if ($module == 'Calendar') { $act_id = $adb->query_result($list_result, $i - 1, "activityid"); $activitytype = $adb->query_result($list_result, $i - 1, 'activitytype'); if (empty($activitytype)) { $cal_sql = "select activitytype from vtiger_activity where activityid=?"; $cal_res = $adb->pquery($cal_sql, array($act_id)); if ($adb->num_rows($cal_res) >= 0) { $activitytype = $adb->query_result($cal_res, 0, "activitytype"); } } } if (($module == 'Calendar' || $module == 'Emails' || $module == 'HelpDesk' || $module == 'Invoice' || $module == 'Leads' || $module == 'Contacts') && ($fieldname == 'parent_id' || $name == 'Contact Name' || $name == 'Close' || $fieldname == 'firstname')) { if ($module == 'Calendar') { if ($fieldname == 'status') { if ($activitytype == 'Task') { $fieldname = 'taskstatus'; } else { $fieldname = 'eventstatus'; } } if ($activitytype == 'Task') { if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') { $has_permission = 'yes'; } else { $has_permission = 'no'; } } else { if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') { $has_permission = 'yes'; } else { $has_permission = 'no'; } } } if ($module != 'Calendar' || $module == 'Calendar' && $has_permission == 'yes') { if ($fieldname == 'parent_id') { $value = getRelatedTo($module, $list_result, $i - 1); } if ($name == 'Contact Name') { $contact_id = $adb->query_result($list_result, $i - 1, "contactid"); $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts"); $value = ""; //Added to get the contactname for activities custom view - t=2190 if ($contact_id != '' && !empty($contact_name)) { $displayValueArray = getEntityName('Contacts', $contact_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } } if ($contact_name != "" && $contact_id != 'NULL') { $value = "<a href='index.php?module=Contacts&action=DetailView&parenttab=" . $tabname . "&record=" . $contact_id . "'>" . textlength_check($contact_name) . "</a>"; } } if ($fieldname == "firstname") { $first_name = textlength_check($adb->query_result($list_result, $i - 1, "firstname")); $value = '<a href="index.php?action=DetailView&module=' . $module . '&parenttab=' . $tabname . '&record=' . $entity_id . '">' . $first_name . '</a>'; } if ($name == 'Close') { $status = $adb->query_result($list_result, $i - 1, "status"); $activityid = $adb->query_result($list_result, $i - 1, "activityid"); if (empty($activityid)) { $activityid = $adb->query_result($list_result, $i - 1, "tmp_activity_id"); } if ($activitytype != 'Task' && $activitytype != 'Emails') { $eventstatus = $adb->query_result($list_result, $i - 1, "eventstatus"); if (isset($eventstatus)) { $status = $eventstatus; } } if ($status == 'Deferred' || $status == 'Completed' || $status == 'Held' || $status == '') { $value = ""; } else { if ($activitytype == 'Task') { $evt_status = '&status=Completed'; } else { $evt_status = '&eventstatus=Held'; } if (isPermitted("Calendar", 'EditView', $activityid) == 'yes') { if ($returnset == '') { $returnset = '&return_module=Calendar&return_action=ListView&return_id=' . $activityid . '&return_viewname=' . $oCv->setdefaultviewid; } $value = "<a href='index.php?action=Save&module=Calendar&record=" . $activityid . "&parenttab=" . $tabname . "&change_status=true" . $returnset . $evt_status . "&start=" . $navigation_array['current'] . "'>X</a>"; } else { $value = ""; } } } } else { $value = ""; } } elseif ($module == "Documents" && ($fieldname == 'filelocationtype' || $fieldname == 'filename' || $fieldname == 'filesize' || $fieldname == 'filestatus' || $fieldname == 'filetype')) { $value = $adb->query_result($list_result, $i - 1, $fieldname); if ($fieldname == 'filelocationtype') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } if ($fieldname == 'filename') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); if ($downloadtype == 'I') { $fld_value = $value; $ext_pos = strrpos($fld_value, "."); $ext = substr($fld_value, $ext_pos + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fld_value = $value; $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $fld_value = '--'; $fileicon = ''; } } else { $fld_value = ' --'; $fileicon = ''; } $file_name = $adb->query_result($list_result, $i - 1, 'filename'); $notes_id = $adb->query_result($list_result, $i - 1, 'crmid'); $folder_id = $adb->query_result($list_result, $i - 1, 'folderid'); $download_type = $adb->query_result($list_result, $i - 1, 'filelocationtype'); $file_status = $adb->query_result($list_result, $i - 1, 'filestatus'); $fileidQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileidres = $adb->pquery($fileidQuery, array($notes_id)); $fileid = $adb->query_result($fileidres, 0, 'attachmentsid'); if ($file_name != '' && $file_status == 1) { if ($download_type == 'I') { $fld_value = "<a href='index.php?module=uploads&action=downloadfile&entityid={$notes_id}&fileid={$fileid}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$notes_id});'>" . textlength_check($fld_value) . "</a>"; } elseif ($download_type == 'E') { $fld_value = "<a target='_blank' href='{$file_name}' onclick='javascript:dldCntIncrease({$notes_id});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . textlength_check($fld_value) . "</a>"; } else { $fld_value = ' --'; } } $value = $fileicon . $fld_value; } if ($fieldname == 'filesize') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); if ($downloadtype == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } if ($fieldname == 'filestatus') { $filestatus = $value; if ($filestatus == 1) { $value = getTranslatedString('yes', $module); } elseif ($filestatus == 0) { $value = getTranslatedString('no', $module); } else { $value = ' --'; } } if ($fieldname == 'filetype') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); $filetype = $adb->query_result($list_result, $i - 1, 'filetype'); if ($downloadtype == 'E' || $downloadtype != 'I') { $value = ' --'; } else { $value = $filetype; } } if ($fieldname == 'notecontent') { $value = decode_html($value); $value = textlength_check($value); } } elseif ($module == "Products" && $name == "Related to") { $value = getRelatedTo($module, $list_result, $i - 1); $value = textlength_check($value); } elseif ($name == 'Contact Name' && ($module == 'SalesOrder' || $module == 'Quotes' || $module == 'PurchaseOrder')) { if ($name == 'Contact Name') { $contact_id = $adb->query_result($list_result, $i - 1, "contactid"); $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts"); $value = ""; if ($contact_name != "" && $contact_id != 'NULL') { $value = "<a href='index.php?module=Contacts&action=DetailView&parenttab=" . $tabname . "&record=" . $contact_id . "'>" . textlength_check($contact_name) . "</a>"; } } } elseif ($name == 'Product') { $product_id = textlength_check($adb->query_result($list_result, $i - 1, "productname")); $value = $product_id; } elseif ($name == 'Account Name') { if ($module == 'Accounts') { $account_id = $adb->query_result($list_result, $i - 1, "crmid"); $account_name = $adb->query_result($list_result, $i - 1, 'accountname'); } elseif ($module == 'Potentials' || $module == 'Contacts' || $module == 'Invoice' || $module == 'SalesOrder' || $module == 'Quotes') { //Potential,Contacts,Invoice,SalesOrder & Quotes records sort by Account Name $account_name = $adb->query_result($list_result, $i - 1, 'accountname'); $account_id = $adb->query_result($list_result, $i - 1, "accountid"); } else { $account_id = $adb->query_result($list_result, $i - 1, "accountid"); $account_name = getAccountName($account_id); } if (empty($account_name)) { $account_name = getAccountName($account_id); } $acc_name = textlength_check($account_name); $value = '<a href="index.php?module=Accounts&action=DetailView&record=' . $account_id . '&parenttab=' . $tabname . '">' . htmlspecialchars($acc_name, ENT_QUOTES, $default_charset) . '</a>'; } elseif (($module == 'HelpDesk' || $module == 'PriceBook' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'Faq') && $name == 'Product Name') { if ($module == 'HelpDesk' || $module == 'Faq') { $product_id = $adb->query_result($list_result, $i - 1, "product_id"); } else { $product_id = $adb->query_result($list_result, $i - 1, "productid"); } if ($product_id != '') { $product_name = getProductName($product_id); } else { $product_name = ''; } $value = '<a href="index.php?module=Products&action=DetailView&parenttab=' . $tabname . '&record=' . $product_id . '">' . textlength_check($product_name) . '</a>'; } elseif ($module == 'Quotes' && $name == 'Potential Name' || $module == 'SalesOrder' && $name == 'Potential Name') { $potential_id = $adb->query_result($list_result, $i - 1, "potentialid"); $potential_name = getPotentialName($potential_id); $value = '<a href="index.php?module=Potentials&action=DetailView&parenttab=' . $tabname . '&record=' . $potential_id . '">' . textlength_check($potential_name) . '</a>'; } elseif ($module == 'Emails' && $relatedlist != '' && ($name == 'Subject' || $name == 'Date Sent' || $name == 'To')) { $list_result_count = $i - 1; $tmp_value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); $attrs = $adb->pquery('select count(*) from vtiger_seattachmentsrel where crmid=?', array($entity_id)); $atts = $adb->query_result($attrs, 0, 0); if ($atts > 0) { $value = '<img src="themes/images/attachments.gif"> '; } else { $value = ''; } $value .= '<a href="javascript:;" onClick="ShowEmail(\'' . $entity_id . '\');">' . textlength_check($tmp_value) . '</a>'; if ($name == 'Date Sent') { if (Emails::EmailHasBeenSent($entity_id)) { $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } else { $value = ''; } } } elseif ($module == 'Calendar' && ($fieldname != 'taskstatus' && $fieldname != 'eventstatus')) { if ($activitytype == 'Task') { if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } else { $value = ''; } } else { if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } else { $value = ''; } } } elseif ($module == 'PriceBooks' && $fieldname == 'listprice') { $val_raw = $adb->query_result($list_result, $i - 1, $fieldname); $value = $val_raw; } else { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } } // vtlib customization: For listview javascript triggers if (strpos($value, 'vtlib_metainfo') === false) { $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$entity_id}' vtfieldname='{$fieldname}' vtmodule='{$module}' style='display:none;'></span>"; } // END if ($module == "Calendar" && $name == 'Close') { if (isPermitted("Calendar", "EditView") == 'yes') { if (getFieldVisibilityPermission('Events', $current_user->id, 'eventstatus') == '0' || getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') { array_push($list_header, $value); } } } else { $list_header[] = $value; } } } $varreturnset = ''; if ($returnset == '') { $varreturnset = '&return_module=' . $module . '&return_action=index'; } else { $varreturnset = $returnset; } if ($module == 'Calendar') { $actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype'); if ($actvity_type == 'Task') { $varreturnset .= '&activity_mode=Task'; } else { $varreturnset .= '&activity_mode=Events'; } } //Added for Actions ie., edit and delete links in listview $links_info = ''; if (!(is_array($selectedfields) && $selectedfields != '')) { if (isPermitted($module, 'EditView', '') == 'yes') { $racbr = $wfs->getRACRuleForRecord($module, $entity_id); if (!$racbr or $racbr->hasListViewPermissionTo('edit')) { $edit_link = getListViewEditLink($module, $entity_id, $relatedlist, $varreturnset, $list_result, $list_result_count); $links_info .= "<a href=\"{$edit_link}{$linkstart}\">" . $app_strings['LNK_EDIT'] . "</a> "; } } if (isPermitted($module, 'Delete', '') == 'yes') { $racbr = $wfs->getRACRuleForRecord($module, $entity_id); if (!$racbr or $racbr->hasListViewPermissionTo('delete')) { $del_link = getListViewDeleteLink($module, $entity_id, $relatedlist, $varreturnset, $linkstart); if ($links_info != '' && $del_link != '') { $links_info .= ' | '; } if ($del_link != '') { $links_info .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . $app_strings["LNK_DELETE"] . "</a>"; } } } } // Record Change Notification if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) { if (!$focus->isViewed($entity_id)) { $links_info .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>"; } } // END if ($links_info != "" && !$skipActions) { $list_header[] = $links_info; } list($list_header, $unused, $unused2) = cbEventHandler::do_filter('corebos.filter.listview.render', array($list_header, $adb->query_result_rowdata($list_result, $i - 1), $entity_id)); $list_block[$entity_id] = $list_header; } } $log->debug("Exiting getListViewEntries method ..."); return $list_block; }