/** * @dataProvider xssData */ public function testXssFilterBean($before, $after) { $bean = new EmailTemplate(); $bean->body_html = to_html($before); $bean->cleanBean(); $this->assertEquals(to_html($after), $bean->body_html); }
function safeHtmlFilter($content, $smarty) { //return htmlspecialchars($content,ENT_QUOTES,UTF-8); // NOTE: to_html is being used as data-extraction depends on this // We shall improve this as it plays role across the product. return to_html($content); }
public function testto_html() { //execute the method and test if it returns expected values $string = ''; $expected = ''; $actual = to_html($string); $this->assertSame($expected, $actual); $string = "'test'&trial<\">"; $expected = ''test'&trial<">'; $actual = to_html($string); $this->assertSame($expected, $actual); }
/** * Generating new label with HTML tags * @group 43069 */ public function testLabelSaving() { $mod_strings = return_module_language($this->_lang, $this->_test_module); $this->_old_label = $mod_strings[$this->_test_label]; $pref = '<img alt="<script>" src="www.test.com/img.png" ="alert(7001)" width="1" height="1"/>'; $prepared_pref = to_html(strip_tags(from_html($pref))); $new_label = $prepared_pref . ' ' . $this->_old_label; // save the new label to the language file ParserLabel::addLabels($this->_lang, array($this->_test_label => $new_label), $this->_test_module); // read the language file to get the new value include "custom/modules/{$this->_test_module}/language/{$this->_lang}.lang.php"; $this->assertEquals($new_label, $mod_strings[$this->_test_label]); $this->assertNotEquals($pref . ' ' . $this->_old_label, $mod_strings[$this->_test_label]); }
protected function ConstruireElemRetourInvisible(&$element) { $retourInvisible = 'contexte=' . CONT_ORIENTATION . '&cf=' . GSession::NumCheckFormulaire(); foreach ($this->champs as $nomChamp => $champ) { if ($champ[LISTE_CHAMPLISTE_RETOURINVISIBLE] === true) { if ($retourInvisible !== '') { $retourInvisible .= '&'; } $retourInvisible .= GContexte::FormaterVariable(CONT_ORIENTATION, $nomChamp) . '=' . $element[$nomChamp][LISTE_ELEMENT_VALEURCONSULT]; } } // On enregistre ce retour pour l'élément. $element[LISTE_ELEMENT_RETOUR] = to_html($retourInvisible); $divRetInv = new SBalise(BAL_DIV); $divRetInv->AddClass(LISTE_JQ_ELEMENT_PARAM); $divRetInv->SetText($element[LISTE_ELEMENT_RETOUR]); return $divRetInv; }
public function getCurrentUserSidebarFavorites($id = null) { global $db, $current_user; $return_array = array(); if ($id) { $query = "SELECT parent_id, parent_type FROM favorites WHERE assigned_user_id = '" . $current_user->id . "' AND parent_id = '" . $id . "' AND deleted = 0 ORDER BY date_entered desc"; } else { $query = "SELECT parent_id, parent_type FROM favorites WHERE assigned_user_id = '" . $current_user->id . "' AND deleted = 0 ORDER BY date_entered desc"; } $result = $db->query($query); $i = 0; while ($row = $db->fetchByAssoc($result)) { $bean = BeanFactory::getBean($row['parent_type'], $row['parent_id']); $return_array[$i]['item_summary'] = $bean->name; $return_array[$i]['item_summary_short'] = to_html(getTrackerSubstring($bean->name)); $return_array[$i]['id'] = $row['parent_id']; $return_array[$i]['module_name'] = $row['parent_type']; $return_array[$i]['image'] = SugarThemeRegistry::current()->getImage($row['parent_type'], 'border="0" align="absmiddle"', null, null, '.gif', $bean->name); $i++; } return $return_array; }
public function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $tplId = $request->get('id'); $record = $request->get('record_id'); $selectModule = $request->get('select_module'); $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName); $output = $recordModel->getTemplete($tplId); if ($record && $selectModule) { $recordModel->findVar($output['content'], 0, $record, $selectModule, 'a', $request); $recordModel->findVar($output['content'], 0, $record, $selectModule, 'b', $request); $recordModel->findVar($output['content'], 0, $record, $selectModule, 'c', $request); $recordModel->findVar($output['content'], 0, $record, $selectModule, 'd', $request); $recordModel->findVar($output['content'], 0, $record, $selectModule, 's', $request); } if ('true' === $request->get('as_var')) { $output['content'] = to_html($output['content']); return $output; } else { $response = new Vtiger_Response(); $response->setResult($output); $response->emit(); } }
function query_result_rowdata(&$result, $row = 0) { if (!is_object($result)) { throw new Exception("result is not an object"); } $result->Move($row); $rowdata = $this->change_key_case($result->FetchRow()); foreach ($rowdata as $col => $coldata) { if ($col != 'fieldlabel') { $rowdata[$col] = to_html($coldata); } } return $rowdata; }
/** * sets up the search forms, populates the preset values * */ function setup() { global $mod_strings, $app_strings, $app_list_strings, $theme, $timedate; $GLOBALS['log']->debug('SearchForm.php->setup()'); $this->xtpl = new XTemplate($this->tpl); $this->xtpl->assign("MOD", $mod_strings); $this->xtpl->assign("APP", $app_strings); $this->xtpl->assign("THEME", $theme); $this->xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format()); $this->xtpl->assign("USER_DATEFORMAT", '(' . $timedate->get_user_date_format() . ')'); foreach ($this->searchFields as $name => $params) { if (isset($params['template_var'])) { $templateVar = $params['template_var']; } else { $templateVar = strtoupper($name); } if (isset($params['value'])) { // populate w/ preselected values if (isset($params['options'])) { $options = $app_list_strings[$params['options']]; if (isset($params['options_add_blank']) && $params['options_add_blank']) { array_unshift($options, ''); } $this->xtpl->assign($templateVar, get_select_options_with_id($options, $params['value'])); } else { if (isset($params['input_type'])) { switch ($params['input_type']) { case 'checkbox': // checkbox input if ($params['value'] == 'on' || $params['value']) { $this->xtpl->assign($templateVar, 'checked'); } break; } } else { // regular text input if (is_array($params['value'])) { $value = array_map('to_html', $params['value']); } else { if (is_string($params['value'])) { $value = to_html($params['value']); } } $this->xtpl->assign($templateVar, $value); } } } else { // populate w/o preselected values if (isset($params['options'])) { $options = $app_list_strings[$params['options']]; if (isset($params['options_add_blank']) && $params['options_add_blank']) { array_unshift($options, ''); } $this->xtpl->assign($templateVar, get_select_options_with_id($options, '')); } } } if (!empty($_REQUEST['assigned_user_id'])) { $this->xtpl->assign("USER_FILTER", get_select_options_with_id(get_user_array(FALSE), $_REQUEST['assigned_user_id'])); } else { $this->xtpl->assign("USER_FILTER", get_select_options_with_id(get_user_array(FALSE), '')); } // handle my items only if (isset($this->searchFields['current_user_only']) && isset($this->searchFields['current_user_only']['value'])) { $this->xtpl->assign("CURRENT_USER_ONLY", "checked"); } }
********************************************************************************/ /********************************************************************************* * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Users/Authenticate.php,v 1.10 2005/02/28 05:25:22 jack Exp $ * Description: TODO: To be written. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ require_once 'modules/Users/Users.php'; require_once 'modules/Users/CreateUserPrivilegeFile.php'; require_once 'include/logging.php'; require_once 'user_privileges/audit_trail.php'; global $mod_strings, $default_charset; $focus = new Users(); // Add in defensive code here. $focus->column_fields["user_name"] = to_html($_REQUEST['user_name']); $user_password = vtlib_purify($_REQUEST['user_password']); $focus->load_user($user_password); if ($focus->is_authenticated()) { //Inserting entries for audit trail during login if ($audit_trail == 'true') { if ($record == '') { $auditrecord = ''; } else { $auditrecord = $record; } $date_var = $adb->formatDate(date('Y-m-d H:i:s'), true); $query = "insert into vtiger_audit_trial values(?,?,?,?,?,?)"; $params = array($adb->getUniqueID('vtiger_audit_trial'), $focus->id, 'Users', 'Authenticate', '', $date_var); $adb->pquery($query, $params); }
/** * @param string $string * @param bool $encoded * * @return mixed|string */ public static function stripTags($string, $encoded = true) { if ($encoded) { $string = from_html($string); } $string = filter_var($string, FILTER_SANITIZE_STRIPPED, FILTER_FLAG_NO_ENCODE_QUOTES); return $encoded ? to_html($string) : $string; }
/** * Generate the compose data package consumed by the full and quick compose screens. * * @param Array $data * @param Bool $forFullCompose If full compose is set to TRUE, then continue execution and include the full Emails UI. Otherwise * the data generated is returned. * @param SugarBean $bean Optional - parent object with data */ function generateComposeDataPackage($data, $forFullCompose = TRUE, $bean = null) { // we will need the following: if (isset($data['parent_type']) && !empty($data['parent_type']) && isset($data['parent_id']) && !empty($data['parent_id']) && !isset($data['ListView']) && !isset($data['replyForward'])) { if (empty($bean)) { global $beanList; global $beanFiles; global $mod_strings; $parentName = ''; $class = $beanList[$data['parent_type']]; require_once $beanFiles[$class]; $bean = new $class(); $bean->retrieve($data['parent_id']); } if (isset($bean->full_name)) { $parentName = $bean->full_name; } elseif (isset($bean->name)) { $parentName = $bean->name; } else { $parentName = ''; } $parentName = from_html($parentName); $namePlusEmail = ''; if (isset($data['to_email_addrs'])) { $namePlusEmail = $data['to_email_addrs']; $namePlusEmail = from_html(str_replace(" ", " ", $namePlusEmail)); } else { if (isset($bean->full_name)) { $namePlusEmail = from_html($bean->full_name) . " <" . from_html($bean->emailAddress->getPrimaryAddress($bean)) . ">"; } else { if (isset($bean->emailAddress)) { $namePlusEmail = "<" . from_html($bean->emailAddress->getPrimaryAddress($bean)) . ">"; } } } $subject = ""; $body = ""; $email_id = ""; $attachments = array(); if ($bean->module_dir == 'Cases') { $subject = str_replace('%1', $bean->case_number, $bean->getEmailSubjectMacro() . " " . from_html($bean->name)); //bug 41928 $bean->load_relationship("contacts"); $contact_ids = $bean->contacts->get(); $contact = new Contact(); foreach ($contact_ids as $cid) { $contact->retrieve($cid); $namePlusEmail .= empty($namePlusEmail) ? "" : ", "; $namePlusEmail .= from_html($contact->full_name) . " <" . from_html($contact->emailAddress->getPrimaryAddress($contact)) . ">"; } } if ($bean->module_dir == 'KBDocuments') { require_once "modules/Emails/EmailUI.php"; $subject = $bean->kbdocument_name; $article_body = str_replace('/cache/images/', $GLOBALS['sugar_config']['site_url'] . '/cache/images/', KBDocument::get_kbdoc_body_without_incrementing_count($bean->id)); $body = from_html($article_body); $attachments = KBDocument::get_kbdoc_attachments_for_newemail($bean->id); $attachments = $attachments['attachments']; } // if if ($bean->module_dir == 'Quotes' && isset($data['recordId'])) { $quotesData = getQuotesRelatedData($bean, $data); global $current_language; $namePlusEmail = $quotesData['toAddress']; $subject = $quotesData['subject']; $body = $quotesData['body']; $attachments = $quotesData['attachments']; $email_id = $quotesData['email_id']; } // if $ret = array('to_email_addrs' => $namePlusEmail, 'parent_type' => $data['parent_type'], 'parent_id' => $data['parent_id'], 'parent_name' => $parentName, 'subject' => $subject, 'body' => $body, 'attachments' => $attachments, 'email_id' => $email_id); } else { if (isset($_REQUEST['ListView'])) { $email = new Email(); $namePlusEmail = $email->getNamePlusEmailAddressesForCompose($_REQUEST['action_module'], explode(",", $_REQUEST['uid'])); $ret = array('to_email_addrs' => $namePlusEmail); } else { if (isset($data['replyForward'])) { require_once "modules/Emails/EmailUI.php"; $ret = array(); $ie = new InboundEmail(); $ie->email = new Email(); $ie->email->email2init(); $replyType = $data['reply']; $email_id = $data['record']; $ie->email->retrieve($email_id); $emailType = ""; if ($ie->email->type == 'draft') { $emailType = $ie->email->type; } $ie->email->from_addr = $ie->email->from_addr_name; $ie->email->to_addrs = to_html($ie->email->to_addrs_names); $ie->email->cc_addrs = to_html($ie->email->cc_addrs_names); $ie->email->bcc_addrs = $ie->email->bcc_addrs_names; $ie->email->from_name = $ie->email->from_addr; $preBodyHTML = " <div><hr></div>"; if ($ie->email->type != 'draft') { $email = $ie->email->et->handleReplyType($ie->email, $replyType); } else { $email = $ie->email; $preBodyHTML = ""; } // else if ($ie->email->type != 'draft') { $emailHeader = $email->description; } $ret = $ie->email->et->displayComposeEmail($email); if ($ie->email->type != 'draft') { $ret['description'] = $emailHeader; } if ($replyType == 'forward' || $emailType == 'draft') { $ret = $ie->email->et->getDraftAttachments($ret); } $return = $ie->email->et->getFromAllAccountsArray($ie, $ret); if ($replyType == "forward") { $return['to'] = ''; } else { if ($email->type != 'draft') { $return['to'] = from_html($ie->email->from_addr); } } // else $ret = array('to_email_addrs' => $return['to'], 'parent_type' => $return['parent_type'], 'parent_id' => $return['parent_id'], 'parent_name' => $return['parent_name'], 'subject' => $return['name'], 'body' => $preBodyHTML . $return['description'], 'attachments' => isset($return['attachments']) ? $return['attachments'] : array(), 'email_id' => $email_id, 'fromAccounts' => $return['fromAccounts']); // If it's a 'Reply All' action, append the CC addresses if ($data['reply'] == 'replyAll') { $ret['cc_addrs'] = from_html($ie->email->to_addrs); } } else { $ret = array('to_email_addrs' => ''); } } } if ($forFullCompose) { initFullCompose($ret); } else { return $ret; } }
/** Returns the URL for Basic and Advance Search ** Added to fix the issue 4600 **/ function getBasic_Advance_SearchURL() { $url = ''; if ($_REQUEST['searchtype'] == 'BasicSearch') { $url .= isset($_REQUEST['query']) ? '&query=' . $_REQUEST['query'] : ''; $url .= isset($_REQUEST['search_field']) ? '&search_field=' . $_REQUEST['search_field'] : ''; $url .= isset($_REQUEST['search_text']) ? '&search_text=' . to_html($_REQUEST['search_text']) : ''; $url .= isset($_REQUEST['searchtype']) ? '&searchtype=' . $_REQUEST['searchtype'] : ''; $url .= isset($_REQUEST['type']) ? '&type=' . $_REQUEST['type'] : ''; } if ($_REQUEST['searchtype'] == 'advance') { $url .= isset($_REQUEST['query']) ? '&query=' . $_REQUEST['query'] : ''; $count = $_REQUEST['search_cnt']; for ($i = 0; $i < $count; $i++) { $url .= isset($_REQUEST['Fields' . $i]) ? '&Fields' . $i . '=' . stripslashes(str_replace("'", "", $_REQUEST['Fields' . $i])) : ''; $url .= isset($_REQUEST['Condition' . $i]) ? '&Condition' . $i . '=' . $_REQUEST['Condition' . $i] : ''; $url .= isset($_REQUEST['Srch_value' . $i]) ? '&Srch_value' . $i . '=' . to_html($_REQUEST['Srch_value' . $i]) : ''; } $url .= isset($_REQUEST['searchtype']) ? '&searchtype=' . $_REQUEST['searchtype'] : ''; $url .= isset($_REQUEST['search_cnt']) ? '&search_cnt=' . $_REQUEST['search_cnt'] : ''; $url .= isset($_REQUEST['matchtype']) ? '&matchtype=' . $_REQUEST['matchtype'] : ''; } return $url; }
function trace_to_html($trace) { $result = ""; foreach ($trace as $step) { //arguments $args = array(); if (isset($step['args'])) { foreach ($step['args'] as $arg) { $args[] = to_html($arg); } } $args = implode(", ", $args); //the rest if (array_key_exists("file", $step)) { $file = $step["file"]; } else { $file = "Unknown file"; } if (array_key_exists("line", $step)) { $line = $step["line"]; } else { $line = "?"; } if (array_key_exists("function", $step)) { $func = $step["function"]; } else { $func = "Unknown Function"; } //create message $step_message = ""; $step_message .= $func . "({$args})<br>"; $step_message .= " " . html_escape(basename($file)) . " (" . $line . ")<br>"; $step_message .= "<br>"; //store it $result .= $step_message; } return $result; }
?> &#&#&# <?php } ?> <form name="massdelete" method="POST" id="massdelete"> <input name='search_url' id="search_url" type='hidden' value='<?php echo $this->_tpl_vars['SEARCH_URL']; ?> '> <input name="idlist" id="idlist" type="hidden"> <input name="change_owner" type="hidden"> <input name="change_status" type="hidden"> <input name="action" type="hidden"> <input name="where_export" type="hidden" value="<?php echo to_html($_SESSION['export_where']); ?> "> <input name="step" type="hidden"> <input name="allids" type="hidden" id="allids" value="<?php echo $this->_tpl_vars['ALLIDS']; ?> "> <input name="selectedboxes" id="selectedboxes" type="hidden" value="<?php echo $this->_tpl_vars['SELECTEDIDS']; ?> "> <input name="allselectedboxes" id="allselectedboxes" type="hidden" value="<?php echo $this->_tpl_vars['ALLSELECTEDIDS']; ?> ">
$id_in = "('" . implode("','", $r_ids) . "')"; $where = ' paper.id in ' . $id_in; } $search_form->assign("USER_DATEFORMAT", '(' . $timedate->get_user_date_format() . ')'); $search_form->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format()); $search_form->assign("THEME", $theme); $search_form->assign("MOD", $current_module_strings); $search_form->assign("APP", $app_strings); $search_form->assign("IMAGE_PATH", $image_path); $search_form->assign("JAVASCRIPT", get_clear_form_js()); //$search_form->assign("CATEGORY_OPTIONS", get_select_options_with_id($app_list_strings['product_category_dom'], $category)); if (isset($name)) { $search_form->assign("FNAME", to_html($fname)); } if (isset($pnum)) { $search_form->assign("PNAME", to_html($pname)); } //if (isset($type)) $search_form->assign("TYPE", to_html($type)); //if (isset($spec)) $search_form->assign("SPEC", to_html($spec)); if (isset($current_user_only)) { $search_form->assign("CURRENT_USER_ONLY", "checked"); } //if(isset($subordinate_only)) $search_form->assign("SUBORDINATE_ONLY", "checked"); $header_text = ''; if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) { $header_text = "<a href='index.php?action=index&module=DynamicLayout&from_action=SearchForm&from_module=" . $_REQUEST['module'] . "'>" . get_image($image_path . "EditLayout", "border='0' alt='Edit Layout' align='bottom'") . "</a>"; } echo get_form_header($current_module_strings['LBL_SEARCH_FORM_TITLE'], $header_text, false); $search_form->parse("main"); $search_form->out("main"); echo get_form_footer();
* All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ require_once 'include/ListView/ListViewSmarty.php'; global $app_strings, $app_list_strings, $current_language, $currentModule, $mod_strings; echo getClassicModuleTitle('SavedSearch', array($mod_strings['LBL_MODULE_TITLE']), false); echo get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false); $search_form = new XTemplate('modules/SavedSearch/SearchForm.html'); $search_form->assign('MOD', $mod_strings); $search_form->assign('APP', $app_strings); $search_form->assign('JAVASCRIPT', get_clear_form_js()); if (isset($_REQUEST['name'])) { $search_form->assign('name', to_html($_REQUEST['name'])); } if (isset($_REQUEST['search_module'])) { $search_form->assign('search_module', to_html($_REQUEST['search_module'])); } $search_form->parse('main'); $search_form->out('main'); if (!isset($where)) { $where = "assigned_user_id = {$current_user->id}"; } echo '<br />' . get_form_header($mod_strings['LBL_LIST_FORM_TITLE'], '', false); $savedSearch = new SavedSearch(); $lv = new ListViewSmarty(); if (file_exists('custom/modules/SavedSearch/metadata/listviewdefs.php')) { require_once 'custom/modules/SavedSearch/metadata/listviewdefs.php'; } else { require_once 'modules/SavedSearch/metadata/listviewdefs.php'; } $lv->displayColumns = $listViewDefs['SavedSearch'];
function query_result(&$result, $row, $col = 0) { return to_html($this->query_result_raw($result, $row, $col)); }
<script type="text/javascript"> $(document).ready(function () { $('#pms').DataTable(); $('#pms_wrapper').css({"padding":"10px"}); }); </script> <?php $table = div(div(par("Sent Messages"), "panel-heading"), "panel panel-info"); $table["children"][] = make_table($pms, ["receiver", "subject", "msg", "time"], "table", "pms"); echo to_html($table);
<?php require 'config.php'; require 'helpers.php'; // Pagination variable. if (!isset($_GET['p'])) { $p = 1; } else { $p = filter_input(INPUT_GET, "p", FILTER_VALIDATE_INT); } // Exit if a bad page is supplied. if ($p === False || $p < 1) { exit; } $start = ($p - 1) * $results_per_page; $result = $mysqli->query("SELECT * FROM {$mysql_table} ORDER BY date DESC LIMIT {$start}, {$results_per_page}"); if ($result) { while ($row = $result->fetch_array()) { echo to_html($row['category'], $row['title'], $row['content'], $row['link'], date("c", strtotime($row['date']))); } } // Output the next pagination URL if ($result->num_rows == $results_per_page) { $p += 1; echo '<nav id="social-nav"><a href="get_stream.php?p=' . $p . '"></a></nav>'; } $result->free(); $mysqli->close();
function displayFetchedSortedListXML($ret, $mbox) { global $timedate; global $current_user; global $sugar_config; if (empty($ret['retArr'])) { return array(); } $tPref = $current_user->getUserDateTimePreferences(); $return = array(); foreach ($ret['retArr'] as $msg) { $flagged = $msg->flagged == 0 ? "" : $this->iconFlagged; $status = $msg->deleted ? $this->iconDeleted : ""; $status = $msg->draft == 0 ? $status : $this->iconDraft; $status = $msg->answered == 0 ? $status : $this->iconAnswered; $from = $this->handleMimeHeaderDecode($msg->from); $subject = $this->handleMimeHeaderDecode($msg->subject); //$date = date($tPref['date']." ".$tPref['time'], $msg->date); $date = $timedate->to_display_date_time($this->db->fromConvert($msg->date, 'datetime')); //$date = date($tPref['date'], $this->getUnixHeaderDate($msg->date)); $temp = array(); $temp['flagged'] = $flagged; $temp['status'] = $status; $temp['from'] = to_html($from); $temp['subject'] = $subject; $temp['date'] = $date; $temp['uid'] = $msg->uid; // either from an imap_search() or massaged cache value $temp['mbox'] = $this->mailbox; $temp['ieId'] = $this->id; $temp['site_url'] = $sugar_config['site_url']; $temp['seen'] = $msg->seen; $temp['type'] = isset($msg->type) ? $msg->type : 'remote'; $temp['to_addrs'] = to_html($msg->to); $temp['hasAttach'] = '0'; $return[] = $temp; } return $return; }
/** * Cleans char, varchar, text, etc. fields of XSS type materials */ function cleanBean() { foreach ($this->field_defs as $key => $def) { if (isset($def['type'])) { $type = $def['type']; } if (isset($def['dbType'])) { $type .= $def['dbType']; } if ((strpos($type, 'char') !== false || strpos($type, 'text') !== false || $type == 'enum') && !empty($this->{$key})) { $str = from_html($this->{$key}); // Julian's XSS cleaner $potentials = clean_xss($str, false); if (is_array($potentials) && !empty($potentials)) { foreach ($potentials as $bad) { $str = str_replace($bad, "", $str); } $this->{$key} = to_html($str); } } } }
static function addLabels($language, $labels, $moduleName, $basepath = null, $forRelationshipLabel = false) { $GLOBALS['log']->debug("ParserLabel->addLabels({$language}, \$labels, {$moduleName}, {$basepath} );"); $GLOBALS['log']->debug("\$labels:" . print_r($labels, true)); $deployedModule = false; if (is_null($basepath)) { $deployedModule = true; $basepath = "custom/modules/{$moduleName}/language"; if ($forRelationshipLabel) { $basepath = "custom/modules/{$moduleName}/Ext/Language"; } if (!is_dir($basepath)) { mkdir_recursive($basepath); } } $filename = "{$basepath}/{$language}.lang.php"; if ($forRelationshipLabel) { $filename = "{$basepath}/{$language}.lang.ext.php"; } $dir_exists = is_dir($basepath); $mod_strings = array(); if ($dir_exists) { if (file_exists($filename)) { // obtain $mod_strings include $filename; } else { if ($forRelationshipLabel) { $fh = fopen($filename, 'a'); fclose($fh); } } } else { return false; } $changed = false; //$charset = (isset($app_strings['LBL_CHARSET'])) ? $app_strings['LBL_CHARSET'] : $GLOBALS['sugar_config']['default_charset'] ; foreach ($labels as $key => $value) { if (!isset($mod_strings[$key]) || strcmp($value, $mod_strings[$key]) != 0) { $mod_strings[$key] = to_html(strip_tags(from_html($value))); // must match encoding used in view.labels.php $changed = true; } } if ($changed) { $GLOBALS['log']->debug("ParserLabel->addLabels: writing new mod_strings to {$filename}"); $GLOBALS['log']->debug("ParserLabel->addLabels: mod_strings=" . print_r($mod_strings, true)); if (!write_array_to_file("mod_strings", $mod_strings, $filename)) { $GLOBALS['log']->fatal("Could not write {$filename}"); } else { // if we have a cache to worry about, then clear it now if ($deployedModule) { SugarCache::cleanOpcodes(); $GLOBALS['log']->debug("PaserLabel->addLabels: clearing language cache"); $cache_key = "module_language." . $language . $moduleName; sugar_cache_clear($cache_key); LanguageManager::clearLanguageCache($moduleName, $language); } } } return true; }
$ss->assign('logoUrl', $logoUrl); $ss->assign('MOD', $modStringSrc); $pdfTemplate = new PdfManager(); $pdfTemplate->base_module = 'Quotes'; $pdfTemplate->name = $modStringSrc['LBL_TPL_QUOTE_NAME']; $pdfTemplate->description = $modStringSrc['LBL_TPL_QUOTE_DESCRIPTION']; $pdfTemplate->body_html = to_html($ss->fetch('modules/PdfManager/tpls/templateQuote.tpl')); $pdfTemplate->template_name = $modStringSrc['LBL_TPL_QUOTE_TEMPLATE_NAME']; $pdfTemplate->author = PDF_AUTHOR; $pdfTemplate->title = PDF_TITLE; $pdfTemplate->subject = PDF_SUBJECT; $pdfTemplate->keywords = PDF_KEYWORDS; $pdfTemplate->published = 'yes'; $pdfTemplate->deleted = 0; $pdfTemplate->team_id = 1; $pdfTemplate->save(); $pdfTemplate = new PdfManager(); $pdfTemplate->base_module = 'Quotes'; $pdfTemplate->name = $modStringSrc['LBL_TPL_INVOICE_NAME']; $pdfTemplate->description = $modStringSrc['LBL_TPL_INVOICE_DESCRIPTION']; $pdfTemplate->body_html = to_html($ss->fetch('modules/PdfManager/tpls/templateInvoice.tpl')); $pdfTemplate->template_name = $modStringSrc['LBL_TPL_INVOICE_TEMPLATE_NAME']; $pdfTemplate->author = PDF_AUTHOR; $pdfTemplate->title = PDF_TITLE; $pdfTemplate->subject = PDF_SUBJECT; $pdfTemplate->keywords = PDF_KEYWORDS; $pdfTemplate->published = 'yes'; $pdfTemplate->deleted = 0; $pdfTemplate->team_id = 1; $pdfTemplate->save(); }
/** * creates the standard "Forward" info at the top of the forwarded message * @return string */ function getForwardHeader() { global $mod_strings; global $current_user; //$from = str_replace(array(">","<"), array(")","("), $this->from_name); $from = to_html($this->from_name); $subject = to_html($this->name); $ret = "<br /><br />"; $ret .= $this->replyDelimiter . "{$mod_strings['LBL_FROM']} {$from}<br />"; $ret .= $this->replyDelimiter . "{$mod_strings['LBL_DATE_SENT']} {$this->date_sent}<br />"; $ret .= $this->replyDelimiter . "{$mod_strings['LBL_TO']} {$this->to_addrs}<br />"; $ret .= $this->replyDelimiter . "{$mod_strings['LBL_CC']} {$this->cc_addrs}<br />"; $ret .= $this->replyDelimiter . "{$mod_strings['LBL_SUBJECT']} {$subject}<br />"; $ret .= $this->replyDelimiter . "<br />"; return $ret; //return from_html($ret); }
function resumo($string = NULL, $palavras = 50, $decodifica_html = TRUE, $remove_tags = TRUE) { if ($string != NULL) { if ($decodifica_html) { $string = to_html($string); } if ($remove_tags) { $string = strip_tags($string); } $retorno = word_limiter($string, $palavras); } else { $retorno = FALSE; } return $retorno; }
/** * handles the tracker output, and adds a link and a shortened name. * given html safe input, it will preserve html safety * * @param array $history - returned from the tracker * @return array augmented history with image link and shortened name */ protected function processRecentRecords($history) { foreach ($history as $key => $row) { $history[$key]['item_summary_short'] = to_html(getTrackerSubstring($row['item_summary'])); //bug 56373 - need to re-HTML-encode $history[$key]['image'] = SugarThemeRegistry::current()->getImage($row['module_name'], 'border="0" align="absmiddle"', null, null, '.gif', $row['item_summary']); } return $history; }
/** * This function sends a mail to the handler whenever the product reaches the reorder level. * Param $product_id - product id * Param $upd_qty - updated product quantity in no's * Param $prod_name - product name * Param $qtyinstk - quantity in stock * Param $qty - quantity * Param $module - module name * return type void */ function sendPrdStckMail($product_id, $upd_qty, $prod_name, $qtyinstk, $qty, $module) { global $log; $log->debug("Entering sendPrdStckMail(" . $product_id . "," . $upd_qty . "," . $prod_name . "," . $qtyinstk . "," . $qty . "," . $module . ") method ..."); global $current_user; global $adb; $reorderlevel = getPrdReOrderLevel($product_id); $log->debug("Inside sendPrdStckMail function, module=" . $module); $log->debug("Prd reorder level " . $reorderlevel); if ($upd_qty < $reorderlevel) { //send mail to the handler $handler = getRecordOwnerId($product_id); $handler_name = getOwnerName(array_shift(array_values($handler))); if (vtws_isRecordOwnerUser($handler)) { $to_address = getUserEmail($handler); } else { $to_address = implode(',', getDefaultAssigneeEmailIds($handler)); } //Get the email details from database; if ($module == 'SalesOrder') { $notification_table = 'SalesOrderNotification'; $quan_name = '{SOQUANTITY}'; } if ($module == 'Quotes') { $notification_table = 'QuoteNotification'; $quan_name = '{QUOTEQUANTITY}'; } if ($module == 'Invoice') { $notification_table = 'InvoiceNotification'; } $query = "select * from vtiger_inventorynotification where notificationname=?"; $result = $adb->pquery($query, array($notification_table)); $subject = $adb->query_result($result, 0, 'notificationsubject'); $body = $adb->query_result($result, 0, 'notificationbody'); $status = $adb->query_result($result, 0, 'status'); if ($status == 0 || $status == '') { return false; } $subject = str_replace('{PRODUCTNAME}', $prod_name, $subject); $body = str_replace('{HANDLER}', $handler_name, $body); $body = str_replace('{PRODUCTNAME}', $prod_name, $body); if ($module == 'Invoice') { $body = str_replace('{CURRENTSTOCK}', $upd_qty, $body); $body = str_replace('{REORDERLEVELVALUE}', $reorderlevel, $body); } else { $body = str_replace('{CURRENTSTOCK}', $qtyinstk, $body); $body = str_replace($quan_name, $qty, $body); } $body = str_replace('{CURRENTUSER}', $current_user->user_name, $body); $mail_status = send_mail($module, $to_address, $current_user->user_name, $current_user->email1, decode_html($subject), nl2br(to_html($body))); } $log->debug("Exiting sendPrdStckMail method ..."); }
if (isset($secondrow)) { //Asha: Fix for ticket #4432 foreach ($secondrow as $ind => $val) { if (strlen($val) > 30) { $secondrow[$ind] = substr(to_html($val), 0, 30) . " .........."; } else { $secondrow[$ind] = to_html($val); } } if (isset($thirdrow)) { //Asha: Fix for ticket #4432 foreach ($thirdrow as $ind => $val) { if (strlen($val) > 30) { $thirdrow[$ind] = substr(to_html($val), 0, 30) . " .........."; } else { $thirdrow[$ind] = to_html($val); } } } } $field_map = $outlook_contacts_field_map; $mapping_file = new ImportMap(); $saved_map_lists = $mapping_file->getSavedMappingsList($_REQUEST['return_module']); $map_list_combo = '<select class="small" name="source" id="saved_source" disabled onchange="getImportSavedMap(this)">'; $map_list_combo .= '<OPTION value="-1" selected>--Select--</OPTION>'; if (is_array($saved_map_lists)) { foreach ($saved_map_lists as $mapid => $mapname) { $map_list_combo .= '<OPTION value=' . $mapid . '>' . $mapname . '</OPTION>'; } } $map_list_combo .= '</select>';
/** This function returns the detail view form vtiger_field and and its properties in array format. * Param $uitype - UI type of the vtiger_field * Param $fieldname - Form vtiger_field name * Param $fieldlabel - Form vtiger_field label name * Param $col_fields - array contains the vtiger_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $tabid - vtiger_tab id to which the Field belongs to (default is "") * Return type is an array */ function getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid = '', $module = '') { global $log; $log->debug("Entering getDetailViewOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $col_fields . "," . $generatedtype . "," . $tabid . ") method ..."); global $adb; global $mod_strings; global $app_strings; global $current_user; global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $fieldlabel = from_html($fieldlabel); $custfld = ''; $value = ''; $arr_data = array(); $label_fld = array(); $data_fld = array(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; // vtlib customization: New uitype to handle relation between modules if ($uitype == '10') { $fieldlabel = getTranslatedString($fieldlabel, $module); $parent_id = $col_fields[$fieldname]; if (!empty($parent_id)) { $parent_module = getSalesEntityType($parent_id); $valueTitle = getTranslatedString($parent_module, $parent_module); $displayValueArray = getEntityName($parent_module, $parent_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $value) { $displayValue = $value; } } // vtlib customization: For listview javascript triggers $modMetaInfo = getEntityFieldNames($parent_module); $modEName = is_array($modMetaInfo['fieldname']) ? $modMetaInfo['fieldname'][0] : $modMetaInfo['fieldname']; $vtlib_metainfo = "<span type='vtlib_metainfo' vtrecordid='{$parent_id}' vtfieldname=" . "'{$modEName}' vtmodule='{$parent_module}' style='display:none;'></span>"; // END $label_fld = array($fieldlabel, "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>{$vtlib_metainfo}"); } else { $moduleSpecificMessage = 'MODULE_NOT_SELECTED'; if ($mod_strings[$moduleSpecificMessage] != "") { $moduleSpecificMessage = $mod_strings[$moduleSpecificMessage]; } $label_fld = array($fieldlabel, ''); } } else { if ($uitype == 99) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; if ($fieldname == 'confirm_password') { return null; } } elseif ($uitype == 116 || $uitype == 117) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getCurrencyName($col_fields[$fieldname]); $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name'); $currency_id = $adb->query_result($pickListResult, $j, 'id'); if ($col_fields[$fieldname] == $currency_id) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[$currency_id] = array($pickListValue => $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 13 || $uitype == 104) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 16) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getTranslatedString($col_fields[$fieldname], $module); $fieldname = $adb->sql_escape_string($fieldname); $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid"; $params = array(); $pickListResult = $adb->pquery($pick_query, $params); $noofpickrows = $adb->num_rows($pickListResult); $options = array(); $count = 0; $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname))); $col_fields[$fieldname] = decode_html($col_fields[$fieldname]); if ($col_fields[$fieldname] == $pickListValue) { $chk_val = "selected"; $count++; $found = true; } else { $chk_val = ''; } $pickListValue = to_html($pickListValue); $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 15) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; $roleid = $current_user->roleid; $valueArr = explode("|##|", $col_fields[$fieldname]); $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $count = 0; $found = false; if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { if (in_array(trim($pickListValue), array_map("trim", $valueArr))) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected'); } } $label_fld["options"] = $options; } elseif ($uitype == 115) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getTranslatedString($col_fields[$fieldname]); $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname); $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname)); if ($col_fields[$fieldname] == $pickListValue) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 33) { //uitype 33 added for multiselector picklist - Jeri $roleid = $current_user->roleid; $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = str_ireplace(' |##| ', ', ', $col_fields[$fieldname]); $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); $options = array(); $selected_entries = array(); $selected_entries = explode(' |##| ', $col_fields[$fieldname]); if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { foreach ($selected_entries as $selected_entries_value) { if (trim($selected_entries_value) == trim(htmlentities($pickListValue, ENT_QUOTES, $default_charset))) { $chk_val = 'selected'; $pickcount++; break; } else { $chk_val = ''; } } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $not_access_lbl = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; $options[] = array($not_access_lbl, trim($selected_entries_value), 'selected'); } } $label_fld["options"] = $options; } elseif ($uitype == 17) { $label_fld[] = getTranslatedString($fieldlabel, $module); $matchPattern = "^[\\w]+:\\/\\/^"; $value = $col_fields[$fieldname]; preg_match($matchPattern, $value, $matches); if (!empty($matches[0])) { $fieldValue = str_replace($matches, "", $value); $label_fld[] = $value; } else { if ($value != null) { $label_fld[] = 'http://' . $value; } else { $label_fld[] = ''; } } } elseif ($uitype == 19) { if ($fieldname == 'notecontent' or $module == 'Timecontrol') { $col_fields[$fieldname] = decode_html($col_fields[$fieldname]); } else { $col_fields[$fieldname] = str_replace("<br />", "<br>", $col_fields[$fieldname]); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 20 || $uitype == 21 || $uitype == 22 || $uitype == 24) { // Armando LC<scher 11.08.2005 -> B'descriptionSpan -> Desc: removed $uitype == 19 and made an aditional elseif above if ($uitype == 20) { //Fix the issue #4680 $col_fields[$fieldname] = $col_fields[$fieldname]; } else { $col_fields[$fieldname] = nl2br($col_fields[$fieldname]); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { $account_id = $col_fields[$fieldname]; if ($account_id != '') { $account_name = getAccountName($account_id); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $account_name; $label_fld["secid"] = $account_id; $label_fld["link"] = "index.php?module=Accounts&action=DetailView&record=" . $account_id; //Account Name View } elseif ($uitype == 52 || $uitype == 77 || $uitype == 101) { $label_fld[] = getTranslatedString($fieldlabel, $module); $user_id = $col_fields[$fieldname]; $user_name = getOwnerName($user_id); if ($user_id != '') { $assigned_user_id = $user_id; } else { $assigned_user_id = $current_user->id; } if (is_admin($current_user)) { $label_fld[] = '<a href="index.php?module=Users&action=DetailView&record=' . $user_id . '">' . $user_name . '</a>'; } else { $label_fld[] = $user_name; } if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $user_id), $assigned_user_id); } $label_fld["options"] = $users_combo; } elseif ($uitype == 11) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 53) { global $noof_group_rows, $adb; $owner_id = $col_fields[$fieldname]; $user = '******'; $result = $adb->pquery("SELECT count(*) as count from vtiger_users where id = ?", array($owner_id)); if ($adb->query_result($result, 0, 'count') > 0) { $user = '******'; } $owner_name = getOwnerName($owner_id); $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $owner_name; if (is_admin($current_user)) { $label_fld["secid"][] = $owner_id; if ($user == 'no') { $label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=" . $owner_id; } else { $label_fld["link"][] = "index.php?module=Users&action=DetailView&record=" . $owner_id; } //$label_fld["secid"][] = $groupid; //$label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=".$groupid; } //Security Checks if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $result = get_current_user_access_groups($module_name); } else { $result = get_group_options(); } if ($result) { $nameArray = $adb->fetch_array($result); } global $current_user; //$value = $user_id; if ($owner_id != '') { if ($user == 'yes') { $label_fld["options"][] = 'User'; $assigned_user_id = $owner_id; $user_checked = "checked"; $team_checked = ''; $user_style = 'display:block'; $team_style = 'display:none'; } else { //$record = $col_fields["record_id"]; //$module = $col_fields["record_module"]; $label_fld["options"][] = 'Group'; $assigned_group_id = $owner_id; $user_checked = ''; $team_checked = 'checked'; $user_style = 'display:none'; $team_style = 'display:block'; } } else { $label_fld["options"][] = 'User'; $assigned_user_id = $current_user->id; $user_checked = "checked"; $team_checked = ''; $user_style = 'display:block'; $team_style = 'display:none'; } if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id), $assigned_user_id); } if ($noof_group_rows != 0) { if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id, 'private'), $current_user->id); } else { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id), $current_user->id); } } $label_fld["options"][] = $users_combo; $label_fld["options"][] = $groups_combo; } elseif ($uitype == 55 || $uitype == 255) { if ($tabid == 4) { $query = "select vtiger_contactdetails.imagename from vtiger_contactdetails where contactid=?"; $result = $adb->pquery($query, array($col_fields['record_id'])); $imagename = $adb->query_result($result, 0, 'imagename'); if ($imagename != '') { $imgpath = "test/contact/" . $imagename; $label_fld[] = getTranslatedString($fieldlabel, $module); } else { $label_fld[] = getTranslatedString($fieldlabel, $module); } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); } $value = $col_fields[$fieldname]; if ($uitype == 255) { global $currentModule; $fieldpermission = getFieldVisibilityPermission($currentModule, $current_user->id, 'firstname'); } if ($uitype == 255 && $fieldpermission == 0 && $fieldpermission != '') { $fieldvalue[] = ''; } else { $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = implode("','", $subrole); $roleids = $roleids . "','" . $roleid; } else { $roleids = $roleid; } if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $pick_query = "select salutationtype from vtiger_salutationtype order by salutationtype"; $params = array(); } else { $pick_query = "select * from vtiger_salutationtype left join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid=vtiger_salutationtype.picklist_valueid where picklistid in (select picklistid from vtiger_picklist where name='salutationtype') and roleid=? order by salutationtype"; $params = array($current_user->roleid); } $pickListResult = $adb->pquery($pick_query, $params); $noofpickrows = $adb->num_rows($pickListResult); $sal_value = $col_fields["salutationtype"]; $salcount = 0; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, "salutationtype"); if ($sal_value == $pickListValue) { $chk_val = "selected"; $salcount++; } else { $chk_val = ''; } } if ($salcount == 0 && $sal_value != '') { $notacc = $app_strings['LBL_NOT_ACCESSIBLE']; } $sal_value = $col_fields["salutationtype"]; if ($sal_value == '--None--') { $sal_value = ''; } $label_fld["salut"] = getTranslatedString($sal_value); $label_fld["notaccess"] = $notacc; } $label_fld[] = $value; } elseif ($uitype == 56) { $label_fld[] = getTranslatedString($fieldlabel, $module); $value = $col_fields[$fieldname]; if ($value == 1) { //Since "yes" is not been translated it is given as app strings here.. $displayValue = $app_strings['yes']; } else { $displayValue = $app_strings['no']; } $label_fld[] = $displayValue; } elseif ($uitype == 156) { $label_fld[] = getTranslatedString($fieldlabel, $module); $value = $col_fields[$fieldname]; if ($value == 'on') { //Since "yes" is not been translated it is given as app strings here.. $displayValue = $app_strings['yes']; } else { $displayValue = $app_strings['no']; } $label_fld[] = $displayValue; } elseif ($uitype == 57) { $label_fld[] = getTranslatedString($fieldlabel, $module); $contact_id = $col_fields[$fieldname]; if ($contact_id != '') { $displayValueArray = getEntityName('Contacts', $contact_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } } $label_fld[] = $contact_name; $label_fld["secid"] = $contact_id; $label_fld["link"] = "index.php?module=Contacts&action=DetailView&record=" . $contact_id; } elseif ($uitype == 58) { $label_fld[] = getTranslatedString($fieldlabel, $module); $campaign_id = $col_fields[$fieldname]; if ($campaign_id != '') { $campaign_name = getCampaignName($campaign_id); } $label_fld[] = $campaign_name; $label_fld["secid"] = $campaign_id; $label_fld["link"] = "index.php?module=Campaigns&action=DetailView&record=" . $campaign_id; } elseif ($uitype == 59) { $label_fld[] = getTranslatedString($fieldlabel, $module); $product_id = $col_fields[$fieldname]; if ($product_id != '') { $product_name = getProductName($product_id); } //Account Name View $label_fld[] = $product_name; $label_fld["secid"] = $product_id; $label_fld["link"] = "index.php?module=Products&action=DetailView&record=" . $product_id; } elseif ($uitype == 61) { global $adb; $label_fld[] = getTranslatedString($fieldlabel, $module); if ($tabid == 10) { $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])); for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) { $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid'); if ($attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); if ($attachmentsname != '') { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '">' . $attachmentsname . '</a>'; } else { $custfldval = ''; } } $label_fld['options'][] = $custfldval; } } else { $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } //This is added to strip the crmid and _ from the file name and show the original filename //$org_filename = ltrim($col_fields[$fieldname],$col_fields['record_id'].'_'); /* Above line is not required as the filename in the database is stored as it is and doesn't have crmid attached to it. This was the cause for the issue reported in ticket #4645 */ $org_filename = $col_fields[$fieldname]; // For Backward Compatibility version < 5.0.4 $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_'); if ($filename_pos === 0) { $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_'); $org_filename = substr($org_filename, $start_idx); } if ($org_filename != '') { if ($col_fields['filelocationtype'] == 'E') { if ($col_fields['filestatus'] == 1) { //&& strlen($col_fields['filename']) > 7 ){ $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } elseif ($col_fields['filelocationtype'] == 'I') { if ($col_fields['filestatus'] == 1) { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } else { $custfldval = ''; } } $label_fld[] = $custfldval; } } elseif ($uitype == 28) { $label_fld[] = getTranslatedString($fieldlabel, $module); $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } $org_filename = $col_fields[$fieldname]; // For Backward Compatibility version < 5.0.4 $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_'); if ($filename_pos === 0) { $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_'); $org_filename = substr($org_filename, $start_idx); } if ($org_filename != '') { if ($col_fields['filelocationtype'] == 'E') { if ($col_fields['filestatus'] == 1) { //&& strlen($col_fields['filename']) > 7 ){ $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } elseif ($col_fields['filelocationtype'] == 'I') { if ($col_fields['filestatus'] == 1) { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } else { $custfldval = ''; } } $label_fld[] = $custfldval; } elseif ($uitype == 69) { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($tabid == 14) { $images = array(); $query = 'select productname, vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?'; $result_image = $adb->pquery($query, array($col_fields['record_id'])); for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) { $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid'); //decode_html - added to handle UTF-8 characters in file names //urlencode - added to handle special characters like #, %, etc., $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name'))); $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name')); $imagepath_array[] = $adb->query_result($result_image, $image_iter, 'path'); } if (count($image_array) > 1) { if (count($image_array) < 4) { $sides = count($image_array) * 2; } else { $sides = 8; } $image_lists = '<div id="Carousel" style="position:relative;vertical-align: middle;"> <img src="modules/Products/placeholder.gif" width="571" height="117" style="position:relative;"> </div><script>var Car_NoOfSides=' . $sides . '; Car_Image_Sources=new Array('; for ($image_iter = 0; $image_iter < count($image_array); $image_iter++) { $images[] = '"' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '","' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '"'; } $image_lists .= implode(',', $images) . ');</script><script language="JavaScript" type="text/javascript" src="modules/Products/Productsslide.js"></script><script language="JavaScript" type="text/javascript">Carousel();</script>'; $label_fld[] = $image_lists; } elseif (count($image_array) == 1) { list($pro_image_width, $pro_image_height) = getimagesize($imagepath_array[0] . $image_id_array[0] . "_" . $image_orgname_array[0]); if ($pro_image_width > 450 || $pro_image_height > 300) { $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="450" height="300">'; } else { $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="' . $pro_image_width . '" height="' . $pro_image_height . '">'; } } else { $label_fld[] = ''; } } 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 from vtiger_attachments\n\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t and vtiger_attachments.name = ?\n\t\t\t and vtiger_seattachmentsrel.crmid=?"; $image_res = $adb->pquery($sql, array($col_fields[$fieldname], $col_fields['record_id'])); $image_id = $adb->query_result($image_res, 0, 'attachmentsid'); $image_path = $adb->query_result($image_res, 0, 'path'); //decode_html - added to handle UTF-8 characters in file names //urlencode - added to handle special characters like #, %, etc., $image_name = urlencode(decode_html($adb->query_result($image_res, 0, 'name'))); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { $ftype = $adb->query_result($image_res, 0, 'type'); $isimage = stripos($ftype, 'image') !== false; if ($isimage) { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image'); $label_fld[] = '<img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 500px;">'; } else { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents'); $label_fld[] = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>'; } } else { $label_fld[] = ''; } } } elseif ($uitype == 62) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } elseif ($parent_module == "Potentials") { $label_fld[] = $app_strings['LBL_POTENTIAL_NAME']; $sql = "select * from vtiger_potential where potentialid=?"; $result = $adb->pquery($sql, array($value)); $potentialname = $adb->query_result($result, 0, "potentialname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>'; } elseif ($parent_module == "Products") { $label_fld[] = $app_strings['LBL_PRODUCT_NAME']; $sql = "select * from vtiger_products where productid=?"; $result = $adb->pquery($sql, array($value)); $productname = $adb->query_result($result, 0, "productname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $productname . '</a>'; } elseif ($parent_module == "PurchaseOrder") { $label_fld[] = $app_strings['LBL_PORDER_NAME']; $sql = "select * from vtiger_purchaseorder where purchaseorderid=?"; $result = $adb->pquery($sql, array($value)); $pordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>'; } elseif ($parent_module == "SalesOrder") { $label_fld[] = $app_strings['LBL_SORDER_NAME']; $sql = "select * from vtiger_salesorder where salesorderid=?"; $result = $adb->pquery($sql, array($value)); $sordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>'; } elseif ($parent_module == "Invoice") { $label_fld[] = $app_strings['LBL_INVOICE_NAME']; $sql = "select * from vtiger_invoice where invoiceid=?"; $result = $adb->pquery($sql, array($value)); $invoicename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>'; } elseif ($parent_module == "Quotes") { $label_fld[] = $app_strings['LBL_QUOTES_NAME']; $sql = "select * from vtiger_quotes where quoteid=?"; $result = $adb->pquery($sql, array($value)); $quotename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>'; } elseif ($parent_module == "HelpDesk") { $label_fld[] = $app_strings['LBL_HELPDESK_NAME']; $sql = "select * from vtiger_troubletickets where ticketid=?"; $result = $adb->pquery($sql, array($value)); $title = $adb->query_result($result, 0, "title"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $title . '</a>'; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 105) { //Added for user image $label_fld[] = getTranslatedString($fieldlabel, $module); //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select vtiger_attachments.* from vtiger_attachments left join vtiger_salesmanattachmentsrel on vtiger_salesmanattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid where vtiger_salesmanattachmentsrel.smid=?"; $image_res = $adb->pquery($sql, array($col_fields['record_id'])); $image_id = $adb->query_result($image_res, 0, 'attachmentsid'); $image_path = $adb->query_result($image_res, 0, 'path'); $image_name = $adb->query_result($image_res, 0, 'name'); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { //Added the following check for the image to retain its in original size. list($pro_image_width, $pro_image_height) = getimagesize(decode_html($imgpath)); $label_fld[] = '<a href="' . $imgpath . '" target="_blank"><img src="' . $imgpath . '" width="' . $pro_image_width . '" height="' . $pro_image_height . '" alt="' . $col_fields['user_name'] . '" title="' . $col_fields['user_name'] . '" border="0"></a>'; } else { $label_fld[] = ''; } } elseif ($uitype == 66) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } elseif ($parent_module == "Potentials") { $label_fld[] = $app_strings['LBL_POTENTIAL_NAME']; $sql = "select * from vtiger_potential where potentialid=?"; $result = $adb->pquery($sql, array($value)); $potentialname = $adb->query_result($result, 0, "potentialname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>'; } elseif ($parent_module == "Quotes") { $label_fld[] = $app_strings['LBL_QUOTE_NAME']; $sql = "select * from vtiger_quotes where quoteid=?"; $result = $adb->pquery($sql, array($value)); $quotename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>'; } elseif ($parent_module == "PurchaseOrder") { $label_fld[] = $app_strings['LBL_PORDER_NAME']; $sql = "select * from vtiger_purchaseorder where purchaseorderid=?"; $result = $adb->pquery($sql, array($value)); $pordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>'; } elseif ($parent_module == "SalesOrder") { $label_fld[] = $app_strings['LBL_SORDER_NAME']; $sql = "select * from vtiger_salesorder where salesorderid=?"; $result = $adb->pquery($sql, array($value)); $sordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>'; } elseif ($parent_module == "Invoice") { $label_fld[] = $app_strings['LBL_INVOICE_NAME']; $sql = "select * from vtiger_invoice where invoiceid=?"; $result = $adb->pquery($sql, array($value)); $invoicename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>'; } elseif ($parent_module == "Campaigns") { $label_fld[] = $app_strings['LBL_CAMPAIGN_NAME']; $sql = "select * from vtiger_campaign where campaignid=?"; $result = $adb->pquery($sql, array($value)); $campaignname = $adb->query_result($result, 0, "campaignname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $campaignname . '</a>'; } elseif ($parent_module == "HelpDesk") { $label_fld[] = $app_strings['LBL_HELPDESK_NAME']; $sql = "select * from vtiger_troubletickets where ticketid=?"; $result = $adb->pquery($sql, array($value)); $tickettitle = $adb->query_result($result, 0, "title"); if (strlen($tickettitle) > 25) { $tickettitle = substr($tickettitle, 0, 25) . '...'; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $tickettitle . '</a>'; } elseif ($parent_module == "Vendors") { //MSL $label_fld[] = $app_strings['LBL_VENDOR_NAME']; $sql = "select vendorname from vtiger_vendor where vendorid=?"; $result = $adb->pquery($sql, array($value)); $vendor_name = $adb->query_result($result, 0, "vendorname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $vendor_name . '</a>'; } //MSL ------------------------------------------- } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 67) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 357) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_name = ''; $parent_id = ''; $myemailid = $_REQUEST['record']; $mysql = "select crmid from vtiger_seactivityrel where activityid=?"; $myresult = $adb->pquery($mysql, array($myemailid)); $mycount = $adb->num_rows($myresult); if ($mycount > 1) { $label_fld[] = $app_strings['LBL_RELATED_TO']; $label_fld[] = $app_strings['LBL_MULTIPLE']; } else { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $accountname = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $accountname . '</a>'; } } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 68) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } else { $value = ''; $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 63) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname] . 'h ' . $col_fields['duration_minutes'] . 'm'; } elseif ($uitype == 6) { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname] == '0') { $col_fields[$fieldname] = ''; } if ($col_fields['time_start'] != '') { $start_time = $col_fields['time_start']; } $dateValue = $col_fields[$fieldname]; if ($col_fields[$fieldname] == '0000-00-00' || empty($dateValue)) { $displayValue = ''; } else { if (empty($start_time) && strpos($col_fields[$fieldname], ' ') == false) { $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]); } else { if (!empty($start_time)) { $date = new DateTimeField($col_fields[$fieldname] . ' ' . $start_time); } else { $date = new DateTimeField($col_fields[$fieldname]); } $displayValue = $date->getDisplayDateTimeValue(); } } $label_fld[] = $displayValue; } elseif ($uitype == 5 || $uitype == 23 || $uitype == 70) { $label_fld[] = getTranslatedString($fieldlabel, $module); $dateValue = $col_fields[$fieldname]; if ($col_fields['time_end'] != '' && ($tabid == 9 || $tabid == 16) && $uitype == 23) { $end_time = $col_fields['time_end']; } if ($dateValue == '0000-00-00' || empty($dateValue)) { $displayValue = ''; } else { if (empty($end_time) && strpos($dateValue, ' ') == false) { $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]); } else { if (!empty($end_time)) { $date = new DateTimeField($col_fields[$fieldname] . ' ' . $end_time); } else { $date = new DateTimeField($col_fields[$fieldname]); } $displayValue = $date->getDisplayDateTimeValue(); } } $label_fld[] = $displayValue; } elseif ($uitype == 71 || $uitype == 72) { $label_fld[] = getTranslatedString($fieldlabel, $module); $currencyField = new CurrencyField($col_fields[$fieldname]); if ($uitype == 72) { // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($fieldname == 'unit_price') { $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module)); $label_fld[] = $currencyField->getDisplayValue(null, true); $label_fld["cursymb"] = $rate_symbol['symbol']; } else { $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']); $label_fld[] = $currencyField->getDisplayValue(null, true); $label_fld["cursymb"] = $currency_info['currency_symbol']; } } else { $label_fld[] = $currencyField->getDisplayValue(); $label_fld["cursymb"] = $currencyField->getCurrencySymbol(); } } elseif ($uitype == 75 || $uitype == 81) { $label_fld[] = getTranslatedString($fieldlabel, $module); $vendor_id = $col_fields[$fieldname]; if ($vendor_id != '') { $vendor_name = getVendorName($vendor_id); } $label_fld[] = $vendor_name; $label_fld["secid"] = $vendor_id; $label_fld["link"] = "index.php?module=Vendors&action=DetailView&record=" . $vendor_id; } elseif ($uitype == 76) { $label_fld[] = getTranslatedString($fieldlabel, $module); $potential_id = $col_fields[$fieldname]; if ($potential_id != '') { $potential_name = getPotentialName($potential_id); } $label_fld[] = $potential_name; $label_fld["secid"] = $potential_id; $label_fld["link"] = "index.php?module=Potentials&action=DetailView&record=" . $potential_id; } elseif ($uitype == 78) { $label_fld[] = getTranslatedString($fieldlabel, $module); $quote_id = $col_fields[$fieldname]; if ($quote_id != '') { $quote_name = getQuoteName($quote_id); } $label_fld[] = $quote_name; $label_fld["secid"] = $quote_id; $label_fld["link"] = "index.php?module=Quotes&action=DetailView&record=" . $quote_id; } elseif ($uitype == 79) { $label_fld[] = getTranslatedString($fieldlabel, $module); $purchaseorder_id = $col_fields[$fieldname]; if ($purchaseorder_id != '') { $purchaseorder_name = getPoName($purchaseorder_id); } $label_fld[] = $purchaseorder_name; $label_fld["secid"] = $purchaseorder_id; $label_fld["link"] = "index.php?module=PurchaseOrder&action=DetailView&record=" . $purchaseorder_id; } elseif ($uitype == 80) { $label_fld[] = getTranslatedString($fieldlabel, $module); $salesorder_id = $col_fields[$fieldname]; if ($salesorder_id != '') { $salesorder_name = getSoName($salesorder_id); } $label_fld[] = $salesorder_name; $label_fld["secid"] = $salesorder_id; $label_fld["link"] = "index.php?module=SalesOrder&action=DetailView&record=" . $salesorder_id; } elseif ($uitype == 30) { $rem_days = 0; $rem_hrs = 0; $rem_min = 0; $reminder_str = ""; $rem_days = floor($col_fields[$fieldname] / (24 * 60)); $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60); $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60; $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname]) { $reminder_str = $rem_days . ' ' . $mod_strings['LBL_DAYS'] . ' ' . $rem_hrs . ' ' . $mod_strings['LBL_HOURS'] . ' ' . $rem_min . ' ' . $mod_strings['LBL_MINUTES'] . ' ' . $mod_strings['LBL_BEFORE_EVENT']; } $label_fld[] = ' ' . $reminder_str; } elseif ($uitype == 98) { $label_fld[] = getTranslatedString($fieldlabel, $module); if (is_admin($current_user)) { $label_fld[] = '<a href="index.php?module=Settings&action=RoleDetailView&roleid=' . $col_fields[$fieldname] . '">' . getRoleName($col_fields[$fieldname]) . '</a>'; } else { $label_fld[] = getRoleName($col_fields[$fieldname]); } } elseif ($uitype == 85) { //Added for Skype by Minnie $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 26) { $label_fld[] = getTranslatedString($fieldlabel, $module); $query = "select foldername from vtiger_attachmentsfolder where folderid = ?"; $result = $adb->pquery($query, array($col_fields[$fieldname])); $folder_name = $adb->query_result($result, 0, "foldername"); $label_fld[] = $folder_name; } elseif ($uitype == 27) { if ($col_fields[$fieldname] == 'I') { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $mod_strings['LBL_INTERNAL']; } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $mod_strings['LBL_EXTERNAL']; } } elseif ($uitype == 31) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; $options = array(); $themeList = get_themes(); foreach ($themeList as $theme) { if ($current_user->theme == $theme) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($theme), $theme, $selected); } $label_fld["options"] = $options; } elseif ($uitype == 32) { $options = array(); $languageList = Vtiger_Language::getAll(); $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = isset($languageList[$col_fields[$fieldname]]) ? $languageList[$col_fields[$fieldname]] : $col_fields[$fieldname]; foreach ($languageList as $prefix => $label) { if ($current_user->language == $prefix) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($label), $prefix, $selected); } $label_fld["options"] = $options; } else { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname] == '0' && $fieldname != 'filedownloadcount' && $fieldname != 'filestatus' && $fieldname != 'filesize') { $col_fields[$fieldname] = ''; } //code for Documents module :start if ($tabid == 8) { $downloadtype = $col_fields['filelocationtype']; if ($fieldname == 'filename') { if ($downloadtype == 'I') { //$file_value = $mod_strings['LBL_INTERNAL']; $fld_value = $col_fields['filename']; $ext_pos = strrpos($fld_value, "."); $ext = substr($fld_value, $ext_pos + 1); $ext = strtolower($ext); 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'>"; } } else { $fld_value = $col_fields['filename']; $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' title='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' hspace='3' align='absmiddle' border='0'>"; } $label_fld[] = $fileicon . $fld_value; } if ($fieldname == 'filesize') { if ($col_fields['filelocationtype'] == 'I') { $filesize = $col_fields[$fieldname]; if ($filesize < 1024) { $label_fld[] = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $label_fld[] = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $label_fld[] = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $label_fld[] = ' --'; } } if ($fieldname == 'filetype' && $col_fields['filelocationtype'] == 'E') { $label_fld[] = ' --'; } /* if($fieldname == 'filestatus') { $filestatus = $col_fields[$fieldname]; if($filestatus == 0) $label_fld[]=$mod_strings['LBL_ACTIVE']; else $label_fld[]=$mod_strings['LBL_INACTIVE']; } */ } //code for Documents module :end $label_fld[] = $col_fields[$fieldname]; } } $label_fld[] = $uitype; //sets whether the currenct user is admin or not if (is_admin($current_user)) { $label_fld["isadmin"] = 1; } else { $label_fld["isadmin"] = 0; } $log->debug("Exiting getDetailViewOutputHtml method ..."); return $label_fld; }