/** * Openbiz Cubi Application Platform * * LICENSE http://code.google.com/p/openbiz-cubi/wiki/CubiLicense * * @package \ * @copyright Copyright (c) 2005-2011, Openbiz Technology LLC * @license http://code.google.com/p/openbiz-cubi/wiki/CubiLicense * @link http://code.google.com/p/openbiz-cubi/ * @version $Id: license_exception.php 5261 2013-01-23 07:00:16Z hellojixian@gmail.com $ */ function ioncube_event_handler($err_code, $params) { $current_file = $params['current_file']; $current_file = str_replace(Openbiz::$app->getModulePath(), "", $current_file); preg_match("|[\\\\/]?(.*?)[\\\\/]{1}|si", $current_file, $matches); $moduleName = $matches[1]; Openbiz::$app->getSessionContext()->setVar("LIC_SOURCE_URL", $_SERVER['REQUEST_URI']); Openbiz::$app->getSessionContext()->setVar("LIC_MODULE", $moduleName); $rh_file = Openbiz::$app->getModulePath() . DIRECTORY_SEPARATOR . $moduleName . DIRECTORY_SEPARATOR . 'register_handler.php'; $rh_func = false; if (is_file($rh_file)) { include_once $rh_file; if (function_exists($moduleName . "_register_handler")) { $rh_func = true; } } $lic_file = Openbiz::$app->getModulePath() . DIRECTORY_SEPARATOR . $moduleName . DIRECTORY_SEPARATOR . 'license.key'; if (!is_file($lic_file) && $rh_func) { $formObj = Openbiz::getObject("common.form.LicenseInitializeForm"); $formObj->sourceURL = $_SERVER['REQUEST_URI']; $formObj->errorCode = $err_code; $formObj->errorParams = $params; $viewObj = Openbiz::getObject("common.view.LicenseInitializeView"); $viewObj->render(); } else { $formObj = Openbiz::getObject("common.form.LicenseInvalidForm"); $formObj->sourceURL = $_SERVER['REQUEST_URI']; $formObj->errorCode = $err_code; $formObj->errorParams = $params; $viewObj = Openbiz::getObject("common.view.LicenseInvalidView"); $viewObj->render(); } exit; }
protected function executeJob($cronRecord) { $name = $cronRecord['name']; $maxRun = $cronRecord['max_run']; $numRun = $this->getRealNumRun($cronRecord); $command = $cronRecord['command']; $message = "To execute cron job name={$name}, maxrun={$maxRun}, numrun={$numRun}"; $this->log($cronRecord, $message); // check job max_run and num_run if ($cronRecord['max_run'] <= 0 || $cronRecord['max_run'] <= $numRun) { $this->log($cronRecord, "Skip cron job {$name} due to reaching maxrun"); return; } // mark job num_run++ $this->updateNumRun($cronRecord, true); // execute the command and write log $command = Expression::evaluateExpression($command, null); $output = array(); exec($command, $output); foreach ($output as $out) { $outputStr .= $out . "\n"; } $this->log($cronRecord, "Exec results of '{$command}'\n" . $outputStr); // mark job num_run-- $this->updateNumRun($cronRecord, false); // send email $emails = trim($cronRecord['sendmail']); if ($emails != "") { $this->log($cronRecord, "Send job output to '{$emails}'"); $emailService = Openbiz::getObject(self::emailService); $emailService->CronJobEmail($emails, $name, $outputStr); } }
/** * 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 = Openbiz::$app->getClientProxy()->getFormInputs("__this"); // get the current UI bizobj $formObj = Openbiz::getObject($objName); // get the existing bizform object $bizDataObj = $formObj->getDataObj(); // get chart config xml file $chartXmlFile = ObjectFactoryHelper::getXmlFileWithPath($objName . "_chart"); $xmlArr = ObjectFactoryHelper::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; } } } }
public function getLocationInfo($id) { $locationRec = Openbiz::getObject("backup.do.BackupDeviceDO")->fetchById($id); if ($locationRec) { $this->folder = Expression::evaluateExpression($locationRec['location'], null); $this->folder = Expression::evaluateExpression($locationRec['location'], null); } }
public function loadDialog($formName = null, $id = null) { $formObj1 = Openbiz::getObject($formName); $formObj1->setRecordId($id); //$formObj1->setParentForm($this->formObj->objectName); $output = $formObj1->render(); if (!empty($output)) { Openbiz::$app->getClientProxy()->redrawForm("DIALOG", $output); } }
protected function inheritParentObj() { if (!$this->inheritFrom) { return; } $parentObj = Openbiz::getObject($this->inheritFrom); parent::inheritParentObj(); $this->range = $this->range ? $this->range : $parentObj->range; $this->fixSearchRule = $this->fixSearchRule ? $this->fixSearchRule : $parentObj->fixSearchRule; $this->defaultFixSearchRule = $this->defaultFixSearchRule ? $this->defaultFixSearchRule : $parentObj->defaultFixSearchRule; }
/** * Render the pdf output * * @global BizSystem $g_BizSystem * @param string $viewName name of view object * @return void */ public function renderView($viewName) { $viewObj = Openbiz::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"); } }
/** * Process URL to get the form param and add the form in the FormRefs * * @return void */ protected function processURL() { // if url has form=... $paramForm = isset($_GET['form']) ? $_GET['form'] : null; $paramCForm = isset($_GET['cform']) ? $_GET['cform'] : null; if (!$paramForm) { return; } // add the form in FormRefs if ($paramForm) { if ($this->isInFormRefLibs($paramForm)) { $xmlArr["ATTRIBUTES"]["NAME"] = $paramForm; $xmlArr["ATTRIBUTES"]["SUBFORMS"] = $paramCForm ? $paramCForm : ""; $formRef = new FormReference($xmlArr); $this->formRefs->set($paramForm, $formRef); if ($paramCForm) { if ($this->isInFormRefLibs($paramCForm)) { $xmlArr["ATTRIBUTES"]["NAME"] = $paramCForm; $xmlArr["ATTRIBUTES"]["SUBFORMS"] = ""; $cformRef = new FormReference($xmlArr); $this->formRefs->set($paramCForm, $cformRef); } } } } // check url arg as fld:name=val $getKeys = array_keys($_GET); $paramFields = null; foreach ($getKeys as $key) { if (substr($key, 0, 4) == "fld:") { $fieldName = substr($key, 4); $fieldValue = $_GET[$key]; $paramFields[$fieldName] = $fieldValue; } } if (!$paramFields) { return; } $paramForm = $this->prefixPackage($paramForm); $formObj = Openbiz::getObject($paramForm); $formObj->setRequestParams($paramFields); }
/** * Audit DataObj * * @param string $dataObjName * @return boolean * @todo all return false? really? */ public function audit($dataObjName) { // get audit dataobj $auditDataObj = Openbiz::getObject($this->auditDataObj); if (!$auditDataObj) { return false; } // get the source dataobj $srcDataObj = Openbiz::getObject($dataObjName); if (!$srcDataObj) { return false; } // for each onaudit field, add a record in audit dataobj $auditFields = $srcDataObj->getOnAuditFields(); foreach ($auditFields as $field) { if ($field->oldValue == $field->value) { continue; } $recArr = $auditDataObj->newRecord(); if ($recArr == false) { Openbiz::$app->getLog()->log(LOG_ERR, "DATAOBJ", $auditDataObj->getErrorMessage()); return false; } $profile = Openbiz::$app->getUserProfile(); $recArr['DataObjName'] = $dataObjName; $recArr['ObjectId'] = $srcDataObj->getFieldValue("Id"); $recArr['FieldName'] = $field->objectName; $recArr['OldValue'] = $field->oldValue; $recArr['NewValue'] = $field->value; $recArr['ChangeTime'] = date("Y-m-d H:i:s"); $recArr['ChangeBy'] = $profile["USERID"]; $recArr['ChangeFrom'] = $_SERVER['REMOTE_ADDR']; $recArr['RequestURI'] = $_SERVER['REQUEST_URI']; $recArr['Timestamp'] = date("Y-m-d H:i:s"); $ok = $auditDataObj->insertRecord($recArr); if ($ok == false) { Openbiz::$app->getLog()->log(LOG_ERR, "DATAOBJ", $auditDataObj->getErrorMessage()); return false; } } }
#!/usr/bin/env php <?php /* * Cubi license acquisition */ include_once "../app_init.php"; if (!defined("CLI")) { exit; } $licenseClient = "service.licenseClient"; // get package service //echo "get license client service"; $licsvc = Openbiz::getObject($licenseClient); $activationCode = "hacq2b"; $contactEmail = "*****@*****.**"; $serverData = ""; //base64_encode(ioncube_server_data()); $license = $licsvc->acquireLicense($activationCode, $contactEmail, $serverData); print_r($license);
#!/usr/bin/env php <?php /* * Cubi package discovery */ include_once "../app_init.php"; if (!defined("CLI")) { exit; } $packageService = "package.lib.PackageService"; // get package service $pkgsvc = Openbiz::getObject($packageService); $categories = $pkgsvc->discoverCategories(); print_r($categories); $packages = $pkgsvc->discoverPackages(); print_r($packages); //$pkgsvc->downloadPackage('grm');
/** * Log that an email attemp was made. * We assume it was successfull, since \Zend_Mail throws an exception otherwise * * @param string $subject * @param array $To * @param array $CCs * @param array $BCCs * @return mixed boolean|string|void */ public function logEmail($result, $subject, $body = NULL, $TOs = NULL, $CCs = NULL, $BCCs = NULL) { //Log the email attempt $recipients = ''; // add TO addresses if ($TOs) { foreach ($TOs as $to) { if (is_array($to)) { $recipients .= $to['name'] . "<" . $to['email'] . ">;"; } else { $recipients .= $to . ";"; } } } // add CC addresses if ($CCs) { foreach ($CCs as $cc) { if (is_array($cc)) { $recipients .= $cc['name'] . "<" . $cc['email'] . ">;"; } else { $recipients .= $cc . ";"; } } } // add BCC addresses if ($BCCs) { foreach ($BCCs as $bcc) { if (is_array($bcc)) { $recipients .= $bcc['name'] . "<" . $bcc['email'] . ">;"; } else { $recipients .= $bcc . ";"; } } } if ($this->_logType == 'DB') { $account = $this->accounts->get($this->useAccount); $sender_name = $account->fromName; $sender = $account->fromEmail; // Store the message log $boMessageLog = Openbiz::getObject($this->_logObject); $mlArr = $boMessageLog->newRecord(); $mlArr["sender"] = $sender; $mlArr["sender_name"] = $sender_name; $mlArr["recipients"] = $recipients; $mlArr["subject"] = $subject; $mlArr["content"] = $body; $mlArr["result"] = $result; /* * as long as data could read from db, its no longer need to addslashes //Escape Data since this may contain quotes or other goodies foreach ($mlArr as $key => $value) { $mlArr[$key] = addslashes($value); } */ $ok = $boMessageLog->insertRecord($mlArr); if (!$ok) { return $boMessageLog->getErrorMessage(); } else { return TRUE; } } else { $back_trace = debug_backtrace(); if ($result == 'Success') { $logNum = LOG_INFO; } else { $logNum = LOG_ERR; } Openbiz::$app->getLog()->log($logNum, "EmailService", "Sent email with subject - \"{$subject}\" and body - {$body} to - {$recipients} with result {$result}.", NULL, $back_trace); } }
/** * Render the html tabs * * @global BizSystem $g_BizSystem * @return string html content of the tabs */ public function render() { $curView = Openbiz::$app->getCurrentViewName(); $curViewobj = $curView ? Openbiz::getObject($curView) : null; $profile = Openbiz::$app->getUserProfile(); $svcobj = Openbiz::getService(ACCESS_SERVICE); $role = isset($profile["ROLE"]) ? $profile["ROLE"] : null; // list all views and highlight the current view // pass $tabs(caption, url, target, icon, current) to template $smarty = TemplateHelper::getSmartyTemplate(); $tabs = array(); $i = 0; $hasForms = false; foreach ($this->tabViews as $tview) { // tab is renderd if no definition is found in accessservice.xml (default) if ($svcobj->allowViewAccess($tview->view, $role)) { $tabs[$i]['name'] = $tview->objectName; //Name of each tab--jmmz $tabs[$i]['forms'] = $this->_renderJSCodeForForms($tview->forms); //Configuration of the forms to hide or show--jmmz $tabs[$i]['caption'] = $tview->caption; $tabs[$i]['url'] = $this->_renderURL($tview); //Call the method to render the url--jmmz //If I have forms to hide or show I add the event because I don't need an URL, I need an event if ((bool) $tview->hasForms()) { $tabs[$i]['event'] = $tabs[$i]['url']; //Assign The url rendered to the event on click $tabs[$i]['url'] = 'javascript:void(0)'; //If I put url in '' then the href want send me to another direction $this->setCurrentTabInSession($tview, $curViewobj, $curView); //I set the current tab wrote in session $hasForms = TRUE; } $tabs[$i]['target'] = $tview->target; $tabs[$i]['icon'] = $tview->icon; $tabs[$i]['current'] = $this->isCurrentTab($tview, $curViewobj, $curView); //I get the current tab. $i++; } } $this->setClientScripts($tabs, $hasForms); $smarty->assign("tabs", $tabs); $smarty->assign("tabs_Name", $this->objectName); return $smarty->fetch(TemplateHelper::getTplFileWithPath($this->templateFile, $this->package)); }
echo "usage: php link_do.php child_do parent_do" . PHP_EOL; exit; } $do1name = $argv[1]; $do2name = $argv[2]; include_once dirname(dirname(__FILE__)) . "/app_init.php"; include_once Openbiz::$app->getModulePath() . "/tool/lib/DomMeta.php"; if (!defined("CLI")) { exit; } $moduleDir = Openbiz::$app->getModulePath() . DIRECTORY_SEPARATOR . str_replace(".", DIRECTORY_SEPARATOR, $module); // read do1 $do1 = Openbiz::getObject($do1name); $do1Table = $do1->mainTableName; // read do2 $do2 = Openbiz::getObject($do2name); $do2Table = $do2->mainTableName; $fkCol = ""; foreach ($do1->bizRecord as $field) { if ($field->column == "{$do2name}" . "_id") { $fkCol = $field->column; } } if ($fkCol != null) { echo "{$do1name} has foreign key column pointing to {$do2name}: {$fkCol}\n"; } else { echo "Select the '{$do1Table}' foreign key column pointing to '{$do2Table}':\n"; $i = 1; foreach ($do1->bizRecord as $field) { if (stripos($field->column, "id") !== false && $field->objectName != "Id") { echo "\t{$i}. {$field->objectName} ({$field->column})\n";
/** * Add a record (popup) to the parent form if OK button clicked, (M-M or M-1/1-1) * * @return void */ public function addToParent($recIds = null) { if (!is_array($recIds)) { $recIdArr = array(); $recIdArr[] = $recIds; } else { $recIdArr = $recIds; } /* @var $parentForm EasyForm */ $parentForm = Openbiz::getObject($this->parentFormName); foreach ($recIdArr as $recId) { //clear parent form search rules $this->searchRule = ""; $parentForm->getDataObj()->clearSearchRule(); $do = $this->getDataObj(); $baseSearchRule = $do->baseSearchRule; $do->baseSearchRule = ""; $do->clearSearchRule(); $rec = $do->fetchById($recId); $do->baseSearchRule = $baseSearchRule; if (!$rec) { $rec = Openbiz::getObject($do->objectName, 1)->fetchById($recId); } // add record to parent form's dataObj who is M-M or M-1/1-1 to its parent dataobj $ok = $parentForm->getDataObj()->addRecord($rec, $bPrtObjUpdated); if (!$ok) { return $parentForm->processDataObjError($ok); } } $this->close(); $parentForm->rerender(); if ($parentForm->parentFormName) { $parentForm->renderParent(); } }
/** * Import from XML file, the file read from client (uploaded by user) * * @param string $objName * @return void */ public function importXML($objName) { // read in file from $_FILE // read in file data and attributes foreach ($_FILES as $file) { $error = $file['error']; if ($error != 0) { $this->reportError($error); return; } $tmpName = $file['tmp_name']; $xml = simplexml_load_file($tmpName); if (!$xml) { $errorMsg = "Invalid input data format, could not create xml object."; Openbiz::$app->getClientProxy()->showErrorMessage($errorMsg); return; } // only read the first one break; } // get the current UI bizobj /* @var $form EasyForm */ $form = Openbiz::getObject($objName); // get the existing bizform object /* @var $parentForm EasyForm */ $parentForm = Openbiz::getObject($form->GetParentForm()); /* @var $dataObj BizDataObj */ $dataObj = $parentForm->getDataObj(); //$oldCacheMode = $dataObj->GetCacheMode(); //$dataObj->SetCacheMode(0); // turn off cache mode, not affect the current cache // check if BizDataObj name matches $dataObjName = $xml['Name']; if ($dataObj->objectName != ${$dataObjName}) { $errorMsg = "Invalid input data. Input data object is not same as the current data object."; Openbiz::$app->getClientProxy()->showErrorMessage($errorMsg); return; } // read records foreach ($xml->Record as $record) { // insert record // todo: check if there's same user keys in the table $recArray = null; $recArray = $dataObj->newRecord(); foreach ($record as $field) { $value = ""; foreach ($field->attributes() as $attributeName => $attributeValue) { if ($attributeName == 'Name') { $name = $attributeValue . ""; } else { if ($attributeName == 'Value') { $value = $attributeValue . ""; } } } if ($name != "Id") { $recArray[$name] = $value; } } if (!$dataObj->insertRecord($recArray)) { $errorMsg = $dataObj->getErrorMessage(); Openbiz::$app->getClientProxy()->showErrorMessage($errorMsg); return; } } $form->setFormState(1); // indicate the import is done }
/** * Cancel, clean up the sessions of view and all forms * * @return void */ public function cancel() { // call all step forms Cancel method if (is_array($this->formStates)) { foreach ($this->formStates as $formName => $state) { if ($state['visited']) { Openbiz::getObject($formName)->cancel(); } } } $this->dropSession = true; }
protected function prepareSubFormsDataObj() { if ($this->subForms && $this->getDataObj()) { foreach ($this->subForms as $subForm) { $formObj = Openbiz::getObject($subForm); $dataObj = $this->getDataObj()->getRefObject($formObj->dataObjName); if ($dataObj) { $formObj->setDataObj($dataObj); } } } }
/** * Audit trail * * @param array $argList * @return void */ protected function auditTrail($argList) { $auditServiceName = $argList["AuditService"]; $auditService = Openbiz::getObject($auditServiceName); if ($auditService == null) { return; } $dataObjName = $argList["DataObjectName"]; $ok = $auditService->audit($dataObjName); if ($ok == false) { // log $auditSvc->getErrorMsg(); } }
private static function _removeRecord1toM($dataObj, $recArr) { $column = $dataObj->association['Column']; $field = $dataObj->getFieldNameByColumn($column); $column2 = $dataObj->association['Column2']; $field2 = $dataObj->getFieldNameByColumn($column2); $newRecArr["Id"] = $recArr["Id"]; $newRecArr[$field] = ''; if ($field2) { $newRecArr[$field2] = ''; } $cond_column = $dataObj->association['CondColumn']; $cond_value = $dataObj->association['CondValue']; if ($cond_column) { $cond_field = $dataObj->getFieldNameByColumn($cond_column); $newRecArr[$cond_field] = $cond_value; } $ok = Openbiz::getObject($dataObj->objectName, 1)->updateRecord($newRecArr, $recArr); if ($ok == false) { return false; } // requery on this object return true; }
$app = \Slim\Slim::getInstance(); // forward to module rest service implementation $restServiceName = $module . ".websvc." . "RestService"; $restSvc = Openbiz::getObject($restServiceName); $restSvc->get($resource, $id, $app->request(), $app->response()); }); // POST request $app->post('/:module/:resource', function ($module, $resource) { $app = \Slim\Slim::getInstance(); // forward to module rest service implementation $restServiceName = $module . ".websvc." . "RestService"; $restSvc = Openbiz::getObject($restServiceName); $restSvc->post($resource, $app->request(), $app->response()); }); // PUT request $app->put('/:module/:resource/:id', function ($module, $resource, $id) { $app = \Slim\Slim::getInstance(); // forward to module rest service implementation $restServiceName = $module . ".websvc." . "RestService"; $restSvc = Openbiz::getObject($restServiceName); $restSvc->put($resource, $id, $app->request(), $app->response()); }); // DELETE request $app->delete('/:module/:resource/:id', function ($module, $resource, $id) { $app = \Slim\Slim::getInstance(); // forward to module rest service implementation $restServiceName = $module . ".websvc." . "RestService"; $restSvc = Openbiz::getObject($restServiceName); $restSvc->delete($resource, $id, $app->request(), $app->response()); }); $app->run();
/** * Authenticate User that stored in database * * @param string $userName * @param string $password * @return boolean */ protected function authDBUser($userName, $password) { $boAuth = Openbiz::getObject($this->authticationDataObj); if (!$boAuth) { return false; } $searchRule = "[login]='{$userName}'"; $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; }
$inputs = explode("/", $url); $module = $inputs[0]; $service = isset($inputs[1]) ? $inputs[1] : $_REQUEST['service']; if (isset($inputs[2]) && !preg_match("/^\\?.*/si", $inputs[2])) { //http://local.openbiz.me/ws.php/oauth/callback/login/?type=qzone $_REQUEST['method'] = $inputs[2]; } if (count($inputs) >= 3) { for ($i = 3; $i < count($inputs); $i++) { $param = $inputs[$i]; if ($param) { preg_match("/^(.*?)_(.*)\$/s", $param, $match); $key = $match[1]; $value = $match[2]; $_REQUEST[$key] = $value; } } } ErrorHandler::$errorMode = 'text'; if ($module && $service) { if (!preg_match("/Service\$/s", $service)) { $service .= "Service"; } $websvc = $module . ".websvc." . $service; // get service object $svcObj = Openbiz::getObject($websvc); // invoke the method $svcObj->invoke(); } else { echo "Openbiz Webservice Ready!"; }
/** * Get raw data to display in the spreadsheet. header and data table * * @param string $objName * @return array */ protected function getDataTable($objName) { /* @var $formObj EasyForm */ $formObj = Openbiz::getObject($objName); // get the existing EasyForm|BizForm object // if BizForm, call BizForm::renderTable if ($formObj instanceof BizForm) { $dataTable = $formObj->renderTable(); } // if EasyForm, call EasyForm->DataPanel::renderTable if ($formObj instanceof EasyForm) { $recordSet = $formObj->fetchDataSet(); $dataSet = $formObj->dataPanel->renderTable($recordSet); foreach ($dataSet['elems'] as $elem) { $labelRow[] = $elem['label']; } $dataTable = array_merge(array($labelRow), $dataSet['data']); } return $dataTable; }
<?php include_once dirname(dirname(__FILE__)) . "/app_init.php"; if (!defined("CLI")) { exit; } foreach ($argv as $arg) { if (preg_match("/-p(.*)/si", $arg, $match)) { $password_preset = trim($match[1]); } } echo "Authentication Required: " . PHP_EOL; $do = "system.do.UserDO"; $do = Openbiz::getObject($do); $adminRec = $do->fetchById(1); $username = $adminRec['username']; $password = $adminRec['password']; echo "Your password will not prompted in below" . PHP_EOL; echo "Username: [ {$username} ]" . PHP_EOL; echo "Password: "******"" . PHP_EOL; $svcobj = Openbiz::getService(AUTH_SERVICE); $result = $svcobj->authenticateUser($username, $password_preset); if ($result) { echo "Authentication Sucessed! " . PHP_EOL; echo "Access Grant! " . PHP_EOL; break; } else {
/** * render the report output * * @param string $objName object name which is the bizform name * @return void */ public function render($objName) { // get the current UI bizobj $bizform = Openbiz::getObject($objName); // get the existing bizform object $bizobj = $bizform->getDataObj(); $h = opendir($this->targetReportPath); if (!$h) { echo "cannot read dir " . $this->targetReportPath; exit; } // create a tmp csv file for hold the data, then feed csv file to report engine $uid = $this->getUniqueString(); $tmpfname = $this->targetReportPath . $uid . ".csv"; //echo "csv file is at $tmpfname.<br>"; $fp = fopen($tmpfname, 'w'); $keyList = $bizform->recordRow->GetSortControlKeys(); $fieldNames = array(); foreach ($keyList as $key) { $fieldNames[] = $bizform->GetControl($key)->bizFieldName; } fputcsv($fp, $fieldNames); $recList = $bizobj->directFetch(); foreach ($recList as $recArray) { unset($fieldValues); $fieldValues = array(); $line = ""; foreach ($keyList as $key) { $fieldValues[] = $recArray[$bizform->GetControl($key)->bizFieldName]; } fputcsv($fp, $fieldValues); } fclose($fp); $i = 0; foreach ($keyList as $key) { $rpt_fields[$i]["name"] = $bizform->GetControl($key)->bizFieldName; $rpt_fields[$i]["type"] = $bizobj->getField($rpt_fields[$i]["name"])->type; $i++; } // dataobj.rptdesign.tpl // $rpt_data_dir, $rpt_title, $rpt_csv_file, $rpt_fields[](name,type) $smarty = TemplateHelper::getSmartyTemplate(); $smarty->assign("rpt_data_dir", $this->targetReportPath); $smarty->assign("rpt_title", $bizform->title); $smarty->assign("rpt_csv_file", basename($tmpfname)); $smarty->assign("rpt_fields", $rpt_fields); $reportContent = $smarty->fetch($this->rptTemplate); $tmpRptDsgn = $this->targetReportPath . $uid . ".rptdesign"; //echo "temp rpt design file is at $tmpRptDsgn.<br>"; $fp = fopen($tmpRptDsgn, 'w'); fwrite($fp, $reportContent); fclose($fp); ob_clean(); $designFileName = $uid . ".rptdesign"; $content = "<div style='font-family:Arial; font-size:12px; background-color:#FCFCFC;'>"; $content .= "Reports can be viewed as "; $content .= "<li><a href='" . $this->birtViewer . "/run?__report=report\\{$designFileName}' target='__blank'>HTML report</a></li>"; $content .= "<li><a href='" . $this->birtViewer . "/run?__report=report\\{$designFileName}&__format=pdf' target='__blank'>PDF report</a></li>"; $content .= "<li><a href='" . $this->birtViewer . "/frameset?__report=report\\{$designFileName}' target='__blank'>Interactive report</a></li>"; $content .= "</div>"; echo $content; exit; }