Exemplo n.º 1
0
 public function ShareRecord()
 {
     $prtForm = $this->m_ParentFormName;
     if (!$prtForm) {
         return;
     }
     $prtFormObj = BizSystem::GetObject($prtForm);
     $recId = $this->m_ParentRecordId;
     $dataObj = $prtFormObj->getDataObj();
     $dataRec = $dataObj->fetchById($recId);
     $recArr = $this->readInputRecord();
     $DataRec = $dataRec;
     $DataRecOld = $dataRec;
     $currentRecord = $DataRecOld->toArray();
     //notice users has new shared data
     //test if changed a new owner
     if ($recArr['notify_user']) {
         $data = $this->fetchData();
         $data['app_index'] = APP_INDEX;
         $data['app_url'] = APP_URL;
         $data['operator_name'] = BizSystem::GetProfileName(BizSystem::getUserProfile("Id"));
         $emailSvc = BizSystem::getService(USER_EMAIL_SERVICE);
         if ($DataRec['owner_id'] != $recArr['owner_id']) {
             $emailSvc->DataAssignedEmail($recArr['owner_id'], $data);
         }
         //test if changes for group level visiable
         if ($recArr['group_perm'] >= 1) {
             $group_id = $recArr['group_id'];
             $userList = $this->_getGroupUserList($group_id);
             foreach ($userList as $user_id) {
                 $emailSvc->DataSharingEmail($user_id, $data);
             }
         }
         //test if changes for other group level visiable
         if ($recArr['other_perm'] >= 1) {
             $groupList = $this->_getGroupList();
             foreach ($groupList as $group_id) {
                 if ($recArr['group_id'] == $group_id) {
                     continue;
                 }
                 $userList = $this->_getGroupUserList($group_id);
                 foreach ($userList as $user_id) {
                     $emailSvc->DataSharingEmail($user_id, $data);
                 }
             }
         }
     }
     if (isset($recArr['group_perm'])) {
         $DataRec['group_perm'] = $recArr['group_perm'];
     }
     if (isset($recArr['other_perm'])) {
         $DataRec['other_perm'] = $recArr['other_perm'];
     }
     if (isset($recArr['group_id'])) {
         $DataRec['group_id'] = $recArr['group_id'];
     }
     if (isset($recArr['owner_id'])) {
         $DataRec['owner_id'] = $recArr['owner_id'];
     }
     if (isset($recArr['create_by'])) {
         $DataRec['create_by'] = $recArr['create_by'];
         $DataRec['update_by'] = $recArr['create_by'];
         $DataRec['update_time'] = date('Y-m-d H:i:s');
     }
     $DataRec->save();
     $inputRecord = $recArr;
     //$prtFormObj->getDataObj()->updateRecord($newDataRec,$dataRec);
     //save change log
     $postFields = $_POST;
     $elem_mapping = array();
     foreach ($postFields as $elem_name => $value) {
         $elem = $this->m_DataPanel->get($elem_name);
         $fld_name = $elem->m_FieldName;
         if ($elem) {
             $elem_mapping[$fld_name] = $elem;
         }
     }
     $logDO = $dataObj->getRefObject($this->m_LogDO);
     if ($logDO) {
         $cond_column = $logDO->m_Association['CondColumn'];
         $cond_value = $logDO->m_Association['CondValue'];
         if ($cond_column) {
             $type = $cond_value;
         }
         $foreign_id = $currentRecord['Id'];
         $logRecord = array();
         foreach ($inputRecord as $fldName => $fldVal) {
             $oldVal = $currentRecord[$fldName];
             if ($oldVal == $fldVal) {
                 continue;
             }
             if ($oldVal === null || $fldVal === null) {
                 continue;
             }
             $elem = $elem_mapping[$fldName]->m_XMLMeta;
             if (!$elem) {
                 $elem = $this->m_DataPanel->getByField($fldName)->m_XMLMeta;
             }
             $logRecord[$fldName] = array('old' => $oldVal, 'new' => $fldVal, 'element' => $elem);
         }
         $formMetaLite = array("name" => $this->m_Name, "package" => $this->m_Package, "message_file" => $this->m_MessageFile);
         // save to comment do
         $logRec = new DataRecord(null, $logDO);
         $logRec['foreign_id'] = $foreign_id;
         $logRec['type'] = $type;
         $logRec['form'] = serialize($formMetaLite);
         $logRec['data'] = serialize($logRecord);
         $logRec['comment'] = $comment;
         $logRec->save();
     }
     //end save change log
     if ($recArr['update_ref_data']) {
         if ($dataObj->m_ObjReferences->count()) {
             $this->_casacadeUpdate($dataObj, $recArr);
         }
     }
     if ($this->m_ParentFormName) {
         $this->close();
         $this->renderParent();
     }
     $this->processPostAction();
 }
Exemplo n.º 2
0
 public function SendEmailToContact($template_name, $recipient_contact_id, $data)
 {
     //init email info
     $template = $this->m_Tempaltes[$template_name]["TEMPLATE"];
     $subject = $this->m_Tempaltes[$template_name]["TITLE"];
     $sender = $this->m_Tempaltes[$template_name]["EMAILACCOUNT"];
     //render the email tempalte
     $data['app_index'] = APP_INDEX;
     $data['app_url'] = APP_URL;
     $data['operator_name'] = BizSystem::GetProfileName($data['create_by']);
     $data['operator_email'] = BizSystem::GetProfileEmail($data['create_by']);
     $data['refer_url'] = SITE_URL;
     //prepare recipient info
     $userObj = BizSystem::getObject("contact.do.ContactSystemDO");
     $userData = $userObj->directFetch("[Id]='" . $recipient_contact_id . "'", 1);
     if (!count($data)) {
         return false;
     }
     $userData = $userData[0];
     $recipient['email'] = $userData['email'];
     $recipient['name'] = $userData['display_name'];
     $data['contact_display_name'] = $userData['display_name'];
     $tplFile = BizSystem::getTplFileWithPath($template, "email");
     $content = $this->renderEmail($data, $tplFile);
     if ($userData['email'] == '') {
         //if no email address , then do nothing
         return;
     }
     //send it to the queue
     $result = $this->sendEmail($sender, $recipient, $subject, $content);
     return $result;
 }
Exemplo n.º 3
0
 public function ShareRecord()
 {
     $prtForm = $this->m_ParentFormName;
     $prtFormObj = BizSystem::GetObject($prtForm);
     $recId = $this->m_RecordId;
     $dataObj = $prtFormObj->getDataObj();
     $dataRec = $dataObj->fetchById($recId);
     $recArr = $this->readInputRecord();
     $DataRec = $dataRec;
     //notice users has new published data
     //test if changed a new owner
     if ($recArr['notify_user'] && $recArr['group_perm']) {
         $data = $this->fetchData();
         $data['app_index'] = APP_INDEX;
         $data['app_url'] = APP_URL;
         $data['operator_name'] = BizSystem::GetProfileName(BizSystem::getUserProfile("Id"));
         $emailSvc = BizSystem::getService(USER_EMAIL_SERVICE);
         //test if changes for group level visiable
         if ($recArr['group_perm'] >= 1) {
             $group_id = $recArr['group_id'];
             $userList = $this->_getGroupUserList($group_id);
             foreach ($userList as $user_id) {
                 $emailSvc->DataPublishEmail($user_id, $data);
             }
         }
         //test if changes for other group level visiable
         if ($recArr['other_perm'] >= 1) {
             $groupList = $this->_getGroupList();
             foreach ($groupList as $group_id) {
                 $userList = $this->_getGroupUserList($group_id);
                 foreach ($userList as $user_id) {
                     $emailSvc->DataPublishEmail($user_id, $data);
                 }
             }
         }
     }
     if (isset($recArr['group_perm'])) {
         $DataRec['group_perm'] = $recArr['group_perm'];
     }
     if (isset($recArr['other_perm'])) {
         $DataRec['other_perm'] = $recArr['other_perm'];
     }
     if (isset($recArr['group_id'])) {
         $DataRec['group_id'] = $recArr['group_id'];
     }
     if (isset($recArr['owner_id'])) {
         $DataRec['owner_id'] = $recArr['owner_id'];
     }
     if ($DataRec['group_perm'] == '0') {
         $DataRec['other_perm'] = '0';
     }
     $DataRec->save();
     //$prtFormObj->getDataObj()->updateRecord($newDataRec,$dataRec);
     if ($recArr['update_ref_data']) {
         if ($dataObj->m_ObjReferences->count()) {
             $this->_casacadeUpdate($dataObj, $recArr);
         }
     }
     if ($this->m_ParentFormName) {
         $this->close();
         $this->renderParent();
     }
     $this->processPostAction();
 }