public function insertRecord() { $recArr = $this->readInputRecord(); $this->setActiveRecord($recArr); if (count($recArr) == 0) { return; } //generate fast_index $svcobj = BizSystem::getService("service.chineseService"); if ($svcobj->isChinese($recArr['first_name'])) { $fast_index = $svcobj->Chinese2Pinyin($recArr['first_name']); } else { $fast_index = $recArr['first_name']; } $recArr['fast_index'] = substr($fast_index, 0, 1); try { $this->ValidateForm(); } catch (ValidationException $e) { $this->processFormObjError($e->m_Errors); return; } $this->_doInsert($recArr); // in case of popup form, close it, then rerender the parent form if ($this->m_ParentFormName) { $this->close(); $this->renderParent(); } $this->processPostAction(); }
protected function _remoteCall($method, $params = null) { $uri = $this->m_ReportServer; $cache_id = md5($this->m_Name . $uri . $method . serialize($params)); $cacheSvc = BizSystem::getService(CACHE_SERVICE, 1); $cacheSvc->init($this->m_Name, $this->m_CacheLifeTime); if (substr($uri, strlen($uri) - 1, 1) != '/') { $uri .= '/'; } $uri .= "ws.php/udc/CollectService"; if ($cacheSvc->test($cache_id) && (int) $this->m_CacheLifeTime > 0) { $resultSetArray = $cacheSvc->load($cache_id); } else { try { $argsJson = urlencode(json_encode($params)); $query = array("method={$method}", "format=json", "argsJson={$argsJson}"); $httpClient = new HttpClient('POST'); foreach ($query as $q) { $httpClient->addQuery($q); } $headerList = array(); $out = $httpClient->fetchContents($uri, $headerList); $cats = json_decode($out, true); $resultSetArray = $cats['data']; $cacheSvc->save($resultSetArray, $cache_id); } catch (Exception $e) { $resultSetArray = array(); } } return $resultSetArray; }
public function ExportCSV() { $eventlogSvc = BizSystem::getService(EVENTLOG_SERVICE); $eventlogSvc->ExportCSV(); $this->runEventLog(); return true; }
/** * Reset the password * * @return void */ public function resetPassword() { global $g_BizSystem; $recArr = $this->readInputs(); $this->setActiveRecord($recArr); if (count($recArr) == 0) { return; } try { $this->ValidateForm(); if ($this->ValidateEmail($recArr['username'], $recArr['email'])) { //Init user profile for event logging $profile = $g_BizSystem->InituserProfile($recArr['username']); } else { return; } //generate pass_token $token = $this->GenerateToken($profile); if ($token) { //event log $eventlog = BizSystem::getService(EVENTLOG_SERIVCE); $logComment = array($username, $_SERVER['REMOTE_ADDR']); $eventlog->log("USER_MANAGEMENT", "MSG_GET_PASSWORD_TOKEN", $logComment); //send user email $emailObj = BizSystem::getService(USER_EMAIL_SERIVCE); $emailObj->UserResetPassword($token['Id']); BizSystem::SessionContext()->destroy(); //goto URL $this->processPostAction(); } } catch (ValidationException $e) { $this->processFormObjError($e->m_Errors); return; } }
public function resetPassword() { $currentRec = $this->fetchData(); $recArr = $this->readInputRecord(); $this->setActiveRecord($recArr); try { $this->ValidateForm(); } catch (ValidationException $e) { $this->processFormObjError($e->m_Errors); return; } if (count($recArr) == 0) { return; } $this->_doUpdate($recArr, $currentRec); $this->rerender(); // if 'notify email' option is checked, send confirmation email to user email address // ... // init profile global $g_BizSystem; $profile = $g_BizSystem->InitUserProfile($currentRec['username']); //run eventlog $eventlog = BizSystem::getService(EVENTLOG_SERIVCE); $logComment = array($currentRec['username']); $eventlog->log("USER_MANAGEMENT", "MSG_RESET_PASSWORD_BY_TOKEN", $logComment); $this->m_Notices[] = $this->GetMessage("USER_DATA_UPDATED"); $this->processPostAction(); }
protected function _doCreateUser() { $recArr = $this->readInputRecord(); $this->setActiveRecord($recArr); if (count($recArr) == 0) { return; } if ($this->_checkDupUsername()) { $errorMessage = $this->GetMessage("USERNAME_USED"); $errors['fld_username'] = $errorMessage; $this->processFormObjError($errors); return; } if ($this->_checkDupEmail()) { $errorMessage = $this->GetMessage("EMAIL_USED"); $errors['fld_email'] = $errorMessage; $this->processFormObjError($errors); return; } try { $this->ValidateForm(); } catch (ValidationException $e) { $this->processFormObjError($e->m_Errors); return; } $recArr['create_by'] = "0"; $recArr['update_by'] = "0"; $password = BizSystem::ClientProxy()->GetFormInputs("fld_password"); $recArr['password'] = hash(HASH_ALG, $password); $this->_doInsert($recArr); //set default user role to member $userinfo = $this->getActiveRecord(); $userRoleObj = BizSystem::getObject('system.do.UserRoleDO'); foreach (BizSystem::getObject('system.do.RoleDO')->directfetch("[default]='1'") as $roleRec) { $roleId = $roleRec['Id']; $uesrRoleArr = array("user_id" => $userinfo['Id'], "role_id" => $roleId); $userRoleObj->insertRecord($uesrRoleArr); } //set default group to member $userGroupObj = BizSystem::getObject('system.do.UserGroupDO'); foreach (BizSystem::getObject('system.do.GroupDO')->directfetch("[default]='1'") as $groupRec) { $groupId = $groupRec['Id']; $uesrGroupArr = array("user_id" => $userinfo['Id'], "group_id" => $groupId); $userGroupObj->insertRecord($uesrGroupArr); } //record event log global $g_BizSystem; $eventlog = BizSystem::getService(EVENTLOG_SERVICE); $logComment = array($userinfo['username'], $_SERVER['REMOTE_ADDR']); $eventlog->log("USER_MANAGEMENT", "MSG_USER_REGISTERED", $logComment); //send user email $emailObj = BizSystem::getService(USER_EMAIL_SERVICE); $emailObj->UserWelcomeEmail($userinfo['Id']); //init profile for future use like redirect to my account view $profile = $g_BizSystem->InituserProfile($userinfo['username']); return $userinfo; }
public function Report() { //send an email to admin includes error messages; $system_uuid = BizSystem::getService("system.lib.CubiService")->getSystemUUID(); $report = array("system_uuid" => $system_uuid, "error_info" => $this->m_Errors["system"], "server_info" => $_SERVER, "php_version" => phpversion(), "php_extension" => get_loaded_extensions()); $reportId = BizSystem::getObject("common.lib.ErrorReportService")->report($report); $this->m_Notices = array("status" => "REPORTED", "report_id" => $reportId); $this->ReRender(); }
public function Report() { //send an email to admin includes error messages; $recipient['email'] = $this->m_AdminEmail; $recipient['name'] = $this->m_AdminName; $emailObj = BizSystem::getService(USER_EMAIL_SERIVCE); $emailObj->SystemInternalErrorEmail($recipient, $this->m_Errors["system"]); $this->m_Notices = array("status" => "REPORTED"); $this->ReRender(); }
/** * Create a user record * * @return void */ public function CreateUser() { if ($cfg_siremis_public_registrations == false) { $errorMessage = "Public registration is not enabled!"; $errors['fld_username'] = $errorMessage; $this->processFormObjError($errors); return; } $recArr = $this->readInputRecord(); $this->setActiveRecord($recArr); if (count($recArr) == 0) { return; } if ($this->_checkDupUsername()) { $errorMessage = $this->GetMessage("USERNAME_USED"); $errors['fld_username'] = $errorMessage; $this->processFormObjError($errors); return; } if ($this->_checkDupEmail()) { $errorMessage = $this->GetMessage("EMAIL_USED"); $errors['fld_email'] = $errorMessage; $this->processFormObjError($errors); return; } try { $this->ValidateForm(); } catch (ValidationException $e) { $this->processFormObjError($e->m_Errors); return; } $recArr['create_by'] = "0"; $recArr['update_by'] = "0"; $this->_doInsert($recArr); //set default user role to sip user $userinfo = $this->getActiveRecord(); $userRoleObj = BizSystem::getObject('system.do.UserRoleDO'); $uesrRoloArr = array("user_id" => $userinfo['Id'], "role_id" => "3"); $userRoleObj->insertRecord($uesrRoloArr); //record event log global $g_BizSystem; $eventlog = BizSystem::getService(EVENTLOG_SERIVCE); $logComment = array($userinfo['username'], $_SERVER['REMOTE_ADDR']); $eventlog->log("USER_MANAGEMENT", "MSG_USER_REGISTERED", $logComment); //send user email //$emailObj = BizSystem::getService(USER_EMAIL_SERIVCE); //$emailObj->UserWelcomeEmail($userinfo['Id']); //init profile for future use like redirect to my account view $profile = $g_BizSystem->InituserProfile($userinfo['username']); $serUserObj = BizSystem::getObject('ser.sbs.authdb.do.SubscriberDO'); $serUserArr = array("username" => $recArr['username'], "domain" => $recArr['domain'], "password" => $recArr['password'], "email_address" => $recArr['email']); $serUserObj->InsertRecord($serUserArr); $this->processPostAction(); }
/** * login action * * @return void */ public function Login() { $recArr = $this->readInputRecord(); try { $this->ValidateForm(); } catch (ValidationException $e) { $this->processFormObjError($e->m_Errors); return; } // get the username and password $this->username = BizSystem::ClientProxy()->getFormInputs("username"); $this->password = BizSystem::ClientProxy()->getFormInputs("password"); global $g_BizSystem; $svcobj = BizSystem::getService(AUTH_SERVICE); $eventlog = BizSystem::getService(EVENTLOG_SERIVCE); try { if ($svcobj->authenticateUser($this->username, $this->password)) { // after authenticate user: 1. init profile $profile = $g_BizSystem->InitUserProfile($this->username); // after authenticate user: 2. insert login event $logComment = array($this->username, $_SERVER['REMOTE_ADDR']); $eventlog->log("LOGIN", "MSG_LOGIN_SUCCESSFUL", $logComment); // after authenticate user: 3. update login time in user record if (!$this->UpdateloginTime()) { return false; } $redirectPage = APP_INDEX . $profile['roleStartpage'][0]; $cookies = BizSystem::ClientProxy()->getFormInputs("session_timeout"); if ($cookies) { $password = $this->password; $password = md5(md5($password . $this->username) . md5($profile['create_time'])); setcookie("SYSTEM_SESSION_USERNAME", $this->username, time() + (int) $cookies, "/"); setcookie("SYSTEM_SESSION_PASSWORD", $password, time() + (int) $cookies, "/"); } if ($profile['roleStartpage'][0]) { BizSystem::clientProxy()->ReDirectPage($redirectPage); } else { parent::processPostAction(); } return true; } else { $logComment = array($this->username, $_SERVER['REMOTE_ADDR'], $this->password); $eventlog->log("LOGIN", "MSG_LOGIN_FAILED", $logComment); $errorMessage['password'] = $this->getMessage("PASSWORD_INCORRECT"); $errorMessage['login_status'] = $this->getMessage("LOGIN_FAILED"); $this->processFormObjError($errorMessage); } } catch (Exception $e) { BizSystem::ClientProxy()->showErrorMessage($e->getMessage()); } }
protected function getProfileByCookie() { if (isset($_COOKIE["SYSTEM_SESSION_USERNAME"]) && isset($_COOKIE["SYSTEM_SESSION_PASSWORD"])) { $username = $_COOKIE["SYSTEM_SESSION_USERNAME"]; $password = $_COOKIE["SYSTEM_SESSION_PASSWORD"]; $svcobj = BizSystem::getService(AUTH_SERVICE); if ($svcobj->authenticateUserByCookies($username, $password)) { $this->InitProfile($username); } else { setcookie("SYSTEM_SESSION_USERNAME", null, time() - 100, "/"); setcookie("SYSTEM_SESSION_PASSWORD", null, time() - 100, "/"); } } return null; }
public function SwitchSession() { if (!BizSystem::allowUserAccess('Session.Switch_Session')) { if (!BizSystem::sessionContext()->getVar("_PREV_USER_PROFILE")) { return; } } $data = $this->readInputRecord(); $username = $data['username']; if (!$username) { return; } $serviceObj = BizSystem::getService(PROFILE_SERVICE); if (method_exists($serviceObj, 'SwitchUserProfile')) { $serviceObj->SwitchUserProfile($username); } BizSystem::clientProxy()->runClientScript("<script>window.location.reload();</script>"); }
public function getSearchRule() { $value = BizSystem::clientProxy()->getFormInputs($this->m_Name); $value = addslashes($value); //escape sql strings if ($value != '') { $searchStr = " [{$this->m_FieldName}] LIKE '%{$value}%' "; } else { return ""; } if ($this->m_SearchFields) { $fields = $lovService = BizSystem::getService(LOV_SERVICE)->getList($this->m_SearchFields); foreach ($fields as $opt) { $field = $opt['val']; $searchStr .= " OR [{$field}] LIKE '%{$value}%' "; } } $searchStr = "( {$searchStr} )"; return $searchStr; }
public function login() { $username = $_GET['username']; $password = $_GET['password']; $svcobj = BizSystem::getService(AUTH_SERVICE); if ($svcobj->authenticateUser($username, $password)) { // after authenticate user: 1. init profile $profile = BizSystem::instance()->InitUserProfile($username); // after authenticate user: 2. insert login event $eventlog = BizSystem::getService(EVENTLOG_SERVICE); $logComment = array($username, $_SERVER['REMOTE_ADDR']); $eventlog->log("LOGIN", "MSG_LOGIN_SUCCESSFUL", $logComment); // after authenticate user: 3. update login time in user record $userObj = BizSystem::getObject('system.do.UserDO'); $userRec = $userObj->fetchOne("[username]='{$username}'"); $userRec['lastlogin'] = date("Y-m-d H:i:s"); $userId = $userRec['Id']; $userRec->save(); } $result = array("user_id" => $userId); return $result; }
/** * Render single menu item * @param array $menuItem menu item metadata xml array * @return string html content of each menu item */ protected function renderSingleMenuItem(&$menuItem) { global $g_BizSystem; $profile = $g_BizSystem->getUserProfile(); $svcobj = BizSystem::getService("accessService"); $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; }
public function render() { if (!$this->allowAccess()) { return ""; } if ($this->m_CacheLifeTime > 0) { $cache_id = md5($this->m_Name); //try to process cache service. $cacheSvc = BizSystem::getService(CACHE_SERVICE, 1); $cacheSvc->init($this->m_Name, $this->m_CacheLifeTime); if ($cacheSvc->test($cache_id)) { BizSystem::log(LOG_DEBUG, "MENU", "Cache Hit. menu widget name = " . $this->m_Name); $output = $cacheSvc->load($cache_id); } else { BizSystem::log(LOG_DEBUG, "MENU", "Set cache. menu widget = " . $this->m_Name); $output = $this->renderHTML(); $cacheSvc->save($output, $cache_id); } return $output; } $renderedHTML = $this->renderHTML(); return $renderedHTML; }
/** * Get the number of records according the Select SQL * * @param object $db database connection * @param string $sql SQL string * @return int number of records */ private function _getNumberRecords($db, $sql) { $has_subquery = false; if (preg_match("/\\(\\s*?SELECT\\s*?.+\\)/si", $sql)) { $has_subquery = true; } if (preg_match("/^\\s*SELECT\\s+DISTINCT/is", $sql) || preg_match('/\\s+GROUP\\s+BY\\s+/is', $sql)) { // ok, has SELECT DISTINCT or GROUP BY so see if we can use a table alias $rewritesql = preg_replace('/(\\sORDER\\s+BY\\s.*)/is', '', $sql); $rewritesql = "SELECT COUNT(*) FROM ({$rewritesql}) _TABLE_ALIAS_"; } elseif ($has_subquery == false) { // now replace SELECT ... FROM with SELECT COUNT(*) FROM $rewritesql = preg_replace('/\\s*?SELECT\\s.*?\\s+FROM\\s/is', 'SELECT COUNT(*) FROM ', $sql); // Because count(*) and 'order by' fails with mssql, access and postgresql. // Also a good speedup optimization - skips sorting! $rewritesql = preg_replace('/(\\sORDER\\s+BY\\s.*)/is', '', $rewritesql); } else { $rewritesql = $sql; } try { if ($this->m_CacheLifeTime > 0) { $cache_id = md5($this->m_Name . $rewritesql . serialize($bindValues)); //try to process cache service. $cacheSvc = BizSystem::getService(CACHE_SERVICE); $cacheSvc->init($this->m_Name, $this->m_CacheLifeTime); if ($cacheSvc->test($cache_id)) { //BizSystem::log(LOG_DEBUG, "DATAOBJ", ". Query Sql = ".$rewritesql); $resultArray = $cacheSvc->load($cache_id); } else { BizSystem::log(LOG_DEBUG, "DATAOBJ", "Query Sql = " . $rewritesql); $result = $db->query($rewritesql); $resultArray = $result->fetch(); $cacheSvc->save($resultArray, $cache_id); } } else { BizSystem::log(LOG_DEBUG, "DATAOBJ", "Query Sql = " . $rewritesql); $resultSet = $db->query($rewritesql); $resultArray = $resultSet->fetch(); } } catch (Exception $e) { BizSystem::log(LOG_ERR, "DATAOBJ", "Query Error: " . $e->getMessage()); $this->m_ErrorMessage = $this->getMessage("DATA_ERROR_QUERY") . ": Rewrite:" . $rewritesql . ". Raw:" . $sql . ". " . $e->getMessage(); throw new BDOException($this->m_ErrorMessage); return 0; } if ($has_subquery) { $record_count = (int) $resultSet->rowCount(); } else { $record_count = (int) $resultArray[0]; } return (string) $record_count; }
public function sendEmailNow($email_id) { //prepare email data $dataObj = BizSystem::getObject($this->m_EmailDataObj); $dataObj->setSearchRule("[Id]='" . $email_id . "' and [status]!='sending' ", true); $data = $dataObj->fetch(); $dataObj->setActiveRecord($data[0]); if (!count($data)) { return false; } $data = $data[0]; $sender = $data["sender"]; $recipient = array(array("email" => $data["recipient"], "name" => $data["recipient_name"])); $subject = $data["subject"]; $content = $data["content"]; //update queue status to sending $recArr = array("status" => "sending"); $dataObj->updateRecord($recArr); //init email service $emailObj = BizSystem::getService(EMAIL_SERVICE); $emailObj->useAccount($sender); $emailObj->sendEmail($recipient, null, null, $subject, $content, null, true); //update queue status to sent $recArr = array("status" => "sent"); $dataObj->updateRecord($recArr); return; }
private function _casacadeUpdate($obj, $setting) { $dataShareSvc = BizSystem::getService(DATAPERM_SERVICE); foreach ($obj->m_ObjReferences as $doRef) { $do = BizSystem::getObject($doRef->m_Name); $rs = $do->fetch(); foreach ($rs as $rec) { if ($dataShareSvc->checkDataOwner($rec)) { $newRec = $rec; $newRec['group_perm'] = $setting['group_perm']; $newRec['other_perm'] = $setting['other_perm']; $newRec['group_id'] = $setting['group_id']; if ($rec['owner_id']) { $newRec['owner_id'] = $setting['owner_id']; } $ok = $do->updateRecord($newRec, $rec); } } if ($do->m_ObjReferences->count()) { //$this->_casacadeUpdate($do, $setting); } } }
/** * Render the html tabs * @return string html content of the tabs */ public function render() { global $g_BizSystem; $curView = $g_BizSystem->getCurrentViewName(); $curViewobj = $curView ? BizSystem::getObject($curView) : null; $profile = $g_BizSystem->getUserProfile(); $svcobj = BizSystem::getService("accessService"); $role = isset($profile["ROLE"]) ? $profile["ROLE"] : null; // list all views and highlight the current view // pass $tabs(caption, url, target, icon, current) to template $smarty = BizSystem::getSmartyTemplate(); $tabs = array(); $i = 0; foreach ($this->m_TabViews as $tview) { // tab is renderd if no definition is found in accessservice.xml (default) if ($svcobj->allowViewAccess($tview->m_View, $role)) { $tabs[$i]['name'] = $tview->m_Name; //Name of each tab--jmmz $tabs[$i]['forms'] = $this->_renderJSCodeForForms($tview->m_Forms); //Configuration of the forms to hide or show--jmmz $tabs[$i]['caption'] = $tview->m_Caption; $tabs[$i]['url'] = $this->_renderURL($tview); //Call the method to render the url--jmmz //If I have forms to hide or show I add the event because I don't need an URL, I need an event if ((bool) $tview->hasForms()) { $tabs[$i]['event'] = $tabs[$i]['url']; //Assign The url rendered to the event on click $tabs[$i]['url'] = 'javascript:void(0)'; //If I put url in '' then the href want send me to another direction $this->setCurrentTabInSession($tview, $curViewobj, $curView); //I set the current tab wrote in session $hasForms = TRUE; } $tabs[$i]['target'] = $tview->m_Target; $tabs[$i]['icon'] = $tview->m_Icon; $tabs[$i]['current'] = $this->isCurrentTab($tview, $curViewobj, $curView); //I get the current tab. $i++; } } $this->setClientScripts($tabs, $hasForms); $smarty->assign_by_ref("tabs", $tabs); $smarty->assign_by_ref("tabs_Name", $this->m_Name); return $smarty->fetch(BizSystem::getTplFileWithPath($this->m_TemplateFile, $this->m_Package)); }
/** * Check value type * * @param mixed $value * @return mixed|boolean */ public function checkValueType($value = null) { if (!$value) { $value = $this->m_Value; } $validator = BizSystem::getService(VALIDATE_SERVICE); switch ($this->m_Type) { case "Number": $result = is_numeric($value); break; case "Text": $result = is_string($value); break; case "Date": $result = $validator->date($value); break; /* case "Datetime": // zend doesn't support date time $result = $validator->date($value); break; case "Currency": $result = $validator->date($value); break; */ /* case "Datetime": // zend doesn't support date time $result = $validator->date($value); break; case "Currency": $result = $validator->date($value); break; */ case "Phone": $result = $validator->phone($value); break; default: $result = true; break; } return $result; }
/** * Render this form (return html content), * called by EasyView's render method (called when form is loaded). * Query is issued before returning the html content. * * @return string - HTML text of this form's read mode * @example ../../../example/FormObject.php */ public function render() { if (!$this->allowAccess()) { return ""; } if ($this->m_CacheLifeTime > 0 && $this->m_SubForms == null) { $cache_id = md5($this->m_Name); //try to process cache service. $cacheSvc = BizSystem::getService(CACHE_SERVICE, 1); $cacheSvc->init($this->m_Name, $this->m_CacheLifeTime); if ($cacheSvc->test($cache_id)) { BizSystem::log(LOG_DEBUG, "FORM", "Cache Hit. form name = " . $this->m_Name); $output = $cacheSvc->load($cache_id); } else { BizSystem::log(LOG_DEBUG, "FORM", "Set cache. form name = " . $this->m_Name); $output = $this->renderHTML(); $cacheSvc->save($output, $cache_id); } return $output; } //Moved the renderHTML function infront of declaring subforms $renderedHTML = $this->renderHTML(); // prepare the subforms' dataobjs, since the subform relates to parent form by dataobj association /* if ($this->m_SubForms && $this->getDataObj()) { foreach ($this->m_SubForms as $subForm) { $formObj = BizSystem::objectFactory()->getObject($subForm); $dataObj = $this->getDataObj()->getRefObject($formObj->m_DataObjName); if ($dataObj) $formObj->setDataObj($dataObj); } } */ if (!$this->allowAccess()) { return ""; } return $renderedHTML; }
/** * Invoke service method, this bizform name is passed to the method * * @param string $class * @param string $method * @return mixed - return value of the service method */ public function callService($class, $method) { $serviceObj = BizSystem::getService($class); return $serviceObj->{$method}($this->m_Name); }
/** * Get record array by converting input indexed-Value array to Field-Value pairs * * @param array $sqlArr column value pair array * @return array record array **/ public final function getRecordArr($sqlArr = null) { if ($sqlArr) { $this->_setSqlRecord($sqlArr); } $recArr = array(); foreach ($this->m_var as $key => $field) { if (strtoupper($field->m_Encrypted) == 'Y') { $svcobj = BizSystem::getService(CRYPT_SERVICE); $value = $svcobj->decrypt($field->getValue()); $recArr[$key] = $value; } else { $recArr[$key] = $field->getValue(); } } return $recArr; }
protected function authUser() { $svcobj = BizSystem::getService(AUTH_SERVICE); $result = $svcobj->authenticateUser($this->username, $this->password); return $result; }
/** * Check if the view can be accessed by current user. Call accessService to do the check * * @param string $viewName view name * @return boolean true= allow, false not allow */ private function _checkViewAccess($viewName) { // load accessService $svcobj = BizSystem::getService(ACCESS_SERVICE); return $svcobj->allowViewAccess($viewName); }
public function fetchTreeByName($start_item, $deep) { if ($this->m_CacheLifeTime > 0) { $cache_id = md5($this->m_Name . "-" . $start_item . "-" . $deep); //try to process cache service. $cacheSvc = BizSystem::getService(CACHE_SERVICE, 1); $cacheSvc->init($this->m_Name, $this->m_CacheLifeTime); if ($cacheSvc->test($cache_id)) { BizSystem::log(LOG_DEBUG, "MENU", "Cache Hit. menu fetch tree, name = " . $this->m_Name); $output = $cacheSvc->load($cache_id); } else { BizSystem::log(LOG_DEBUG, "MENU", "Set cache. menu fetch tree, name = " . $this->m_Name); if ($start_item != "") { //$this->fetchEntireTree(); $tree = $this->getTreeByStartItem($start_item); } $output = $this->cutTree($tree, $deep); $cacheSvc->save($output, $cache_id); } $tree = $output; } else { if ($start_item != "") { //$this->fetchEntireTree(); $tree = $this->getTreeByStartItem($start_item); } $tree = $this->cutTree($tree, $deep); } return $tree->m_ChildNodes; }
/** * Log message to log file * * @global BizSystem $g_BizSystem * @param integer $priority. it can be one of following value * LOG_EMERG system is unusable = 1 * LOG_ALERT action must be taken immediately = LOG_EMERG * LOG_CRIT critical conditions = LOG_EMERG * LOG_ERR error conditions = 4 * LOG_WARNING warning conditions = 5 * LOG_NOTICE normal, but significant, condition = 6 * LOG_INFO informational message = LOG_NOTICE * LOG_DEBUG debug-level message = LOG_NOTICE * ### So LOG_EMERG, LOG_ERR, LOG_WARNING and LOG_DEBUG are valid inputs ### * * @param string $subject. the log subject decided by caller function * @param string $message. the message to be logged in log file * @param string $fileName file to save to * @return void */ public static function logError($priority, $subject, $message, $fileName = NULL) { $svcobj = BizSystem::getService(LOG_SERVICE); $svcobj->logError($priority, $subject, $message, $fileName); }
/** * Clean chache * * @global BizSystem $g_BizSystem * @return void */ public function cleanCache() { if ($this->m_CacheLifeTime > 0) { $cacheSvc = BizSystem::getService(CACHE_SERVICE, 1); $cacheSvc->init($this->m_Name, $this->m_CacheLifeTime); $cacheSvc->cleanAll(); } }
/** * Validate input on EasyForm level * default form validation do nothing. * developers need to override this method to implement their logic * * @return boolean */ protected function validateForm($cleanError = true) { if ($cleanError == true) { $this->m_ValidateErrors = array(); } $this->m_DataPanel->rewind(); while ($this->m_DataPanel->valid()) { /* @var $element Element */ $element = $this->m_DataPanel->current(); if ($element->m_Label) { $elementName = $element->m_Label; } else { $elementName = $element->m_Text; } if ($element->checkRequired() === true && ($element->m_Value == null || $element->m_Value == "")) { $errorMessage = $this->getMessage("FORM_ELEMENT_REQUIRED", array($elementName)); $this->m_ValidateErrors[$element->m_Name] = $errorMessage; //return false; } elseif ($element->m_Value !== null && $element->Validate() == false) { $validateService = BizSystem::getService(VALIDATE_SERVICE); $errorMessage = $this->getMessage("FORM_ELEMENT_INVALID_INPUT", array($elementName, $value, $element->m_Validator)); if ($errorMessage == false) { //Couldn't get a clear error message so let's try this $errorMessage = $validateService->getErrorMessage($element->m_Validator, $elementName); } $this->m_ValidateErrors[$element->m_Name] = $errorMessage; //return false; } $this->m_DataPanel->next(); } if (count($this->m_ValidateErrors) > 0) { throw new ValidationException($this->m_ValidateErrors); return false; } return true; }