本文整理汇总了PHP中getUserId_Ol函数的典型用法代码示例。如果您正苦于以下问题:PHP getUserId_Ol函数的具体用法?PHP getUserId_Ol怎么用?PHP getUserId_Ol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getUserId_Ol函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changePassword
public function changePassword($request)
{
$request = new Vtiger_Request($request);
$viewer = Vtiger_Viewer::getInstance();
$userName = $request->get('username');
$newPassword = $request->get('password');
$confirmPassword = $request->get('confirmPassword');
$shortURLID = $request->get('shorturl_id');
$secretHash = $request->get('secret_hash');
$shortURLModel = Vtiger_ShortURL_Helper::getInstance($shortURLID);
$secretToken = $shortURLModel->handler_data['secret_token'];
$validateData = array('username' => $userName, 'secret_token' => $secretToken, 'secret_hash' => $secretHash);
$valid = $shortURLModel->compareEquals($validateData);
if ($valid) {
$userId = getUserId_Ol($userName);
$user = Users::getActiveAdminUser();
$wsUserId = vtws_getWebserviceEntityId('Users', $userId);
vtws_changePassword($wsUserId, '', $newPassword, $confirmPassword, $user);
} else {
$viewer->assign('ERROR', true);
}
$shortURLModel->delete();
$viewer->assign('USERNAME', $userName);
$viewer->assign('PASSWORD', $newPassword);
$viewer->view('FPLogin.tpl', 'Users');
}
示例2: changePassword
public function changePassword($request)
{
$request = new Vtiger_Request($request);
$viewer = Vtiger_Viewer::getInstance();
$username = $request->get('username');
$newPassword = $request->get('password');
$confirmPassword = $request->get('confirmPassword');
$userId = getUserId_Ol($username);
$user = Users::getActiveAdminUser();
$wsUserId = vtws_getWebserviceEntityId('Users', $userId);
vtws_changePassword($wsUserId, '', $newPassword, $confirmPassword, $user);
$viewer->assign('USERNAME', $username);
$viewer->assign('PASSWORD', $newPassword);
$viewer->view('FPLogin.tpl', 'Users');
}
示例3: transformForImport
public function transformForImport($fieldData, $moduleMeta, $fillDefault = true, $mergeMode = false)
{
$moduleFields = $moduleMeta->getModuleFields();
$defaultFieldValues = $this->getDefaultFieldValues($moduleMeta);
foreach ($fieldData as $fieldName => $fieldValue) {
$fieldInstance = $moduleFields[$fieldName];
if (!is_object($fieldInstance)) {
continue;
}
// specially for Inventory module import which has virtual item line fields
if ($fieldInstance->getFieldDataType() == 'owner') {
global $adb;
if (strpos($fieldValue, '::::') > 0) {
$fieldValueDetails = explode('::::', $fieldValue);
} else {
$fieldValueDetails = explode(':::', $fieldValue);
}
if (count($fieldValueDetails) == 2) {
$fieldValue = $fieldValueDetails[1];
}
if (count($fieldValueDetails) == 3) {
$user_qry = 'select vtiger_users.id from vtiger_users where ' . $fieldValueDetails[2] . ' = ?';
$res = $adb->pquery($user_qry, array($fieldValueDetails[1]));
$ownerId = 0;
if ($res and $adb->num_rows($res) > 0) {
$ownerId = $adb->query_result($res, 0, 'id');
}
} else {
$ownerId = getUserId_Ol($fieldValue);
if (empty($ownerId)) {
$ownerId = getGrpId($fieldValue);
}
}
if (empty($ownerId) && isset($defaultFieldValues[$fieldName])) {
$ownerId = $defaultFieldValues[$fieldName];
}
if (empty($ownerId) || !Import_Utils::hasAssignPrivilege($moduleMeta->getEntityName(), $ownerId)) {
$ownerId = $this->user->id;
}
$fieldData[$fieldName] = $ownerId;
} elseif ($fieldInstance->getFieldDataType() == 'reference') {
$entityId = false;
if (!empty($fieldValue)) {
if (strpos($fieldValue, '::::') > 0) {
$fieldValueDetails = explode('::::', $fieldValue);
} else {
$fieldValueDetails = explode(':::', $fieldValue);
}
if (count($fieldValueDetails) > 1) {
$referenceModuleName = trim($fieldValueDetails[0]);
$entityLabel = trim($fieldValueDetails[1]);
if (!empty($fieldValueDetails[2])) {
$entityId = getEntityId($referenceModuleName, $entityLabel, $fieldValueDetails[2]);
} else {
$entityId = getEntityId($referenceModuleName, $entityLabel);
}
} else {
$referencedModules = $fieldInstance->getReferenceList();
$entityLabel = $fieldValue;
foreach ($referencedModules as $referenceModule) {
$referenceModuleName = $referenceModule;
if ($referenceModule == 'Users') {
$referenceEntityId = getUserId_Ol($entityLabel);
if (empty($referenceEntityId) || !Import_Utils::hasAssignPrivilege($moduleMeta->getEntityName(), $referenceEntityId)) {
$referenceEntityId = $this->user->id;
}
} else {
$referenceEntityId = getEntityId($referenceModule, $entityLabel);
}
if ($referenceEntityId != 0) {
$entityId = $referenceEntityId;
break;
}
}
}
if ((empty($entityId) || $entityId == 0) && (!empty($referenceModuleName) and !in_array($referenceModuleName, getInventoryModules()))) {
if (isPermitted($referenceModuleName, 'EditView') == 'yes') {
$wsEntityIdInfo = $this->createEntityRecord($referenceModuleName, $entityLabel);
$wsEntityId = $wsEntityIdInfo['id'];
$entityIdComponents = vtws_getIdComponents($wsEntityId);
$entityId = $entityIdComponents[1];
}
}
$fieldData[$fieldName] = $entityId;
} else {
$referencedModules = $fieldInstance->getReferenceList();
if ($referencedModules[0] == 'Users') {
if (isset($defaultFieldValues[$fieldName])) {
$fieldData[$fieldName] = $defaultFieldValues[$fieldName];
}
if (empty($fieldData[$fieldName]) || !Import_Utils::hasAssignPrivilege($moduleMeta->getEntityName(), $fieldData[$fieldName])) {
$fieldData[$fieldName] = $this->user->id;
}
} else {
$fieldData[$fieldName] = '';
}
}
} elseif ($fieldInstance->getFieldDataType() == 'picklist') {
global $default_charset;
if (empty($fieldValue) && isset($defaultFieldValues[$fieldName])) {
//.........这里部分代码省略.........
示例4: getRealValues
/** to get the realvalues for the given value
* @param $tablename :: type string
* @param $fieldname :: type string
* @param $comparator :: type string
* @param $value :: type string
* @returns $value as a string in the following format
* $tablename.$fieldname comparator
*/
function getRealValues($tablename, $fieldname, $comparator, $value, $datatype)
{
//we have to add the fieldname/tablename.fieldname and the corresponding value (which we want) we can add here. So that when these LHS field comes then RHS value will be replaced for LHS in the where condition of the query
global $adb, $mod_strings, $currentModule, $current_user;
//Added for proper check of contact name in advance filter
if ($tablename == "vtiger_contactdetails" && $fieldname == "lastname") {
$fieldname = "contactid";
}
$contactid = "vtiger_contactdetails.lastname";
if ($currentModule != "Contacts" && $currentModule != "Leads" && getFieldVisibilityPermission("Contacts", $current_user->id, 'firstname') == '0' && $currentModule != 'Campaigns') {
$contactid = "concat(vtiger_contactdetails.lastname,' ',vtiger_contactdetails.firstname)";
}
$change_table_field = array("product_id" => "vtiger_products.productname", "contactid" => $contactid, "contact_id" => $contactid, "accountid" => "", "account_id" => "", "vendorid" => "vtiger_vendor.vendorname", "vendor_id" => "vtiger_vendor.vendorname", "potentialid" => "vtiger_potential.potentialname", "vtiger_account.parentid" => "vtiger_account2.accountname", "quoteid" => "vtiger_quotes.subject", "salesorderid" => "vtiger_salesorder.subject", "campaignid" => "vtiger_campaign.campaignname", "vtiger_contactdetails.reportsto" => "concat(vtiger_contactdetails2.lastname,' ',vtiger_contactdetails2.firstname)", "vtiger_pricebook.currency_id" => "vtiger_currency_info.currency_name");
if ($fieldname == "smownerid") {
$temp_value = "( vtiger_users.user_name" . $this->getAdvComparator($comparator, $value, $datatype);
$temp_value .= " OR vtiger_groups.groupname" . $this->getAdvComparator($comparator, $value, $datatype);
$value = $temp_value . ")";
} elseif ($fieldname == "inventorymanager") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, getUserId_Ol($value), $datatype);
} elseif ($change_table_field[$fieldname] != '') {
$value = $change_table_field[$fieldname] . $this->getAdvComparator($comparator, $value, $datatype);
} elseif ($change_table_field[$tablename . "." . $fieldname] != '') {
$tmp_value = '';
if (($comparator == 'e' || $comparator == 's' || $comparator == 'c') && trim($value) == '' || ($comparator == 'n' || $comparator == 'k') && trim($value) != '') {
$tmp_value = $change_table_field[$tablename . "." . $fieldname] . ' IS NULL or ';
}
$value = $tmp_value . $change_table_field[$tablename . "." . $fieldname] . $this->getAdvComparator($comparator, $value, $datatype);
} elseif ($fieldname == "handler") {
$value = "vtiger_users.user_name" . $this->getAdvComparator($comparator, $value, $datatype);
} elseif ($fieldname == "crmid" && $tablename != 'vtiger_crmentity' || $fieldname == "parent_id" || $fieldname == 'parentid') {
//For crmentity.crmid the control should not come here. This is only to get the related to modules
$value = $this->getSalesRelatedName($comparator, $value, $datatype, $tablename, $fieldname);
} else {
//For checkbox type values, we have to convert yes/no as 1/0 to get the values
$field_uitype = getUItype($this->customviewmodule, $fieldname);
if ($field_uitype == 56) {
if (strtolower($value) == 'yes') {
$value = 1;
} elseif (strtolower($value) == 'no') {
$value = 0;
}
} else {
if (is_uitype($field_uitype, '_picklist_')) {
/* Fix for tickets 4465 and 4629 */
// Get all the keys for the for the Picklist value
$mod_keys = array_keys($mod_strings, $value);
// Iterate on the keys, to get the first key which doesn't start with LBL_ (assuming it is not used in PickList)
foreach ($mod_keys as $mod_idx => $mod_key) {
$stridx = strpos($mod_key, 'LBL_');
// Use strict type comparision, refer strpos for more details
if ($stridx !== 0) {
$value = $mod_key;
break;
}
}
}
}
//added to fix the ticket
if ($this->customviewmodule == "Calendar" && ($fieldname == "status" || $fieldname == "taskstatus" || $fieldname == "eventstatus")) {
if (getFieldVisibilityPermission("Calendar", $current_user->id, 'taskstatus') == '0') {
$value = " (case when (vtiger_activity.status not like '') then vtiger_activity.status else vtiger_activity.eventstatus end)" . $this->getAdvComparator($comparator, $value, $datatype);
} else {
$value = " vtiger_activity.eventstatus " . $this->getAdvComparator($comparator, $value, $datatype);
}
} elseif ($comparator == 'e' && (trim($value) == "NULL" || trim($value) == '')) {
$value = '(' . $tablename . "." . $fieldname . ' IS NULL OR ' . $tablename . "." . $fieldname . ' = \'\')';
} else {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $value, $datatype);
}
//end
}
return $value;
}
示例5: transformForImport
public function transformForImport($fieldData, $moduleMeta, $fillDefault = true, $checkMandatoryFieldValues = true)
{
$moduleFields = $moduleMeta->getModuleFields();
$defaultFieldValues = $this->getDefaultFieldValues($moduleMeta);
foreach ($fieldData as $fieldName => $fieldValue) {
$fieldInstance = $moduleFields[$fieldName];
if ($fieldInstance->getFieldDataType() == 'owner') {
$ownerId = getUserId_Ol(trim($fieldValue));
if (empty($ownerId)) {
$ownerId = getGrpId($fieldValue);
}
if (empty($ownerId) && isset($defaultFieldValues[$fieldName])) {
$ownerId = $defaultFieldValues[$fieldName];
}
if (empty($ownerId) || !Import_Utils_Helper::hasAssignPrivilege($moduleMeta->getEntityName(), $ownerId)) {
$ownerId = $this->user->id;
}
$fieldData[$fieldName] = $ownerId;
} elseif ($fieldInstance->getFieldDataType() == 'multipicklist') {
$trimmedValue = trim($fieldValue);
if (!$trimmedValue && isset($defaultFieldValues[$fieldName])) {
$explodedValue = explode(',', $defaultFieldValues[$fieldName]);
} else {
$explodedValue = explode(' |##| ', $trimmedValue);
}
foreach ($explodedValue as $key => $value) {
$explodedValue[$key] = trim($value);
}
$implodeValue = implode(' |##| ', $explodedValue);
$fieldData[$fieldName] = $implodeValue;
} elseif ($fieldInstance->getFieldDataType() == 'reference') {
$entityId = false;
if (!empty($fieldValue)) {
if (strpos($fieldValue, '::::') > 0) {
$fieldValueDetails = explode('::::', $fieldValue);
} else {
if (strpos($fieldValue, ':::') > 0) {
$fieldValueDetails = explode(':::', $fieldValue);
} else {
$fieldValueDetails = $fieldValue;
}
}
if (count($fieldValueDetails) > 1) {
$referenceModuleName = trim($fieldValueDetails[0]);
$entityLabel = trim($fieldValueDetails[1]);
$entityId = getEntityId($referenceModuleName, $entityLabel);
} else {
$referencedModules = $fieldInstance->getReferenceList();
$entityLabel = $fieldValue;
foreach ($referencedModules as $referenceModule) {
$referenceModuleName = $referenceModule;
if ($referenceModule == 'Users') {
$referenceEntityId = getUserId_Ol($entityLabel);
if (empty($referenceEntityId) || !Import_Utils_Helper::hasAssignPrivilege($moduleMeta->getEntityName(), $referenceEntityId)) {
$referenceEntityId = $this->user->id;
}
} elseif ($referenceModule == 'Currency') {
$referenceEntityId = getCurrencyId($entityLabel);
} else {
$referenceEntityId = getEntityId($referenceModule, $entityLabel);
}
if ($referenceEntityId != 0) {
$entityId = $referenceEntityId;
break;
}
}
}
if ((empty($entityId) || $entityId == 0) && !empty($referenceModuleName)) {
if (isPermitted($referenceModuleName, 'EditView') == 'yes') {
try {
$wsEntityIdInfo = $this->createEntityRecord($referenceModuleName, $entityLabel);
$wsEntityId = $wsEntityIdInfo['id'];
$entityIdComponents = vtws_getIdComponents($wsEntityId);
$entityId = $entityIdComponents[1];
} catch (Exception $e) {
$entityId = false;
}
}
}
$fieldData[$fieldName] = $entityId;
} else {
$referencedModules = $fieldInstance->getReferenceList();
if ($referencedModules[0] == 'Users') {
if (isset($defaultFieldValues[$fieldName])) {
$fieldData[$fieldName] = $defaultFieldValues[$fieldName];
}
if (empty($fieldData[$fieldName]) || !Import_Utils_Helper::hasAssignPrivilege($moduleMeta->getEntityName(), $fieldData[$fieldName])) {
$fieldData[$fieldName] = $this->user->id;
}
} else {
$fieldData[$fieldName] = '';
}
}
} elseif ($fieldInstance->getFieldDataType() == 'picklist') {
$fieldValue = trim($fieldValue);
global $default_charset;
if (empty($fieldValue) && isset($defaultFieldValues[$fieldName])) {
$fieldData[$fieldName] = $fieldValue = $defaultFieldValues[$fieldName];
}
$olderCacheEnable = Vtiger_Cache::$cacheEnable;
//.........这里部分代码省略.........
示例6: sendMessage
function sendMessage($content, $touser, $fromuser = 'System')
{
global $log;
$log->debug("Entering sendPM method ...");
global $adb;
$id = $adb->getUniqueID("ec_message");
if ($fromuser == 'System') {
$fromuserid = -1;
} else {
$fromuserid = getUserId_Ol($fromuser);
}
$touserid = getUserId_Ol($touser);
$to_insert = "('" . $id . "','" . $content . "', 'msg', '" . $fromuserid . "', '" . $touserid . "','" . date("Y-m-d H:i") . "',0,0)";
$query = "insert into ec_message(id,message, type, sender, recipient,stamp,deleted_sender,deleted_recipient) values" . $to_insert;
$adb->query($query);
$log->debug("Exit sendPM method ...");
}
示例7: getRealValues
/** to get the realvalues for the given value
* @param $tablename :: type string
* @param $fieldname :: type string
* @param $comparator :: type string
* @param $value :: type string
* @returns $value as a string in the following format
* $tablename.$fieldname comparator
*/
function getRealValues($tablename, $fieldname, $comparator, $value, $datatype)
{
if ($fieldname == "smownerid" || $fieldname == "approvedby" || $fieldname == "smcreatorid") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, getUserId_Ol($value), $datatype);
} else {
if ($fieldname == "parentid") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $this->getAccountId($value), $datatype);
} else {
if ($fieldname == "accountid") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $this->getAccountId($value), $datatype);
} else {
if ($fieldname == "contactid") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $this->getContactId($value), $datatype);
} else {
if ($fieldname == "vendor_id" || $fieldname == "vendorid") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $this->getVendorId($value), $datatype);
} else {
if ($fieldname == "potentialid") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $this->getPotentialId($value), $datatype);
} else {
if ($fieldname == "quoteid") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $this->getQuoteId($value), $datatype);
} else {
if ($fieldname == "product_id") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $this->getProductId($value), $datatype);
} else {
if ($fieldname == "salesorderid") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $this->getSoId($value), $datatype);
} else {
if ($fieldname == "crmid" || $fieldname == "parent_id") {
//Added on 14-10-2005 -- for HelpDesk
if ($this->Fenzumodule == 'HelpDesk' && $fieldname == "crmid") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $value, $datatype);
} else {
$value = $tablename . "." . $fieldname . " in (" . $this->getSalesEntityId($value) . ") ";
}
} else {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $value, $datatype);
}
}
}
}
}
}
}
}
}
}
return $value;
}
示例8: count
/** function used to save the records into database
* @param array $rows - array of total rows of the csv file
* @param array $rows1 - rows to be saved
* @param object $focus - object of the corresponding import module
* @param int $ret_field_count - total number of fields(columns) available in the csv file
* @param int $col_pos_to_field - field position in the mapped array
* @param int $start - starting row count value to import
* @param int $recordcount - count of records to be import ie., number of records to import
* @param string $module - import module
* @param int $totalnoofrows - total number of rows available
* @param int $skip_required_count - number of records skipped
This function will redirect to the ImportStep3 if the available records is greater than the record count (ie., number of records import in a single loop) otherwise (total records less than 500) then it will be redirected to import step last
*/
function InsertImportRecords($rows, $rows1, $focus, $ret_field_count, $col_pos_to_field, $start, $recordcount, $module, $totalnoofrows, $skip_required_count)
{
global $current_user;
global $adb;
global $mod_strings;
global $dup_ow_count;
global $process_fields;
// MWC ** Getting vtiger_users
$users_groups_list = array();
$dup_count = 0;
$count = 0;
$dup_ow_count = 0;
$process_fields = 'false';
if ($start == 0) {
$_SESSION['totalrows'] = $rows;
$_SESSION['return_field_count'] = $ret_field_count;
$_SESSION['column_position_to_field'] = $col_pos_to_field;
}
$ii = $start;
// go thru each row, process and save()
foreach ($rows1 as $row) {
$adb->println("Going to Save the row " . $ii . " =====> ");
$adb->println($row);
global $mod_strings;
$do_save = 1;
//MWC
$my_userid = $current_user->id;
//If we want to set default values for some fields for each entity then we have to set here
if ($module == 'Products' || $module == 'Services') {
//discontinued is not null. if we unmap active, NULL will be inserted and query will fail
$focus->column_fields['discontinued'] = 'on';
}
for ($field_count = 0; $field_count < $ret_field_count; $field_count++) {
p("col_pos[" . $field_count . "]=" . $col_pos_to_field[$field_count]);
if (isset($col_pos_to_field[$field_count])) {
p("set =" . $field_count);
if (!isset($row[$field_count])) {
continue;
}
p("setting");
// TODO: add check for user input
// addslashes, striptags, etc..
$field = $col_pos_to_field[$field_count];
//picklist function is added to avoid duplicate picklist entries
$pick_orginal_val = getPicklist($field, $row[$field_count]);
if ($pick_orginal_val != null) {
$focus->column_fields[$field] = $pick_orginal_val;
} elseif ($field == "assignedto" || $field == "assigned_user_id") {
//Here we are assigning the user id in column fields, so in function assign_user (ImportLead.php and ImportProduct.php files) we should use the id instead of user name when query the user
//or we can use $focus->column_fields['smownerid'] = $users_groups_list[$row[$field_count]];
$row[$field_count] = trim($row[$field_count]);
if (empty($users_groups_list[$row[$field_count]])) {
$id = getUserId_Ol($row[$field_count]);
if (empty($id)) {
$id = getGrpId($row[$field_count]);
}
$users_groups_list[trim($row[$field_count])] = $id;
}
$focus->column_fields[$field] = $users_groups_list[$row[$field_count]];
p("setting my_userid={$my_userid} for user=" . $row[$field_count]);
} else {
//$focus->$field = $row[$field_count];
$focus->column_fields[$field] = $row[$field_count];
p("Setting " . $field . "=" . $row[$field_count]);
}
}
}
if ($focus->column_fields['notify_owner'] == '') {
$focus->column_fields['notify_owner'] = '0';
}
if ($focus->column_fields['reference'] == '') {
$focus->column_fields['reference'] = '0';
}
if ($focus->column_fields['emailoptout'] == '') {
$focus->column_fields['emailoptout'] = '0';
}
if ($focus->column_fields['donotcall'] == '') {
$focus->column_fields['donotcall'] = '0';
}
if ($focus->column_fields['discontinued'] == '') {
$focus->column_fields['discontinued'] = '0';
}
if ($focus->column_fields['active'] == '') {
$focus->column_fields['active'] = '0';
}
p("setting done");
p("do save before req vtiger_fields=" . $do_save);
//.........这里部分代码省略.........
示例9: getWhereCondition
function getWhereCondition($currentModule)
{
global $log;
$column_array = getColumnOrTableArr();
$table_col_array = getColumnOrTableArr(false);
$log->debug("Entering getWhereCondition(" . $currentModule . ") method ...");
if ($_REQUEST['searchtype'] != 'advance') {
$where = Search($currentModule);
} else {
$adv_string = '';
$url_string = '';
if (isset($_REQUEST['search_cnt'])) {
$tot_no_criteria = $_REQUEST['search_cnt'];
}
if ($_REQUEST['matchtype'] == 'all') {
$matchtype = "and";
} else {
$matchtype = "or";
}
for ($i = 0; $i < $tot_no_criteria; $i++) {
if ($i == $tot_no_criteria - 1) {
$matchtype = "";
}
$table_colname = 'Fields' . $i;
$search_condition = 'Condition' . $i;
$search_value = 'Srch_value' . $i;
$tab_col = '';
$tab_col = str_replace('\'', '', stripslashes($_REQUEST[$table_colname]));
$tab_col = str_replace('\\', '', $tab_col);
$srch_cond = str_replace('\'', '', stripslashes($_REQUEST[$search_condition]));
$srch_cond = str_replace('\\', '', $srch_cond);
$srch_val = $_REQUEST[$search_value];
list($tab_name, $column_name) = split("[.]", $tab_col);
$url_string .= "&Fields" . $i . "=" . $tab_col . "&Condition" . $i . "=" . $srch_cond . "&Srch_value" . $i . "=" . $srch_val;
if ($tab_col == "smownerid") {
$adv_string .= getSearch_criteria($srch_cond, $srch_val, 'ec_users.user_name') . $matchtype;
} elseif ($tab_col == "smcreatorid") {
$user_id = getUserId_Ol($srch_val);
$adv_string .= " smcreatorid='" . $user_id . "' " . $matchtype;
} elseif ($tab_col == "approvedby") {
$user_id = getUserId_Ol($srch_val);
$adv_string .= " approvedby='" . $user_id . "' " . $matchtype;
} elseif ($tab_col == "approved") {
$srch_val = getApproveIdByStatus($srch_val);
$adv_string .= " approved='" . $srch_val . "' " . $matchtype;
} elseif ($tab_col == "ec_activity.status") {
$adv_string .= " (" . getSearch_criteria($srch_cond, $srch_val, 'ec_activity.status') . " or";
$adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, 'ec_activity.eventstatus') . " )" . $matchtype;
} elseif ($tab_col == "ec_cntactivityrel.contactid") {
$adv_string .= " (" . getSearch_criteria($srch_cond, $srch_val, 'ec_contactdetails.firstname') . " or";
$adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, 'ec_contactdetails.lastname') . " )" . $matchtype;
} elseif ($tab_col == "ec_products.catalogid") {
$adv_string .= getSearch_criteria($srch_cond, $srch_val, 'ec_catalog.catalogname') . " " . $matchtype;
} elseif ($tab_col == "ec_faq.faqcategoryid") {
$adv_string .= getSearch_criteria($srch_cond, $srch_val, 'ec_faqcategory.faqcategoryname') . " " . $matchtype;
} elseif (in_array($column_name, $column_array)) {
$adv_string .= getValuesforColumns($column_name, $srch_val) . " " . $matchtype;
} else {
$adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, $tab_col) . " " . $matchtype;
}
}
$where = "(" . $adv_string . ")#@@#" . $url_string . "&searchtype=advance&search_cnt=" . $tot_no_criteria . "&matchtype=" . $_REQUEST['matchtype'];
}
/*
elseif($_REQUEST['type']=='dbrd')
{
$where = getdashboardcondition();
}
else
{
$where=Search($currentModule);
}
*/
$log->info("getWhereCondition method where condition:" . $where);
$log->debug("Exiting getWhereCondition method ...");
return $where;
}
示例10: getRealValues
/** to get the realvalues for the given value
* @param $tablename :: type string
* @param $fieldname :: type string
* @param $comparator :: type string
* @param $value :: type string
* @returns $value as a string in the following format
* $tablename.$fieldname comparator
*/
function getRealValues($tablename, $fieldname, $comparator, $value, $datatype)
{
//we have to add the fieldname/tablename.fieldname and the corresponding value (which we want) we can add here. So that when these LHS field comes then RHS value will be replaced for LHS in the where condition of the query
$adb = PearDatabase::getInstance();
$current_user = vglobal('current_user');
$currentModule = vglobal('currentModule');
$mod_strings = vglobal('mod_strings');
//Added for proper check of contact name in advance filter
if ($tablename == "vtiger_contactdetails" && $fieldname == "lastname") {
$fieldname = "contactid";
}
$contactid = "vtiger_contactdetails.lastname";
if ($currentModule != "Contacts" && $currentModule != "Leads" && $currentModule != 'Campaigns') {
$contactid = getSqlForNameInDisplayFormat(array('lastname' => 'vtiger_contactdetails.lastname', 'firstname' => 'vtiger_contactdetails.firstname'), 'Contacts');
}
$change_table_field = array("product_id" => "vtiger_products.productname", "contactid" => 'trim(' . $contactid . ')', "contact_id" => 'trim(' . $contactid . ')', "accountid" => "", "account_id" => "", "vendorid" => "vtiger_vendor.vendorname", "vendor_id" => "vtiger_vendor.vendorname", "potentialid" => "vtiger_potential.potentialname", "vtiger_account.parentid" => "vtiger_account2.accountname", "quoteid" => "vtiger_quotes.subject", "salesorderid" => "vtiger_salesorder.subject", "campaignid" => "vtiger_campaign.campaignname", "vtiger_contactdetails.reportsto" => getSqlForNameInDisplayFormat(array('lastname' => 'vtiger_contactdetails2.lastname', 'firstname' => 'vtiger_contactdetails2.firstname'), 'Contacts'), "vtiger_pricebook.currency_id" => "vtiger_currency_info.currency_name");
if ($fieldname == "smownerid" || $fieldname == 'modifiedby') {
if ($fieldname == "smownerid") {
$tableNameSuffix = '';
} elseif ($fieldname == "modifiedby") {
$tableNameSuffix = '2';
}
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users' . $tableNameSuffix . '.first_name', 'last_name' => 'vtiger_users' . $tableNameSuffix . '.last_name'), 'Users');
$temp_value = '( trim(' . $userNameSql . ')' . $this->getAdvComparator($comparator, $value, $datatype);
$temp_value .= " OR vtiger_groups{$tableNameSuffix}.groupname" . $this->getAdvComparator($comparator, $value, $datatype) . ')';
$value = $temp_value;
// Hot fix: removed unbalanced closing bracket ")";
} elseif ($fieldname == "inventorymanager") {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, getUserId_Ol($value), $datatype);
} elseif ($change_table_field[$fieldname] != '') {
//Added to handle special cases
$value = $change_table_field[$fieldname] . $this->getAdvComparator($comparator, $value, $datatype);
} elseif ($change_table_field[$tablename . "." . $fieldname] != '') {
//Added to handle special cases
$tmp_value = '';
if (($comparator == 'e' || $comparator == 's' || $comparator == 'c') && trim($value) == '' || ($comparator == 'n' || $comparator == 'k') && trim($value) != '') {
$tmp_value = $change_table_field[$tablename . "." . $fieldname] . ' IS NULL or ';
}
$value = $tmp_value . $change_table_field[$tablename . "." . $fieldname] . $this->getAdvComparator($comparator, $value, $datatype);
} elseif ($fieldname == "crmid" && $tablename != 'vtiger_crmentity' || $fieldname == "parent_id" || $fieldname == 'parentid') {
//For crmentity.crmid the control should not come here. This is only to get the related to modules
$value = $this->getSalesRelatedName($comparator, $value, $datatype, $tablename, $fieldname);
} else {
//For checkbox type values, we have to convert yes/no as 1/0 to get the values
$field_uitype = getUItype($this->customviewmodule, $fieldname);
if ($field_uitype == 56) {
if (strtolower($value) == 'yes') {
$value = 1;
} elseif (strtolower($value) == 'no') {
$value = 0;
}
} else {
if (is_uitype($field_uitype, '_picklist_')) {
/* Fix for tickets 4465 and 4629 */
// Get all the keys for the for the Picklist value
$mod_keys = array_keys($mod_strings, $value);
// Iterate on the keys, to get the first key which doesn't start with LBL_ (assuming it is not used in PickList)
foreach ($mod_keys as $mod_idx => $mod_key) {
$stridx = strpos($mod_key, 'LBL_');
// Use strict type comparision, refer strpos for more details
if ($stridx !== 0) {
$value = $mod_key;
break;
}
}
}
}
//added to fix the ticket
if ($this->customviewmodule == "Calendar" && ($fieldname == "status" || $fieldname == "activitystatus")) {
$value = " vtiger_activity.status " . $this->getAdvComparator($comparator, $value, $datatype);
} elseif ($comparator == 'e' && (trim($value) == "NULL" || trim($value) == '')) {
$value = '(' . $tablename . "." . $fieldname . ' IS NULL OR ' . $tablename . "." . $fieldname . ' = \'\')';
} else {
$value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $value, $datatype);
}
//end
}
return $value;
}
示例11: transformForImport
public function transformForImport($fieldData, $moduleMeta, $fillDefault=true) {
$moduleFields = $moduleMeta->getModuleFields();
$defaultFieldValues = $this->getDefaultFieldValues($moduleMeta);
foreach ($fieldData as $fieldName => $fieldValue) {
$fieldInstance = $moduleFields[$fieldName];
if ($fieldInstance->getFieldDataType() == 'owner') {
$ownerId = getUserId_Ol($fieldValue);
if (empty($ownerId)) {
$ownerId = getGrpId($fieldValue);
}
if (empty($ownerId) && isset($defaultFieldValues[$fieldName])) {
$ownerId = $defaultFieldValues[$fieldName];
}
if(empty($ownerId) ||
!Import_Utils::hasAssignPrivilege($moduleMeta->getEntityName(), $ownerId)) {
$ownerId = $this->user->id;
}
$fieldData[$fieldName] = $ownerId;
} elseif ($fieldInstance->getFieldDataType() == 'reference') {
$entityId = false;
if (!empty($fieldValue)) {
if(strpos($fieldValue, '::::') > 0) {
$fieldValueDetails = explode('::::', $fieldValue);
} else {
$fieldValueDetails = explode(':::', $fieldValue);
}
if (count($fieldValueDetails) > 1) {
$referenceModuleName = trim($fieldValueDetails[0]);
$entityLabel = trim($fieldValueDetails[1]);
$entityId = getEntityId($referenceModuleName, $entityLabel);
} else {
$referencedModules = $fieldInstance->getReferenceList();
$entityLabel = $fieldValue;
foreach ($referencedModules as $referenceModule) {
$referenceModuleName = $referenceModule;
if ($referenceModule == 'Users') {
$referenceEntityId = getUserId_Ol($entityLabel);
if(empty($referenceEntityId) ||
!Import_Utils::hasAssignPrivilege($moduleMeta->getEntityName(), $referenceEntityId)) {
$referenceEntityId = $this->user->id;
}
} else {
$referenceEntityId = getEntityId($referenceModule, $entityLabel);
}
if ($referenceEntityId != 0) {
$entityId = $referenceEntityId;
break;
}
}
}
if ((empty($entityId) || $entityId == 0) && !empty($referenceModuleName)) {
if(isPermitted($referenceModuleName, 'EditView') == 'yes') {
$wsEntityIdInfo = $this->createEntityRecord($referenceModuleName, $entityLabel);
$wsEntityId = $wsEntityIdInfo['id'];
$entityIdComponents = vtws_getIdComponents($wsEntityId);
$entityId = $entityIdComponents[1];
}
}
$fieldData[$fieldName] = $entityId;
} else {
$referencedModules = $fieldInstance->getReferenceList();
if ($referencedModules[0] == 'Users') {
if(isset($defaultFieldValues[$fieldName])) {
$fieldData[$fieldName] = $defaultFieldValues[$fieldName];
}
if(empty($fieldData[$fieldName]) ||
!Import_Utils::hasAssignPrivilege($moduleMeta->getEntityName(), $fieldData[$fieldName])) {
$fieldData[$fieldName] = $this->user->id;
}
} else {
$fieldData[$fieldName] = '';
}
}
} elseif ($fieldInstance->getFieldDataType() == 'picklist') {
global $default_charset;
if (empty($fieldValue) && isset($defaultFieldValues[$fieldName])) {
$fieldData[$fieldName] = $fieldValue = $defaultFieldValues[$fieldName];
}
$allPicklistDetails = $fieldInstance->getPicklistDetails();
$allPicklistValues = array();
foreach ($allPicklistDetails as $picklistDetails) {
$allPicklistValues[] = $picklistDetails['value'];
}
$encodePicklistValue = htmlentities($fieldValue,ENT_QUOTES,$default_charset);
if (!in_array($encodePicklistValue, $allPicklistValues)) {
$moduleObject = Vtiger_Module::getInstance($moduleMeta->getEntityName());
$fieldObject = Vtiger_Field::getInstance($fieldName, $moduleObject);
$fieldObject->setPicklistValues(array($fieldValue));
}
} else {
if ($fieldInstance->getFieldDataType() == 'datetime' && !empty($fieldValue)) {
if($fieldValue == null || $fieldValue == '0000-00-00 00:00:00') {
$fieldValue = '';
}
$valuesList = explode(' ', $fieldValue);
if(count($valuesList) == 1) $fieldValue = '';
$fieldValue = getValidDBInsertDateTimeValue($fieldValue);
if (preg_match("/^[0-9]{2,4}[-][0-1]{1,2}?[0-9]{1,2}[-][0-3]{1,2}?[0-9]{1,2} ([0-1][0-9]|[2][0-3])([:][0-5][0-9]){1,2}$/",
//.........这里部分代码省略.........