public function Validate() { $formobj = $this->GetFormObj(); BizSystem::sessionContext()->getObjVar($formobj->m_Name, $this->m_Name, $orgValue); $inputValue = strtoupper($this->getValue()); if ($inputValue == $orgValue) { return true; } else { return false; } }
public function UpdateRecord($recArr, $oldRec = null) { $l_Profile = BizSystem::sessionContext()->getVar("_USER_PROFILE"); if (!$l_Profile) { return false; } $recArr['username'] = $l_Profile['username']; $recArr['ha1'] = md5($recArr['username'] . ':' . $recArr['domain'] . ':' . $recArr['password']); $recArr['ha1b'] = md5($recArr['username'] . '@' . $recArr['domain'] . ':' . $recArr['domain'] . ':' . $recArr['password']); return parent::UpdateRecord($recArr, $oldRec); }
public function setValue($value) { BizSystem::sessionContext()->getObjVar($this->getFormObj()->m_Name, $this->m_Name, $this->m_Value); $valueArr = $_POST[$this->m_Name]; if (is_array($valueArr)) { foreach ($valueArr as $key => $value) { $this->m_Value[$key] = $value; } } BizSystem::sessionContext()->setObjVar($this->getFormObj()->m_Name, $this->m_Name, $this->m_Value); }
/** * 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(); }
/** * Get a metadata based object instance. * It returns the instance the internal object map or create a new one and save it in the map. * * @param string $objName name of object that want to get * @return object */ public function getObject($objName, $new = 0) { if (array_key_exists($objName, $this->_objsRefMap) && $new == 0) { return $this->_objsRefMap[$objName]; } $obj = $this->constructObject($objName); if ($obj) { $this->_objsRefMap[$objName] = $obj; } // save object to cache if (method_exists($obj, "GetSessionVars")) { $obj->getSessionVars(BizSystem::sessionContext()); } return $obj; }
public function getProfile($attr = null) { if (!$this->m_Profile) { $this->m_Profile = BizSystem::sessionContext()->getVar("_USER_PROFILE"); } if (!$this->m_Profile) { $this->getProfileByCookie(); if (!$this->m_Profile) { return null; } } if ($attr && isset($this->m_Profile[$attr])) { return $this->m_Profile[$attr]; } return $this->m_Profile; }
public static function allowAccess($res_action) { //if (aclService::$_accessMatrix) // return 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; } // get the user role id $roleIds = $profile['roles']; if (!$roleIds) { $roleIds[0] = 0; } // guest $roleId_query = implode(",", $roleIds); // generate the access matrix $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; } }
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>"); }
/** * BizForm::render() - render this form (return html content), called by bizview'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 */ public function render() { // when in NEW mode or when parent form in NEW mode, do nothing global $g_BizSystem; $prtMode = ""; if ($this->m_ParentFormName) { $prtForm = BizSystem::getObject($this->m_ParentFormName); $prtMode = $prtForm->GetDisplayMode()->GetMode(); } if ($this->m_Mode != MODE_N && $prtMode != MODE_N) { // get view history if (!$this->m_NoHistoryInfo) { $this->SetHistoryInfo(BizSystem::sessionContext()->getViewHistory($this->m_Name)); } } if ($this->m_Mode == MODE_N) { //$this->UpdateActiveRecord($this->getDataObj()->newRecord()); $this->UpdateActiveRecord($this->getNewRecord()); $this->m_QueryONRender = false; } //Moved the renderHTML function infront of declaring subforms $renderedHTML = $this->renderHTML(); global $g_BizSystem; // prepare the subforms' dataobjs, since the subform relates to parent form by dataobj association if ($this->m_SubForms) { foreach ($this->m_SubForms as $subForm) { $formObj = BizSystem::getObject($subForm); $dataObj = $this->getDataObj()->getRefObject($formObj->m_DataObjName); if ($dataObj) { $formObj->setDataObj($dataObj); } } } $this->setClientScripts(); return $renderedHTML; }
/** * * @param type $userId */ public function switchUserProfile($userId) { //get previously profile if (!BizSystem::sessionContext()->getVar("_PREV_USER_PROFILE")) { $prevProfile = BizSystem::sessionContext()->getVar("_USER_PROFILE"); BizSystem::sessionContext()->clearVar("_USER_PROFILE"); BizSystem::sessionContext()->setVar("_PREV_USER_PROFILE", $prevProfile); } BizSystem::initUserProfile($userId); }
/** * Get user profile * * @param string $attribute user attribute * @return array user profile array */ public static function getUserProfile($attribute = null) { $serviceObj = BizSystem::getService(PROFILE_SERVICE); if (method_exists($serviceObj, 'getProfile')) { return $serviceObj->getProfile($attribute); } else { $profile = BizSystem::sessionContext()->getVar("_USER_PROFILE"); return isset($profile[$attribute]) ? $profile[$attribute] : ""; } }
public static function getCurrentTheme() { if (Resource::$_currentTheme != null) { return Resource::$_currentTheme; } $currentTheme = ""; if (isset($_GET['theme'])) { $currentTheme = $_GET['theme']; } if ($currentTheme == "") { $currentTheme = BizSystem::sessionContext()->getVar("THEME"); } if ($currentTheme == "") { $currentTheme = BizSystem::getUserPreference("theme"); } if ($currentTheme == "" && defined('THEME_NAME')) { $currentTheme = THEME_NAME; } if ($currentTheme == "") { $currentTheme = Resource::DEFAULT_THEME; } // TODO: user pereference has language setting BizSystem::sessionContext()->setVar("THEME", $currentTheme); Resource::$_currentTheme = $currentTheme; return $currentTheme; }
/** * Render a bizview * * @param string $viewName name of bizview * @param string $rule the search rule of a bizform who is not depent on (a subctrl of) another bizform * @return void */ public function renderView($viewName, $form = "", $rule = "", $params = null, $hist = "") { global $g_BizSystem; /* @var $viewObj EasyView */ if ($viewName == "__DynPopup") { $viewObj = BizSystem::getObject($viewName); $viewObj->render(); return; } // if previous view is different with the to-be-loaded view, clear the previous session objects $prevViewName = $g_BizSystem->getCurrentViewName(); $prevViewSet = $g_BizSystem->getCurrentViewSet(); // need to set current view before get view object $g_BizSystem->setCurrentViewName($viewName); $viewObj = BizSystem::getObject($viewName); if (!$viewObj) { return; } $viewSet = $viewObj->getViewSet(); $g_BizSystem->setCurrentViewSet($viewSet); if ($prevViewSet && $viewSet && $prevViewSet == $viewSet) { // keep prev view session objects if they have same viewset BizSystem::sessionContext()->clearSessionObjects(true); } else { BizSystem::sessionContext()->clearSessionObjects(false); } if ($hist == "N") { // clean view history $viewObj->CleanViewHistory(); } if ($form != "" && $rule != "") { $viewObj->processRule($form, $rule, TRUE); } if ($params) { $viewObj->setParameters($params); } if (isset($_GET['mode'])) { // can specify mode of form $viewObj->SetFormMode($form, $_GET['mode']); } $viewObj->render(); //BizController::hidePageLoading(); }
* @license http://code.google.com/p/openbiz-cubi/wiki/CubiLicense * @link http://code.google.com/p/openbiz-cubi/ * @version $Id: index.php 5513 2014-06-04 04:34:06Z rockyswen@gmail.com $ */ /* cubi rest web service entry point request example: url http://host/cubi/rest.php/system/users?start=10&limit=10 */ include_once 'bin/app_init.php'; include_once OPENBIZ_HOME . "/bin/ErrorHandler.php"; require 'bin/Slim/Slim.php'; \Slim\Slim::registerAutoloader(); $app = new \Slim\Slim(); // start session context object BizSystem::sessionContext(); // GET form $app->get('/f/:module/:form(/:id)', function ($module, $form, $id = null) { $app = \Slim\Slim::getInstance(); // get real form name module.form.formnameView $realFormName = getFormName($form, $module); // render view $formObj = BizSystem::getObject($realFormName); if (!$formObj) { // render NOTFOUND_FORM return; } if ($id) { $formObj->setRequestParams(array('Id' => $id)); } print $formObj->render();
$graycolor = ImageColorallocate($im, 102, 102, 102); switch ($CodeLevel) { default: case "1": for ($i = 0; $i < $CodeLength; $i++) { //$font = ImageColorAllocate($im, rand(100,255),rand(0,100),rand(100,255)); $authnum = rand(1, 9); $vcodes .= $authnum; imagestring($im, 5, 2 + $i * 10, 3, $authnum, $graycolor); } break; case "2": for ($i = 0; $i < $CodeLength; $i++) { //$font = ImageColorAllocate($im, rand(100,255),rand(0,100),rand(100,255)); $codebase = "123456789ABCDEFGHIJKLMNPQRSTUVWXYZ"; $codepos = rand(1, strlen($codebase)); $authnum = substr($codebase, $codepos - 1, 1); $vcodes .= $authnum; imagestring($im, 5, 2 + $i * 10, 3, $authnum, $graycolor); } break; } for ($i = 0; $i < 100; $i++) { //$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255)); imagesetpixel($im, rand() % 70, rand() % 30, $graycolor); } ImagePNG($im); ImageDestroy($im); $vcodes = strtoupper($vcodes); BizSystem::sessionContext()->setObjVar($_GET['form'], $_GET['name'], $vcodes);
/** * Get current language setting from session, browser, url, * @return string language name */ public function getCurrentLanguage() { if ($this->_curLang != null) { return $this->_curLang; } $sessionContext = BizSystem::sessionContext(); $currentLanguage = BizSystem::sessionContext()->getVar("LANG"); if ($currentLanguage == "") { $currentLanguage = I18n::DEFAULT_LANGUAGE; if (!$currentLanguage) { $currentLanguage = I18n::getBestAvailableLanguageFromBrowser(); } $sessionContext->setVar("LANG", $currentLanguage); } if (isset($_REQUEST['lang'])) { $requestedLanguage = $_REQUEST['lang']; if (!isset($this->_zTrans[$requestedLanguage])) { $result = $this->_loadLanguage($requestedLanguage); if ($result == false) { $parts = explode('_', $requestedLanguage); $requestedLanguage = $parts[0]; $result = $this->_loadLanguage($requestedLanguage); } if ($result == true) { $currentLanguage = $requestedLanguage; $sessionContext->setVar("LANG", $requestedLanguage); } } } if (!isset($this->_zTrans[$currentLanguage])) { $this->_loadLanguage($currentLanguage); } $this->_curLang = $currentLanguage; return $currentLanguage; }
public function getLastViewURL() { return BizSystem::sessionContext()->getVar("_GROUP_INITIALIZE_LASTVIEW"); }
/** * Clean ACL cache from session */ public function clearACLCache() { aclService::$_accessMatrix = null; BizSystem::sessionContext()->setVar("_ACCESS_MATRIX", array()); BizSystem::sessionContext()->clearVar("_ACCESS_MATRIX"); }
/** * Save the current tab in the session object * * @param TabView $tview * @param EasyView $curViewObj current View Object * @param string $curViewName name of the current view * @return void */ public function setCurrentTabInSession($tview, $curViewObj, $curViewName) { $sessionContext = BizSystem::sessionContext(); if (!$sessionContext->varExists('CURRENT_TAB_' . $this->m_Name)) { if ($this->isCurrentTab($tview, $curViewObj, $curViewName)) { $sessionContext->setVar('CURRENT_TAB_' . $this->m_Name, $tview->m_Name); } else { //Don't set var if isn't the current var } } else { $this->setCurrentTab($sessionContext->getVar('CURRENT_TAB_' . $this->m_Name)); } }
/** * Get user preference * * @param string $attribute key that representing attribute * @return mixed */ public static function getUserPreference($attribute = null) { if (!BizSystem::GetXmlFileWithPath(PREFERENCE_SERVICE)) { return null; } $preferenceService = BizSystem::getService(PREFERENCE_SERVICE); if (method_exists($preferenceService, 'getPreference')) { return $preferenceService->getPreference($attribute); } else { $preference = BizSystem::sessionContext()->getVar("_USER_PREFERENCE"); return isset($preference[$attribute]) ? $preference[$attribute] : ""; } }
public static function getCurrentLangCode() { if (I18n::$_langCode != null) { return I18n::$_langCode; } $currentLanguage = BizSystem::sessionContext()->getVar("LANG"); // default language if ($currentLanguage == "") { $currentLanguage = BizSystem::getUserPreference("language"); } if ($currentLanguage == "") { $currentLanguage = I18n::DEFAULT_LANGUAGE; } // language from url if (isset($_GET['lang'])) { $currentLanguage = $_GET['lang']; BizSystem::sessionContext()->setVar("LANG", $currentLanguage); } // TODO: user pereference has language setting BizSystem::sessionContext()->setVar("LANG", $currentLanguage); I18n::$_langCode = $currentLanguage; return $currentLanguage; }