• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP loadBean函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中loadBean函数的典型用法代码示例。如果您正苦于以下问题:PHP loadBean函数的具体用法?PHP loadBean怎么用?PHP loadBean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了loadBean函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: loadBean

 /**
  * @see SugarController::loadBean()
  */
 public function loadBean()
 {
     global $mod_strings;
     $this->importModule = isset($_REQUEST['import_module']) ? $_REQUEST['import_module'] : '';
     $this->bean = loadBean($this->importModule);
     if ($this->bean) {
         if (!$this->bean->importable) {
             $this->bean = false;
         } elseif ($_REQUEST['import_module'] == 'Users' && !is_admin($GLOBALS['current_user'])) {
             $this->bean = false;
         } elseif ($this->bean->bean_implements('ACL')) {
             if (!ACLController::checkAccess($this->bean->module_dir, 'import', true)) {
                 ACLController::displayNoAccess();
                 sugar_die('');
             }
         }
     }
     if (!$this->bean && $this->importModule != "Administration") {
         $_REQUEST['message'] = $mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'];
         $this->view = 'error';
         $this->_processed = true;
     } else {
         $GLOBALS['FOCUS'] = $this->bean;
     }
 }
开发者ID:noor017,项目名称:sugarcrm_dev,代码行数:28,代码来源:controller.php


示例2: remove_zero

 function remove_zero(SugarBean $bean, $event, $arguments)
 {
     if ($bean->number_of_floor == '' || $bean->number_of_floor == 0) {
         $bean->number_of_floor = '';
     }
     if ($bean->floor == '' || $bean->floor == 0) {
         $bean->floor = '';
     }
     if ($bean->rooms_quantity == '' || $bean->rooms_quantity == 0) {
         $bean->rooms_quantity = '';
     }
     if ($bean->living_square == '' || $bean->living_square == 0) {
         $bean->living_square = '';
     }
     if ($event == 'process_record') {
         // из какой заявки(интересующая недвижимость для контактов)
         if ($_REQUEST['module'] == 'Contacts' && $_REQUEST['action'] == 'DetailView') {
             global $db;
             $q = "SELECT rrit.request_id as id,  r.name as name\n\t\t\t\t\tFROM realty_requests_interest_table AS rrit\n\t\t\t\t\tLEFT JOIN request as r ON r.id = rrit.request_id\n\t\t\t\t\tWHERE \n\t\t\t\t\t\trrit.realty_id = '{$bean->id}'\n\t\t\t\t\t\tAND rrit.deleted = 0\n\t\t\t\t\t\tAND r.deleted = 0";
             $res = $db->query($q);
             if ($r = $db->fetchByAssoc($res)) {
                 $bean->request = "<a href='index.php?module=Request&action=DetailView&record={$r['id']}'>{$r['name']}</a>";
             }
         }
         //
         if ($_REQUEST['action'] == 'index') {
             $realty = loadBean('Realty');
             $realty->retrieve($bean->id);
             if ($realty->reserved) {
                 //бронь
                 $bean->name .= "<img style='display:none;' src='themes/default/images/help.gif' width='0' height='0' onload=\"this.parentNode.parentNode.parentNode.parentNode.style.backgroundColor = '#ccc';\" />";
             }
         }
     }
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:35,代码来源:Not_zero.php


示例3: testDateTimeImport

 /**
  * @dataProvider providerCsvData
  */
 public function testDateTimeImport($content_idx, $expected_datetime, $date_format, $time_format)
 {
     $file = $GLOBALS['sugar_config']['upload_dir'] . 'test.csv';
     $ret = file_put_contents($file, self::$CsvContent[$content_idx]);
     $this->assertGreaterThan(0, $ret, 'Failed to write to ' . $file . ' for content ' . $content_idx);
     $importSource = new ImportFile($file, ',', '"');
     $bean = loadBean($this->_importModule);
     $_REQUEST['columncount'] = 2;
     $_REQUEST['colnum_0'] = 'date_entered';
     $_REQUEST['colnum_1'] = 'last_name';
     $_REQUEST['import_module'] = 'Contacts';
     $_REQUEST['importlocale_charset'] = 'UTF-8';
     $_REQUEST['importlocale_dateformat'] = $date_format;
     $_REQUEST['importlocale_timeformat'] = $time_format;
     $_REQUEST['importlocale_timezone'] = 'GMT';
     $_REQUEST['importlocale_default_currency_significant_digits'] = '2';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_dec_sep'] = '.';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_default_locale_name_format'] = 's f l';
     $_REQUEST['importlocale_num_grp_sep'] = ',';
     $importer = new Importer($importSource, $bean);
     $importer->import();
     $query = "SELECT date_entered from contacts where created_by='{$GLOBALS['current_user']->id}'";
     $result = $GLOBALS['db']->query($query);
     $row = $GLOBALS['db']->fetchByAssoc($result);
     $this->assertEquals($expected_datetime, $GLOBALS['db']->fromConvert($row['date_entered'], 'datetime'), 'Got incorrect date_entered.');
 }
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:31,代码来源:ImporterTest.php


示例4: ejecutar

 public function ejecutar($focus, $string_parametros)
 {
     $this->procesar_parametros($string_parametros);
     $alarma = loadBean('gcoop_alarmas');
     $alarma->parent_type = $focus->module_dir;
     $alarma->parent_id = $focus->id;
     $alarma->destinatario = $this->destinatario;
     $alarma->notificacion = $this->notificacion;
     $alarma->parametro = $this->parametro;
     $alarma->valor = $this->valor;
     #sumarle dias no fin de semana!
     $fecha = new DateTime();
     $dia = new DateInterval('P1D');
     while ($this->cantidad_dias > 0) {
         $fecha->add($dia);
         if ($fecha->format('N') < 6) {
             $this->cantidad_dias -= 1;
         }
     }
     $timedate = TimeDate::getInstance();
     $alarma->fecha_disparo = $timedate->asDb($fecha);
     $alarma->save();
     if (method_exists($focus, 'notificar')) {
         $focus->notificar("Se creó alarama con fecha de disparo {$alarma->fecha_disparo}", 'Alarma');
     }
 }
开发者ID:dinhquyet92,项目名称:sugarcrm_advanced_workflows,代码行数:26,代码来源:CrearAlarma.php


示例5: testProcessFullListQuery

 public function testProcessFullListQuery()
 {
     $loadedContact = loadBean('Contacts');
     $loadedContact->disable_row_level_security = true;
     $contactList = $loadedContact->get_full_list();
     $exampleContact = array_pop($contactList);
     $this->assertNotNull($exampleContact->fetched_row['last_name']);
 }
开发者ID:nickpro,项目名称:sugarcrm_dev,代码行数:8,代码来源:Bug40989Test.php


示例6: changeUserTitle

 function changeUserTitle(SugarBean $bean, $event, $arguments)
 {
     if ($bean->fetched_row['assigned_user_id'] != $bean->assigned_user_id) {
         $user = loadBean('Users');
         $user->retrieve($bean->assigned_user_id);
         $user->title = 'branch';
         $user->save();
     }
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:9,代码来源:hooks.php


示例7: echo_module_fields

function echo_module_fields($module)
{
    global $current_language, $app_list_strings;
    $bean = loadBean($module);
    $mod_strings = return_module_language($current_language, $bean->module_dir);
    echo "<div class='container' style='font-size:110%;'><center style='font-weight:bold;'>Поля модуля {$app_list_strings['moduleList'][$module]}:</center>\r\n\t\t<br/><table style='width:100%;font-size:100%;'>";
    foreach ($bean->field_defs as $field) {
        echo "<tr><td style='background-color:#596971;color:#fff;text-align:right;padding-right:5px;' width='60%'>\r\n\t\t\t<b>{$mod_strings[$field['vname']]}</b> [{$field['type']}]:</td>\r\n\t\t<td style='background-color:#FFF'>\r\n\t\t\t{$field['name']}</td></tr>";
    }
    echo "</table></div>";
}
开发者ID:omusico,项目名称:sugar_work,代码行数:11,代码来源:add_functions.php


示例8: setUp

 public function setUp()
 {
     global $dictionary, $bean_list;
     $this->old_dictionary = $dictionary;
     $this->old_bean_list = $bean_list;
     $this->test_standart_field = new TestStandardField();
     $this->test_standart_field->module = 'Accounts';
     loadBean($this->test_standart_field->module);
     $this->test_field = get_widget('varchar');
     $this->test_field->name = 'name';
     $this->bean_name = get_valid_bean_name($this->test_standart_field->module);
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:12,代码来源:Bug51427Test.php


示例9: get_new_record_form

function get_new_record_form()
{
    $module = !empty($GLOBALS['QCModule']) ? $GLOBALS['QCModule'] : $GLOBALS['module'];
    $focus = loadBean($module);
    if (!$focus->ACLAccess('save')) {
        return;
    }
    $view_sqc = new ViewFactory();
    //avoid ViewFactory::_loadConfig() undefined value
    $view_sqc->module = '';
    $view_sqc->action = '';
    $view_sqc = $view_sqc->loadView('sidequickcreate', $module);
    $view_sqc->module = $module;
    if ($view_sqc->preDisplay()) {
        return $view_sqc->display();
    }
}
开发者ID:nerdystudmuffin,项目名称:dashlet-subpanels,代码行数:17,代码来源:SideQuickCreate.php


示例10: action_delete

 protected function action_delete()
 {
     if ($_REQUEST['record'] != $GLOBALS['current_user']->id && $GLOBALS['current_user']->isAdminForModule('Users')) {
         $u = new User();
         $u->retrieve($_REQUEST['record']);
         $u->status = 'Inactive';
         $u->deleted = 1;
         $u->employee_status = 'Terminated';
         $u->save();
         $GLOBALS['log']->info("User id: {$GLOBALS['current_user']->id} deleted user record: {$_REQUEST['record']}");
         $eapm = loadBean('EAPM');
         $eapm->delete_user_accounts($_REQUEST['record']);
         $GLOBALS['log']->info("Removing user's External Accounts");
         SugarApplication::redirect("index.php?module=Users&action=index");
     } else {
         sugar_die("Unauthorized access to administration.");
     }
 }
开发者ID:nartnik,项目名称:sugarcrm_test,代码行数:18,代码来源:controller.php


示例11: process_relate

 private function process_relate($field)
 {
     $id_name = $this->bean->field_defs[$field]['id_name'];
     $link = $this->bean->field_defs[$field]['link'];
     $relationship = $this->bean->field_defs[$link]['relationship'];
     $id_list = array();
     if (isset($_REQUEST[$id_name]) && !empty($_REQUEST[$id_name]) || isset($this->bean->{$id_name}) && !empty($this->bean->{$id_name})) {
         $parent_id = empty($this->bean->id) ? $_REQUEST[$id_name] : $this->bean->{$id_name};
         $parent_bean = loadBean($this->bean->field_defs[$field]['module']);
         $parent_bean->retrieve($parent_id);
         foreach ($parent_bean->field_defs as $parent_field => $defs) {
             if ($defs['type'] == 'link' && $defs['relationship'] == $relationship) {
                 $parent_bean->load_relationship($parent_field);
                 $id_list = $parent_bean->{$parent_field}->get();
             }
         }
     }
     return $id_list;
 }
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:19,代码来源:DuplicateFields.php


示例12: afterSave

 function afterSave(&$bean)
 {
     if (isset($bean->realty_id) && $bean->realty_id != '') {
         $realty = new Realty();
         $realty->retrieve($bean->realty_id);
         if (isset($realty->last_contact)) {
             $realty->last_contact = date('Y-m-d');
             $realty->save();
         }
     }
     if (isset($bean->parent_id) && $bean->parent_id != '') {
         $client = loadBean($bean->parent_type);
         $client->retrieve($bean->parent_id);
         if (isset($client->last_contact)) {
             $client->last_contact = date('Y-m-d');
             $client->save();
         }
     }
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:19,代码来源:hooks.php


示例13: testParentsAreRelatedDuringImport

 public function testParentsAreRelatedDuringImport()
 {
     $file = 'upload://test50438.csv';
     $ret = file_put_contents($file, $this->fileArr);
     $this->assertGreaterThan(0, $ret, 'Failed to write to ' . $file . ' for content ' . var_export($this->fileArr, true));
     $importSource = new ImportFile($file, ',', '"');
     $bean = loadBean('Calls');
     $_REQUEST['columncount'] = 5;
     $_REQUEST['colnum_0'] = 'id';
     $_REQUEST['colnum_1'] = 'subject';
     $_REQUEST['colnum_2'] = 'status';
     $_REQUEST['colnum_3'] = 'parent_type';
     $_REQUEST['colnum_4'] = 'parent_id';
     $_REQUEST['import_module'] = 'Contacts';
     $_REQUEST['importlocale_charset'] = 'UTF-8';
     $_REQUEST['importlocale_timezone'] = 'GMT';
     $_REQUEST['importlocale_default_currency_significant_digits'] = '2';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_dec_sep'] = '.';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_default_locale_name_format'] = 's f l';
     $_REQUEST['importlocale_num_grp_sep'] = ',';
     $_REQUEST['importlocale_dateformat'] = 'm/d/y';
     $_REQUEST['importlocale_timeformat'] = 'h:i:s';
     $importer = new Importer($importSource, $bean);
     $importer->import();
     //fetch the bean using the passed in id and get related contacts
     require_once 'modules/Calls/Call.php';
     $call = new Call();
     $call->retrieve($this->call_id);
     $call->load_relationship('contacts');
     $related_contacts = $call->contacts->get();
     //test that the contact id is in the array of related contacts.
     $this->assertContains($this->contact->id, $related_contacts, ' Contact was not related during simulated import despite being set in related parent id');
     unset($call);
     /*
     if (is_file($file)) {
         unlink($file);
     }
     */
 }
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:41,代码来源:Bug50438Test.php


示例14: preDisplay

 /**
  * @see SugarView::preDisplay()
  */
 public function preDisplay()
 {
     if (!empty($_REQUEST['source_module']) && $_REQUEST['source_module'] != 'undefined' && !empty($_REQUEST['record'])) {
         $this->bean = loadBean($_REQUEST['source_module']);
         if ($this->bean instanceof SugarBean && !in_array($this->bean->object_name, array('EmailMan'))) {
             $this->bean->retrieve($_REQUEST['record']);
             if (!empty($this->bean->id)) {
                 $_REQUEST['parent_id'] = $this->bean->id;
             }
             if (!empty($this->bean->module_dir)) {
                 $_REQUEST['parent_type'] = $this->bean->module_dir;
             }
             if (!empty($this->bean->name)) {
                 $_REQUEST['parent_name'] = $this->bean->name;
             }
             if (!empty($this->bean->id)) {
                 $_REQUEST['return_id'] = $this->bean->id;
             }
             if (!empty($this->bean->module_dir)) {
                 $_REQUEST['return_module'] = $this->bean->module_dir;
             }
             //Now preload any related fields
             if (isset($_REQUEST['module'])) {
                 $target_bean = loadBean($_REQUEST['module']);
                 foreach ($target_bean->field_defs as $fields) {
                     if ($fields['type'] == 'relate' && isset($fields['module']) && $fields['module'] == $_REQUEST['source_module'] && isset($fields['rname'])) {
                         $rel_name = $fields['rname'];
                         if (isset($this->bean->{$rel_name})) {
                             $_REQUEST[$fields['name']] = $this->bean->{$rel_name};
                         }
                         if (!empty($_REQUEST['record']) && !empty($fields['id_name'])) {
                             $_REQUEST[$fields['id_name']] = $_REQUEST['record'];
                         }
                     }
                 }
             }
         }
         $this->_isDCForm = true;
     }
 }
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:43,代码来源:view.quickcreate.php


示例15: handleSave

 /**
  * Saves a new Contact as well as any related items passed in.
  *
  * @return null
  */
 protected function handleSave()
 {
     require_once 'modules/Campaigns/utils.php';
     require_once "include/formbase.php";
     $lead = false;
     if (!empty($_REQUEST['record'])) {
         $lead = new Lead();
         $lead->retrieve($_REQUEST['record']);
     }
     global $beanList;
     $this->loadDefs();
     $beans = array();
     $selectedBeans = array();
     $selects = array();
     // Make sure the contact object is availible for relationships.
     $beans['Contacts'] = new Contact();
     // Contacts
     if (!empty($_REQUEST['selectedContact'])) {
         $beans['Contacts']->retrieve($_REQUEST['selectedContact']);
         if (!empty($beans['Contacts']->id)) {
             $beans['Contacts']->new_with_id = false;
             unset($_REQUEST["convert_create_Contacts"]);
             unset($_POST["convert_create_Contacts"]);
         }
     } elseif (!empty($_REQUEST["convert_create_Contacts"]) && $_REQUEST["convert_create_Contacts"] != "false" && !isset($_POST['ContinueContact'])) {
         require_once 'modules/Contacts/ContactFormBase.php';
         $contactForm = new ContactFormBase();
         $duplicateContacts = $contactForm->checkForDuplicates('Contacts');
         if (isset($duplicateContacts)) {
             echo $contactForm->buildTableForm($duplicateContacts, 'Contacts');
             return;
         }
         $this->new_contact = true;
     } elseif (isset($_POST['ContinueContact'])) {
         $this->new_contact = true;
     }
     // Accounts
     if (!empty($_REQUEST['selectedAccount'])) {
         $_REQUEST['account_id'] = $_REQUEST['selectedAccount'];
         unset($_REQUEST["convert_create_Accounts"]);
         unset($_POST["convert_create_Accounts"]);
     } elseif (!empty($_REQUEST["convert_create_Accounts"]) && $_REQUEST["convert_create_Accounts"] != "false" && empty($_POST['ContinueAccount'])) {
         require_once 'modules/Accounts/AccountFormBase.php';
         $accountForm = new AccountFormBase();
         $duplicateAccounts = $accountForm->checkForDuplicates('Accounts');
         if (isset($duplicateAccounts)) {
             echo $accountForm->buildTableForm($duplicateAccounts);
             return;
         }
     }
     foreach ($this->defs as $module => $vdef) {
         //Create a new record if "create" was selected
         if (!empty($_REQUEST["convert_create_{$module}"]) && $_REQUEST["convert_create_{$module}"] != "false") {
             //Save the new record
             $bean = $beanList[$module];
             if (empty($beans[$module])) {
                 $beans[$module] = new $bean();
             }
             $this->populateNewBean($module, $beans[$module], $beans['Contacts'], $lead);
             // when creating a new contact, create the id for linking with other modules
             // and do not populate it with lead's old account_id
             if ($module == 'Contacts') {
                 $beans[$module]->id = create_guid();
                 $beans[$module]->new_with_id = true;
                 $beans[$module]->account_id = '';
             }
         } else {
             if (!empty($vdef['ConvertLead']['select'])) {
                 //Save the new record
                 $select = $vdef['ConvertLead']['select'];
                 $fieldDef = $beans['Contacts']->field_defs[$select];
                 if (!empty($fieldDef['id_name']) && !empty($_REQUEST[$fieldDef['id_name']])) {
                     $beans['Contacts']->{$fieldDef}['id_name'] = $_REQUEST[$fieldDef['id_name']];
                     $selects[$module] = $_REQUEST[$fieldDef['id_name']];
                     if (!empty($_REQUEST[$select])) {
                         $beans['Contacts']->{$select} = $_REQUEST[$select];
                     }
                     // Bug 39268 - Add the existing beans to a list of beans we'll potentially add the lead's activities to
                     $bean = loadBean($module);
                     $bean->retrieve($_REQUEST[$fieldDef['id_name']]);
                     $selectedBeans[$module] = $bean;
                     // If we selected the Contact, just overwrite the $beans['Contacts']
                     if ($module == 'Contacts') {
                         $beans[$module] = $bean;
                     }
                 }
             }
         }
     }
     $this->handleActivities($lead, $beans);
     // Bug 39268 - Add the lead's activities to the selected beans
     $this->handleActivities($lead, $selectedBeans);
     //link selected account to lead if it exists
     if (!empty($selectedBeans['Accounts'])) {
         $lead->account_id = $selectedBeans['Accounts']->id;
//.........这里部分代码省略.........
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:101,代码来源:view.convertlead.php


示例16: fillBeans

 /**
  * fillBeans
  * This function wraps the call to getList, but takes an additional Array argument
  * and loads the SugarBean's fields with the results as defined in the connector
  * loadBean configuration mapping
  *
  * @param $args Array of arguments to pass into getItem
  * @param $module String value of the module to map bean to
  * @param $bean Array to load SugarBean intances into
  * @throws Exception Thrown if errors are found
  */
 public function fillBeans($args = array(), $module = null, $beans = array())
 {
     $results = array();
     $args = $this->mapInput($args, $module);
     if (empty($args)) {
         $GLOBALS['log']->fatal($GLOBALS['app_strings']['ERR_MISSING_MAPPING_ENTRY_FORM_MODULE']);
         throw new Exception($GLOBALS['app_strings']['ERR_MISSING_MAPPING_ENTRY_FORM_MODULE']);
     }
     require_once 'include/connectors/filters/FilterFactory.php';
     $filter = FilterFactory::getInstance(get_class($this->_source));
     $list = $filter->getList($args, $module);
     if (!empty($list)) {
         $resultSize = count($list);
         if (!empty($beans)) {
             if (count($beans) != $resultSize) {
                 throw new Exception($GLOBALS['app_strings']['ERR_CONNECTOR_FILL_BEANS_SIZE_MISMATCH']);
             }
         } else {
             for ($x = 0; $x < $resultSize; $x++) {
                 $beans[$x] = loadBean($module);
             }
         }
         $keys = array_keys($beans);
         $count = 0;
         foreach ($list as $entry) {
             //Change the result keys to lower case.  This has important ramifications.
             //This was done because the listviewdefs.php files may not know the proper casing
             //of the fields to display.  We change the keys to lowercase so that the values
             //may be mapped to the beans without having to rely on the proper string casing
             //in the listviewdefs.php files.
             $entry = array_change_key_case($entry, CASE_LOWER);
             $results[] = $this->mapOutput($beans[$keys[$count]], $entry);
             $count++;
         }
         $field_defs = $this->getFieldDefs();
         $map = $this->getMapping();
         $hasOptions = !empty($map['options']) ? true : false;
         if ($hasOptions) {
             $options = $map['options'];
             $optionFields = array();
             foreach ($field_defs as $name => $field) {
                 if (!empty($field['options']) && !empty($map['options'][$field['options']]) && !empty($map['beans'][$module][$name])) {
                     $optionFields[$name] = $map['beans'][$module][$name];
                 }
             }
             foreach ($results as $key => $bean) {
                 foreach ($optionFields as $sourceField => $sugarField) {
                     $options_map = $options[$field_defs[$sourceField]['options']];
                     $results[$key]->{$sugarField} = !empty($options_map[$results[$key]->{$sugarField}]) ? $options_map[$results[$key]->{$sugarField}] : $results[$key]->{$sugarField};
                 }
             }
             //foreach
         }
     }
     return $results;
 }
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:67,代码来源:component.php


示例17: create_export_query_relate_link_patch

/**
 * create_export_query is used for export and massupdate
 * We haven't handle the these fields: $field['type'] == 'relate' && isset($field['link']
 * This function will correct the where clause and output necessary join condition for them
 * @param $module: the module name
 * @param $searchFields: searchFields which is got after $searchForm->populateFromArray()
 * @param $where: where clauses
 * @return $ret_array['where']: corrected where clause
 * @return $ret_array['join']: extra join condition
 */
function create_export_query_relate_link_patch($module, $searchFields, $where)
{
    if (file_exists('modules/' . $module . '/SearchForm.html')) {
        $ret_array['where'] = $where;
        return $ret_array;
    }
    $seed = loadBean($module);
    foreach ($seed->field_defs as $name => $field) {
        if ($field['type'] == 'relate' && isset($field['link']) && !empty($searchFields[$name]['value'])) {
            $seed->load_relationship($field['link']);
            $params = array();
            if (empty($join_type)) {
                $params['join_type'] = ' LEFT JOIN ';
            } else {
                $params['join_type'] = $join_type;
            }
            if (isset($data['join_name'])) {
                $params['join_table_alias'] = $field['join_name'];
            } else {
                $params['join_table_alias'] = 'join_' . $field['name'];
            }
            if (isset($data['join_link_name'])) {
                $params['join_table_link_alias'] = $field['join_link_name'];
            } else {
                $params['join_table_link_alias'] = 'join_link_' . $field['name'];
            }
            $join = $seed->{$field}['link']->getJoin($params, true);
            $join_table_alias = 'join_' . $field['name'];
            if (isset($field['db_concat_fields'])) {
                $db_field = db_concat($join_table_alias, $field['db_concat_fields']);
                $where = preg_replace('/' . $field['name'] . '/', $db_field, $where);
            } else {
                $where = preg_replace('/(^|[\\s(])' . $field['name'] . '/', '${1}' . $join_table_alias . '.' . $field['rname'], $where);
            }
        }
    }
    $ret_array = array('where' => $where, 'join' => $join['join']);
    return $ret_array;
}
开发者ID:razorinc,项目名称:sugarcrm-example,代码行数:49,代码来源:utils.php


示例18: __construct

 function __construct()
 {
     $result = $GLOBALS['db']->query("SELECT id FROM saved_search");
     while ($row = $GLOBALS['db']->fetchByAssoc($result)) {
         $focus = new SavedSearch();
         $focus->retrieve($row['id']);
         $contents = unserialize(base64_decode($focus->contents));
         $has_team_name_saved = isset($contents['team_name_advanced']) || isset($contents['team_name_basic']) ? true : false;
         //If $contents['searchFormTab'] is set then this is coming from a 4.x saved search
         if (isset($contents['searchFormTab']) && $contents['searchFormTab'] == 'saved_views') {
             $new_contents = array();
             $module = $contents['search_module'];
             $advanced = !empty($contents['advanced']);
             $field_map = array();
             if (file_exists("custom/modules/{$module}/metadata/searchdefs.php")) {
                 require "custom/modules/{$module}/metadata/searchdefs.php";
                 $field_map = $advanced ? $searchdefs[$module]['layout']['advanced_search'] : $searchdefs[$module]['layout']['basic_search'];
             } else {
                 if (file_exists("modules/{$module}/metadata/SearchFields.php")) {
                     require "modules/{$module}/metadata/SearchFields.php";
                     $field_map = $searchFields[$module];
                 } else {
                     $bean = loadBean($module);
                     $field_map = $bean->field_name_map;
                 }
             }
             //Special case for team_id field (from 4.5.x)
             if (isset($contents['team_id'])) {
                 $contents['team_name'] = $contents['team_id'];
                 unset($contents['team_id']);
             }
             foreach ($contents as $key => $value) {
                 if (isset($field_map[$key])) {
                     $new_key = $key . ($advanced ? '_advanced' : '_basic');
                     if (preg_match('/^team_name_(advanced|basic)$/', $new_key)) {
                         if (!is_array($value)) {
                             $temp_value = array();
                             $teap_value[] = $value;
                             $value = $temp_value;
                         }
                         $team_results = $GLOBALS['db']->query("SELECT id, name FROM teams where id in ('" . implode("','", $value) . "')");
                         if (!empty($team_results)) {
                             $count = 0;
                             while ($team_row = $GLOBALS['db']->fetchByAssoc($team_results)) {
                                 $team_key = $new_key . '_collection_' . $count;
                                 $new_contents[$team_key] = $team_row['name'];
                                 $new_contents['id_' . $team_key] = $team_row['id'];
                                 $count++;
                             }
                             //while
                         }
                         //if
                         //Unset the original key
                         unset($new_contents[$key]);
                         //Add the any switch
                         $new_contents[$new_key . '_type'] = 'any';
                     } else {
                         $new_contents[$new_key] = $value;
                     }
                 } else {
                     $new_contents[$key] = $value;
                 }
             }
             $new_contents['searchFormTab'] = $advanced ? 'advanced_search' : 'basic_search';
             $content = base64_encode(serialize($new_contents));
             $GLOBALS['db']->query("UPDATE saved_search SET contents = '{$content}' WHERE id = '{$row['id']}'");
         } else {
             if ($has_team_name_saved) {
                 //Otherwise, if the boolean has_team_name_saved is set to true, we also need to parse (coming from 5.x)
                 if (isset($contents['team_name_advanced'])) {
                     $team_results = $GLOBALS['db']->query("SELECT name FROM teams where id = '{$contents['team_name_advanced']}'");
                     if (!empty($team_results)) {
                         $team_row = $GLOBALS['db']->fetchByAssoc($team_results);
                         $contents['team_name_advanced_collection_0'] = $team_row['name'];
                         $contents['id_team_name_advanced_collection_0'] = $contents['team_name_advanced'];
                         $contents['team_name_advanced_type'] = 'any';
                         unset($contents['team_name_advanced']);
                         $content = base64_encode(serialize($contents));
                         $GLOBALS['db']->query("UPDATE saved_search SET contents = '{$content}' WHERE id = '{$row['id']}'");
                     }
                 }
             }
         }
     }
     //while
 }
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:86,代码来源:UpgradeSavedSearch.php


示例19: populateRequest

 function populateRequest()
 {
     global $timedate;
     if (isset($this->contents['search_module'])) {
         $searchModuleBean = loadBean($this->contents['search_module']);
     }
     foreach ($this->contents as $key => $val) {
         if ($key != 'advanced' && $key != 'module' && !strpos($key, '_ORDER_BY') && $key != 'lvso') {
             if (isset($searchModuleBean) && !empty($val) && preg_match('/^(start_range_|end_range_|range_)?(.*?)(_advanced|_basic)$/', $key, $match)) {
                 $field = $match[2];
                 if (isset($searchModuleBean->field_defs[$field]['type'])) {
                     $type = $searchModuleBean->field_defs[$field]['type'];
                     //Avoid macro values for the date types
                     if (($type == 'date' || $type == 'datetime' || $type == 'datetimecombo') && preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $val) && !preg_match('/^\\[.*?\\]$/', $val)) {
                         $val = $timedate->to_display_date($val, false);
                     } else {
                         if (($type == 'int' || $type == 'currency' || $type == 'decimal' || $type == 'float') && isset($this->contents[$key . '_unformatted_number']) && preg_match('/^\\d+$/', $val)) {
                             require_once 'modules/Currencies/Currency.php';
                             $val = format_number($val);
                             if ($type == 'currency' && isset($this->contents[$key . '_currency_symbol'])) {
                                 $val = $this->contents[$key . '_currency_symbol'] . $val;
                             }
                         }
                     }
                 }
             }
             $_REQUEST[$key] = $val;
             $_GET[$key] = $val;
         }
     }
 }
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:31,代码来源:SavedSearch.php


示例20: action_DefaultSoapPopup

 function action_DefaultSoapPopup()
 {
     $this->view = 'ajax';
     $source_id = $_REQUEST['source_id'];
     $module = $_REQUEST['module_id'];
     $id = $_REQUEST['record_id'];
     $mapping = $_REQUEST['mapping'];
     $mapping = explode(',', $mapping);
     //Error checking
     //Load bean
     $bean = loadBean($module);
     $bean->retrieve($id);
     require_once 'include/connectors/ConnectorFactory.php';
     $component = ConnectorFactory::getInstance($source_id);
     //Create arguments
     $args = array();
     $field_defs = $bean->getFieldDefinitions();
     foreach ($field_defs as $id => $field) {
         if (!empty($bean->{$id})) {
             $args[$id] = $bean->{$id};
         }
     }
     $beans = $component->fillBeans($args, $module);
     if (!empty($beans) && !empty($mapping)) {
         $results = array();
         $count = 0;
         foreach ($beans as $bean) {
             foreach ($mapping as $field) {
                 $results[$count][$field] = $bean->{$field};
             }
             $count++;
         }
         $json = getJSONobj();
         echo $json->encode($results);
     } else {
         $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MISSING_MAPPING_ENTRY_FORM_MODULE']);
         echo '';
     }
 }
开发者ID:nartnik,项目名称:sugarcrm_test,代码行数:39,代码来源:controller.php



注:本文中的loadBean函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP loadClass函数代码示例发布时间:2022-05-15
下一篇:
PHP loadAllPageData函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap