public function getSystemUserData($sendContact = 1) { //sendContact = 0 ; don't send contact info //sendContact = 1 ; send contact info $contactRec = array(); if ($sendContact) { $profileId = BizSystem::getUserProfile("profile_Id"); $recArr = BizSystem::getObject("contact.do.ContactDO")->fetchById($profileId); $contactRec['name'] = $recArr['display_name']; $contactRec['company'] = $recArr['company']; $contactRec['email'] = $recArr['email']; $contactRec['mobile'] = $recArr['mobile']; $contactRec['phone'] = $recArr['phone']; } $system_uuid = $this->getSystemUUID(); $system_name = DEFAULT_SYSTEM_NAME; $system_language = DEFAULT_LANGUAGE; $system_url = SITE_URL; $system_cubi_ver = $this->getVersion(); $system_openbiz_ver = BizSystem::getVersion(); $system_port = $_SERVER['SERVER_PORT']; $system_admin = $_SERVER['SERVER_ADMIN']; $internal_ip_address = $_SERVER['SERVER_ADDR']; if (function_exists("ioncube_server_data")) { $server_data = ioncube_server_data(); } else { $server_data = ""; } $systemRec = array("internal_ipaddr" => $internal_ip_address, "language" => $system_language, "system_name" => $system_name, "system_uuid" => $system_uuid, "system_url" => $system_url, "system_admin" => $system_admin, "system_port" => $system_port, "system_cubi_ver" => $system_cubi_ver, "system_openbiz_ver" => $system_openbiz_ver, "system_server_data" => $server_data); $params = array("contact_data" => $contactRec, "system_data" => $systemRec); return $params; }
protected function validateInputs($inputRecord) { $errors = null; if (strlen($inputRecord->password_old) < 4) { $errors["password_old"] = "Old password needs to longer than 4 characters"; } if (strlen($inputRecord->password_new) < 4) { $errors["password_new"] = "New password needs to longer than 4 characters"; } if (strlen($inputRecord->password_repeat) < 4) { $errors["password_repeat"] = "Repeat password needs to longer than 4 characters"; } if ($errors) { throw new ValidationException($errors); } $profile = BizSystem::getUserProfile(); $userId = $profile['Id']; $username = $profile['username']; //check old password $old_password = $inputRecord->password_old; $svcobj = BizSystem::getService(AUTH_SERVICE); $result = $svcobj->authenticateUser($username, $old_password); if (!$result) { $errors = array("password_old" => "Input password does not match user current password"); throw new ValidationException($errors); } // check repeat password $password_new = $inputRecord->password_new; $password_repeat = $inputRecord->password_repeat; if ($password_new != $password_repeat) { $errors = array("password_repeat" => "Repeat password is not same as the password"); throw new ValidationException($errors); } return true; }
public function outputAttrs() { $profile = BizSystem::getUserProfile(); $userId = $profile['Id']; $output = parent::outputAttrs(); $output['queryString'] = "Id=" . $userId; return $output; }
public function fetchData() { $url = $_SERVER['REQUEST_URI']; $roleStartpages = BizSystem::getUserProfile("roleStartpage"); $default_url = APP_INDEX . $roleStartpages[0]; if ($url == $default_url) { $this->m_isDefaultPage = 1; } else { $this->m_isDefaultPage = 0; } return parent::fetchData(); }
public static function group($groupIdField) { // get current user's group list $userProfile = BizSystem::getUserProfile(); //print_r($userProfile); if (!$userProfile || !$userProfile['groups']) { return "[" . $groupIdField . "] is null"; } $userId = $userProfile['Id']; $groupList = implode(",", $userProfile['groups']); return "[" . $groupIdField . "] in (" . $groupList . ")"; }
public function getStatus() { $result = array(); $userId = BizSystem::getUserProfile("Id"); if ($userId) { $result['login_status'] = 1; $result['display_name'] = BizSystem::getUserProfile("profile_display_name"); $result['email'] = BizSystem::getUserProfile("email"); } else { $result['login_status'] = 0; } return $result; }
public function reorderWidgets() { $sortorder = BizSystem::clientProxy()->getFormInputs('_widgets'); // get the widgets ordering of columns parse_str($sortorder, $output); $columns = array(); $columnCounts = array(); $n = 0; foreach ($output as $k => $val) { if (strpos($k, 'column') === 0) { $columns[$n] = explode(",", $val); $columnCounts[$n] = count($columns[$n]); $n++; } } //print_r($columns); // update ordering of all user_widget records $userWidgetDo = BizSystem::getObject($this->userWidgetDOName); $userWidgetTable = $userWidgetDo->m_MainTable; $db = $userWidgetDo->getDbConnection(); $myProfile = BizSystem::getUserProfile(); $myUserId = $myProfile['Id']; $currentView = BizSystem::instance()->getCurrentViewName(); $m = 1; foreach ($columns as $column) { $n = 1; foreach ($column as $widgetName) { if (empty($widgetName)) { continue; } // remove "_widget" from the widget name $widgetName = str_replace("_widget", "", $widgetName); // find the widget by name in the current view, set the new order $searchRule = "[user_id]={$myUserId} and [widget]='{$widgetName}' and [view]='{$currentView}'"; $record = $userWidgetDo->fetchOne($searchRule); $ordering = $n * 10; if ($record) { // update the order $data = array('column' => $m, 'ordering' => $ordering); $db->update($userWidgetTable, $data, "id=" . $record['Id']); } else { // insert a record with the order $data = array('user_id' => $myUserId, 'widget' => $widgetName, 'view' => $currentView, 'column' => $m, 'ordering' => $ordering); $db->insert($userWidgetTable, $data); } $n++; } $m++; } }
/** * Set user preference * * @param <type> $preference */ public function setPreference($attribute, $value = null) { $this->m_Preference[$attribute] = $value; BizSystem::sessionContext()->setVar("_USER_PREFERENCE", $this->m_Preference); //update user preference to DB $do = BizSystem::getObject($this->m_PreferenceObj); if (!$do) { return false; } $user_id = BizSystem::getUserProfile("Id"); $prefRec = $do->fetchOne("[user_id]='{$user_id}' AND [name]='{$attribute}'"); $prefRec['value'] = (string) $value; return $prefRec->save(); }
public function processUserInit() { $prefService = BizSystem::getService(PREFERENCE_SERVICE); $userId = BizSystem::getUserProfile("Id"); $currentView = $this->getViewObject()->m_Name; if ($currentView != 'myaccount.view.ResetPasswordView' && !isset($_GET['force']) && (int) $prefService->getPreference("force_change_passwd") == 1) { BizSystem::clientProxy()->redirectPage(APP_INDEX . '/myaccount/reset_password/force'); return true; } if ($currentView != 'myaccount.view.MyProfileView' && !isset($_GET['force']) && (int) $prefService->getPreference("force_complete_profile") == 1) { BizSystem::clientProxy()->redirectPage(APP_INDEX . '/myaccount/my_profile/force'); return true; } return false; }
public static function allowAccess($res_action) { if (!aclService::$_accessMatrix) { // get the access matrix from session aclService::$_accessMatrix = BizSystem::sessionContext()->getVar("_ACCESS_MATRIX"); if (!aclService::$_accessMatrix || count(aclService::$_accessMatrix) == 0) { // get user profile $profile = BizSystem::getUserProfile(); if (!$profile) { return false; } // user not login // get the user role id $roleIds = $profile['roles']; if (!$roleIds) { $roleIds[0] = 0; } // guest $roleId_query = implode(",", $roleIds); // generate the access matrix /* @var $do BizDataObj */ $do = BizSystem::getObject(aclService::$role_actionDataObj); $rs = $do->directFetch("[role_id] in ({$roleId_query})"); if (count($rs) == 0) { return false; } aclService::$_accessMatrix = aclService::_generateAccessMatrix($rs); BizSystem::sessionContext()->setVar("_ACCESS_MATRIX", aclService::$_accessMatrix); } $accessLevel = self::$_defaultAccess; // default is deny } if (isset(aclService::$_accessMatrix[$res_action])) { $accessLevel = aclService::$_accessMatrix[$res_action]; } switch ($accessLevel) { case DENY: // if access level is DENY, return false return false; case ALLOW: // if access level is ALLOW or empty, return true return true; case ALLOW_OWNER: // if access level is ALLOW_OWNER, check the OwnerField and OwnerValue. // if ownerField's value == ownerValue, return true. return true; } }
protected function getSelectFrom() { $formobj = $this->getFormObj(); if (!BizSystem::allowUserAccess("data_assign.assign_to_other")) { $groups = BizSystem::getUserProfile("groups"); if ($groups) { $ids = implode(",", $groups); $selectFrom = $this->m_SelectFrom . ",[Id] IN ({$ids})"; } else { $selectFrom = $this->m_SelectFrom; } } else { $selectFrom = $this->m_SelectFrom; } return Expression::evaluateExpression($selectFrom, $formobj); }
protected function addWidget($widgetName) { // add widget to user_widget table $userWidgetDo = BizSystem::getObject($this->userWidgetDOName); $userWidgetTable = $userWidgetDo->m_MainTable; $db = $userWidgetDo->getDbConnection(); $myProfile = BizSystem::getUserProfile(); $myUserId = $myProfile['Id']; $currentView = BizSystem::instance()->getCurrentViewName(); $searchRule = "[user_id]={$myUserId} and [widget]='{$widgetName}' and [view]='{$currentView}'"; $record = $userWidgetDo->fetchOne($searchRule); if ($record) { BizSystem::clientProxy()->showClientAlert("The widget {$widgetName} is already on the page."); } else { $data = array('user_id' => $myUserId, 'widget' => $widgetName, 'view' => $currentView, 'ordering' => 0); $db->insert($userWidgetTable, $data); } }
/** * Audit DataObj * * @param string $dataObjName * @return boolean * @todo all return false? really? */ public function audit($dataObjName) { // get audit dataobj $auditDataObj = BizSystem::getObject($this->m_AuditDataObj); if (!$auditDataObj) { return false; } // get the source dataobj $srcDataObj = BizSystem::getObject($dataObjName); if (!$srcDataObj) { return false; } // for each onaudit field, add a record in audit dataobj $auditFields = $srcDataObj->getOnAuditFields(); foreach ($auditFields as $field) { if ($field->m_OldValue == $field->m_Value) { continue; } $recArr = $auditDataObj->newRecord(); if ($recArr == false) { BizSystem::log(LOG_ERR, "DATAOBJ", $auditDataObj->getErrorMessage()); return false; } $profile = BizSystem::getUserProfile(); $recArr['DataObjName'] = $dataObjName; $recArr['ObjectId'] = $srcDataObj->getFieldValue("Id"); $recArr['FieldName'] = $field->m_Name; $recArr['OldValue'] = $field->m_OldValue; $recArr['NewValue'] = $field->m_Value; $recArr['ChangeTime'] = date("Y-m-d H:i:s"); $recArr['ChangeBy'] = $profile["USERID"]; $recArr['ChangeFrom'] = $_SERVER['REMOTE_ADDR']; $recArr['RequestURI'] = $_SERVER['REQUEST_URI']; $recArr['Timestamp'] = date("Y-m-d H:i:s"); $ok = $auditDataObj->insertRecord($recArr); if ($ok == false) { BizSystem::log(LOG_ERR, "DATAOBJ", $auditDataObj->getErrorMessage()); return false; } } }
public function getSearchRule() { $value = BizSystem::clientProxy()->getFormInputs($this->m_Name); $searchRule = ""; $my_user_id = BizSystem::getUserProfile("Id"); $user_groups = BizSystem::GetUserProfile('groups'); if (count($user_groups)) { $group_id_range = implode(",", $user_groups); $group_where = " ( [group_id] IN ({$group_id_range} ) )"; } if (count($user_groups)) { $group_id_range = implode(",", $user_groups); $other_where = " ( [group_id] NOT IN ({$group_id_range} ) )"; } switch ((int) $value) { case 1: if ($this->hasOwnerField()) { $searchRule = "([create_by]= '{$my_user_id}' OR [owner_id]='{$my_user_id}')"; } else { $searchRule = "([create_by]= '{$my_user_id}')"; } break; case 2: $searchRule = "({$group_where} and [create_by]!= '{$my_user_id}')"; break; case 3: $searchRule = "({$other_where} and [create_by] != '{$my_user_id}' )"; break; case 4: $searchRule = "([create_by]= '{$my_user_id}')"; break; case 5: $searchRule = "([create_by] != '{$my_user_id}' AND [owner_id] = '{$my_user_id}' )"; break; case 6: $searchRule = "([create_by] = '{$my_user_id}' AND [owner_id] != '{$my_user_id}' )"; break; } return $searchRule; }
protected function allowDisplay($user_id) { if (BizSystem::allowUserAccess("data_manage.manage")) { return true; } //get user acl info $actionRec = BizSystem::getObject("system.do.AclActionDO")->fetchOne("[module]='common' AND [resource]='data_assign' AND [action]='accept_other_assigned'"); $actionId = $actionRec['Id']; if (!$actionId) { //the system doesnt support accept_other_assigned feature then return true; return true; } //get list of all roles which enabled this action $roleList = BizSystem::getObject("system.do.AclRoleActionDO")->directFetch("[action_id]='{$actionId}' AND ([access_level]='1' OR [access_level]='2')"); foreach ($roleList as $roleRec) { $roleId = $roleRec['role_id']; //check if target user has this role $AssocRecs = BizSystem::getObject("system.do.UserRoleDO")->directFetch("[role_id]='{$roleId}' AND [user_id]='{$user_id}'"); if ($AssocRecs->count()) { return true; } } //if we are in same group return true //get user groups info $user_id = (int) $user_id; $groups = BizSystem::getUserProfile("groups"); $groupset = BizSystem::getObject("system.do.UserGroupDO")->directFetch("[user_id]='{$user_id}'"); foreach ($groupset as $groupRec) { $user_group_id = $groupRec['group_id']; foreach ($groups as $group_id) { if ($group_id == $user_group_id) { return true; } } } return false; }
/** * Get path based on config options * * @global BizSystem $g_BizSystem * @param string $fileName * @return string log_path - The path where a log entry should be written */ private function _getPath($fileName = null) { if ($fileName) { return LOG_PATH . '/' . $fileName . $this->_extension; } switch ($this->_org) { case 'DATE': return LOG_PATH . '/' . date("Y_d_m") . $this->_extension; break; case 'LEVEL': switch ($this->_level) { case 0: $level = 'EMERG'; break; case 1: $level = 'ALERT'; break; case 2: $level = 'CRIT'; break; case 3: $level = 'ERR'; break; case 4: $level = 'WARN'; break; case 5: $level = 'NOTICE'; break; case 6: $level = 'INFO'; break; case 7: $level = 'DEBUG'; break; default: break; } return LOG_PATH . '/' . $level . $this->_extension; break; case 'PROFILE': $profile = BizSystem::getUserProfile('USERID'); if (!$profile) { $profile = 'Guest'; } return LOG_PATH . '/' . $profile . $this->_extension; break; default: break; } }
public function SendEmailToUser($template_name, $recipient_user_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(BizSystem::getUserProfile("Id")); $data['refer_url'] = SITE_URL; $tplFile = BizSystem::getTplFileWithPath($template, "email"); $content = $this->renderEmail($data, $tplFile); //prepare recipient info $userObj = BizSystem::getObject("system.do.UserDO"); $userData = $userObj->directFetch("[Id]='" . $recipient_user_id . "'", 1); if (!count($data)) { return false; } $userData = $userData[0]; $recipient['email'] = $userData['email']; $recipient['name'] = $userData['username']; //send it to the queue $result = $this->sendEmail($sender, $recipient, $subject, $content); return $result; }
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(); }
/** * Get user profile array. Profile is provided by profileService * * @return array profile array */ private function _getUserProfile() { return BizSystem::getUserProfile(); }
$module_name = $urlArr[0]; $view_name = getViewName($urlArr[1]); } elseif (preg_match("/^[a-z_]*\$/si", $urlArr[0])) { // http://localhost/?/FormName/ $module_name = $DEFAULT_MODULE; $view_name = getViewName($urlArr[0]); } if (empty($urlArr[count($urlArr) - 1])) { unset($urlArr[count($urlArr) - 1]); } } } else { // http://localhost/ $module_name = $DEFAULT_MODULE; $view_name = $DEFAULT_VIEW; $profile = BizSystem::getUserProfile(); if ($profile['roleStartpage'][0]) { $DEFAULT_URL = APP_INDEX . $profile['roleStartpage'][0]; } header("Location: {$DEFAULT_URL}"); } $TARGET_VIEW = $module_name . ".view." . $view_name; $_GET['view'] = $_REQUEST['view'] = $TARGET_VIEW; $PARAM_MAPPING = getParameters($urlArr); if (isset($PARAM_MAPPING)) { foreach ($PARAM_MAPPING as $param => $value) { //if (isset($_GET[$param])) $_GET[$param] = $_REQUEST[$param] = $value; } } include dirname(__FILE__) . '/controller.php';
/** * Render single menu item * * @param array $menuItem menu item metadata xml array * @return string html content of each menu item */ protected function renderSingleMenuItem(&$menuItem) { $profile = BizSystem::getUserProfile(); $svcobj = BizSystem::getService(ACCESS_SERVICE); $role = isset($profile["ROLE"]) ? $profile["ROLE"] : null; if (array_key_exists('URL', $menuItem["ATTRIBUTES"])) { $url = $menuItem["ATTRIBUTES"]["URL"]; } elseif (array_key_exists('VIEW', $menuItem["ATTRIBUTES"])) { $view = $menuItem["ATTRIBUTES"]["VIEW"]; // menuitem's containing VIEW attribute is renderd if access is granted in accessservice.xml // menuitem's are rendered if no definition is found in accessservice.xml (default) if ($svcobj->allowViewAccess($view, $role)) { $url = "javascript:GoToView('" . $view . "')"; } else { return ''; } } $caption = I18n::getInstance()->translate($menuItem["ATTRIBUTES"]["CAPTION"]); $target = $menuItem["ATTRIBUTES"]["TARGET"]; $icon = $menuItem["ATTRIBUTES"]["ICON"]; $img = $icon ? "<img src='" . Resource::getImageUrl() . "/{$icon}' class=menu_img> " : ""; if ($view) { $url = "javascript:GoToView('" . $view . "')"; } if ($target) { $sHTML .= "<li><a href=\"" . $url . "\" target='{$target}'>{$img}" . $caption . "</a>"; } else { $sHTML .= "<li><a href=\"" . $url . "\">{$img}" . $caption . "</a>"; } if ($menuItem["MENUITEM"]) { $sHTML .= "\n<ul>\n"; $sHTML .= $this->renderMenuItems($menuItem["MENUITEM"]); $sHTML .= "</ul>"; } $sHTML .= "</li>\n"; return $sHTML; }
/** * Get path based on config options * * @global BizSystem $g_BizSystem * @param string $fileName * @return string log_path - The path where a log entry should be written */ private function _getPath($fileName = null) { $level = $this->_level; if ($fileName) { return LOG_PATH . '/' . $fileName . $this->_extension; } switch ($this->_org) { case 'DATE': return LOG_PATH . '/' . date("Y_m_d") . $this->_extension; break; case 'LEVEL': $level = $this->_level2filename($level); return LOG_PATH . '/' . $level . $this->_extension; break; case 'LEVEL-DATE': $level = $this->_level2filename($level); //delete old log files if ($this->_daystolive > 0) { if (is_array(glob(LOG_PATH . '/' . $level . '-*' . $this->_extension))) { foreach (glob(LOG_PATH . '/' . $level . '-*' . $this->_extension) as $filename) { $mtime = filemtime($filename); if (time() - $mtime >= $this->_daystolive * 86400) { @unlink($filename); } } } } return LOG_PATH . '/' . $level . '-' . date("Y_m_d") . $this->_extension; break; case 'PROFILE': $profile = BizSystem::getUserProfile('USERID'); if (!$profile) { $profile = 'Guest'; } return LOG_PATH . '/' . $profile . $this->_extension; break; default: break; } }
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(); }
/** * Replace var expression * @objname:property, @objname:field[fldname].property, @objname:control[ctrlname].property * @:prop = @thisobjname:prop * * @global BizSystem $g_BizSystem * @param string $expression * @param object $object * @return string */ protected static function replaceVarExpr($expression, $object) { /* @var $g_BizSystem BizSystem */ // replace @objname:property to GetObject()->getProperty(property) while (true) { // TODO: one clause must be separated by whitespace //modified by jixian for support package full name of a object //e.g : shared.objects.compaines.objCompany:Field[Id].Value $pattern = "/@([[a-zA-Z0-9_\\.]*):([a-zA-Z0-9_\\.\\[\\]]+)/"; if (!preg_match($pattern, $expression, $matches)) { break; } $macro = $matches[0]; $objName = $matches[1]; $propExpr = $matches[2]; $obj = null; if ($objName == "profile") { // @profile:attribute is reserved $profileAttribute = BizSystem::getUserProfile($propExpr); $expression = str_replace($macro, $profileAttribute, $expression); continue; } if ($objName == "home") { // @home:url is reserved switch ($propExpr) { case "url": $value = "'" . APP_INDEX . "'"; break; case "base_url": $value = "'" . APP_URL . "'"; break; } $expression = str_replace($macro, $value, $expression); continue; } elseif (in_array($objName, array_keys(Expression::$services))) { // reserved keywords $body = $expression; $objFunc = '@' . $objName . ':' . $propExpr; $posStart = strpos($body, $objFunc); $beforeString = substr($body, 0, $posStart); $paramStart = strpos($body, $objFunc . '(') + strlen($objFunc . '('); $paramEnd = strpos($body, ')', $paramStart); $paramLen = $paramEnd - $paramStart; $function = $propExpr; $paramString = substr($body, $paramStart, $paramLen); $restString = substr($body, $paramEnd + 1); $paramString = Expression::evaluateExpression('{' . $paramString . '}', $object); $serviceName = Expression::$services[$objName]; $serviceObj = BizSystem::getService($serviceName); $params = explode(',', $paramString); for ($i = 0; $i < count($params); $i++) { $params[$i] = trim($params[$i]); } $val_result = call_user_func_array(array($serviceObj, $function), $params); return $beforeString . $val_result . $restString; } elseif ($objName == "" || $objName == "this") { $obj = $object; } else { $obj = BizSystem::getObject($objName); } if ($obj == null) { throw new Exception("Wrong expression syntax " . $expression . ", cannot get object " . $objName); } $pos = strpos($propExpr, "."); if ($pos > 0) { // in case of @objname:field[fldname].property $property1 = substr($propExpr, 0, $pos); $property2 = substr($propExpr, $pos + 1); $propertyObj = $obj->getProperty($property1); if ($propertyObj == null) { $propertyObj = $obj->getDataObj()->getProperty($property1); if ($propertyObj == null) { throw new Exception("Wrong expression syntax " . $expression . ", cannot get property object " . $property1 . " of object " . $objName); } else { $val = $propertyObj->getProperty($property2); } } $val = $propertyObj->getProperty($property2); } else { // in case of @objname:property $val = $obj->getProperty($propExpr); } if ($val === null) { $val = ""; } if (is_string($val)) { $val = "'{$val}'"; } $expression = str_replace($macro, $val, $expression); } return $expression; }