示例#1
0
 public function postLoadingModule($moduelLoader)
 {
     $roleRec = BizSystem::getObject("system.do.RoleDO")->fetchOne("[name]='Collaboration Admin'");
     $adminRoleId = $roleRec['Id'];
     $roleRec = BizSystem::getObject("system.do.RoleDO")->fetchOne("[name]='Data Manager'");
     $managerRoleId = $roleRec['Id'];
     $roleRec = BizSystem::getObject("system.do.RoleDO")->fetchOne("[name]='Data Assigner'");
     $assignerRoleId = $roleRec['Id'];
     //set up acls for Data assigner
     $actionList = BizSystem::getObject("system.do.AclActionDO")->directfetch("[module]='common' AND [resource]='data_assign'");
     foreach ($actionList as $actionRec) {
         $actionId = $actionRec["Id"];
         $aclRecord = array("role_id" => $assignerRoleId, "action_id" => $actionId, "access_level" => 1);
         BizSystem::getObject("system.do.AclRoleActionDO")->insertRecord($aclRecord);
         $aclRecord = array("role_id" => $managerRoleId, "action_id" => $actionId, "access_level" => 1);
         BizSystem::getObject("system.do.AclRoleActionDO")->insertRecord($aclRecord);
     }
     //set up acls for Data manager
     $actionList = BizSystem::getObject("system.do.AclActionDO")->directfetch("[module]='common' AND [resource]='data_manage'");
     foreach ($actionList as $actionRec) {
         $actionId = $actionRec["Id"];
         $aclRecord = array("role_id" => $managerRoleId, "action_id" => $actionId, "access_level" => 1);
         BizSystem::getObject("system.do.AclRoleActionDO")->insertRecord($aclRecord);
     }
     //delete data manage permission from admin
     $actionRec = BizSystem::getObject("system.do.AclActionDO")->fetchOne("[module]='common' AND [resource]='data_manage' AND [action]='manage'");
     $actionId = $actionRec['Id'];
     BizSystem::getObject("system.do.AclRoleActionDO", 1)->deleteRecords("[role_id]='{$adminRoleId}' AND [action_id]='{$actionId}'");
 }
示例#2
0
 /**
  * Render the chart output
  *
  * @param string $objName object name which is the bizform name
  * @return void
  */
 public function render($objName)
 {
     // get the value of the control that issues the call
     $chartName = BizSystem::clientProxy()->getFormInputs("__this");
     // get the current UI bizobj
     $formObj = BizSystem::getObject($objName);
     // get the existing bizform object
     $bizDataObj = $formObj->getDataObj();
     // get chart config xml file
     $chartXmlFile = BizSystem::GetXmlFileWithPath($objName . "_chart");
     $xmlArr = BizSystem::getXmlArray($chartXmlFile);
     ob_clean();
     // get the chart section from config xml file
     foreach ($xmlArr["BIZFORM_CHART"]["CHARTLIST"]["CHART"] as $chart) {
         if (count($xmlArr["BIZFORM_CHART"]["CHARTLIST"]["CHART"]) == 1) {
             $chart = $xmlArr["BIZFORM_CHART"]["CHARTLIST"]["CHART"];
         }
         // try to match the chartName, if no chartName given, always draw the first chart defined in xml file
         if ($chartName && $chart["ATTRIBUTES"]["NAME"] == $chartName || !$chartName) {
             if ($chart["ATTRIBUTES"]["GRAPHTYPE"] == 'XY') {
                 $this->xyGraphRender($bizDataObj, $chart);
                 break;
             }
             if ($chart["ATTRIBUTES"]["GRAPHTYPE"] == 'Pie') {
                 $this->pieGraphRender($bizDataObj, $chart);
                 break;
             }
         }
     }
 }
示例#3
0
 public function putChildren($resource, $id, $childresource, $request, $response)
 {
     $roleId = $id;
     $reqArray = json_decode($request->getBody());
     $dataObj = BizSystem::getObject("system.do.AclRoleActionDO");
     // get actionIds and accessLevels from request
     foreach ($reqArray as $reqRecord) {
         $actionId = $reqRecord->Id;
         $accessLevel = $reqRecord->access_level;
         // if find the record, update it, or insert a new one
         try {
             $rs = $dataObj->directFetch("[role_id]={$roleId} AND [action_id]={$actionId}", 1);
             if (count($rs) == 1) {
                 if ($rs[0]['access_level'] != $accessLevel) {
                     // update
                     $recArr = $rs[0];
                     $recArr['access_level'] = $accessLevel;
                     $dataObj->updateRecord($recArr, $rs[0]);
                 }
             } else {
                 // insert
                 if ($accessLevel !== null && $accessLevel !== "") {
                     $recArr = array("role_id" => $roleId, "action_id" => $actionId, "access_level" => $accessLevel);
                     $dataObj->insertRecord($recArr);
                 }
             }
         } catch (BDOException $e) {
             $response->status(400);
             $response->body($e->getMessage());
         }
     }
     $response->body("Successfully update role access levels.");
 }
示例#4
0
 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;
 }
示例#5
0
 public function getDefaultLangName($lang = null)
 {
     if ($lang == null) {
         $do = BizSystem::getObject("myaccount.do.PreferenceDO", 1);
         $rec = $do->fetchOne("[user_id]='0' AND [name]='language'");
         if ($rec) {
             $lang = $rec['value'];
         } else {
             $lang = DEFAULT_LANGUAGE;
         }
     }
     $current_locale = I18n::getCurrentLangCode();
     require_once 'Zend/Locale.php';
     $locale = new Zend_Locale($current_locale);
     $display_name = Zend_Locale::getTranslation($lang, 'language', $locale);
     if ($display_name) {
         return $display_name;
     } else {
         if ($lang) {
             return $lang;
         } else {
             return DEFAULT_LANGUAGE;
         }
     }
 }
示例#6
0
 /**
  * Draw the element according to the mode
  *
  * @return string HTML text
  */
 public function render()
 {
     if (!$this->m_FormReference) {
         return null;
     }
     $formObj = $this->getFormObj();
     $formElementObj = BizSystem::GetObject($this->m_FormReference);
     $formElementObj->m_ParentFormName = $formObj->m_Name;
     $formElementObj->m_ParentFormElementMeta = $this->m_XMLMeta;
     $formElementObj->m_CanUpdateRecord = $formObj->m_CanUpdateRecord;
     if (method_exists($formObj, "SetSubForms")) {
         $formObj->setSubForms($this->m_FormReference);
         if ($formObj->m_DataObjName) {
             $formDataObj = BizSystem::getObject($formObj->m_DataObjName);
             $dataObj = $formDataObj->getRefObject($formElementObj->m_DataObjName);
         }
         if ($dataObj) {
             $formObj->setDataObj($dataObj);
         }
     }
     $sHTML = $formElementObj->render();
     $formObj->setDataObj($formDataObj);
     $this->FormRecordCount();
     if (strlen($sHTML)) {
         $this->m_Hidden = "N";
     } else {
         $this->m_Hidden = "Y";
     }
     return $sHTML;
 }
示例#7
0
 public function fetchDataSet()
 {
     $roleId = $this->GetRoleId();
     // fetch acl_action records
     $do = BizSystem::getObject("system.do.AclActionDO");
     $do->setLimit($this->m_Range, ($this->m_CurrentPage - 1) * $this->m_Range);
     $rs = $do->fetch();
     $this->m_TotalRecords = $do->count();
     if ($this->m_Range && $this->m_Range > 0) {
         $this->m_TotalPages = ceil($this->m_TotalRecords / $this->m_Range);
     }
     // fetch role and access
     $this->getDataObj()->setSearchRule("[role_id]={$roleId}");
     $rs1 = $this->getDataObj()->fetch();
     foreach ($rs1 as $rec) {
         $actionRoleAccess[$rec['action_id']] = $rec;
     }
     //print_r($actionRoleAccess);
     // merge 2 rs
     for ($i = 0; $i < count($rs); $i++) {
         $actionId = $rs[$i]['Id'];
         $rs[$i]['access_level'] = "";
         if (isset($actionRoleAccess[$actionId])) {
             $rs[$i]['access_level'] = $actionRoleAccess[$actionId]['access_level'];
         }
     }
     return $rs;
 }
示例#8
0
 public function searchSipTrace($id = null)
 {
     include_once OPENBIZ_BIN . "/easy/SearchHelper.php";
     $searchRule = "";
     foreach ($this->m_DataPanel as $element) {
         if (!$element->m_FieldName) {
             continue;
         }
         $value = BizSystem::clientProxy()->getFormInputs($element->m_Name);
         if ($element->m_FuzzySearch == "Y") {
             $value = "*{$value}*";
         }
         if ($value) {
             $searchStr = inputValToRule($element->m_FieldName, $value, $this);
             if ($searchRule == "") {
                 $searchRule .= $searchStr;
             } else {
                 $searchRule .= " AND " . $searchStr;
             }
         }
     }
     $searchRuleBindValues = QueryStringParam::getBindValues();
     $listFormObj = BizSystem::getObject($this->localListForm);
     $listFormObj->setSearchRule($searchRule, $searchRuleBindValues);
     $listFormObj->rerender();
 }
示例#9
0
 public function GetDefaultRoleID()
 {
     $roleRec = BizSystem::getObject("system.do.RoleDO")->fetchOne("[default]='1'", "[Id] DESC");
     if ($roleRec) {
         $Id = $roleRec['Id'];
     }
     return (int) $Id;
 }
示例#10
0
 public function postLoadingModule($moduelLoader)
 {
     $roleRec = BizSystem::getObject("system.do.RoleDO")->fetchOne("[name]='Cubi Member'");
     $roleId = $roleRec['Id'];
     $actionRec = BizSystem::getObject("system.do.AclActionDO")->fetchOne("[module]='user' AND [resource]='UserAccount' AND [action]='Edit_Own_Account'");
     $actionId = $actionRec["Id"];
     $aclRecord = array("role_id" => $roleId, "action_id" => $actionId, "access_level" => 1);
     BizSystem::getObject("system.do.AclRoleActionDO")->insertRecord($aclRecord);
 }
示例#11
0
 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();
 }
示例#12
0
 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;
 }
示例#13
0
 public function isModuleInstalled($module)
 {
     $do = BizSystem::getObject($this->m_ModuleDO);
     $modRec = $do->fetchOne("[name]='{$module}'");
     if ($modRec) {
         return $modRec['version'];
     } else {
         return false;
     }
 }
示例#14
0
 public function loadDialog($formName = null, $id = null)
 {
     $formObj1 = BizSystem::getObject($formName);
     $formObj1->setRecordId($id);
     //$formObj1->setParentForm($this->formObj->m_Name);
     $output = $formObj1->render();
     if (!empty($output)) {
         BizSystem::clientProxy()->redrawForm("DIALOG", $output);
     }
 }
示例#15
0
 /**
  * Render smarty template for view object
  *
  * @param EasyView $viewObj
  * @param string $tplFile
  * @return string result of rendering process
  */
 protected static function renderSmarty($viewObj, $tplFile)
 {
     $smarty = BizSystem::getSmartyTemplate();
     $newClntObjs = '';
     // render the viewobj attributes
     $smarty->assign("view", $viewObj->outputAttrs());
     $smarty->assign("module", $viewObj->getModuleName($viewObj->m_Name));
     if ($viewObj->m_Tiles) {
         foreach ($viewObj->m_Tiles as $tname => $tile) {
             foreach ($tile as $formRef) {
                 if ($formRef->m_Display == false) {
                     continue;
                 }
                 $tiles[$tname][$formRef->m_Name] = BizSystem::getObject($formRef->m_Name)->render();
                 $tiletabs[$tname][$formRef->m_Name] = $formRef->m_Description;
             }
         }
     } else {
         foreach ($viewObj->m_FormRefs as $formRef) {
             if ($formRef->m_Display == false) {
                 continue;
             }
             $forms[$formRef->m_Name] = BizSystem::getObject($formRef->m_Name)->render();
             $formtabs[$formRef->m_Name] = $formRef->m_Description;
         }
     }
     // add clientProxy scripts
     $includedScripts = BizSystem::clientProxy()->getAppendedScripts();
     $styles = BizSystem::clientProxy()->getAppendedStyles();
     if ($viewObj->m_IsPopup && $bReRender == false) {
         $moveToCenter = "moveToCenter(self, " . $viewObj->m_Width . ", " . $viewObj->m_Height . ");";
         $scripts = $includedScripts . "\n<script>\n" . $newClntObjs . $moveToCenter . "</script>\n";
     } else {
         $scripts = $includedScripts . "\n<script>\n" . $newClntObjs . "</script>\n";
     }
     if ($viewObj->m_Title) {
         $title = Expression::evaluateExpression($viewObj->m_Title, $viewObj);
     } else {
         $title = $viewObj->m_Description;
     }
     $smarty->assign("scripts", $scripts);
     $smarty->assign("style_sheets", $styles);
     $smarty->assign("title", $title);
     $smarty->assign("description", $viewObj->m_Description);
     $smarty->assign("keywords", $viewObj->m_Keywords);
     $smarty->assign("forms", $forms);
     $smarty->assign("formtabs", $formtabs);
     $smarty->assign("tiles", $tiles);
     $smarty->assign("tiletabs", $tiletabs);
     if ($viewObj->m_ConsoleOutput) {
         $smarty->display(BizSystem::getTplFileWithPath($viewObj->m_TemplateFile, $viewObj->m_Package));
     } else {
         return $smarty->fetch(BizSystem::getTplFileWithPath($viewObj->m_TemplateFile, $viewObj->m_Package));
     }
 }
示例#16
0
 protected function inheritParentObj()
 {
     if (!$this->m_InheritFrom) {
         return;
     }
     $parentObj = BizSystem::getObject($this->m_InheritFrom);
     parent::inheritParentObj();
     $this->m_Range = $this->m_Range ? $this->m_Range : $parentObj->m_Range;
     $this->m_FixSearchRule = $this->m_FixSearchRule ? $this->m_FixSearchRule : $parentObj->m_FixSearchRule;
     $this->m_DefaultFixSearchRule = $this->m_DefaultFixSearchRule ? $this->m_DefaultFixSearchRule : $parentObj->m_DefaultFixSearchRule;
 }
示例#17
0
 public function SwitchSearchFieldForm($switchForm, $fieldName, $fieldValue)
 {
     include_once OPENBIZ_BIN . "/easy/SearchHelper.php";
     $this->switchForm($switchForm);
     $listFormObj = BizSystem::getObject($switchForm);
     QueryStringParam::reset();
     $searchRule = inputValToRule($fieldName, $fieldValue, $this);
     $searchRuleBindValues = QueryStringParam::getBindValues();
     $listFormObj->setSearchRule($searchRule, $searchRuleBindValues);
     $listFormObj->rerender();
 }
示例#18
0
 /**
  * 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();
 }
 public function allowAccess()
 {
     $result = parent::allowAccess();
     $do = BizSystem::getObject("myaccount.do.PreferenceDO");
     $rs = $do->fetchOne("[user_id]='0' AND  [section]='Register' AND [name]='find_password'");
     $value = $rs->value;
     if ($value == 0 || $value == null) {
         return 0;
     } else {
         return $result;
     }
 }
示例#20
0
 public function postUnloadModule($moduleLoader)
 {
     $roleRec = BizSystem::getObject("system.do.RoleDO")->fetchOne("[name]='{$this->m_RoleName}'");
     $memberRoleId = $roleRec['Id'];
     $roleRec->delete();
     $actionList = BizSystem::getObject("system.do.AclActionDO")->directfetch("[module]='{$this->m_ModuleName}'");
     foreach ($actionList as $actionRec) {
         $actionId = $actionRec["Id"];
         BizSystem::getObject("system.do.AclRoleActionDO")->deleteRecords("[action_id]='{$actionId}' AND [role_id]='{$memberRoleId}'");
     }
     BizSystem::getObject("system.do.AclActionDO")->deleteRecords("[module]='{$this->m_ModuleName}'");
 }
示例#21
0
 /**
  * Update login time
  *
  * @return void
  */
 protected function UpdateloginTime()
 {
     $userObj = BizSystem::getObject('system.do.UserDO');
     $curRecs = $userObj->directFetch("[username]='" . $this->username . "'", 1);
     if (count($curRecs) == 0) {
         return false;
     }
     $dataRec = new DataRecord($curRecs[0], $userObj);
     $dataRec['lastlogin'] = date("Y-m-d H:i:s");
     $ok = $dataRec->save();
     return true;
 }
示例#22
0
 /**
  * Fetch record
  * 
  * @param string $doName data object name
  * @param string $searchRule rule of search
  * @return mixed
  */
 public function fetchRecord($doName, $searchRule)
 {
     $do = BizSystem::getObject($doName);
     if (!$do) {
         throw new Exception("System cannot get object of {$doName}.");
         return;
     }
     $r = $do->directFetch($searchRule, 1);
     if (count($r) > 0) {
         return $r[0];
     }
     return null;
 }
示例#23
0
 public function put($resource, $id, $request, $response)
 {
     $format = strtolower($request->params('format'));
     $DOName = $this->getDOName($resource);
     if (empty($DOName)) {
         $response->status(404);
         $response->body("Resource '{$resource}' is not found.");
         return;
     }
     $dataObj = BizSystem::getObject($DOName);
     $rec = $dataObj->fetchById($id);
     if (empty($rec)) {
         $response->status(404);
         $response->body("No data is found for {$resource} {$id}");
         return;
     }
     $dataRec = new DataRecord($rec, $dataObj);
     $inputRecord = json_decode($request->getBody());
     if ($inputRecord->password != $inputRecord->password_repeat) {
         $errors['password_repeat'] = "Password repeat is not same as password";
         $this->setErrorResponse(400, $errors, $response, $format);
         return;
     }
     foreach ($inputRecord as $k => $v) {
         // if password is ********, ignore password value
         if ($k == 'password' && $v == '********') {
             continue;
         }
         if ($k == 'password') {
             $v = hash(HASH_ALG, $v);
         }
         if ($k == 'password_repeat') {
             continue;
         }
         $dataRec[$k] = $v;
         // or $dataRec->$k = $v;
     }
     try {
         $dataRec->save();
     } catch (ValidationException $e) {
         $response->status(400);
         $errmsg = implode("\n", $e->m_Errors);
         $response->body($errmsg);
         return;
     } catch (BDOException $e) {
         $response->status(400);
         $response->body($e->getMessage());
         return;
     }
     return $this->setResponse($dataRec->toArray(), $response, $format);
 }
 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++;
     }
 }
示例#25
0
 public function getBreadCrumb()
 {
     $menuTreeDo = BizSystem::getObject("menu.do.MenuTreeDO");
     $breadCrumb = $menuTreeDo->getBreadCrumb($_SERVER['REQUEST_URI']);
     // only output Id, Name, URL of each breadcrumb item
     $bc = array();
     foreach ($breadCrumb as $menuRecord) {
         $id = $menuRecord->m_Id;
         $name = $menuRecord->m_Name;
         $url = $menuRecord->m_URL;
         $bc[] = array('id' => $id, 'name' => $name, 'url' => $url);
     }
     return $bc;
 }
示例#26
0
 public function queryMenuTree($resource, $request, $response)
 {
     $DOName = $this->getDOName($resource);
     if (empty($DOName)) {
         $response->status(404);
         $response->body("Resource '{$resource}' is not found.");
         return;
     }
     // get page and sort parameters
     $allGetVars = $request->get();
     $queryParams = array();
     foreach ($allGetVars as $key => $value) {
         if ($key == 'depth' || $key == 'format') {
             continue;
         }
         //if ($value !== null && $value !== '') {
         $queryParams[$key] = $value;
         //}
     }
     $depth = $request->params('depth');
     if (!$depth) {
         $depth = 1;
     }
     $dataObj = BizSystem::getObject($DOName);
     $tree = $dataObj->fetchTreeByQueryParams($queryParams, $depth);
     /*
     // include app tab - PId's sibling nodes
     $PId = $request->params('PId');
     // first find the menu record with Id=PId and get its app_root_menu_PId
     $appRootMenuRec = $dataObj->fetchById($PId);
     $appRootMenuRecPId = $appRootMenuRec['PId'];
     // then find menu records whose PId=app_root_menu_PId
     $appTab = $dataObj->fetchTreeBySearchRule("[PId]='$appRootMenuRecPId' AND [published]=1", 1);
     
     $comboMenus = array('tree'=>$tree,'tab'=>$appTab);
     */
     $format = strtolower($request->params('format'));
     $response->status(200);
     if ($format == 'json') {
         $response['Content-Type'] = 'application/json';
         $response->body(json_encode($tree));
     } else {
         $response['Content-Type'] = "text/xml; charset=utf-8";
         $xml = new array2xml('Data');
         $xml->createNode($tree);
         $response->body($xml);
     }
     return;
 }
示例#27
0
 protected function getLogData()
 {
     $logDataObj = BizSystem::getObject($this->m_logDataObj);
     $recordList = array();
     $logDataObj->fetchRecords("", $recordList);
     for ($i = 0; $i < count($recordList); $i++) {
         $data[$i]['timestamp'] = $recordList[$i]['timestamp'];
         $data[$i]['ipaddr'] = $recordList[$i]['ipaddr'];
         $data[$i]['event'] = $this->GetLogMessage($recordList[$i]['event']);
         $data[$i]['message'] = $this->GetLogMessage($recordList[$i]['message'], $recordList[$i]['comment']);
         $data[$i]['event'] = $this->convertEncoding($data[$i]['event']);
         $data[$i]['message'] = $this->convertEncoding($data[$i]['message']);
     }
     return $data;
 }
示例#28
0
 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;
     }
 }
示例#29
0
 protected function authDBUser($username, $password)
 {
     $boAuth = BizSystem::getObject($this->m_AuthticationDataObj);
     if (!$boAuth) {
         return false;
     }
     $searchRule = "[username]='{$username}' and status='1'";
     $recordList = array();
     $boAuth->fetchRecords($searchRule, $recordList, 1);
     $encType = $recordList[0]["enctype"];
     $realPassword = $recordList[0]["password"];
     if ($this->checkPassword($encType, $password, $realPassword)) {
         return true;
     }
     return false;
 }
示例#30
0
 /**
  * Render the pdf output
  *
  * @global BizSystem $g_BizSystem
  * @param string $viewName name of view object
  * @return void
  */
 public function renderView($viewName)
 {
     $viewObj = BizSystem::getObject($viewName);
     if ($viewObj) {
         $viewObj->setConsoleOutput(false);
         $sHTML = $viewObj->render();
         //$sHTML = "Test";
         //require_once("dompdf/dompdf_config.inc.php");
         $domPdf = new DOMPDF();
         $domPdf->load_html($sHTML);
         //$dompdf->set_paper($_POST["paper"], $_POST["orientation"]);
         $domPdf->render();
         $this->output($domPdf);
         //$dompdf->stream("dompdf_out.pdf");
     }
 }