当前位置: 首页>>代码示例>>PHP>>正文


PHP BeanFactory::newBean方法代码示例

本文整理汇总了PHP中BeanFactory::newBean方法的典型用法代码示例。如果您正苦于以下问题:PHP BeanFactory::newBean方法的具体用法?PHP BeanFactory::newBean怎么用?PHP BeanFactory::newBean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BeanFactory的用法示例。


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

示例1: getAgenda

 public function getAgenda($api, $args)
 {
     // Fetch the next 14 days worth of meetings (limited to 20)
     $end_time = new SugarDateTime("+14 days");
     $start_time = new SugarDateTime("-1 hour");
     $meeting = BeanFactory::newBean('Meetings');
     $meetingList = $meeting->get_list('date_start', "date_start > " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($start_time->asDb()), 'datetime') . " AND date_start < " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($end_time->asDb()), 'datetime'));
     // Setup the breaks for the various time periods
     $datetime = new SugarDateTime();
     $today_stamp = $datetime->get_day_end()->getTimestamp();
     $tomorrow_stamp = $datetime->setDate($datetime->year, $datetime->month, $datetime->day + 1)->get_day_end()->getTimestamp();
     $timeDate = TimeDate::getInstance();
     $returnedMeetings = array('today' => array(), 'tomorrow' => array(), 'upcoming' => array());
     foreach ($meetingList['list'] as $meetingBean) {
         $meetingStamp = $timeDate->fromUser($meetingBean->date_start)->getTimestamp();
         $meetingData = $this->formatBean($api, $args, $meetingBean);
         if ($meetingStamp < $today_stamp) {
             $returnedMeetings['today'][] = $meetingData;
         } else {
             if ($meetingStamp < $tomorrow_stamp) {
                 $returnedMeetings['tomorrow'][] = $meetingData;
             } else {
                 $returnedMeetings['upcoming'][] = $meetingData;
             }
         }
     }
     return $returnedMeetings;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:28,代码来源:MeetingsApi.php

示例2: updateBean

 protected function updateBean(SugarBean $bean, ServiceBase $api, $args)
 {
     $id = parent::updateBean($bean, $api, $args);
     //retrieve a Bean created
     if (isset($args['record']) && !empty($args['record'])) {
         $projectBean = BeanFactory::retrieveBean($args['module'], $args['record']);
     } else {
         $projectBean = $bean;
     }
     //Create a Diagram row
     $diagramBean = BeanFactory::getBean('pmse_BpmnDiagram')->retrieve_by_string_fields(array('prj_id' => $id));
     if (empty($diagramBean)) {
         $diagramBean = BeanFactory::newBean('pmse_BpmnDiagram');
         $diagramBean->dia_uid = PMSEEngineUtils::generateUniqueID();
     }
     $diagramBean->name = $projectBean->name;
     $diagramBean->description = $projectBean->description;
     $diagramBean->assigned_user_id = $projectBean->assigned_user_id;
     $diagramBean->prj_id = $id;
     $dia_id = $diagramBean->save();
     //Create a Process row
     $processBean = BeanFactory::getBean('pmse_BpmnProcess')->retrieve_by_string_fields(array('prj_id' => $id));
     if (empty($processBean)) {
         $processBean = BeanFactory::newBean('pmse_BpmnProcess');
         $processBean->pro_uid = PMSEEngineUtils::generateUniqueID();
     }
     $processBean->name = $projectBean->name;
     $processBean->description = $projectBean->description;
     $processBean->assigned_user_id = $projectBean->assigned_user_id;
     $processBean->prj_id = $id;
     $processBean->dia_id = $dia_id;
     $pro_id = $processBean->save();
     //Create a ProcessDefinition row
     $processDefinitionBean = BeanFactory::getBean('pmse_BpmProcessDefinition')->retrieve_by_string_fields(array('prj_id' => $id));
     if (empty($processDefinitionBean)) {
         $processDefinitionBean = BeanFactory::newBean('pmse_BpmProcessDefinition');
         $processDefinitionBean->id = $pro_id;
         $processDefinitionBean->new_with_id = true;
     }
     $processDefinitionBean->prj_id = $id;
     $processDefinitionBean->pro_module = $projectBean->prj_module;
     $processDefinitionBean->pro_status = $projectBean->prj_status;
     $processDefinitionBean->assigned_user_id = $projectBean->assigned_user_id;
     $processDefinitionBean->save();
     $relDepStatus = $projectBean->prj_status == 'ACTIVE' ? 'INACTIVE' : 'ACTIVE';
     while ($relatedDepBean = BeanFactory::getBean('pmse_BpmRelatedDependency')->retrieve_by_string_fields(array('prj_id' => $id, 'pro_status' => $relDepStatus))) {
         $relatedDepBean->pro_status = $projectBean->prj_status;
         $relatedDepBean->save();
     }
     $keysArray = array('prj_id' => $id, 'pro_id' => $pro_id);
     $dynaF = BeanFactory::getBean('pmse_BpmDynaForm')->retrieve_by_string_fields(array('prj_id' => $id, 'pro_id' => $pro_id, 'name' => 'Default'));
     if (empty($dynaF)) {
         $editDyna = false;
     } else {
         $editDyna = true;
     }
     $dynaForm = new PMSEDynaForm();
     $dynaForm->generateDefaultDynaform($processDefinitionBean->pro_module, $keysArray, $editDyna);
     return $id;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:60,代码来源:PMSEProjectCRUDApi.php

示例3: getRelationship

 public static function getRelationship($modulo)
 {
     $bean = BeanFactory::newBean($modulo);
     require_once "modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php";
     $res = array();
     $x = new DeployedRelationships($modulo);
     $res = array();
     //print_r($bean->field_name_map);
     foreach ($bean->field_name_map as $field => $data) {
         if ($data['type'] === 'link') {
             if ($def = $x->get($data['relationship'])) {
                 $def = $def->getDefinition();
                 if ($def['relationship_type'] == 'many-to-many') {
                     continue;
                 } elseif ($def['lhs_module'] == $modulo && $def['relationship_type'] == 'one-to-many') {
                     continue;
                 } else {
                     $res[$data['name']] = "{$data['name']} : {$def['lhs_module']} {$def['relationship_type']} {$def['rhs_module']}";
                 }
                 //print_r($def);
             }
         }
     }
     return $res;
 }
开发者ID:juanOspina13,项目名称:SRX,代码行数:25,代码来源:CoreFnCrm.php

示例4: addRecordsToProspectList

 /**
  * Add records to a specific prospect list
  *
  * @param $moduleName         the module name for the records that will be associated to the prospect list
  * @param $prospectListId the id of the prospect list
  * @param $recordIds      Array of record ids to be added to the prospect list
  * @return $results       Associative array containing status for each record.
  */
 public function addRecordsToProspectList($moduleName, $prospectListId, $recordIds)
 {
     $prospectList = BeanFactory::getBean("ProspectLists", $prospectListId, array('strict_retrieve' => true));
     if (empty($prospectList)) {
         return false;
     }
     $bean = BeanFactory::newBean($moduleName);
     $results = array();
     $relationship = '';
     foreach ($bean->get_linked_fields() as $field => $def) {
         if ($bean->load_relationship($field)) {
             if ($bean->{$field}->getRelatedModuleName() == 'ProspectLists') {
                 $relationship = $field;
                 break;
             }
         }
     }
     if ($relationship != '') {
         foreach ($recordIds as $id) {
             $retrieveResult = $bean->retrieve($id);
             if ($retrieveResult === null) {
                 $results[$id] = false;
             } else {
                 $bean->load_relationship($relationship);
                 $bean->prospect_lists->add($prospectListId);
                 $results[$id] = true;
             }
         }
     }
     return $results;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:39,代码来源:ProspectListsService.php

示例5: save

 /**
  * Saves the Dashboard Backup
  *
  * @param boolean $check_notify Optional, default false, if set to true assignee of the record is notified via email.
  * @return parent function
  */
 function save($check_notify = FALSE)
 {
     //handle user default backup - for admins to retrieve their favorite dashboard easily
     if ($this->user_default == 1) {
         $backup_list = BeanFactory::newBean("dash_DashboardBackups");
         $results = $backup_list->get_list("", "assigned_user_id='{$this->assigned_user_id}'");
         foreach ($results['list'] as $id => $backupObj) {
             if (!isset($this->fetched_row['id']) || $this->id != $id) {
                 $backupObj->user_default = 0;
                 $backupObj->ignore = true;
                 $backupObj->save();
             }
         }
     }
     //if being manually created
     if (empty($this->name) && !empty($this->assigned_user_id) && isset($_REQUEST['module']) && $this->ignore == false) {
         $userObj = BeanFactory::getBean("Users", $this->assigned_user_id);
         $this->unencoded_pages = $userObj->getPreference('pages', 'Home');
         $this->unencoded_dashlets = $userObj->getPreference('dashlets', 'Home');
         $this->name = "Manual Backup";
     }
     //encode for save
     $this->encoded_pages = base64_encode(serialize($this->unencoded_pages));
     $this->encoded_dashlets = base64_encode(serialize($this->unencoded_dashlets));
     return parent::save($check_notify);
 }
开发者ID:omusico,项目名称:SelkirkCRM,代码行数:32,代码来源:dash_DashboardBackups.php

示例6: expandField

 public function expandField()
 {
     if (!isset($this->def['source']) || $this->def['source'] == 'db') {
         return;
     }
     // Exists only checks
     if (!empty($this->def['rname_exists'])) {
         $this->markNonDb();
         $this->rNameExists = true;
         return;
     }
     if (!empty($this->def['rname']) && !empty($this->def['link'])) {
         $this->table = $this->query->getJoinAlias($this->def['link']);
         $this->field = $this->def['rname'];
     } elseif (!empty($this->def['rname']) && !empty($this->def['table'])) {
         $this->table = $this->query->getJoinAlias($this->def['table'], false);
         $this->field = $this->def['rname'];
     } elseif (!empty($this->def['rname_link']) && !empty($this->def['link'])) {
         $this->field = $this->def['rname_link'];
     }
     if (!empty($this->def['module'])) {
         $this->moduleName = $this->def['module'];
         $bean = BeanFactory::newBean($this->moduleName);
         if (isset($bean->field_defs[$this->field])) {
             $this->def = $bean->field_defs[$this->field];
         }
     }
     $this->checkCustomField();
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:29,代码来源:Condition.php

示例7: save_lines

 function save_lines(array $post, AOR_Report $bean, $postKey)
 {
     $seenIds = array();
     if (isset($post[$postKey . 'id'])) {
         foreach ($post[$postKey . 'id'] as $key => $id) {
             if ($id) {
                 $aorChart = BeanFactory::getBean('AOR_Charts', $id);
             } else {
                 $aorChart = BeanFactory::newBean('AOR_Charts');
             }
             $aorChart->name = $post[$postKey . 'title'][$key];
             $aorChart->type = $post[$postKey . 'type'][$key];
             $aorChart->x_field = $post[$postKey . 'x_field'][$key];
             $aorChart->y_field = $post[$postKey . 'y_field'][$key];
             $aorChart->aor_report_id = $bean->id;
             $aorChart->save();
             $seenIds[] = $aorChart->id;
         }
     }
     //Any beans that exist but aren't in $seenIds must have been removed.
     foreach ($bean->get_linked_beans('aor_charts', 'AOR_Charts') as $chart) {
         if (!in_array($chart->id, $seenIds)) {
             $chart->mark_deleted($chart->id);
         }
     }
 }
开发者ID:switcode,项目名称:SuiteCRM,代码行数:26,代码来源:AOR_Chart.php

示例8: getTempImage

 /**
  * Gets a single temporary file for rendering and removes it from filesystem.
  *
  * @param ServiceBase $api The service base
  * @param array $args Arguments array built by the service base
  */
 public function getTempImage($api, $args)
 {
     // Get the field
     if (empty($args['field'])) {
         // @TODO Localize this exception message
         throw new SugarApiExceptionMissingParameter('Field name is missing');
     }
     $field = $args['field'];
     // Get the bean
     $bean = BeanFactory::newBean($args['module']);
     // Handle ACL
     $this->verifyFieldAccess($bean, $field);
     $filepath = UploadStream::path("upload://tmp/") . $args['temp_id'];
     if (is_file($filepath)) {
         $filedata = getimagesize($filepath);
         $info = array('content-type' => $filedata['mime'], 'path' => $filepath);
         require_once "include/download_file.php";
         $dl = new DownloadFileApi($api);
         $dl->outputFile(false, $info);
         if (!empty($args['keep'])) {
             return;
         }
         register_shutdown_function(function () use($filepath) {
             if (is_file($filepath)) {
                 unlink($filepath);
             }
         });
     } else {
         throw new SugarApiExceptionInvalidParameter('File not found');
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:37,代码来源:FileTempApi.php

示例9: display

 public function display()
 {
     global $current_user, $current_language, $sugar_flavor, $sugar_config;
     if (!$current_user->is_admin) {
         sugar_die(translate("LBL_MUST_BE_ADMIN"));
     }
     //RemoveTabSave: let dashboard pass since we are still altering it
     if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'RemoveTabSave') {
         if (isset($_REQUEST['TabToRemove'])) {
             $dashboardManager = BeanFactory::newBean("dash_DashboardManager");
             $dashboardManager->temp_unencoded_pages = $dashboardManager->deletePageByKey($_REQUEST['TabToRemove'], $current_user->getPreference('pages', 'Home'));
             $dashboardManager->temp_unencoded_dashlets = $current_user->getPreference('dashlets', 'Home');
             $dashboardManager->setDashboardForUser($current_user);
             $current_user->getPreference('pages', 'Home');
             $current_user->getPreference('dashlets', 'Home');
         }
     } elseif (isset($this->bean->fetched_row['id'])) {
         //set this dashboard for current user
         $this->bean->setDashboardForUser($current_user);
     } else {
         //set dashboard back to clean template
         $current_user->resetPreferences('Home');
     }
     parent::display();
     //get language for dashboard
     $mod_strings = return_module_language($current_language, 'Home');
     //render dashboard
     $lock_homepage = $sugar_config['lock_homepage'];
     $sugar_config['lock_homepage'] = false;
     require_once "modules/Home/index.php";
     $sugar_config['lock_homepage'] = $lock_homepage;
 }
开发者ID:omusico,项目名称:SelkirkCRM,代码行数:32,代码来源:view.edit.php

示例10: getTags

 /**
  *	Esta funcion devuelve los tags disponibles para el PDF
  */
 public static function getTags($plantilla_id)
 {
     require_once "modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php";
     $res = array();
     $plantilla_bean = BeanFactory::getBean('opalo_plantillas', $plantilla_id);
     $modulo = $plantilla_bean->pariente;
     $relaciones = unencodeMultienum($plantilla_bean->relaciones);
     ///CARGA LOS CAMPOS DEL MODULO
     $bean = BeanFactory::newBean($modulo);
     foreach ($bean->field_name_map as $campo => $data) {
         $res[$campo] = $data['type'];
     }
     $x = new DeployedRelationships($modulo);
     ///CARGA LOS CAMPOS DE LA RELACION <relationship_name>::<field_name>
     foreach ($relaciones as $relation) {
         $rel = $bean->field_name_map[$relation]['relationship'];
         $def = $x->get($rel)->getDefinition();
         $otro_modulo = $def['rhs_module'];
         if ($modulo == $def['rhs_module']) {
             $otro_modulo = $def['lhs_module'];
         }
         $bean_seg = BeanFactory::newBean($otro_modulo);
         foreach ($bean_seg->field_name_map as $campo => $data) {
             $res[$relation . "::" . $campo] = $data['type'];
         }
         $bean->load_relationship($relation);
     }
     return $res;
 }
开发者ID:juanOspina13,项目名称:SRX,代码行数:32,代码来源:CoreFnPdf.php

示例11: testGetLinkedBeans

 public function testGetLinkedBeans()
 {
     //Test the accounts_leads relationship
     $account = BeanFactory::newBean("Accounts");
     $account->name = "GetLinkedBeans Test Account";
     $account->save();
     $this->createdBeans[] = $account;
     $case = BeanFactory::newBean("Cases");
     $case->name = "GetLinkedBeans Test Cases";
     $case->save();
     $this->createdBeans[] = $case;
     $this->assertTrue($account->load_relationship("cases"));
     $this->assertInstanceOf("Link2", $account->cases);
     $this->assertTrue($account->cases->loadedSuccesfully());
     $account->cases->add($case);
     $account->save();
     $where = array('lhs_field' => 'id', 'operator' => ' LIKE ', 'rhs_value' => "{$case->id}");
     $cases = $account->get_linked_beans('cases', 'Case', array(), 0, 10, 0, $where);
     $this->assertEquals(1, count($cases), 'Assert that we have found the test case linked to the test account');
     $contact = BeanFactory::newBean("Contacts");
     $contact->first_name = "First Name GetLinkedBeans Test Contacts";
     $contact->last_name = "First Name GetLinkedBeans Test Contacts";
     $contact->save();
     $this->createdBeans[] = $contact;
     $this->assertTrue($account->load_relationship("contacts"));
     $this->assertInstanceOf("Link2", $account->contacts);
     $this->assertTrue($account->contacts->loadedSuccesfully());
     $account->contacts->add($contact);
     $where = array('lhs_field' => 'id', 'operator' => ' LIKE ', 'rhs_value' => "{$contact->id}");
     $contacts = $account->get_linked_beans('contacts', 'Contact', array(), 0, -1, 0, $where);
     $this->assertEquals(1, count($contacts), 'Assert that we have found the test contact linked to the test account');
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:32,代码来源:GetLinkedBeansTest.php

示例12: massUpdate

 /**
  * To perform massupdate, either update or delete, based on the args parameter
  * @param $api ServiceBase The API class of the request, used in cases where the API changes how the fields are pulled from the args array.
  * @param $args array The arguments array passed in from the API
  * @return String
  */
 public function massUpdate($api, $args)
 {
     $this->requireArgs($args, array('massupdate_params', 'module'));
     $mu_params = $args['massupdate_params'];
     $mu_params['module'] = $args['module'];
     // should pass success status once uid is empty.
     if (empty($mu_params['uid']) && empty($mu_params['entire'])) {
         return array('status' => 'done', 'failed' => 0);
     }
     if (isset($mu_params['entire']) && empty($mu_params['entire'])) {
         unset($mu_params['entire']);
     }
     if (isset($mu_params['team_name'])) {
         if (isset($mu_params['team_name_type']) && $mu_params['team_name_type'] === '1') {
             $mu_params['team_name_type'] = "add";
         } else {
             $mu_params['team_name_type'] = "replace";
         }
     }
     // check ACL
     $bean = BeanFactory::newBean($mu_params['module']);
     if (!$bean instanceof SugarBean) {
         throw new SugarApiExceptionInvalidParameter("Invalid bean, is module valid?");
     }
     $action = $this->delete ? 'delete' : 'save';
     if (!$bean->ACLAccess($action)) {
         throw new SugarApiExceptionNotAuthorized('No access to mass update records for module: ' . $mu_params['module']);
     }
     $mu_params['action'] = $action;
     $massUpdateJob = new SugarJobMassUpdate();
     $result = $massUpdateJob->runUpdate($mu_params);
     $result['status'] = 'done';
     return $result;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:40,代码来源:MassUpdateApi.php

示例13: createLeadRecord

 /**
  * Creates lead records
  * @param $apiServiceBase The API class of the request, used in cases where the API changes how the fields are pulled from the args array.
  * @param $args array The arguments array passed in from the API
  * @return array properties on lead bean formatted for display
  */
 public function createLeadRecord($api, $args)
 {
     // Bug 54647 Lead registration can create empty leads
     if (!isset($args['last_name'])) {
         throw new SugarApiExceptionMissingParameter();
     }
     /**
      *
      * Bug56194: This API can be hit without logging into Sugar, but the creation of a Lead SugarBean
      * uses messages that require the use of the app strings.
      *
      **/
     global $app_list_strings;
     global $current_language;
     if (!isset($app_list_strings)) {
         $app_list_strings = return_app_list_strings_language($current_language);
     }
     $bean = BeanFactory::newBean('Leads');
     // we force team and teamset because there is no current user to get them from
     $fields = array('team_set_id' => '1', 'team_id' => '1', 'lead_source' => 'Support Portal User Registration');
     $admin = Administration::getSettings();
     if (isset($admin->settings['portal_defaultUser']) && !empty($admin->settings['portal_defaultUser'])) {
         $fields['assigned_user_id'] = json_decode(html_entity_decode($admin->settings['portal_defaultUser']));
     }
     $fieldList = array('first_name', 'last_name', 'phone_work', 'email', 'primary_address_country', 'primary_address_state', 'account_name', 'title', 'preferred_language');
     foreach ($fieldList as $fieldName) {
         if (isset($args[$fieldName])) {
             $fields[$fieldName] = $args[$fieldName];
         }
     }
     $id = $this->updateBean($bean, $api, $fields);
     return $id;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:39,代码来源:RegisterLeadApi.php

示例14: testGetRelatedListFunctionWithLink2Class

 public function testGetRelatedListFunctionWithLink2Class()
 {
     $focusModule = 'Accounts';
     $linkedModules = array('Bugs', 'Contacts');
     $focus = BeanFactory::newBean($focusModule);
     $focus->name = "bug49505";
     $focus->save();
     $this->_createdBeans[] = $focus;
     foreach ($linkedModules as $v) {
         $linkedBean = BeanFactory::newBean($v);
         $linkedBean->name = "bug49505";
         $linkedBean->save();
         $this->_createdBeans[] = $linkedBean;
         $link = new Link2(strtolower($v), $focus);
         $link->add(array($linkedBean));
         // get relation from 'Link2' class
         $link2List = $focus->get_related_list($linkedBean, strtolower($v));
         // get relation for 'get_related_list' function from Link class
         $focus->field_defs[strtolower($v)]['link_class'] = 'Link';
         $focus->field_defs[strtolower($v)]['link_file'] = 'data/Link.php';
         $linkList = $focus->get_related_list($linkedBean, strtolower($v));
         unset($focus->field_defs[strtolower($v)]['link_class']);
         unset($focus->field_defs[strtolower($v)]['link_file']);
         $this->assertEquals($linkedBean->id, $linkList['list'][0]->id);
         $this->assertEquals($linkedBean->id, $link2List['list'][0]->id);
     }
 }
开发者ID:newLoki,项目名称:sugarcrm_dev,代码行数:27,代码来源:Bug49505Test.php

示例15: newBean

 protected function newBean($module)
 {
     $bean = BeanFactory::newBean($module);
     if (empty($bean)) {
         throw new Exception("No bean for module {$module}");
     }
     return $bean;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:8,代码来源:PMSERelatedModule.php


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