コード例 #1
0
ファイル: BizDataObj.php プロジェクト: que273/siremis
 /**
  * Generate Id according to the IdGeneration attribute
  *
  * @param boolean $isBeforeInsert
  * @param string $tableName
  * @param string $idCloumnName
  * @return long|string|boolean
  */
 protected function generateId($isBeforeInsert = true, $tableName = null, $idCloumnName = null)
 {
     // Identity type id is generated after insert is done.
     // If this method is called before insert, return null.
     if ($isBeforeInsert && $this->m_IdGeneration == 'Identity') {
         return null;
     }
     if (!$isBeforeInsert && $this->m_IdGeneration != 'Identity') {
         $this->m_ErrorMessage = BizSystem::getMessage("DATA_UNABLE_GET_ID", $this->m_Name);
         return false;
     }
     /* @var $genIdService genIdService */
     $genIdService = BizSystem::getService(GENID_SERVICE);
     $db = $this->getDBConnection();
     $dbInfo = BizSystem::Configuration()->getDatabaseInfo($this->m_Database);
     $dbType = $dbInfo["Driver"];
     $table = $tableName ? $tableName : $this->m_MainTable;
     $column = $idCloumnName ? $idCloumnName : $this->getField("Id")->m_Column;
     try {
         $newId = $genIdService->getNewID($this->m_IdGeneration, $db, $dbType, $table, $column);
     } catch (Exception $e) {
         $this->m_ErrorMessage = $e->getMessage();
         return false;
     }
     return $newId;
 }
コード例 #2
0
ファイル: securityService.php プロジェクト: que273/siremis
 /**
  * Proses security rule
  * return true go to check next rule
  * return false report an error and stop checking
  *
  * @return boolean
  */
 public function process()
 {
     if (strtoupper($this->m_Status) == 'ENABLE') {
         parent::process();
         if (!$this->checkEffectiveTime()) {
             return true;
         } else {
             $get_str = serialize($_GET);
             if (preg_match("/" . $this->m_Match . "/si", $get_str)) {
                 if (strtoupper($this->m_Action) == 'DENY') {
                     $this->m_ErrorMessage = BizSystem::getMessage('SECURITYSVC_GET_DENIED');
                     return false;
                 } elseif (strtoupper($this->m_Action) == 'ALLOW') {
                     return true;
                 }
                 return false;
             }
         }
     }
 }
コード例 #3
0
ファイル: Configuration.php プロジェクト: que273/siremis
 /**
  * Returns the database info from <DataSource> defined in Config.xml as an array.
  * Returned array is a 2D map.
  * (DBName1 => ["Name"], ["Driver"], ["Server"], ["DBName"], ["User"], {"Password"])
  * (DBName2 => ["Name"], ["Driver"], ["Server"], ["DBName"], ["User"], {"Password"])
  * (...)
  * If DBName is given, returns the record only related to the given DBName,
  * otherwise returns all records
  *
  * @param string $dbName
  * @return array database information
  */
 public function getDatabaseInfo($dbName = null)
 {
     if ($dbName && $this->_databaseInfo[$dbName]) {
         return $this->_databaseInfo[$dbName];
     }
     if (!$this->_xmlArr["CONFIG"]["DATASOURCE"]) {
         $errMsg = BizSystem::getMessage("SYS_ERROR_NODBINFO");
         trigger_error($errMsg, E_USER_ERROR);
     }
     $breakFlag = false;
     foreach ($this->_xmlArr["CONFIG"]["DATASOURCE"]["DATABASE"] as $db) {
         if (array_key_exists('ATTRIBUTES', $this->_xmlArr["CONFIG"]["DATASOURCE"]["DATABASE"])) {
             $db = $this->_xmlArr["CONFIG"]["DATASOURCE"]["DATABASE"];
             $breakFlag = true;
         }
         $tmp["Name"] = $db["ATTRIBUTES"]["NAME"];
         $tmp["Driver"] = $db["ATTRIBUTES"]["DRIVER"];
         $tmp["Server"] = $db["ATTRIBUTES"]["SERVER"];
         $tmp["DBName"] = $db["ATTRIBUTES"]["DBNAME"];
         $tmp["User"] = $db["ATTRIBUTES"]["USER"];
         $tmp["Password"] = $db["ATTRIBUTES"]["PASSWORD"];
         $tmp["Port"] = isset($db["ATTRIBUTES"]["PORT"]) ? $db["ATTRIBUTES"]["PORT"] : null;
         $tmp["Charset"] = isset($db["ATTRIBUTES"]["CHARSET"]) ? $db["ATTRIBUTES"]["CHARSET"] : null;
         $tmp["Options"] = isset($db["ATTRIBUTES"]["OPTIONS"]) ? $db["ATTRIBUTES"]["OPTIONS"] : null;
         $this->_databaseInfo[$tmp["Name"]] = $tmp;
         if ($breakFlag) {
             break;
         }
     }
     if ($dbName && $this->_databaseInfo[$dbName]) {
         return $this->_databaseInfo[$dbName];
     }
     if ($dbName && !isset($this->_databaseInfo[$dbName])) {
         $errMsg = BizSystem::getMessage("DATA_INVALID_DBNAME", array($dbName, $dbName));
         trigger_error($errMsg, E_USER_ERROR);
     }
     if (!$dbName) {
         return $this->_databaseInfo;
     }
 }
コード例 #4
0
ファイル: Resource.php プロジェクト: Why-Not-Sky/cubi-ng
 /**
  * Get openbiz template file path by searching modules/package, /templates
  *
  * @param string $className
  * @return string php library file path
  * */
 public static function getTplFileWithPath($templateFile, $packageName)
 {
     //for not changing a lot things, the best injection point is added theme support here.
     $theme = Resource::getCurrentTheme();
     $themePath = $theme;
     // BizSystem::configuration()->GetThemePath($theme);
     if ($themePath) {
         $templateRoot = THEME_PATH . "/" . $themePath . "/template";
     } else {
         $templateRoot = SMARTY_TPL_PATH;
     }
     $names = explode(".", $packageName);
     if (count($names) > 0) {
         $moduleName = $names[0];
     }
     $packagePath = str_replace('.', '/', $packageName);
     // check the leading char '@'
     $checkExtModule = true;
     if (strpos($packagePath, '@') === 0) {
         $packagePath = substr($packagePath, 1);
         $checkExtModule = false;
     }
     $searchTpls = array(MODULE_PATH . "/{$packagePath}/template/{$templateFile}", dirname(MODULE_PATH . "/{$packagePath}") . "/template/{$templateFile}", MODULE_PATH . "/{$moduleName}/template/{$templateFile}", $templateRoot . "/{$templateFile}");
     if ($checkExtModule && defined('MODULE_EX_PATH')) {
         array_unshift($searchTpls, MODULE_EX_PATH . "/{$packagePath}/template/{$templateFile}");
     }
     // device
     if (defined('CLIENT_DEVICE')) {
         array_unshift($searchTpls, MODULE_PATH . "/{$moduleName}/template/" . CLIENT_DEVICE . "/{$templateFile}");
     }
     foreach ($searchTpls as $tplFile) {
         if (file_exists($tplFile)) {
             return $tplFile;
         }
     }
     $errmsg = BizSystem::getMessage("UNABLE_TO_LOCATE_TEMPLATE_FILE", array($templateFile));
     trigger_error($errmsg, E_USER_ERROR);
     return null;
 }
コード例 #5
0
ファイル: validateService.php プロジェクト: que273/siremis
 /**
  * Get error message
  *
  * @param string $validator
  * @param string $fieldName
  * @return string
  */
 public function getErrorMessage($validator = null, $fieldName = null)
 {
     if ($this->m_ErrorMessage != "") {
         if ($fieldName != "") {
             $this->m_ErrorMessage = str_replace($this->m_FieldNameMask, $fieldName, $this->m_ErrorMessage);
         }
         return $this->m_ErrorMessage;
     } else {
         $validator = str_replace('{@validate:', '', $validator);
         $pos1 = strpos($validator, '(');
         $type = substr($validator, 0, $pos1);
         switch ($type) {
             case "date":
                 return BizSystem::getMessage("VALIDATESVC_DATE_INVALID", array($fieldName));
                 break;
             case "email":
                 return BizSystem::getMessage("VALIDATESVC_EMAIL_INVALID", array($fieldName));
                 break;
             case "phone":
                 return BizSystem::getMessage("VALIDATESVC_PHONE_INVALID", array($fieldName));
                 break;
             case "zip":
                 return BizSystem::getMessage("VALIDATESVC_ZIP_INVALID", array($fieldName));
                 break;
             case "social":
                 return BizSystem::getMessage("VALIDATESVC_SOCIAL_INVALID", array($fieldName));
                 break;
             case "credit":
                 return BizSystem::getMessage("VALIDATESVC_CREDIT_INVALID", array($fieldName));
                 break;
             case "street":
                 return BizSystem::getMessage("VALIDATESVC_STREET_INVALID", array($fieldName));
                 break;
             case "strongPassword":
                 return BizSystem::getMessage("VALIDATESVC_PASSWORD_NOT_STRONG", array($fieldName));
                 break;
         }
         return BizSystem::getMessage("VALIDATESVC_INVALID", array($fieldName));
     }
 }
コード例 #6
0
ファイル: BizForm_Abstract.php プロジェクト: que273/siremis
 /**
  * Get display mode object
  *
  * @return DisplayMode
  */
 public final function GetDisplayMode()
 {
     if ($dispmode = $this->m_DisplayModes->get($this->m_Mode)) {
         return $dispmode;
     }
     foreach ($this->m_DisplayModes as $dispmode) {
         return $dispmode;
     }
     $errmsg = BizSystem::getMessage("BFM_ERROR_INVALID_DISPMODE", array($this->m_Name));
     trigger_error($errmsg, E_USER_ERROR);
 }
コード例 #7
0
ファイル: BizController.php プロジェクト: que273/siremis
 /**
  * Invoke the action passed from browser
  *
  * @return HTML content
  */
 protected function invoke()
 {
     //patched by jixian for fix ajax post data
     if (isset($_POST['__url'])) {
         $getUrl = parse_url($_POST['__url']);
         $query = $getUrl['query'];
         $parameter = explode('&', $query);
         foreach ($parameter as $param) {
             $data = explode('=', $param);
             $name = $data[0];
             $value = $data[1];
             $_GET[$name] = $value;
         }
     }
     $func = isset($_REQUEST['F']) ? $_REQUEST['F'] : "";
     $arg_list = array();
     $i = 0;
     if ($func != "") {
         eval("\$P{$i} = (isset(\$_REQUEST['P{$i}']) ? \$_REQUEST['P{$i}']:'');");
         $Ptmp = "P" . $i;
         if (strstr($P0, Popup_Suffix)) {
             $name_len = strlen($P0);
             $suffix_len = strlen(Popup_Suffix);
             $P0 = substr($P0, 0, $name_len - $suffix_len - 1) . "]";
         }
         while (${$Ptmp} != "") {
             $parm = ${$Ptmp};
             $parm = substr($parm, 1, strlen($parm) - 2);
             $arg_list[] = $parm;
             $i++;
             eval("\$P{$i} = (isset(\$_REQUEST['P{$i}']) ? \$_REQUEST['P{$i}']:'');");
             $Ptmp = "P" . $i;
         }
     } else {
         return;
     }
     global $g_BizSystem;
     if ($func != "RPCInvoke" && $func != "Invoke") {
         trigger_error("{$func} is not a valid invocation", E_USER_ERROR);
         return;
     }
     if ($func == "RPCInvoke") {
         BizSystem::clientProxy()->setRPCFlag(true);
     }
     // invoke the function
     $num_arg = count($arg_list);
     if ($num_arg < 2) {
         $errmsg = BizSystem::getMessage("SYS_ERROR_RPCARG", array($class));
         trigger_error($errmsg, E_USER_ERROR);
     } else {
         $objName = array_shift($arg_list);
         $methodName = array_shift($arg_list);
         $obj = BizSystem::getObject($objName);
         if ($obj) {
             if (method_exists($obj, $methodName)) {
                 if (!$this->validateRequest($obj, $methodName)) {
                     $errmsg = BizSystem::getMessage("SYS_ERROR_REQUEST_REJECT", array($obj->m_Name, $methodName));
                     trigger_error($errmsg, E_USER_ERROR);
                 }
                 switch (count($arg_list)) {
                     case 0:
                         $rt_val = $obj->{$methodName}();
                         break;
                     case 1:
                         $rt_val = $obj->{$methodName}($arg_list[0]);
                         break;
                     case 2:
                         $rt_val = $obj->{$methodName}($arg_list[0], $arg_list[1]);
                         break;
                     case 3:
                         $rt_val = $obj->{$methodName}($arg_list[0], $arg_list[1], $arg_list[2]);
                         break;
                     default:
                         $rt_val = call_user_func_array(array($obj, $methodName), $arg_list);
                 }
             } else {
                 $errmsg = BizSystem::getMessage("SYS_ERROR_METHODNOTFOUND", array($objName, $methodName));
                 trigger_error($errmsg, E_USER_ERROR);
             }
         } else {
             $errmsg = BizSystem::getMessage("SYS_ERROR_CLASSNOTFOUND", array($objName));
             trigger_error($errmsg, E_USER_ERROR);
         }
         if ($func == "Invoke") {
             if (BizSystem::clientProxy()->hasOutput()) {
                 BizSystem::clientProxy()->printOutput();
             }
         } else {
             if ($func == "RPCInvoke") {
                 if (BizSystem::clientProxy()->hasOutput()) {
                     if ($_REQUEST['jsrs'] == 1) {
                         echo "<html><body><form name=\"jsrs_Form\"><textarea name=\"jsrs_Payload\" id=\"jsrs_Payload\">";
                     }
                     BizSystem::clientProxy()->printOutput();
                     if ($_REQUEST['jsrs'] == 1) {
                         echo "</textarea></form></body></html>";
                     }
                 } else {
                     return $rt_val;
                 }
             }
         }
     }
 }
コード例 #8
0
ファイル: excelService.php プロジェクト: Why-Not-Sky/cubi-ng
 /**
  * Import from CSV file
  * NOTE: This method must be called from a popup form where a file is uploaded.
  *       The parent form of the popup form is the target to import.
  *
  * @param string $objName
  * @return void
  */
 public function importCSV($objName)
 {
     // read in file from $_FILE
     foreach ($_FILES as $file) {
         $error = $file['error'];
         if ($error != 0) {
             $this->reportError($error);
             return;
         }
         $tmpFileName = $file['tmp_name'];
         break;
     }
     //echo "upload file name = $tmpFileName";
     $filename = $file['name'];
     if (strpos($filename, ".csv") === false) {
         $errorMsg = BizSystem::getMessage("EXCELSVC_INVALID_FILE", array($filename));
         BizSystem::log(LOG_ERR, "EXCEL SERVICE", "Import error = " . $errorMsg);
         BizSystem::clientProxy()->showClientAlert($errorMsg);
         return;
     }
     /* @var $formObj EasyForm */
     $formObj = BizSystem::objectFactory()->getObject($objName);
     // get the existing EasyForm object
     $parentFormObj = BizSystem::objectFactory()->getObject($formObj->m_ParentFormName);
     $dataObj = $parentFormObj->getDataObj();
     $handle = fopen($tmpFileName, "r");
     $fields = fgetcsv($handle, 2000, ",");
     if (!$fields || count($fields) < 2) {
         $errorMsg = BizSystem::getMessage("EXCELSVC_INVALID_FILE", array($filename));
         BizSystem::log(LOG_ERR, "EXCEL SERVICE", "Import error = " . $errorMsg);
         BizSystem::clientProxy()->showClientAlert($errorMsg);
         return;
     }
     // convert form element names to DO field names
     foreach ($parentFormObj->m_DataPanel as $element) {
         $elem_fields[$element->m_Label] = $element->m_FieldName;
     }
     // validate with dataobj fields
     for ($i = 0; $i < count($fields); $i++) {
         $fields[$i] = $elem_fields[$fields[$i]];
         $field = $fields[$i];
         if (!$dataObj->getField($field)) {
             $errorMsg = BizSystem::getMessage("EXCELSVC_INVALID_COLUMN", array($field, $dataObj->m_Name));
             BizSystem::log(LOG_ERR, "EXCEL SERVICE", "Import error = " . $errorMsg);
             BizSystem::clientProxy()->showClientAlert($errorMsg);
             return;
         }
     }
     while (($arr = fgetcsv($handle, 2000, ",")) !== FALSE) {
         if (count($arr) != count($fields)) {
             continue;
         }
         unset($recArr);
         $i = 0;
         for ($i = 0; $i < count($arr); $i++) {
             $recArr[$fields[$i]] = $arr[$i];
         }
         //print_r($recArr); echo "<hr>";
         $dataRec = new DataRecord(null, $dataObj);
         foreach ($recArr as $k => $v) {
             $dataRec[$k] = $v;
         }
         $ok = $dataRec->save();
         if (!$ok) {
             // NOTE: EasyForm::processDataObjError() not return any value (void)
             return $formObj->processDataObjError($ok);
         }
     }
     fclose($handle);
     // in case of popup form, close it, then rerender the parent form
     if ($formObj->m_ParentFormName) {
         $formObj->close();
         $formObj->renderParent();
     }
 }
コード例 #9
0
ファイル: BizDataObj.php プロジェクト: Why-Not-Sky/cubi-ng
 public function deleteRecords($condition = null)
 {
     if (!$this->canDeleteRecordCondition()) {
         throw new BDOException(BizSystem::getMessage("DATA_NO_PERMISSION_DELETE", $this->m_Name));
         return false;
     }
     $sql = $this->getSQLHelper()->buildDeleteSQLwithCondition($this, $condition);
     $db = $this->getDBConnection("WRITE");
     try {
         if ($sql) {
             // delete joint table first then delete main table's data'
             BizSystem::log(LOG_DEBUG, "DATAOBJ", "Delete Sql = {$sql}");
             $db->query($sql);
         }
     } catch (Exception $e) {
         BizSystem::log(LOG_ERR, "DATAOBJ", "Query error : " . $e->getMessage());
         $db->rollBack();
         //if one failed then rollback all
         $this->m_ErrorMessage = $this->getMessage("DATA_ERROR_QUERY") . ": " . $sql . ". " . $e->getMessage();
         throw new BDOException($this->m_ErrorMessage);
         return false;
     }
     //clean cached data
     $this->cleanCache();
     return true;
 }
コード例 #10
0
ファイル: Resource.php プロジェクト: que273/siremis
 /**
  * Get openbiz template file path by searching modules/package, /templates
  *
  * @param string $className
  * @return string php library file path
  **/
 public static function getTplFileWithPath($templateFile, $packageName)
 {
     //for not changing a lot things, the best injection point is added theme support here.
     $theme = isset($_GET['theme']) ? $_GET['theme'] : THEME_NAME;
     $themePath = $theme;
     // BizSystem::configuration()->GetThemePath($theme);
     if ($themePath) {
         $templateRoot = THEME_PATH . "/" . $themePath . "/template";
     } else {
         $templateRoot = SMARTY_TPL_PATH;
     }
     $names = explode(".", $packageName);
     if (count($names) > 0) {
         $moduleName = $names[0];
     }
     $packagePath = str_replace('.', '/', $packageName);
     $searchTpls = array(MODULE_PATH . "/{$packagePath}/template/{$templateFile}", dirname(MODULE_PATH . "/{$packagePath}") . "/template/{$templateFile}", MODULE_PATH . "/{$moduleName}/template/{$templateFile}", $templateRoot . "/{$templateFile}");
     foreach ($searchTpls as $tplFile) {
         if (file_exists($tplFile)) {
             return $tplFile;
         }
     }
     $errmsg = BizSystem::getMessage("UNABLE_TO_LOCATE_TEMPLATE_FILE", array($templateFile));
     trigger_error($errmsg, E_USER_ERROR);
     return null;
 }