public static function do_action($eventName, $parameter = false) { $startTime = microtime(true); self::$numCounter[0]++; // if vtiger.footer Action is called, output the timings for admins if ($eventName == 'corebos.footer') { global $current_user; if ($current_user->is_admin == 'on') { echo "<div style='text-align:left;font-size:11px;padding:0 30px;color:rgb(153, 153, 153);'>Event processing <span title='total time the EventHandler was active' alt='total time the EventHandler was active'>" . round(self::$Counter * 1000, 1) . "</span> / <span title='time Events used internal' alt='time Events used internal'>" . round(self::$CounterInternal * 1000, 1) . " msec (" . self::$numCounter[0] . " Actions / " . self::$numCounter[1] . " Filter)</div>"; } } // Handle Events with the internal EventsManager if (self::$_eventManager === false) { global $adb; self::$_eventManager = new VTEventsManager($adb); // Initialize Event trigger cache self::$_eventManager->initTriggerCache(); } $startTime2 = microtime(true); self::$_eventManager->triggerEvent($eventName, $parameter); self::$Counter += microtime(true) - $startTime; self::$CounterInternal += microtime(true) - $startTime2; }
// We check if we have the two new logo fields > if not we create them $cnorg = $adb->getColumnNames('vtiger_organizationdetails'); if (!in_array('faviconlogo', $cnorg)) { $adb->query('ALTER TABLE `vtiger_organizationdetails` ADD `frontlogo` VARCHAR(150) NOT NULL, ADD `faviconlogo` VARCHAR(150) NOT NULL'); } $sql = "select * from vtiger_organizationdetails"; $result = $adb->pquery($sql, array()); //Handle for allowed organization logo/logoname likes UTF-8 Character // $organization_logo = decode_html($adb->query_result($result,0,'logoname')); // if(!file_exists('test/logo/'.$organization_logo)) $organization_logo='noimageloaded.png'; // $smarty->assign("LOGO",$organization_logo); $favicon = decode_html($adb->query_result($result, 0, 'faviconlogo')); if ($favicon == '') { $favicon = 'themes/images/favicon.ico'; } else { $favicon = 'test/logo/' . $favicon; } $smarty->assign("FAVICON", $favicon); $frontlogo = decode_html($adb->query_result($result, 0, 'frontlogo')); if ($frontlogo == '') { $frontlogo = 'noimageloaded.png'; } $smarty->assign("FRONTLOGO", $frontlogo); $companyDetails = array(); $companyDetails['name'] = $adb->query_result($result, 0, 'organizationname'); $companyDetails['website'] = $adb->query_result($result, 0, 'website'); $companyDetails['logo'] = $organization_logo; $smarty->assign("COMPANY_DETAILS", $companyDetails); $smarty->display("Header.tpl"); cbEventHandler::do_action('corebos.header');
//added to get the theme . This is a bad fix as we need to know where the problem lies yet if (isset($_SESSION['vtiger_authenticated_user_theme']) && $_SESSION['vtiger_authenticated_user_theme'] != '') { $theme = $_SESSION['vtiger_authenticated_user_theme']; } else { $theme = $default_theme; } $Ajx_module = $module; if ($module == 'Events') { $Ajx_module = 'Calendar'; } if (!$viewAttachment && (!$viewAttachment && $action != 'home_rss') && $action != 'Tickerdetail' && $action != $Ajx_module . "Ajax" && $action != "chat" && $action != "HeadLines" && $action != 'massdelete' && $action != "DashboardAjax" && $action != "ActivityAjax") { // Under the SPL you do not have the right to remove this copyright statement. $copyrightstatement = "<style>\n\t\t.bggray\n\t\t{\n\t\t\tbackground-color: #dfdfdf;\n\t\t}\n\t.bgwhite\n\t{\n\t\tbackground-color: #FFFFFF;\n\t}\n\t.copy\n\t{\n\t\tfont-size:9px;\n\t\tfont-family: Verdana, Arial, Helvetica, Sans-serif;\n\t}\n\t</style>"; if (!$skipFooters && $action != "about_us" && $action != "vtchat" && $action != "ChangePassword" && $action != "body" && $action != $module . "Ajax" && $action != 'Popup' && $action != 'ImportStep3' && $action != 'ActivityAjax' && $action != 'getListOfRecords') { echo $copyrightstatement; cbEventHandler::do_action('corebos.footer.prefooter'); echo "<br><br><br><table border=0 cellspacing=0 cellpadding=5 width=100% class=settingsSelectedUI >"; echo "<tr><td class=small align=left><span style='color: rgb(153, 153, 153);'>Powered by " . getTranslatedString('APP_NAME') . " <span id='_vtiger_product_version_'>{$coreBOS_app_version}</span></span></td>"; echo "<td class=small align=right><span>© 2004-" . date('Y') . " <a href='{$coreBOS_app_url}' target='_blank'>{$coreBOS_app_name}</a> | <a href='copyright.html' target='_blank'>" . $app_strings['LNK_READ_LICENSE'] . "</a> | <a href='http://corebos.org/page/privacy-policy' target='_blank'>" . getTranslatedString('LNK_PRIVACY_POLICY') . "</a></span></td></tr></table>"; // echo "<table align='center'><tr><td align='center'>"; // Under the Sugar Public License referenced above, you are required to leave in all copyright statements // in both the code and end-user application. // if($calculate_response_time) // { // $endTime = microtime(); // $deltaTime = microtime_diff($startTime, $endTime); // echo(' Server response time: '.$deltaTime.' seconds.'); // } // echo "</td></tr></table>\n"; } if ($action != 'mytkt_rss' && $action != 'home_rss' && $action != $module . "Ajax" && $action != "body" && $action != 'ActivityAjax') {
$tmp_file_name = $import_dir . "IMPORT_" . $focus->id; if (file_exists($tmp_file_name)) { unlink($tmp_file_name); } $arr = $_SESSION['lastpage']; if (isset($_SESSION['lastpage'])) { header("Location: index.php?" . $arr); } else { header("Location: index.php"); } } else { $sql = 'select failed_login_attempts from vtiger_users where user_name=?'; $result = $adb->pquery($sql, array($focus->column_fields["user_name"])); $failed_login_attempts = 0; if ($result and $adb->num_rows($result) > 0) { $failed_login_attempts = $adb->query_result($result, 0, 0); } $maxFailedLoginAttempts = GlobalVariable::getVariable('Application_MaxFailedLoginAttempts', 5); // Increment number of failed login attempts $query = 'UPDATE vtiger_users SET failed_login_attempts=COALESCE(failed_login_attempts,0)+1 where user_name=?'; $adb->pquery($query, array($focus->column_fields['user_name'])); $_SESSION['login_user_name'] = $focus->column_fields["user_name"]; $_SESSION['login_password'] = $user_password; if (empty($_SESSION['login_error'])) { $_SESSION['login_error'] = $failed_login_attempts >= $maxFailedLoginAttempts ? $mod_strings['ERR_MAXLOGINATTEMPTS'] : $mod_strings['ERR_INVALID_PASSWORD']; } cbEventHandler::do_action('corebos.audit.login.attempt', array(0, $focus->column_fields["user_name"], 'Login Attempt', 0, date('Y-m-d H:i:s'))); // go back to the login screen. // create an error message for the user. header("Location: index.php"); }
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. ********************************************************************************/ require_once 'modules/Calendar/Activity.php'; require_once 'include/logging.php'; require_once "config.php"; require_once 'include/database/PearDatabase.php'; require_once 'modules/Calendar/CalendarCommon.php'; require_once 'modules/Calendar4You/CalendarUtils.php'; global $adb, $theme, $mod_strings, $current_user; $local_log =& LoggerManager::getLogger('index'); $_REQUEST = vtlib_purify($_REQUEST); // clean up ALL values if ($_REQUEST['mode'] == 'event_drop' || $_REQUEST['mode'] == 'event_resize') { list($void, $processed) = cbEventHandler::do_filter('corebos.filter.CalendarModule.save', array($_REQUEST, false)); if ($processed) { exit; } } $focus = new Activity(); $activity_mode = vtlib_purify($_REQUEST['activity_mode']); $record = vtlib_purify($_REQUEST['record']); if (empty($activity_mode) and !empty($record)) { $activity_mode = getEventActivityMode($record); } $tab_type = 'Calendar'; if ($activity_mode == 'Events') { $tab_type = 'Events'; } $search = vtlib_purify($_REQUEST['search_url']);
/** function used to get the shipping & handling tax percentage for the given inventory id and taxname * @param int $id - entity id which will be PO/SO/Quotes or Invoice id * @param string $taxname - shipping and handling taxname * @return float $taxpercentage - shipping and handling taxpercentage which is associated with the given entity */ function getInventorySHTaxPercent($id, $taxname) { global $log, $adb; $log->debug("Entering into function getInventorySHTaxPercent({$id}, {$taxname})"); list($void1, $void2, $taxpercentage) = cbEventHandler::do_filter('corebos.filter.TaxCalculation.getInventorySHTaxPercent', array($id, $taxname, '')); if ($taxpercentage == '') { $res = $adb->pquery("select {$taxname} from vtiger_inventoryshippingrel where id= ?", array($id)); $taxpercentage = $adb->query_result($res, 0, $taxname); } if ($taxpercentage == '') { $taxpercentage = '0.00'; } $log->debug("Exit from function getInventorySHTaxPercent({$id}, {$taxname})"); return $taxpercentage; }
/** * Function to related two records of different entity types */ function relateEntities($focus, $sourceModule, $sourceRecordId, $destinationModule, $destinationRecordIds) { if (!is_array($destinationRecordIds)) { $destinationRecordIds = array($destinationRecordIds); } $data = array(); $data['focus'] = $focus; $data['sourceModule'] = $sourceModule; $data['sourceRecordId'] = $sourceRecordId; $data['destinationModule'] = $destinationModule; foreach ($destinationRecordIds as $destinationRecordId) { $data['destinationRecordId'] = $destinationRecordId; cbEventHandler::do_action('corebos.entity.link.before', $data); $focus->save_related_module($sourceModule, $sourceRecordId, $destinationModule, $destinationRecordId); $focus->trackLinkedInfo($sourceModule, $sourceRecordId, $destinationModule, $destinationRecordId); cbEventHandler::do_action('corebos.entity.link.after', $data); } }
/** * Function to track when a record is unlinked to a given record */ function trackUnLinkedInfo($module, $crmid, $with_module, $with_crmid) { global $current_user; $adb = PearDatabase::getInstance(); $currentTime = date('Y-m-d H:i:s'); $data = array(); $data['sourceModule'] = $module; $data['sourceRecordId'] = $crmid; $data['destinationModule'] = $with_module; $data['destinationRecordId'] = $with_crmid; cbEventHandler::do_action('corebos.entity.link.delete', $data); $adb->pquery('UPDATE vtiger_crmentity SET modifiedtime = ?, modifiedby = ? WHERE crmid = ?', array($currentTime, $current_user->id, $crmid)); }
function delete_related_module($module, $crmid, $with_module, $with_crmid) { global $log, $adb; if ($with_module == 'Contacts') { if (!is_array($with_crmid)) { $with_crmid = array($with_crmid); } $data = array(); $data['sourceModule'] = $module; $data['sourceRecordId'] = $crmid; $data['destinationModule'] = $with_module; foreach ($with_crmid as $relcrmid) { $data['destinationRecordId'] = $relcrmid; cbEventHandler::do_action('corebos.entity.link.delete', $data); $adb->pquery('DELETE FROM vtiger_vendorcontactrel WHERE vendorid=? AND contactid=?', array($crmid, $relcrmid)); } } else { parent::delete_related_module($module, $crmid, $with_module, $with_crmid); } }
/** This function is a wrapper that extends the permissions system with a hook to specific functionality **/ function isPermitted($module, $actionname, $record_id = '') { $permission = _vtisPermitted($module, $actionname, $record_id); list($permission, $unused1, $unused2, $unused3) = cbEventHandler::do_filter('corebos.permissions.ispermitted', array($permission, $module, $actionname, $record_id)); return $permission; }
/** Function that Records the Logout info of the User * @param ref variable $usname :: Type varchar * @param ref variable $usip :: Type varchar * @param ref variable $outime :: Type timestamp * Returns the query result which contains the details of User Logout Info */ function user_logout(&$usname, &$usip, &$outtime) { global $adb; cbEventHandler::do_action('corebos.audit.logout', array($usname, 'Users', 'Logout', $usname, date("Y-m-d H:i:s"))); $logid_qry = "SELECT max(login_id) AS login_id from vtiger_loginhistory where user_name=? and user_ip=?"; $result = $adb->pquery($logid_qry, array($usname, $usip)); $loginid = $adb->query_result($result, 0, "login_id"); if ($loginid == '') { return; } // update the user login info. $query = "Update vtiger_loginhistory set logout_time =?, status=? where login_id = ?"; $result = $adb->pquery($query, array($this->db->formatDate($outtime, true), 'Signed off', $loginid)) or die("MySQL error: " . mysql_error()); }
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; }
function process($context = false) { $this->context = $context; $sourceRecordId = $this->getFromContext('ID', true); $usecriteria = $this->criteria === false ? $this->defaultCriteria : $this->criteria; $viewer = $this->getViewer(); $viewer->assign('ID', $sourceRecordId); $viewer->assign('CRITERIA', $usecriteria); $BLOCKOPEN = GlobalVariable::getVariable('ModComments_DefaultBlockStatus', 1); $viewer->assign('BLOCKOPEN', $BLOCKOPEN); list($void, $canaddcomments) = cbEventHandler::do_filter('corebos.filter.ModComments.canAdd', array($sourceRecordId, true)); $viewer->assign('CANADDCOMMENTS', $canaddcomments ? 'YES' : 'NO'); $viewer->assign('COMMENTS', $this->getModels($sourceRecordId, $usecriteria)); return $viewer->fetch(vtlib_getModuleTemplate("ModComments", "widgets/DetailViewBlockComment.tpl")); }
/** * This function is used to set the Object values from the REQUEST values. * @param object reference $focus - reference of the object */ function setObjectValuesFromRequest($focus) { global $log; $moduleName = get_class($focus); $log->debug("Entering setObjectValuesFromRequest({$moduleName}) method ..."); if (isset($_REQUEST['record'])) { $focus->id = $_REQUEST['record']; } if (isset($_REQUEST['mode'])) { $focus->mode = $_REQUEST['mode']; } foreach ($focus->column_fields as $fieldname => $val) { if (isset($_REQUEST[$fieldname])) { if (is_array($_REQUEST[$fieldname])) { $value = $_REQUEST[$fieldname]; } else { $value = trim($_REQUEST[$fieldname]); } $focus->column_fields[$fieldname] = $value; } elseif (isset($_REQUEST[$fieldname . '_hidden'])) { $value = trim($_REQUEST[$fieldname . '_hidden']); $focus->column_fields[$fieldname] = $value; } } $cbfrommodule = $moduleName; $cbfrom = CRMEntity::getInstance($cbfrommodule); $bmapname = $moduleName . '2' . $moduleName; $cbMapid = GlobalVariable::getVariable('BusinessMapping_' . $bmapname, cbMap::getMapIdByName($bmapname)); if (!empty($_REQUEST['cbfromid'])) { $cbfromid = vtlib_purify($_REQUEST['cbfromid']); $cbfrommodule = getSalesEntityType($cbfromid); $bmapname = $cbfrommodule . '2' . $moduleName; $cbfrom = CRMEntity::getInstance($cbfrommodule); $cbfrom->retrieve_entity_info($cbfromid, $cbfrommodule); $cbMapidFromid = GlobalVariable::getVariable('BusinessMapping_' . $bmapname, cbMap::getMapIdByName($bmapname)); if ($cbMapidFromid) { $cbMapid = $cbMapidFromid; } } if ($cbMapid) { $cbMap = cbMap::getMapByID($cbMapid); $focus->column_fields = $cbMap->Mapping($cbfrom->column_fields, $focus->column_fields); } $focus = cbEventHandler::do_filter('corebos.filter.editview.setObjectValues', $focus); $log->debug("Exiting setObjectValuesFromRequest method ..."); }
/** to get the customviewCombo for the class variable customviewmodule * @param $viewid :: Type Integer * $viewid will make the corresponding selected * @returns $customviewCombo :: Type String */ function getCustomViewCombo($viewid = '', $markselected = true) { global $adb, $current_user; global $app_strings; $tabid = getTabid($this->customviewmodule); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $shtml_user = ''; $shtml_pending = ''; $shtml_public = ''; $shtml_others = ''; $selected = 'selected'; if ($markselected == false) { $selected = ''; } $ssql = "select vtiger_customview.*, vtiger_users.first_name,vtiger_users.last_name from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype\n\t\t\t\t\tleft join vtiger_users on vtiger_customview.userid = vtiger_users.id "; $ssql .= " where vtiger_tab.tabid=?"; $sparams = array($tabid); if ($is_admin == false) { $ssql .= " and (vtiger_customview.status=0 or vtiger_customview.userid = ? or vtiger_customview.status = 3 or vtiger_customview.userid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '" . $current_user_parent_role_seq . "::%'))"; array_push($sparams, $current_user->id); } $ssql .= " ORDER BY viewname"; $cuserroles = getRoleAndSubordinateUserIds($current_user->column_fields['roleid']); $result = $adb->pquery($ssql, $sparams); while ($cvrow = $adb->fetch_array($result)) { if ($cvrow['viewname'] == 'All') { $cvrow['viewname'] = $app_strings['COMBO_ALL']; } else { /** Should the filter shown? */ $return = cbEventHandler::do_filter('corebos.filter.listview.filter.show', $cvrow); if ($return == false) { continue; } } $option = ''; $viewname = $cvrow['viewname']; if ($cvrow['status'] == CV_STATUS_DEFAULT || $cvrow['userid'] == $current_user->id) { $disp_viewname = $viewname; } else { $userName = getFullNameFromArray('Users', $cvrow); $disp_viewname = $viewname . " [" . $userName . "] "; } if ($cvrow['setdefault'] == 1 && $viewid == '') { $option = "<option {$selected} value=\"" . $cvrow['cvid'] . "\">" . $disp_viewname . "</option>"; $this->setdefaultviewid = $cvrow['cvid']; } elseif ($cvrow['cvid'] == $viewid) { $option = "<option {$selected} value=\"" . $cvrow['cvid'] . "\">" . $disp_viewname . "</option>"; $this->setdefaultviewid = $cvrow['cvid']; } else { $option = "<option value=\"" . $cvrow['cvid'] . "\">" . $disp_viewname . "</option>"; } // Add the option to combo box at appropriate section if ($option != '') { if ($cvrow['status'] == CV_STATUS_DEFAULT || $cvrow['userid'] == $current_user->id) { $shtml_user .= $option; } elseif ($cvrow['status'] == CV_STATUS_PUBLIC) { if ($shtml_public == '') { $shtml_public = "<option disabled>--- " . $app_strings['LBL_PUBLIC'] . " ---</option>"; } $shtml_public .= $option; } elseif ($cvrow['status'] == CV_STATUS_PENDING) { if (in_array($cvrow['userid'], $cuserroles)) { if ($shtml_pending == '') { $shtml_pending = "<option disabled>--- " . $app_strings['LBL_PENDING'] . " ---</option>"; } $shtml_pending .= $option; } } else { if ($shtml_others == '') { $shtml_others = "<option disabled>--- " . $app_strings['LBL_OTHERS'] . " ---</option>"; } $shtml_others .= $option; } } } $shtml = $shtml_user; $shtml .= $shtml_pending; $shtml = $shtml . $shtml_public . $shtml_others; return $shtml; }
public function createRecords() { $adb = PearDatabase::getInstance(); $moduleName = $this->module; $focus = CRMEntity::getInstance($moduleName); $moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user); $moduleMeta = $moduleHandler->getMeta(); $moduleObjectId = $moduleMeta->getEntityId(); $moduleFields = $moduleMeta->getModuleFields(); $tableName = Import_Utils::getDbTableName($this->user); $sql = 'SELECT * FROM ' . $tableName . ' WHERE status = ' . Import_Data_Controller::$IMPORT_RECORD_NONE; if ($this->batchImport) { $configReader = new ConfigReader('modules/Import/config.inc', 'ImportConfig'); $importBatchLimit = $configReader->getConfig('importBatchLimit'); $sql .= ' LIMIT ' . $importBatchLimit; } $result = $adb->query($sql); $numberOfRecords = $adb->num_rows($result); if ($numberOfRecords <= 0) { return; } $fieldMapping = $this->fieldMapping; $fieldColumnMapping = $moduleMeta->getFieldColumnMapping(); for ($i = 0; $i < $numberOfRecords; ++$i) { $row = $adb->raw_query_result_rowdata($result, $i); $rowId = $row['id']; $entityInfo = null; $fieldData = array(); foreach ($fieldMapping as $fieldName => $index) { $fieldData[$fieldName] = $row[$fieldName]; } $mergeType = $this->mergeType; $createRecord = false; if (method_exists($focus, 'importRecord')) { $entityInfo = $focus->importRecord($this, $fieldData); } else { if (!empty($mergeType) && $mergeType != Import_Utils::$AUTO_MERGE_NONE) { $queryGenerator = new QueryGenerator($moduleName, $this->user); $queryGenerator->initForDefaultCustomView(); $fieldsList = array('id'); $queryGenerator->setFields($fieldsList); $mergeFields = $this->mergeFields; foreach ($mergeFields as $index => $mergeField) { if ($index != 0) { $queryGenerator->addConditionGlue(QueryGenerator::$AND); } $comparisonValue = $fieldData[$mergeField]; $fieldInstance = $moduleFields[$mergeField]; if ($fieldInstance->getFieldDataType() == 'owner') { $userId = getUserId_Ol($comparisonValue); $comparisonValue = getUserFullName($userId); } if ($fieldInstance->getFieldDataType() == 'reference') { if (strpos($comparisonValue, '::::') > 0) { $referenceFileValueComponents = explode('::::', $comparisonValue); } else { $referenceFileValueComponents = explode(':::', $comparisonValue); } if (count($referenceFileValueComponents) > 1) { $comparisonValue = trim($referenceFileValueComponents[1]); } } $queryGenerator->addCondition($mergeField, $comparisonValue, 'e'); } $query = $queryGenerator->getQuery(); $duplicatesResult = $adb->query($query); $noOfDuplicates = $adb->num_rows($duplicatesResult); if ($noOfDuplicates > 0) { if ($mergeType == Import_Utils::$AUTO_MERGE_IGNORE) { $entityInfo['status'] = self::$IMPORT_RECORD_SKIPPED; } elseif ($mergeType == Import_Utils::$AUTO_MERGE_OVERWRITE || $mergeType == Import_Utils::$AUTO_MERGE_MERGEFIELDS) { for ($index = 0; $index < $noOfDuplicates - 1; ++$index) { $duplicateRecordId = $adb->query_result($duplicatesResult, $index, $fieldColumnMapping['id']); $entityId = vtws_getId($moduleObjectId, $duplicateRecordId); vtws_delete($entityId, $this->user); } $baseRecordId = $adb->query_result($duplicatesResult, $noOfDuplicates - 1, $fieldColumnMapping['id']); $baseEntityId = vtws_getId($moduleObjectId, $baseRecordId); if ($mergeType == Import_Utils::$AUTO_MERGE_OVERWRITE) { $fieldData = $this->transformForImport($fieldData, $moduleMeta); $fieldData['id'] = $baseEntityId; $entityInfo = vtws_update($fieldData, $this->user); $entityInfo['status'] = self::$IMPORT_RECORD_UPDATED; //Prepare data for event handler $entityData = array(); $entityData['rowId'] = $rowId; $entityData['tableName'] = $tableName; $entityData['entityInfo'] = $entityInfo; $entityData['fieldData'] = $fieldData; $entityData['moduleName'] = $moduleName; $entityData['user'] = $this->user; cbEventHandler::do_action('corebos.entity.import.overwrite', $entityData); } if ($mergeType == Import_Utils::$AUTO_MERGE_MERGEFIELDS) { $filteredFieldData = array(); $defaultFieldValues = $this->getDefaultFieldValues($moduleMeta); foreach ($fieldData as $fieldName => $fieldValue) { if (!empty($fieldValue)) { $filteredFieldData[$fieldName] = $fieldValue; } } $existingFieldValues = vtws_retrieve($baseEntityId, $this->user); foreach ($existingFieldValues as $fieldName => $fieldValue) { if (empty($fieldValue) && empty($filteredFieldData[$fieldName]) && !empty($defaultFieldValues[$fieldName])) { $filteredFieldData[$fieldName] = $fieldValue; } } $filteredFieldData = $this->transformForImport($filteredFieldData, $moduleMeta, false, true); $filteredFieldData['id'] = $baseEntityId; $entityInfo = vtws_revise($filteredFieldData, $this->user); $entityInfo['status'] = self::$IMPORT_RECORD_MERGED; //Prepare data for event handler $entityData = array(); $entityData['rowId'] = $rowId; $entityData['tableName'] = $tableName; $entityData['entityInfo'] = $entityInfo; $entityData['fieldData'] = $fieldData; $entityData['moduleName'] = $moduleName; $entityData['user'] = $this->user; cbEventHandler::do_action('corebos.entity.import.merge', $entityData); } } else { $createRecord = true; } } else { $createRecord = true; } } else { $createRecord = true; } if ($createRecord) { $fieldData = $this->transformForImport($fieldData, $moduleMeta); if ($fieldData == null) { $entityInfo = null; } else { $entityInfo = vtws_create($moduleName, $fieldData, $this->user); $entityInfo['status'] = self::$IMPORT_RECORD_CREATED; //Prepare data for event handler $entityData = array(); $entityData['rowId'] = $rowId; $entityData['tableName'] = $tableName; $entityData['entityInfo'] = $entityInfo; $entityData['fieldData'] = $fieldData; $entityData['moduleName'] = $moduleName; $entityData['user'] = $this->user; cbEventHandler::do_action('corebos.entity.import.create', $entityData); } } } if ($entityInfo == null) { $entityInfo = array('id' => null, 'status' => self::$IMPORT_RECORD_FAILED); } $this->importedRecordInfo[$rowId] = $entityInfo; $this->updateImportStatus($rowId, $entityInfo); } unset($result); return true; }
/** * This function is used to set the Object values from the REQUEST values. * @param object reference $focus - reference of the object */ function setObjectValuesFromRequest($focus) { global $log; $log->debug("Entering setObjectValuesFromRequest(" . get_class($focus) . ") method ..."); if (isset($_REQUEST['record'])) { $focus->id = $_REQUEST['record']; } if (isset($_REQUEST['mode'])) { $focus->mode = $_REQUEST['mode']; } foreach ($focus->column_fields as $fieldname => $val) { if (isset($_REQUEST[$fieldname])) { if (is_array($_REQUEST[$fieldname])) { $value = $_REQUEST[$fieldname]; } else { $value = trim($_REQUEST[$fieldname]); } $focus->column_fields[$fieldname] = $value; } } $focus = cbEventHandler::do_filter('corebos.filter.editview.setObjectValues', $focus); $log->debug("Exiting setObjectValuesFromRequest method ..."); }
$smarty->assign("UPLOAD_MAXSIZE", $upload_maxsize); // Field Validation Information $tabid = getTabid($currentModule); $validationData = getDBValidationData($focus->tab_name, $tabid); $validationArray = split_validationdataArray($validationData); $smarty->assign("VALIDATION_DATA_FIELDNAME", $validationArray['fieldname']); $smarty->assign("VALIDATION_DATA_FIELDDATATYPE", $validationArray['datatype']); $smarty->assign("VALIDATION_DATA_FIELDLABEL", $validationArray['fieldlabel']); // In case you have a date field $smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']); $smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT'])); // Module Sequence Numbering $mod_seq_field = getModuleSequenceField($currentModule); if ($focus->mode != 'edit' && $mod_seq_field != null) { $autostr = getTranslatedString('MSG_AUTO_GEN_ON_SAVE'); list($mod_seq_string, $mod_seq_prefix, $mod_seq_no, $doNative) = cbEventHandler::do_filter('corebos.filter.ModuleSeqNumber.get', array('', '', '', true)); if ($doNative) { $mod_seq_string = $adb->pquery("SELECT prefix, cur_id from vtiger_modentity_num where semodule = ? and active=1", array($currentModule)); $mod_seq_prefix = $adb->query_result($mod_seq_string, 0, 'prefix'); $mod_seq_no = $adb->query_result($mod_seq_string, 0, 'cur_id'); } if ($adb->num_rows($mod_seq_string) == 0 || $focus->checkModuleSeqNumber($focus->table_name, $mod_seq_field['column'], $mod_seq_prefix . $mod_seq_no)) { $smarty->assign('ERROR_MESSAGE_CLASS', 'cb-alert-warning'); $smarty->assign('ERROR_MESSAGE', '<b>' . getTranslatedString($mod_seq_field['label']) . ' ' . getTranslatedString('LBL_NOT_CONFIGURED') . ' - ' . getTranslatedString('LBL_PLEASE_CLICK') . ' <a href="index.php?module=Settings&action=CustomModEntityNo&parenttab=Settings&selmodule=' . $currentModule . '">' . getTranslatedString('LBL_HERE') . '</a> ' . getTranslatedString('LBL_TO_CONFIGURE') . ' ' . getTranslatedString($mod_seq_field['label']) . '</b>'); } else { $smarty->assign("MOD_SEQ_ID", $autostr); } } else { $smarty->assign("MOD_SEQ_ID", $focus->column_fields[$mod_seq_field['name']]); } //if create Invoice, get all available product taxes and shipping & Handling taxes
public function getListViewHeader($focus, $module, $sort_qry = '', $sorder = '', $orderBy = '', $skipActions = false) { global $log, $singlepane_view, $theme, $current_user; $arrow = ''; $qry = getURLstring($focus); $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $header = array(); //Get the vtiger_tabid of the module $tabid = getTabid($module); $tabname = getParentTab(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $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); //Added on 14-12-2005 to avoid if and else check for every list //vtiger_field for arrow image and change order $change_sorder = array('ASC' => 'DESC', 'DESC' => 'ASC'); $arrow_gif = array('ASC' => 'arrow_down.gif', 'DESC' => 'arrow_up.gif'); foreach ($listViewFields as $fieldName) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } if (in_array($field->getColumnName(), $focus->sortby_fields)) { if ($orderBy == $field->getColumnName()) { $temp_sorder = $change_sorder[$sorder]; $arrow = " <img src ='" . vtiger_imageurl($arrow_gif[$sorder], $theme) . "' border='0'>"; } else { $temp_sorder = 'ASC'; } $label = getTranslatedString($field->getFieldLabelKey(), $module); //added to display vtiger_currency symbol in listview header if ($label == 'Amount') { $label .= ' (' . getTranslatedString('LBL_IN', $module) . ' ' . $user_info['currency_symbol'] . ')'; } if ($field->getUIType() == '9') { $label .= ' (%)'; } if ($module == 'Users' && $fieldName == 'User Name') { $name = "<a href='javascript:;' onClick='getListViewEntries_js(\"" . $module . "\",\"parenttab=" . $tabname . "&order_by=" . $field->getColumnName() . "&sorder=" . $temp_sorder . $sort_qry . "\");' class='listFormHeaderLinks'>" . getTranslatedString('LBL_LIST_USER_NAME_ROLE', $module) . "" . $arrow . "</a>"; } else { if ($this->isHeaderSortingEnabled()) { $name = "<a href='javascript:;' onClick='getListViewEntries_js(\"" . $module . "\",\"parenttab=" . $tabname . "&foldername=Default&order_by=" . $field->getColumnName() . "&start=" . (isset($_SESSION['lvs'][$module]['start']) ? $_SESSION['lvs'][$module]['start'] : '') . "&sorder=" . $temp_sorder . "" . $sort_qry . "\");' class='listFormHeaderLinks'>" . $label . "" . $arrow . "</a>"; } else { $name = $label; } } $arrow = ''; } else { $name = getTranslatedString($field->getFieldLabelKey(), $module); } //added to display vtiger_currency symbol in related listview header if ($name == 'Amount') { $name .= ' (' . getTranslatedString('LBL_IN') . ' ' . $user_info['currency_symbol'] . ')'; } $header[] = $name; } //Added for Action - edit and delete link header in listview if (!$skipActions && (isPermitted($module, "EditView", "") == 'yes' || isPermitted($module, "Delete", "") == 'yes')) { $header[] = getTranslatedString("LBL_ACTION", $module); } $header = cbEventHandler::do_filter('corebos.filter.listview.header', $header); return $header; }
/*+********************************************************************************** * The contents of this file are subject to the vtiger CRM Public License Version 1.0 * ("License"); You may not use this file except in compliance with the License * The Original Code is: vtiger CRM Open Source * The Initial Developer of the Original Code is vtiger. * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. ************************************************************************************/ global $current_user, $currentModule, $singlepane_view; checkFileAccessForInclusion("modules/{$currentModule}/{$currentModule}.php"); require_once "modules/{$currentModule}/{$currentModule}.php"; $search = vtlib_purify($_REQUEST['search_url']); $focus = new $currentModule(); setObjectValuesFromRequest($focus); list($void, $canaddcomments) = cbEventHandler::do_filter('corebos.filter.ModComments.canAdd', array(vtlib_purify($_REQUEST['related_to']), true)); if ($canaddcomments) { $mode = vtlib_purify($_REQUEST['mode']); $record = vtlib_purify($_REQUEST['record']); if ($mode) { $focus->mode = $mode; } if ($record) { $focus->id = $record; } if (isset($_REQUEST['inventory_currency'])) { $focus->column_fields['currency_id'] = vtlib_purify($_REQUEST['inventory_currency']); $cur_sym_rate = getCurrencySymbolandCRate(vtlib_purify($_REQUEST['inventory_currency'])); $focus->column_fields['conversion_rate'] = $cur_sym_rate['rate']; } if ($_REQUEST['assigntype'] == 'U') {
if ($sql_error) { $smarty->assign('ERROR', getTranslatedString('ERROR_GETTING_FILTER')); $smarty->assign("CUSTOMVIEW_OPTION", $customview_html); } else { // Enabling Module Search $url_string = ''; if ($_REQUEST['query'] == 'true') { $queryGenerator->addUserSearchConditions($_REQUEST); $ustring = getSearchURL($_REQUEST); $url_string .= "&query=true{$ustring}"; $smarty->assign('SEARCH_URL', $url_string); } $queryGenerator = cbEventHandler::do_filter('corebos.filter.listview.querygenerator.before', $queryGenerator); $list_query = $queryGenerator->getQuery(); $queryGenerator = cbEventHandler::do_filter('corebos.filter.listview.querygenerator.after', $queryGenerator); $list_query = cbEventHandler::do_filter('corebos.filter.listview.querygenerator.query', $list_query); $where = $queryGenerator->getConditionalWhere(); if (isset($where) && $where != '') { $_SESSION['export_where'] = $where; } else { unset($_SESSION['export_where']); } // Sorting if (!empty($order_by)) { if ($order_by == 'smownerid') { $list_query .= ' ORDER BY user_name ' . $sorder; } else { $tablename = getTableNameForField($currentModule, $order_by); $tablename = $tablename != '' ? $tablename . '.' : ''; $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder; }
} $sid = $sessionManager->startSession($sessionId, $adoptSession); if (!$sessionId && !$operationManager->isPreLoginOperation()) { writeErrorOutput($operationManager, new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, "Authentication required")); return; } if (!$sid) { writeErrorOutput($operationManager, $sessionManager->getError()); return; } $userid = $sessionManager->get("authenticatedUserId"); if ($userid) { $seed_user = new Users(); $current_user = $seed_user->retrieveCurrentUserInfoFromFile($userid); } else { $current_user = null; } $operationInput = $operationManager->sanitizeOperation($input); $includes = $operationManager->getOperationIncludes(); foreach ($includes as $ind => $path) { checkFileAccessForInclusion($path); require_once $path; } cbEventHandler::do_action('corebos.audit.action', array(isset($current_user) ? $current_user->id : 0, 'Webservice', $operation, 0, date('Y-m-d H:i:s'))); $rawOutput = $operationManager->runOperation($operationInput, $current_user); writeOutput($operationManager, $rawOutput); } catch (WebServiceException $e) { writeErrorOutput($operationManager, $e); } catch (Exception $e) { writeErrorOutput($operationManager, new WebServiceException(WebServiceErrorCode::$INTERNALERROR, "Unknown Error while processing request")); }
/** * Get all the link related to module based on type * @param Integer Module ID * @param mixed String or List of types to select * @param Map Key-Value pair to use for formating the link url */ static function getAllByType($tabid, $type = false, $parameters = false) { global $adb, $current_user; self::__initSchema(); $multitype = false; $orderby = ' order by linktype,sequence'; //MSL if ($type) { // Multiple link type selection? if (is_array($type)) { $multitype = true; if ($tabid === self::IGNORE_MODULE) { $sql = 'SELECT * FROM vtiger_links WHERE linktype IN (' . Vtiger_Utils::implodestr('?', count($type), ',') . ') '; $params = $type; $permittedTabIdList = getPermittedModuleIdList(); if (count($permittedTabIdList) > 0 && $current_user->is_admin !== 'on') { $sql .= ' and tabid IN (' . Vtiger_Utils::implodestr('?', count($permittedTabIdList), ',') . ')'; $params[] = $permittedTabIdList; } $result = $adb->pquery($sql . $orderby, array($adb->flatten_array($params))); } else { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE tabid=? AND linktype IN (' . Vtiger_Utils::implodestr('?', count($type), ',') . ')' . $orderby, array($tabid, $adb->flatten_array($type))); } } else { // Single link type selection if ($tabid === self::IGNORE_MODULE) { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE linktype=?' . $orderby, array($type)); } else { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE tabid=? AND linktype=?' . $orderby, array($tabid, $type)); } } } else { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE tabid=?' . $orderby, array($tabid)); } $strtemplate = new Vtiger_StringTemplate(); if ($parameters) { foreach ($parameters as $key => $value) { $strtemplate->assign($key, $value); } } $instances = array(); if ($multitype) { foreach ($type as $t) { $instances[$t] = array(); } } while ($row = $adb->fetch_array($result)) { /** Should the widget be shown */ $return = cbEventHandler::do_filter('corebos.filter.link.show', array($row, $type, $parameters)); if ($return == false) { continue; } $instance = new self(); $instance->initialize($row); if (!empty($row['handler_path']) && isFileAccessible($row['handler_path'])) { checkFileAccessForInclusion($row['handler_path']); require_once $row['handler_path']; $linkData = new Vtiger_LinkData($instance, $current_user); $ignore = call_user_func(array($row['handler_class'], $row['handler']), $linkData); if (!$ignore) { self::log("Ignoring Link ... " . var_export($row, true)); continue; } } if ($parameters) { $instance->linkurl = $strtemplate->merge($instance->linkurl); $instance->linkicon = $strtemplate->merge($instance->linkicon); } if ($multitype) { $instances[$instance->linktype][] = $instance; } else { $instances[] = $instance; } } return $instances; }