Exemplo n.º 1
0
 private function _dumpDatabase($filename, $dbname, $droptable)
 {
     $filename .= ".sql";
     $filename = $this->folder . DIRECTORY_SEPARATOR . $filename;
     $dbconfigList = BizSystem::getConfiguration()->getDatabaseInfo();
     $dbconfig = $dbconfigList[$dbname];
     if (strtolower($dbconfig["Driver"]) != 'pdo_mysql') {
         return;
     }
     include_once dirname(dirname(__FILE__)) . "/lib/MySQLDump.class.php";
     $backup = new MySQLDump();
     if ($droptable == 1) {
         $backup->droptableifexists = true;
     } else {
         $backup->droptableifexists = false;
     }
     if ($dbconfig["Port"]) {
         $dbHost = $dbconfig["Server"] . ":" . $dbconfig["Port"];
     } else {
         $dbHost = $dbconfig["Port"];
     }
     $dbc = $backup->connect($dbHost, $dbconfig["User"], $dbconfig["Password"], $dbconfig["DBName"], $dbconfig["Charset"]);
     if (!$dbc) {
         echo $backup->mysql_error;
     }
     $backup->dump();
     $data = $backup->output;
     file_put_contents($filename, $data);
     @chmod($filename, 0777);
     return $filename;
 }
Exemplo n.º 2
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();
 }
Exemplo n.º 3
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;
             }
         }
     }
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 /**
  * Do insert record
  *
  * @param array $inputRecord
  * @return void
  */
 protected function _doInsert($inputRecord)
 {
     $dataRec = new DataRecord(null, $this->getDataObj());
     // $inputRecord['Id'] = null; // comment it out for name PK case
     foreach ($inputRecord as $k => $v) {
         $dataRec[$k] = $v;
     }
     // or $dataRec->$k = $v;
     try {
         $dataRec->save();
     } catch (ValidationException $e) {
         $errElements = $this->getErrorElements($e->m_Errors);
         if (count($e->m_Errors) == count($errElements)) {
             $this->formHelper->processFormObjError($errElements);
         } else {
             $errmsg = implode("<br />", $e->m_Errors);
             BizSystem::clientProxy()->showErrorMessage($errmsg);
         }
         return;
     } catch (BDOException $e) {
         $this->processBDOException($e);
         return;
     }
     $this->m_ActiveRecord = null;
     $this->getActiveRecord($dataRec["Id"]);
     //$this->runEventLog();
     return $dataRec["Id"];
 }
Exemplo n.º 6
0
 public function GoActive()
 {
     $rec = $this->readInputRecord();
     $this->setActiveRecord($rec);
     if ($rec['eula'] == "0") {
         $this->m_Errors = array("fld_eula" => 'You must agree with the license');
         $this->m_hasError = true;
         BizSystem::clientProxy()->setRPCFlag(true);
         return parent::rerender();
     }
     $appInfo = $this->getAppInfo();
     if (!$appInfo) {
         $rec['howto_active'] = 'ENTER';
     }
     switch (strtoupper($rec['howto_active'])) {
         case "ENTER":
             $this->switchForm("common.form.LicenseActiveForm");
             break;
         case "FREETRIAL":
             if ($this->getTrailLicense()) {
                 $scriptStr = 'location.reload();';
                 BizSystem::clientProxy()->runClientFunction($scriptStr);
             }
             break;
         case "PURCHASE":
             $url = $appInfo['APP_PURCHASE'];
             BizSystem::clientProxy()->redirectPage($url);
             break;
         case "WEBSITE":
             $url = $appInfo['APP_WEBSITE'];
             BizSystem::clientProxy()->redirectPage($url);
             break;
     }
 }
Exemplo n.º 7
0
 public function getFromList(&$list)
 {
     $current_locale = I18n::getInstance()->getCurrentLanguage();
     $country = BizSystem::clientProxy()->getFormInputs("fld_region");
     $country = strtoupper($country);
     if (!$country) {
         $locale = explode('_', $current_locale);
         $country = strtoupper($locale[0]);
     }
     require_once 'Zend/Locale.php';
     $locale = new Zend_Locale($current_locale);
     $code2name = $locale->getTranslationList('territorytolanguage', $locale);
     $list = array();
     $i = 0;
     foreach ($code2name as $key => $value) {
         if (preg_match('/' . $country . '/', $value) || strtoupper($key) == $country) {
             $lang_list = explode(" ", $value);
             foreach ($lang_list as $lang) {
                 $list[$i]['txt'] = strtolower($key) . "_" . strtoupper($lang);
                 $list[$i]['val'] = strtolower($key) . "_" . strtoupper($lang);
                 $i++;
             }
         }
     }
     return $list;
 }
Exemplo n.º 8
0
 public function SetSearchRule()
 {
     $url = $this->GetURL();
     if (!$url) {
         return;
     }
     //search cat_id from mapping table
     $mappingObj = BizSystem::GetObject($this->m_CategoryMappingDO, 1);
     //@todo: $url need to be filtered before use in database
     $records = $mappingObj->directFetch("[url]='{$url}'");
     if (count($records) == 1) {
         $cat_id = (int) $records[0]['cat_id'];
     } else {
         //if no matched, generate record from category table url_match
         $categoryObj = BizSystem::GetObject($this->m_CategoryDO, 1);
         $records = $categoryObj->directFetch();
         foreach ($records as $record) {
             $match = $record['url_match'];
             if ($match) {
                 $pattern = "/" . str_replace('/', '\\/', $match) . "/si";
                 $pattern = "@" . $match . "@si";
                 if (preg_match($pattern, "/" . $url)) {
                     $cat_id = $record['Id'];
                     //cache it into database;
                     $obj_array = array("cat_id" => $cat_id, "url" => $url);
                     $mappingObj->insertRecord($obj_array);
                     break;
                 }
             }
         }
     }
     $this->m_SearchRule = "[category_id]='{$cat_id}'";
 }
Exemplo n.º 9
0
 /**
  * Set value of element
  *
  * @param mixed $value
  * @return string
  */
 function setValue($value)
 {
     if ($this->m_Deleteable == 'N') {
     } else {
         $delete_user_opt = BizSystem::clientProxy()->getFormInputs($this->m_Name . "_DELETE");
         if ($delete_user_opt) {
             $this->m_Value = "";
             return;
         } else {
             if (count($_FILES) > 0) {
             } else {
                 $this->m_Value = $value;
             }
         }
     }
     if (count($_FILES) > 0) {
         if (!$this->m_Uploaded) {
             $file = $_FILES[$this->m_Name];
             if (!is_dir($this->m_UploadRoot . $this->m_UploadFolder)) {
                 mkdir($this->m_UploadRoot . $this->m_UploadFolder, 0777, true);
             }
             $uploadFile = $this->m_UploadFolder . "/" . date("YmdHis") . "-" . urlencode($file['name']);
             if (move_uploaded_file($file['tmp_name'], $this->m_UploadRoot . $uploadFile)) {
                 $this->m_Value = $this->m_UploadRootURL . $uploadFile;
                 $this->m_Uploaded = true;
             }
             return $uploadFile;
         }
     }
 }
Exemplo n.º 10
0
function giveActionAccess($where, $role_id)
{
    $db = BizSystem::dbConnection();
    try {
        if (empty($where)) {
            $sql = "SELECT * FROM acl_action";
        } else {
            $sql = "SELECT * FROM acl_action WHERE {$where}";
        }
        BizSystem::log(LOG_DEBUG, "DATAOBJ", $sql);
        $rs = $db->fetchAll($sql);
        $sql = "";
        foreach ($rs as $r) {
            $sql = "DELETE FROM acl_role_action WHERE role_id={$role_id} AND action_id={$r['0']}; ";
            BizSystem::log(LOG_DEBUG, "DATAOBJ", $sql);
            $db->query($sql);
            $sql = "INSERT INTO acl_role_action (role_id, action_id, access_level) VALUES ({$role_id},{$r['0']},1)";
            BizSystem::log(LOG_DEBUG, "DATAOBJ", $sql);
            $db->query($sql);
        }
    } catch (Exception $e) {
        echo "ERROR: " . $e->getMessage() . "" . PHP_EOL;
        return false;
    }
}
Exemplo n.º 11
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}'");
 }
Exemplo n.º 12
0
 /**
  * Render element, according to the mode
  *
  * @return string HTML text
  */
 public function render()
 {
     BizSystem::clientProxy()->includeCKEditorScripts();
     $elementName = $this->m_Name;
     $value = $this->getValue();
     $value = htmlentities($value, ENT_QUOTES, "UTF-8");
     $style = $this->getStyle();
     $width = $this->m_Width ? $this->m_Width : 600;
     $height = $this->m_Height ? $this->m_Height : 300;
     //$func = "onclick=\"editRichText('$elementName', $width, $height);\"";
     if (!strlen($value) > 0) {
         // fix suggested by smarques
         $value = "&nbsp;";
     }
     $type = strtolower($this->m_Mode);
     $fileBrowserPage = APP_URL . "/bin/filebrowser/browser.html";
     $languageCode = I18n::getCurrentLangCode();
     $languageCode = str_replace("_", "-", $languageCode);
     $config = $this->m_Config;
     $sHTML .= "<textarea id=\"{$elementName}\" name=\"{$elementName}\" >{$value}</textarea>\n";
     $sHTML .= "<script type=\"text/javascript\">\n";
     if ($config) {
         //remove the last commas
         $config = trim($config);
         if (substr($config, strlen($config) - 1, 1) == ',') {
             $config = substr($config, strlen($config) - 1);
         }
         $sHTML .= "Openbiz.CKEditor.init('{$elementName}',{'type':'{$type}','filebrowserBrowseUrl':'{$fileBrowserPage}','language':'{$languageCode}','height':'{$height}','width':'{$width}',{$config}});\n";
     } else {
         $sHTML .= "Openbiz.CKEditor.init('{$elementName}',{'type':'{$type}','filebrowserBrowseUrl':'{$fileBrowserPage}','language':'{$languageCode}','height':'{$height}','width':'{$width}'});\n";
     }
     $sHTML .= "</script>\n";
     return $sHTML;
 }
Exemplo n.º 13
0
 public function render()
 {
     BizSystem::clientProxy()->includeColorPickerScripts();
     if ($this->m_Value != null) {
         $value = $this->m_Value;
     } else {
         $value = $this->getText();
     }
     $disabledStr = $this->getEnabled() == "N" ? "READONLY=\"true\"" : "";
     $style = $this->getStyle();
     $func = $this->getFunction();
     $func_org = $func;
     $formobj = $this->GetFormObj();
     if ($formobj->m_Errors[$this->m_Name]) {
         $func .= "onchange=\"this.className='{$this->m_cssClass}'\"";
     } else {
         $func .= "onfocus=\"this.className='{$this->m_cssFocusClass}'\" onblur=\"this.className='{$this->m_cssClass}'\"";
     }
     $elementName = $this->m_Name;
     $elementTrigger = array();
     if ($value) {
         $default_color = "color: '#{$value}',";
     } else {
         $default_color = "";
         $value = $this->getDefaultValue() ? $this->getDefaultValue() : "";
     }
     switch (strtolower($this->m_Mode)) {
         case "viewonly":
             $sHTML .= "<span id=\"colorpreview_{$elementName}\" {$func_org} class=\"colorpicker_preview\" style=\"background-color:#{$value};width:98px;\" ></span>";
             $elementTrigger = array();
             break;
         case "widget":
             $config = " \n\t\t\t\t\t\t\tonShow: function (colpkr) {\n\t\t\t\t\t\t\t\tif(\$j(colpkr).css('display')=='none'){\n\t\t\t\t\t\t\t\t\t\$j(colpkr).fadeIn(300);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonHide: function (colpkr) {\n\t\t\t\t\t\t\t\t\$j(colpkr).fadeOut(300);\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t},\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tonSubmit: function(hsb, hex, rgb, el) {\n\t\t\t\t\t\t\t\t\$('{$this->m_Name}').value=hex;\n\t\t\t\t\t\t\t\t\$j('#colorpreview_{$this->m_Name}').css('backgroundColor', '#' + hex);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonChange: function (hsb, hex, rgb) {\n\t\t\t\t\t\t\t\t\$('{$this->m_Name}').value=hex;\n\t\t\t\t\t\t\t\t\$j('#colorpreview_{$this->m_Name}').css('backgroundColor', '#' + hex);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t";
             $sHTML .= "<span id=\"colorpreview_{$elementName}\" class=\"colorpicker_preview\" style=\"background-color:#{$value};\" {$func} ></span>";
             $sHTML .= "<INPUT NAME=\"" . $this->m_Name . "\" ID=\"" . $this->m_Name . "\" VALUE=\"" . $value . "\" type=\"hidden\" />";
             $elementTrigger = array("colorpreview_{$elementName}");
             break;
         case "flat":
             $config = "flat: true,\n\t\t\t\t\t\t\tonSubmit: function(hsb, hex, rgb, el) {\n\t\t\t\t\t\t\t\t\$('{$this->m_Name}').value=hex;\n\t\t\t\t\t\t\t\t\$j('#colorpreview_{$this->m_Name}').css('backgroundColor', '#' + hex);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonChange: function (hsb, hex, rgb) {\n\t\t\t\t\t\t\t\t\$('{$this->m_Name}').value=hex;\n\t\t\t\t\t\t\t\t\$j('#colorpreview_{$this->m_Name}').css('backgroundColor', '#' + hex);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t";
             $sHTML .= "<span id=\"colorpreview_{$elementName}\" class=\"colorpicker_preview\" style=\"background-color:#{$value};\" ></span>";
             $sHTML .= "<INPUT NAME=\"" . $this->m_Name . "\" ID=\"" . $this->m_Name . "\" VALUE=\"" . $value . "\" {$disabledStr} {$this->m_HTMLAttr} {$style} {$func} />";
             $sHTML .= "<div id=\"colorpicker_{$elementName}\" style=\"float:left\"></div>";
             $elementTrigger = array("colorpicker_" . $elementName);
             break;
         default:
             $config = " \n\t\t\t\t\t\t\tonShow: function (colpkr) {\n\t\t\t\t\t\t\t\tif(\$j(colpkr).css('display')=='none'){\n\t\t\t\t\t\t\t\t\t\$j(colpkr).fadeIn(300);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonHide: function (colpkr) {\n\t\t\t\t\t\t\t\t\$j(colpkr).fadeOut(300);\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t},\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tonSubmit: function(hsb, hex, rgb, el) {\n\t\t\t\t\t\t\t\t\$('{$this->m_Name}').value=hex;\n\t\t\t\t\t\t\t\t\$j('#colorpreview_{$this->m_Name}').css('backgroundColor', '#' + hex);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonChange: function (hsb, hex, rgb) {\n\t\t\t\t\t\t\t\t\$('{$this->m_Name}').value=hex;\n\t\t\t\t\t\t\t\t\$j('#colorpreview_{$this->m_Name}').css('backgroundColor', '#' + hex);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t";
             $sHTML .= "<span id=\"colorpreview_{$elementName}\" class=\"colorpicker_preview\" style=\"background-color:#{$value};\" ></span>";
             $sHTML .= "<INPUT NAME=\"" . $this->m_Name . "\" ID=\"" . $this->m_Name . "\" VALUE=\"" . $value . "\" {$disabledStr} {$this->m_HTMLAttr} {$style} {$func} />";
             $elementTrigger = array($elementName, "colorpreview_{$elementName}");
             break;
     }
     if ($this->m_Config) {
         $config .= "," . $this->m_Config;
     }
     $config = "{" . $default_color . $config . "}";
     foreach ($elementTrigger as $trigger) {
         $sHTML .= "<script>\$j('#{$trigger}').ColorPicker({$config});</script>\n";
     }
     return $sHTML;
 }
Exemplo n.º 14
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;
 }
Exemplo n.º 15
0
 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();
 }
Exemplo n.º 16
0
 /**
  * Render PHP template for widget object
  *
  * @param MenuWidget $widgetObj
  * @param string $tplFile
  * @return string result of rendering process
  */
 protected static function renderPHP($widgetObj, $tplFile)
 {
     $view = BizSystem::getZendTemplate();
     $view->addScriptPath(dirname($tplFile));
     $view->widget = $widgetObj->OutputAttrs();
     return $view->render($widgetObj->m_TemplateFile);
 }
Exemplo n.º 17
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;
         }
     }
 }
Exemplo n.º 18
0
function siremisFillDB()
{
    siremisReplaceDbConfig();
    BizSystem::log(LOG_DEBUG, "SIREMIS", "install module siremis sql - " . $_REQUEST['db1type']);
    if ($_REQUEST['db1type'] == "Pdo_Pgsql" || $_REQUEST['db1type'] == "pdo_pgsql") {
        $sqlfile = MODULE_PATH . "/ser/mod.install.siremis.pgsql.sql";
    } else {
        $sqlfile = MODULE_PATH . "/ser/mod.install.siremis.sql";
    }
    if (!file_exists($sqlfile)) {
        return true;
    }
    // Getting the SQL file content
    $query = trim(file_get_contents($sqlfile));
    if (empty($query)) {
        return true;
    }
    // $db = BizSystem::dbConnection("Serdb");
    $db = siremisConnectDB();
    include_once MODULE_PATH . "/system/lib/MySQLDumpParser.php";
    $queryArr = MySQLDumpParser::parse($query);
    foreach ($queryArr as $query) {
        try {
            $db->exec($query);
        } catch (Exception $e) {
            BizSystem::log(LOG_DEBUG, "SIREMIS", $e->getMessage());
            echo 'ERROR: ' . $e->getMessage();
            exit;
        }
    }
    return true;
}
Exemplo n.º 19
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.");
 }
Exemplo n.º 20
0
 public function UpdateRecord()
 {
     $result = parent::UpdateRecord();
     $mappingObj = BizSystem::GetObject($this->m_CategoryMappingDO, 1);
     $Id = $this->m_RecordId;
     $mappingObj->deleteRecords("[cat_id]='{$Id}'");
     return $result;
 }
Exemplo n.º 21
0
 public function GetDefaultRoleID()
 {
     $roleRec = BizSystem::getObject("system.do.RoleDO")->fetchOne("[default]='1'", "[Id] DESC");
     if ($roleRec) {
         $Id = $roleRec['Id'];
     }
     return (int) $Id;
 }
Exemplo n.º 22
0
 public function outputAttrs()
 {
     $profile = BizSystem::getUserProfile();
     $userId = $profile['Id'];
     $output = parent::outputAttrs();
     $output['queryString'] = "Id=" . $userId;
     return $output;
 }
Exemplo n.º 23
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();
 }
Exemplo n.º 24
0
 public function render()
 {
     $this->getUrlParameters();
     if (empty($this->m_RecordId)) {
         BizSystem::clientProxy()->showClientAlert($this->getMessage("PLEASE_EDIT_A_RECORD"));
         return;
     }
     return parent::render();
 }
Exemplo n.º 25
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);
 }
Exemplo n.º 26
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;
 }
Exemplo n.º 27
0
 public function isModuleInstalled($module)
 {
     $do = BizSystem::getObject($this->m_ModuleDO);
     $modRec = $do->fetchOne("[name]='{$module}'");
     if ($modRec) {
         return $modRec['version'];
     } else {
         return false;
     }
 }
Exemplo n.º 28
0
 /**
  * Render / draw the element according to the mode
  *
  * @return string HTML text
  */
 public function render()
 {
     BizSystem::clientProxy()->includeCalendarScripts();
     $format = $this->m_DateFormat ? $this->m_DateFormat : "%Y-%m-%d";
     $sHTML = parent::render();
     $showTime = 'false';
     //$image = "<img src=\"".Resource::getImageUrl()."/calendar.gif\" border=0 title=\"Select date...\" align='top' hspace='2'>";
     $sHTML .= "<a class=\"date_picker\" href=\"javascript: void(0);\" onclick=\"return showCalendar('{$this->m_Name}','{$format}',{$showTime},true);\"></a>";
     return $sHTML;
 }
Exemplo n.º 29
0
 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();
 }
Exemplo n.º 30
0
 /**
  * Render / draw the element according to the mode
  *
  * @return string HTML text
  */
 public function render()
 {
     BizSystem::clientProxy()->includeCalendarScripts();
     $format = $this->m_DateFormat ? $this->m_DateFormat : "%Y-%m-%d %H:%M:%S";
     $sHTML = parent::render();
     $showTime = "'24'";
     //$image = "<img src=\"".Resource::getImageUrl()."/calendar.gif\" border=0 title=\"Select date...\" align='top' hspace='2'>";
     $sHTML .= "<a title=\"Select date...\"  class=\"date_picker\" href=\"javascript: void(0);\" onclick=\"return showCalendar('" . $this->m_Name . "', '" . $format . "', " . $showTime . ", true); return false;\"  onmousemove='window.status=\"Select a datetime\"' onmouseout='window.status=\"\"'></a>";
     return $sHTML;
 }