本文整理汇总了PHP中BeanFactory::retrieveBean方法的典型用法代码示例。如果您正苦于以下问题:PHP BeanFactory::retrieveBean方法的具体用法?PHP BeanFactory::retrieveBean怎么用?PHP BeanFactory::retrieveBean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BeanFactory
的用法示例。
在下文中一共展示了BeanFactory::retrieveBean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: setup
function setup()
{
$rel = BeanFactory::getBean('Relationships');
if (!empty($this->vardef['relationship'])) {
$rel->retrieve_by_name($this->vardef['relationship']);
}
if ($rel->relationship_type == 'many-to-many') {
if ($rel->lhs_module == $this->module_dir) {
$this->related_module = $rel->rhs_module;
$module_dir = $rel->lhs_module;
} else {
if ($rel->rhs_module == $this->module_dir) {
$this->related_module = $rel->lhs_module;
$module_dir = $rel->rhs_module;
} else {
die("this field has no relationships mapped with this module");
}
}
if ($module_dir != $this->module_dir) {
die('These modules do not match : ' . $this->module_dir . ' and ' . $module_dir);
}
$this->bean = BeanFactory::retrieveBean($this->module_dir, $_REQUEST['bean_id']);
if (empty($this->bean)) {
die('failed to load the bean');
}
if ($this->bean->load_relationship($this->vardef['name'])) {
$this->retrieve_values();
} else {
die('failed to load the relationship');
}
} else {
die("the relationship is not a many-to-many");
}
}
示例3: filterRelatedSetup
public function filterRelatedSetup(ServiceBase $api, array $args)
{
// Load the parent bean.
$record = BeanFactory::retrieveBean($args['module'], $args['record']);
if (empty($record)) {
throw new SugarApiExceptionNotFound(sprintf('Could not find parent record %s in module: %s', $args['record'], $args['module']));
}
if (!$record->ACLAccess('view')) {
throw new SugarApiExceptionNotAuthorized('No access to view records for module: ' . $args['module']);
}
// Load the relationship.
$linkName = $args['link_name'];
if (!$record->load_relationship($linkName)) {
// The relationship did not load.
throw new SugarApiExceptionNotFound('Could not find a relationship named: ' . $args['link_name']);
}
$linkModuleName = $record->{$linkName}->getRelatedModuleName();
$linkSeed = BeanFactory::getBean($linkModuleName);
if (!$linkSeed->ACLAccess('list')) {
throw new SugarApiExceptionNotAuthorized('No access to list records for module: ' . $linkModuleName);
}
$options = $this->parseArguments($api, $args, $linkSeed);
// If they don't have fields selected we need to include any link fields
// for this relationship
if (empty($args['fields']) && is_array($linkSeed->field_defs)) {
$relatedLinkName = $record->{$linkName}->getRelatedModuleLinkName();
$options['linkDataFields'] = array();
foreach ($linkSeed->field_defs as $field => $def) {
if (empty($def['rname_link']) || empty($def['link'])) {
continue;
}
if ($def['link'] != $relatedLinkName) {
continue;
}
// It's a match
$options['linkDataFields'][] = $field;
$options['select'][] = $field;
}
}
// In case the view parameter is set, reflect those fields in the
// fields argument as well so formatBean only takes those fields
// into account instead of every bean property.
if (!empty($args['view'])) {
$args['fields'] = $options['select'];
}
$q = self::getQueryObject($linkSeed, $options);
// Some relationships want the role column ignored
if (!empty($args['ignore_role'])) {
$ignoreRole = true;
} else {
$ignoreRole = false;
}
$q->joinSubpanel($record, $linkName, array('joinType' => 'INNER', 'ignoreRole' => $ignoreRole));
$q->setJoinOn(array('baseBean' => strtolower($record->object_name), 'baseBeanId' => $record->id));
if (!isset($args['filter']) || !is_array($args['filter'])) {
$args['filter'] = array();
}
self::addFilters($args['filter'], $q->where(), $q);
return array($args, $q, $options, $linkSeed);
}
示例4: filterRelated
public function filterRelated(ServiceBase $api, array $args)
{
if (empty($args['include_child_items']) || !in_array($args['link_name'], array('calls', 'meetings'))) {
return parent::filterRelated($api, $args);
}
$api->action = 'list';
$record = BeanFactory::retrieveBean($args['module'], $args['record']);
if (empty($record)) {
throw new SugarApiExceptionNotFound(sprintf('Could not find parent record %s in module: %s', $args['record'], $args['module']));
}
if (!$record->ACLAccess('view')) {
throw new SugarApiExceptionNotAuthorized(sprintf('No access to view records for module: %s', $args['module']));
}
$linkName = $args['link_name'];
if (!$record->load_relationship($linkName)) {
throw new SugarApiExceptionNotFound(sprintf('Could not find a relationship named: %s', $args['link_name']));
}
$linkModuleName = $record->{$linkName}->getRelatedModuleName();
$linkSeed = BeanFactory::getBean($linkModuleName);
if (!$linkSeed->ACLAccess('list')) {
throw new SugarApiExceptionNotAuthorized(sprintf('No access to list records for module: %s', $linkModuleName));
}
$options = $this->parseArguments($api, $args, $linkSeed);
$q = self::getQueryObject($linkSeed, $options);
if (!isset($args['filter']) || !is_array($args['filter'])) {
$args['filter'] = array();
}
self::addFilters($args['filter'], $q->where(), $q);
// FIXME: this informations should be dynamically retrieved
if ($linkModuleName === 'Meetings') {
$linkToContacts = 'contacts';
$childModuleTable = 'meetings';
$childRelationshipTable = 'meetings_contacts';
$childRelationshipAlias = 'mc';
$childLhsColumn = $childModuleTable . '.id';
$childRhsColumn = $childRelationshipAlias . '.meeting_id';
} else {
$linkToContacts = 'contacts';
$childModuleTable = 'calls';
$childRelationshipTable = 'calls_contacts';
$childRelationshipAlias = 'cc';
$childLhsColumn = $childModuleTable . '.id';
$childRhsColumn = $childRelationshipAlias . '.call_id';
}
// Join contacts if not already requested.
$contactJoin = $q->join($linkToContacts, array('joinType' => 'LEFT'));
// FIXME: there should be the ability to specify from which related module
// the child items should be loaded
$q->joinTable('accounts_contacts', array('alias' => 'ac', 'joinType' => 'LEFT', 'linkingTable' => true))->on()->equalsField('ac.contact_id', $contactJoin->joinName() . '.id')->equals('ac.deleted', 0);
$q->joinTable('accounts', array('alias' => 'a', 'joinType' => 'LEFT', 'linkingTable' => true))->on()->equalsField('a.id', 'ac.account_id')->equals('a.deleted', 0);
$where = $q->where()->queryOr();
$where->queryAnd()->equals('ac.account_id', $record->id);
$where->queryAnd()->equals($childModuleTable . '.parent_type', 'Accounts')->equals($childModuleTable . '.parent_id', $record->id);
return $this->runQuery($api, $args, $q, $options, $linkSeed);
}
示例5: restore
/**
* Restore should merely look for Restore property to be set on the model. Restored is the boolean field to be checked after restore is complete, but simply set Restore (no d) on the model and pass it to the standard PUT request for Recycler module.
*/
public function restore($api, $args)
{
global $app_strings;
$bean = BeanFactory::retrieveBean("dm_Recycler", $args['id']);
$result = $bean->restore();
if ($result) {
$data = array('message' => $app_strings['LBL_DM_DATAMANAGER_RECORD_RESTORE_SUCCESS']);
} else {
$data = array('error' => "1", 'error_message' => $app_strings['LBL_DM_DATAMANAGER_RECORD_RESTORE_FAILURE']);
}
return $data;
}
示例6: setQuotaSubscriptions
public static function setQuotaSubscriptions(Quota $bean, $event, $args)
{
if ($event !== 'before_save') {
return false;
}
// Subscribe the user making the quota change
global $current_user;
Subscription::subscribeUserToRecord($current_user, $bean);
// Subscribe the user whose quota is getting changed
$assignee = BeanFactory::retrieveBean('Users', $bean->user_id);
Subscription::subscribeUserToRecord($assignee, $bean);
return true;
}
示例7: run
public function run()
{
if (version_compare($this->from_version, '7.6.0', '>=')) {
$this->log('ACL role sets should be already registered, skipping');
return;
}
require_once 'modules/ACLRoles/AclRoleSetRegistrar.php';
$registrar = new AclRoleSetRegistrar();
$result = $this->db->query("SELECT id FROM users where deleted = 0");
while ($row = $this->db->fetchByAssoc($result)) {
$user = BeanFactory::retrieveBean('Users', $row['id']);
if ($user) {
$this->log('Registering ACL role sets for user ' . $user->id);
$registrar->registerAclRoleSet($user);
}
}
}
示例8: get_summary_text
/**
* Get summary text
*/
public function get_summary_text()
{
/**
* @var TimePeriod
*/
$timeperiod = BeanFactory::retrieveBean("TimePeriods", $this->timeperiod_id);
// make sure we have the full name before display happens
if (empty($this->user_full_name) && !empty($this->user_id)) {
$user = BeanFactory::getBean('Users', $this->user_id);
$this->user_full_name = $user->full_name;
}
$mod_strings = return_module_language($GLOBALS['current_language'], $this->module_name);
// get the quota type as a label
$quota_type = '';
if (!empty($this->quota_type)) {
$quota_type = $mod_strings['LBL_' . strtoupper($this->quota_type)] . ' ' . $mod_strings['LBL_MODULE_NAME_SINGULAR'] . ' ';
}
return "{$timeperiod->name} {$quota_type}- {$this->user_full_name}";
}
示例9: unsubscribeFromRecord
public function unsubscribeFromRecord(ServiceBase $api, array $args)
{
$this->requireArgs($args, array('module', 'record'));
$bean = BeanFactory::retrieveBean($args['module'], $args['record']);
if (empty($bean)) {
throw new SugarApiExceptionNotFound('Could not find parent record ' . $args['record'] . ' in module ' . $args['module']);
}
if (!$bean->ACLAccess('view')) {
$moduleName = null;
if (isset($args['module'])) {
$failed_module_strings = return_module_language($GLOBALS['current_language'], $args['module']);
$moduleName = $failed_module_strings['LBL_MODULE_NAME'];
}
$args = null;
if (!empty($moduleName)) {
$args = array('moduleName' => $moduleName);
}
throw new SugarApiExceptionNotAuthorized('EXCEPTION_SUBSCRIBE_MODULE_NOT_AUTHORIZED', $args);
}
return Subscription::unsubscribeUserFromRecord($api->user, $bean);
}
示例10: getDownloadToken
/**
* Look up the supplied oauth_token from download token storage.
*
* @param $oauth_token
* oauth_token to be check with.
*
* @return
* An associative array as below, and return NULL if the supplied oauth_token
* is invalid:
* - client_id: Stored client identifier.
* - expires: Stored expiration in unix timestamp.
* - scope: (optional) Stored scope values in space-separated string.
*
* @ingroup oauth2_section_7
*/
public function getDownloadToken($oauth_token)
{
$tokenSeed = BeanFactory::newBean('OAuthTokens');
$token = $tokenSeed->retrieve_by_string_fields(array('download_token' => $oauth_token));
if (empty($token->id)) {
return NULL;
}
$clientBean = BeanFactory::retrieveBean('OAuthKeys', $token->consumer);
if (empty($token->id) || empty($clientBean->id)) {
return NULL;
}
$clientAllowed = $this->isClientAllowed($clientBean);
if (!$clientAllowed) {
return NULL;
}
if (session_id()) {
// The session here could be unrelated to the actual user attached to the
// download token, so let's just close it.
session_write_close();
$_SESSION = array();
}
$tokenData = array('client_id' => $clientBean->c_key, 'user_id' => $token->assigned_user_id, 'expires' => $token->expire_ts);
return $this->getPlatformStore()->getDownloadTokenData($tokenData, $token, $clientBean);
}
示例11: get_invite_calls
function get_invite_calls($user)
{
// First, get the list of IDs.
$query = "SELECT calls_users.required, calls_users.accept_status, calls_users.call_id from calls_users where calls_users.user_id='{$user->id}' AND ( calls_users.accept_status IS NULL OR calls_users.accept_status='none') AND calls_users.deleted=0";
$GLOBALS['log']->debug("Finding linked records {$this->object_name}: " . $query);
$result = $this->db->query($query, true);
$list = array();
while ($row = $this->db->fetchByAssoc($result)) {
$record = BeanFactory::retrieveBean($this->module_dir, $row['call_id']);
if (empty($record)) {
continue;
}
$record->required = $row['required'];
$record->accept_status = $row['accept_status'];
$list[] = $record;
}
return $list;
}
示例12: handleFailedReports
/**
* Handles failed reports by deactivating them and sending email notifications to owner and subscribed user
*/
public function handleFailedReports()
{
/** @var LoggerManager */
global $log;
$schedules_to_deactivate = $this->getSchedulesToDeactivate();
foreach ($schedules_to_deactivate as $schedule) {
$log->info('Deactivating report schedule ' . $schedule['id']);
$this->deactivate($schedule['id']);
$owner = BeanFactory::retrieveBean('Users', $schedule['owner_id']);
$subscriber = BeanFactory::retrieveBean('Users', $schedule['subscriber_id']);
require_once 'modules/Reports/utils.php';
$utils = new ReportsUtilities();
$utils->sendNotificationOfDisabledReport($schedule['report_id'], $owner, $subscriber);
}
}
示例13: createRelatedLinks
/**
* Relates existing records to related bean.
*
* @param ServiceBase $api The API class of the request.
* @param array $args The arguments array passed in from the API.
* @param string $securityTypeLocal What ACL to check on the near side of the link
* @param string $securityTypeRemote What ACL to check on the far side of the link
* @return array Array of formatted fields.
* @throws SugarApiExceptionInvalidParameter If wrong arguments are passed
* @throws SugarApiExceptionNotFound If bean can't be retrieved.
*/
public function createRelatedLinks($api, $args, $securityTypeLocal = 'view', $securityTypeRemote = 'view')
{
$this->requireArgs($args, array('ids'));
$ids = $this->normalizeLinkIds($args['ids']);
$result = array('related_records' => array());
$primaryBean = $this->loadBean($api, $args);
list($linkName) = $this->checkRelatedSecurity($api, $args, $primaryBean, $securityTypeLocal, $securityTypeRemote);
$relatedModuleName = $primaryBean->{$linkName}->getRelatedModuleName();
foreach ($ids as $id => $additionalValues) {
$relatedBean = BeanFactory::retrieveBean($relatedModuleName, $id);
if (!$relatedBean || $relatedBean->deleted) {
throw new SugarApiExceptionNotFound('Could not find the related bean');
}
$primaryBean->{$linkName}->add(array($relatedBean), $additionalValues);
$result['related_records'][] = $this->formatBean($api, $args, $relatedBean);
}
//Clean up any hanging related records.
SugarRelationship::resaveRelatedBeans();
$result['record'] = $this->formatBean($api, $args, $primaryBean);
return $result;
}
示例14: runEngine
/**
*
* @param type $flowData
* @param type $createThread
* @param type $bean
* @param type $externalAction
* @param type $arguments
* @return boolean
* @codeCoverageIgnore
*/
public function runEngine($flowData, $createThread = false, $bean = null, $externalAction = '', $arguments = array())
{
// Load the bean if the request comes from a RESUME_EXECUTION related origin
// like for example: a timer event execution.
if (is_null($bean)) {
$bean = BeanFactory::retrieveBean($flowData['cas_sugar_module'], $flowData['cas_sugar_object_id']);
}
// Validating unreferenced elements when cron jobs are executed, after MACAROON-518 shouldn't have
// unreferenced elements. This will validate previous records created before this fix.
if ($externalAction == 'WAKE_UP') {
$elementBean = BeanFactory::getBean('pmse_BpmnEvent', $flowData['bpmn_id']);
if (!isset($elementBean->id)) {
// Setting active flow to deleted
$fd = BeanFactory::getBean('pmse_BpmFlow', $flowData['id']);
$fd->cas_flow_status = 'DELETED';
$fd->save();
// Updating process to error
$cf = new PMSECaseFlowHandler();
$cf->changeCaseStatus($flowData['cas_id'], 'TERMINATED');
// Exiting without errors
return true;
}
}
$preparedData = $this->caseFlowHandler->prepareFlowData($flowData, $createThread);
$this->logger->debug("Begin process Element {$flowData['bpmn_type']}");
try {
$executionData = $this->processElement($preparedData, $bean, $externalAction, $arguments);
if (isset($executionData['process_bean']) && !empty($executionData['process_bean'])) {
$bean = $executionData['process_bean'];
}
$this->validateFailSafes($flowData, $executionData);
$routeData = $this->flowRouter->routeFlow($executionData, $flowData, $createThread);
} catch (PMSEElementException $e) {
$this->logger->warning($e->getMessage());
$element = $e->getElement();
$flow = $e->getFlowData();
$state = empty($flow['id']) ? 'CREATE' : 'UPDATE';
$executionData = $element->prepareResponse($flow, 'ERROR', $state);
// If the status is put into error then the Inbox record should be updated as well
$this->caseFlowHandler->changeCaseStatus($executionData['flow_data']['cas_id'], 'ERROR');
$routeData = $this->flowRouter->routeFlow($executionData, $flowData, $createThread);
} catch (Exception $e) {
$this->logger->warning($e->getMessage());
$element = $this->retrievePMSEElement('');
$status = $e->getCode() == 0 ? 'QUEUE' : 'ERROR';
$preparedData['cas_flow_status'] = $status;
$executionData = $element->prepareResponse($preparedData, $status, 'CREATE');
// If the status is put into error then the Inbox record should be updated as well
if ($status == 'ERROR') {
$this->caseFlowHandler->changeCaseStatus($executionData['flow_data']['cas_id'], 'ERROR');
}
$routeData = $this->flowRouter->routeFlow($executionData, $flowData, $createThread);
}
if ($this->caseFlowHandler->numberOfCasesByStatus($flowData, 'ERROR') <= 0 && $externalAction == 'RESUME_EXECUTION') {
$this->caseFlowHandler->changeCaseStatus($flowData['cas_id'], 'IN PROGRESS');
}
if (!empty($routeData['next_elements'])) {
$createThread = sizeof($routeData['next_elements']) > 1;
if ($createThread) {
$startTime = ($this->maxExecutionTimeout - $this->executionTime) / sizeof($routeData['next_elements']);
}
foreach ($routeData['next_elements'] as $elementData) {
//reset execution time if the derivation is in parallel
$this->executionTime = $createThread ? $startTime : $this->executionTime;
$this->runEngine($elementData, $createThread, $bean);
}
} else {
// Quick fix to the 0 output printed by some element,
// TODO: Don't remove until the fix to the element is commited
ob_get_clean();
return true;
}
return true;
}
示例15: getClassicModuleTitle
/*
* Your installation or use of this SugarCRM file is subject to the applicable
* terms available at
* http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/.
* If you do not agree to all of the applicable terms or do not have the
* authority to bind the entity as an authorized representative, then do not
* install or use this SugarCRM file.
*
* Copyright (C) SugarCRM Inc. All rights reserved.
*/
global $mod_strings;
global $app_strings;
global $app_list_strings;
global $focus, $support_coming_due, $support_expired;
if (!empty($_REQUEST['record'])) {
$focus = BeanFactory::retrieveBean('WorkFlow', $_REQUEST['record']);
if (empty($focus)) {
sugar_die($app_strings['LBL_UNAUTH_ADMIN']);
}
} else {
header("Location: index.php?module=WorkFlow&action=index");
}
if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
$focus->id = "";
}
echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_TITLE'], $focus->name), true);
$GLOBALS['log']->info("WorkFlow detail view");
$xtpl = new XTemplate('modules/WorkFlow/DetailView.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
$xtpl->assign("GRIDLINE", $gridline);