Exemplo n.º 1
0
 /**
  * Update the email data in the REQUEST global object
  * @param type $bean
  * @param type $newEmailAddress
  */
 public function updateEmails($bean, $newEmailAddress)
 {
     //Note.- in the future will be an 'array' of change fields emails
     $moduleItem = '0';
     $addresses = $bean->emailAddress->getAddressesByGUID($bean->id, $bean->module_dir);
     if (sizeof($addresses) > 0) {
         $_REQUEST[$bean->module_dir . '_email_widget_id'] = 0;
         $_REQUEST['emailAddressWidget'] = 1;
         $_REQUEST['useEmailWidget'] = true;
     }
     foreach ($addresses as $item => $data) {
         if (!isset($data['email_address_id']) || !isset($data['primary_address'])) {
             $this->logger->error(' The Email address Id or the primary address flag does not exist in DB');
             continue;
         }
         $emailAddressId = $data['email_address_id'];
         $emailId = $bean->module_dir . $moduleItem . 'emailAddress';
         if (!empty($emailAddressId) && $data['primary_address'] == 1) {
             $_REQUEST[$emailId . 'PrimaryFlag'] = $emailId . $item;
             $_REQUEST[$emailId . $item] = $newEmailAddress;
         } else {
             $_REQUEST[$emailId . $item] = $data['email_address'];
         }
         $_REQUEST[$emailId . 'Id' . $item] = $emailAddressId;
         $_REQUEST[$emailId . 'VerifiedFlag' . $item] = true;
         $_REQUEST[$emailId . 'VerifiedValue' . $item] = $data['email_address'];
         //$upd_query = "UPDATE email_addresses SET email_address='" . $emailAddress . "', email_address_caps='" . mb_strtoupper($emailAddress) . "', date_modified=" . $db->now() . " WHERE id='" . $row['email_address_id'] . "'";
         //$upd_res = $db->Query($upd_query);
         //$this->bpmLog('INFO',  $upd_query . ' result :  ' . print_r($upd_res,true));
     }
 }
Exemplo n.º 2
0
 /**
  * get the related modules of a determined bean passed as parameter
  * @global type $beanList
  * @global type $beanFiles
  * @global type $db
  * @param type $bean
  * @param type $flowBean
  * @param type $act_field_module
  * @return type
  */
 public function getRelatedModule($bean, $flowBean, $act_field_module)
 {
     global $beanList, $db;
     $moduleName = $flowBean['cas_sugar_module'];
     //$object_id = $flowBean->cas_sugar_object_id;
     $id_mainModule = $bean->id;
     $relatedNew = $this->getRelationshipData($act_field_module, $db);
     $left = $relatedNew['lhs_module'];
     $act_field_module = $related = $relatedNew['rhs_module'];
     if (!isset($beanList[$act_field_module])) {
         $this->logger->error("[][] {$act_field_module} module is not related to {$moduleName}, ain't appear in the bean list");
     } else {
         $this->logger->info("[][] {$moduleName} got a related module named: [{$act_field_module}]");
         //            $moduleClassName = $beanList[$act_field_module];
         //            $moduleDir = $beanFiles[$moduleClassName];
         $moduleName = $act_field_module;
         ///relationship
         //            $relationship = "Relationship";
         //            $RelationshipModuleDir = $beanFiles[$relationship];
         //            require_once ($RelationshipModuleDir);
         $beanRelations = $this->retrieveBean("Relationships");
         $relation = $beanRelations->retrieve_by_sides($left, $related, $db);
         $ID_Related = $relation['rhs_key'];
         $this->logger->info("[][] {$related} {$ID_Related} field found.");
         // related module ID
         //            $classRelatedBean = $beanList[$related];
         //            $RelatedModuleDir = $beanFiles[$classRelatedBean];
         //            require_once ($RelatedModuleDir);
         $beanRelated = $this->retrieveBean("{$related}");
         $singleCondition = $ID_Related . "='" . $id_mainModule . "'";
         $list_bean_related = $beanRelated->get_full_list('', $singleCondition);
         $len = sizeof($list_bean_related);
         if (isset($list_bean_related[$len - 1])) {
             $this->logger->info("[][] Getting the last related record of {$len} records.");
             $beanRelated = $list_bean_related[$len - 1];
         } else {
             $beanRelated->retrieve_by_string_fields(array($ID_Related => $id_mainModule), true);
         }
         if (!isset($beanRelated->id)) {
             $this->logger->info("[][] There is not a data relationship beetween {$act_field_module} and {$flowBean['cas_sugar_module']}");
             $bean = null;
         } else {
             $bean = $this->retrieveBean("{$related}", $beanRelated->id);
             $this->logger->info("[][] Related {$act_field_module} loaded using id: {$beanRelated->id}");
         }
     }
     return $bean;
 }
 /**
  *
  * @param type $flowData
  * @return type
  */
 public function taskAssignment($flowData)
 {
     $activityBean = $this->retrieveBean('pmse_BpmnActivity');
     //new BpmnActivity();
     $activityDefinitionBean = $this->retrieveBean('pmse_BpmActivityDefinition');
     //new BpmActivityDefinition();
     $actId = $flowData['bpmn_id'];
     $activities = $activityBean->get_list('pmse_bpmn_activity.id', "pmse_bpmn_activity.id = '{$actId}'");
     $activityRow = get_object_vars($activities['list'][0]);
     $currentUserId = $flowData['cas_user_id'];
     $currentSugarId = $flowData['cas_sugar_object_id'];
     $currentSugarModule = $flowData['cas_sugar_module'];
     $today = TimeDate::getInstance()->nowDb();
     $activitiesDef = $activityDefinitionBean->get_list('pmse_bpm_activity_definition.id', "pmse_bpm_activity_definition.id = '{$actId}' ", 0, -1, -1, array());
     if (!isset($activitiesDef['list'][0])) {
         //$this->bpmLog('ERROR', "[$flowData['cas_id']][$flowData['cas_index']] Activity Definition not found using act_id: $actId");
         $this->logger->error("[{$flowData['cas_id']}][{$flowData['cas_index']}] Activity Definition not found using act_id: {$actId}");
         $activityDefRow = array();
     } else {
         $activityDefRow = get_object_vars($activitiesDef['list'][0]);
     }
     $bpmnElement = array_merge($activityRow, $activityDefRow);
     //todo: throw an error if something was wrong
     //$expectedTimeObject = json_decode(base64_decode($activityDefRow['act_expected_time']));
     $caseData = new stdClass();
     $caseData->cas_start_date = '';
     $caseData->cas_delegate_date = $today;
     //$expectedTime = PMSEEngineUtils::processExpectedTime($expectedTimeObject, $caseData);
     //$dueDate = (!empty($expectedTime)) ? date('Y-m-d H:i:s', $expectedTime) : null;
     $activityType = $bpmnElement['act_task_type'];
     if ($activityType == 'SCRIPTTASK') {
         $cas_flow_status = 'SCRIPT';
         $cas_sugar_action = $activityType;
         //$this->bpmLog('INFO', "[$flowData['cas_id']][$flowData['cas_index']] next flow is a script");
         $this->logger->info("[{$flowData['cas_id']}][{$flowData['cas_index']}] next flow is a script");
     } else {
         $cas_flow_status = 'FORM';
         $cas_sugar_action = $bpmnElement['act_type'];
         //$this->bpmLog('INFO', "[$flowData['cas_id']][$flowData['cas_index']] next flow is an activity");
         $this->logger->info("[{$flowData['cas_id']}][{$flowData['cas_index']}] next flow is an activity");
         //check assignment rules
         $assignUser = isset($bpmnElement['act_assign_user']) == true ? $bpmnElement['act_assign_user'] : '******';
         $assign_method = isset($bpmnElement['act_assignment_method']) == true ? strtolower($bpmnElement['act_assignment_method']) : 'unknown';
         $assign_team = isset($bpmnElement['act_assign_team']) == true ? $bpmnElement['act_assign_team'] : 'unknown';
         //$last_assigned = $bpmnElement['act_last_user_assigned'];
         if ($assign_method == 'static') {
             switch ($assignUser) {
                 case 'owner':
                     $currentUserId = $this->getRecordOwnerId($currentSugarId, $currentSugarModule);
                     break;
                 case 'supervisor':
                     $currentUserId = $this->getSupervisorId($currentUserId);
                     break;
                 case 'currentuser':
                     $currentUserId = $currentUserId;
                     //$this->getCurrentUserId();
                     break;
                 default:
                     $currentUserId = $assignUser;
                     break;
             }
             //$this->bpmLog('INFO', "[$flowData['cas_id']][$flowData['cas_index']] form assigned to user '$currentUserId'");
             $this->logger->info("[{$flowData['cas_id']}][{$flowData['cas_index']}] form assigned to user '{$currentUserId}'");
         } elseif ($assign_method == 'selfservice') {
             $currentUserId = $assign_team;
             //$this->bpmLog('INFO', "[$flowData['cas_id']][$flowData['cas_index']] form assigned to team $currentUserId (Selfservice)");
             $this->logger->info("[{$flowData['cas_id']}][{$flowData['cas_index']}] form assigned to team {$currentUserId} (Selfservice)");
         } elseif ($assign_method == 'balanced') {
             $currentUserId = $this->getNextUserUsingRoundRobin($actId);
             //$this->bpmLog('INFO', "[$flowData['cas_id']][$flowData['cas_index']] form assigned to user $currentUserId (Round Robin)");
             $this->logger->info("[{$flowData['cas_id']}][{$flowData['cas_index']}] form assigned to user {$currentUserId} (Round Robin)");
         } else {
             //$this->bpmLog('INFO', "[$flowData['cas_id']][$flowData['cas_index']] 'unknown' assigned to user $currentUserId");
             $this->logger->info("[{$flowData['cas_id']}][{$flowData['cas_index']}] 'unknown' assigned to user {$currentUserId}");
         }
         //parent::execute($flowData, $bean);
     }
     return $currentUserId;
 }