예제 #1
0
 public function send($mobile, $content, $schedule = null)
 {
     $providerInfo = $this->_getProviderInfo();
     $CorpID = $providerInfo['username'];
     $Pwd = $providerInfo['password'];
     if ($schedule == "0000-00-00 00:00:00") {
         $schedule = '';
     } else {
         $schedule = date('YmdHis', strtotime($schedule));
     }
     $mobile_log = $mobile;
     $content_log = $content;
     $mobile = urlencode($mobile);
     $content = urlencode(iconv("UTF-8", "GBK", $content));
     $url = $this->url . "BatchSend?CorpID={$CorpID}&Pwd={$Pwd}&Mobile={$mobile}&Content={$content}&Cell=&SendTime={$schedule}";
     $result = file_get_contents($url);
     preg_match("/\">(.*?)<\\/int/si", $result, $match);
     $result = (int) $match[1];
     if ($result < 0) {
         Openbiz::getService(LOG_SERVICE)->log(LOG_ERR, "SMS", "sendMessage: " . $content . " TCLK:" . $mobile . ':' . $result['msg']);
         return false;
     } else {
         $this->HitMessageCounter();
         $this->_log($mobile_log, $content_log, $schedule);
         return true;
     }
 }
예제 #2
0
 public function getSystemUserData($sendContact = 1)
 {
     //sendContact = 0 ; don't send contact info
     //sendContact = 1 ; send contact info
     $contactRec = array();
     if ($sendContact) {
         $profileId = Openbiz::$app->getUserProfile("profile_Id");
         $recArr = Openbiz::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 = OPENBIZ_DEFAULT_SYSTEM_NAME;
     $system_language = OPENBIZ_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;
 }
예제 #3
0
 public function fetchData()
 {
     $result = Openbiz::getService("payment.lib.PaymentService")->getReturnData($_GET['type']);
     $txn_id = $result['txn_id'];
     $verify = Openbiz::getService("payment.lib.PaymentService")->validateNotification($_GET['type'], $txn_id);
     return $result;
 }
예제 #4
0
 public function postLoadingModule($moduelLoader)
 {
     $roleRec = Openbiz::getObject("system.do.RoleDO")->fetchOne("[name]='Collaboration Admin'");
     $adminRoleId = $roleRec['Id'];
     $roleRec = Openbiz::getObject("system.do.RoleDO")->fetchOne("[name]='Data Manager'");
     $managerRoleId = $roleRec['Id'];
     $roleRec = Openbiz::getObject("system.do.RoleDO")->fetchOne("[name]='Data Assigner'");
     $assignerRoleId = $roleRec['Id'];
     //set up acls for Data assigner
     $actionList = Openbiz::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);
         Openbiz::getObject("system.do.AclRoleActionDO")->insertRecord($aclRecord);
         $aclRecord = array("role_id" => $managerRoleId, "action_id" => $actionId, "access_level" => 1);
         Openbiz::getObject("system.do.AclRoleActionDO")->insertRecord($aclRecord);
     }
     //set up acls for Data manager
     $actionList = Openbiz::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);
         Openbiz::getObject("system.do.AclRoleActionDO")->insertRecord($aclRecord);
     }
     //delete data manage permission from admin
     $actionRec = Openbiz::getObject("system.do.AclActionDO")->fetchOne("[module]='common' AND [resource]='data_manage' AND [action]='manage'");
     $actionId = $actionRec['Id'];
     Openbiz::getObject("system.do.AclRoleActionDO", 1)->deleteRecords("[role_id]='{$adminRoleId}' AND [action_id]='{$actionId}'");
 }
 protected function parseName($name)
 {
     $svcobj = Openbiz::getService("service.chineseService");
     if ($svcobj->isChinese($name)) {
         $fast_index = $svcobj->Chinese2Pinyin($name);
     } else {
         $fast_index = $recArr['display_name'];
     }
     $nameArr['fast_index'] = substr($fast_index, 0, 1);
     $nameArr['display_name'] = $name;
     if ($svcobj->isChinese($name)) {
         //chinese name
         switch (mb_strlen($name, 'UTF-8')) {
             case 5:
             case 4:
                 $nameArr['last_name'] = mb_substr($name, 0, 2, 'UTF-8');
                 $nameArr['first_name'] = mb_substr($name, 2, mb_strlen($name, 'UTF-8') - 1, 'UTF-8');
                 break;
             default:
                 $nameArr['last_name'] = mb_substr($name, 0, 1, 'UTF-8');
                 $nameArr['first_name'] = mb_substr($name, 1, mb_strlen($name, 'UTF-8') - 1, 'UTF-8');
                 break;
         }
     } else {
         //english name
         if (preg_match("/(\\S*?)\\s(\\S*)/si", $name, $match)) {
             $nameArr['last_name'] = $match[1];
             $nameArr['first_name'] = $match[2];
         }
     }
     return $nameArr;
 }
 public function Finish()
 {
     $recArr = $this->readInputRecord();
     if (count($recArr) == 0) {
         return;
     }
     $user_id = Openbiz::$app->getUserProfile("Id");
     $contactImportDO = Openbiz::getObject("contact.do.ContactImportDO");
     //process data operation
     $data_operation = $recArr['data_operation'];
     switch ($data_operation) {
         case "0":
             break;
         case "1":
             $contactImportDO->deleteRecords("[user_id]='{$user_id}' AND [selected]='1'");
             break;
         case "2":
             $contactImportDO->deleteRecords("[user_id]='{$user_id}'");
             break;
     }
     if ($this->parentFormName) {
         $this->close();
         $this->renderParent();
     }
     $this->processPostAction();
 }
 protected function _remoteCall($method, $params = null)
 {
     $uri = $this->reportServer;
     $cache_id = md5($this->objectName . $uri . $method . serialize($params));
     $cacheSvc = Openbiz::getService(CACHE_SERVICE, 1);
     $cacheSvc->init($this->objectName, $this->cacheLifeTime);
     if (substr($uri, strlen($uri) - 1, 1) != '/') {
         $uri .= '/';
     }
     $uri .= "ws.php/udc/CollectService";
     if ($cacheSvc->test($cache_id) && (int) $this->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;
 }
예제 #8
0
 public function insertToParent()
 {
     $recArr = $this->readInputRecord();
     $this->setActiveRecord($recArr);
     if (count($recArr) == 0) {
         return;
     }
     //generate fast_index
     $svcobj = Openbiz::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);
     if (!$recArr['company']) {
         $recArr['company'] = 'N/A';
     }
     try {
         $this->ValidateForm();
     } catch (Openbiz\Validation\Exception $e) {
         $this->processFormObjError($e->errors);
         return;
     }
     $recId = $this->_doInsert($recArr);
     $selIds[] = $recId;
     // if no parent elem or picker map, call AddToParent
     if (!$this->parentFormElemName) {
         $this->addToParent($selIds);
     }
     // if has parent elem and picker map, call JoinToParent
     if ($this->parentFormElemName && $this->pickerMap) {
         $this->joinToParent($selIds);
     }
 }
예제 #9
0
 public function insertRecord()
 {
     $recArr = $this->readInputRecord();
     $this->setActiveRecord($recArr);
     if (count($recArr) == 0) {
         return;
     }
     try {
         $this->ValidateForm();
     } catch (Openbiz\Validation\Exception $e) {
         $this->processFormObjError($e->errors);
         return;
     }
     $repo_uri = $recArr['repository_uri'];
     $svc = Openbiz::getService("market.lib.PackageService");
     $repoInfo = $svc->discoverRepository($repo_uri);
     $recArr['repository_uid'] = $repoInfo['_repo_uid'];
     $recArr['repository_name'] = $repoInfo['_repo_name'];
     $this->_doInsert($recArr);
     // in case of popup form, close it, then rerender the parent form
     if ($this->parentFormName) {
         $this->close();
         $this->renderParent();
     }
     $this->processPostAction();
 }
예제 #10
0
 public function exportCSV()
 {
     $eventlogSvc = Openbiz::getService(OPENBIZ_EVENTLOG_SERVICE);
     $eventlogSvc->exportCSV();
     $this->runEventLog();
     return true;
 }
 public function Cleanup()
 {
     $searchRule = "[app_id]=0 OR [install_state]!='OK'";
     Openbiz::getObject($this->marketInstalledDO)->deleteRecords($searchRule);
     $this->notices = array("cleanup" => $this->getMessage("MSG_CLEANUP"));
     $this->rerender();
 }
 public function insertRecord()
 {
     $recArr = $this->readInputRecord();
     $this->setActiveRecord($recArr);
     if (count($recArr) == 0) {
         return;
     }
     //generate fast_index
     $svcobj = Openbiz::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 (Openbiz\Validation\Exception $e) {
         $this->processFormObjError($e->errors);
         return;
     }
     $this->_doInsert($recArr);
     // in case of popup form, close it, then rerender the parent form
     if ($this->parentFormName) {
         $this->close();
         $this->renderParent();
     }
     $this->processPostAction();
 }
예제 #13
0
 public function getDefaultLangName($lang = null)
 {
     if ($lang == null) {
         $do = Openbiz::getObject("myaccount.do.PreferenceDO", 1);
         $rec = $do->fetchOne("[user_id]='0' AND [name]='language'");
         if ($rec) {
             $lang = $rec['value'];
         } else {
             $lang = OPENBIZ_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 OPENBIZ_DEFAULT_LANGUAGE;
         }
     }
 }
예제 #14
0
 public function ExportCSV()
 {
     $excelSvc = Openbiz::getService(EXCEL_SERVICE);
     $excelSvc->renderCSV($this->objectName);
     $this->runEventLog();
     return true;
 }
예제 #15
0
 public function render()
 {
     $sHTML = "";
     if (Openbiz::getService('system.lib.ModuleService')->isModuleInstalled('oauth')) {
         $do = Openbiz::getObject('oauth.do.OauthProviderDO');
         $recArr = $do->directFetch("[status]=1", 30);
         $recArr = $recArr->toArray();
         if ($this->redirectURL) {
             $this->redirectURL = Expression::evaluateExpression($this->redirectURL, $this);
             $url_append .= "redirect_url=" . urlencode($this->redirectURL) . "&";
         }
         if ($this->assocURL) {
             $this->assocURL = Expression::evaluateExpression($this->assocURL, $this);
             $url_append .= "assoc_url=" . urlencode($this->assocURL) . "&";
         }
         if (count($recArr)) {
             $sHTML .= "<span class=\"oauth_bar\" {$style}>";
             foreach ($recArr as $oauthProvider) {
                 $url = OPENBIZ_APP_URL . "/ws.php/oauth/callback/login/type_" . $oauthProvider['type'] . '/';
                 if ($url_append) {
                     $url .= '?' . $url_append;
                 }
                 $sHTML .= "<a id=\"oauth_" . $oauthProvider['type'] . "\" title=\"" . $oauthProvider['type'] . "\"   href=\"{$url}\" style=\"\"></a>";
             }
             $sHTML .= "</span>";
         }
     }
     return $sHTML;
 }
예제 #16
0
 public function UpdateRecord()
 {
     $result = parent::UpdateRecord();
     $mappingObj = Openbiz::getObject($this->categoryMappingDO, 1);
     $Id = $this->recordId;
     $mappingObj->deleteRecords("[cat_id]='{$Id}'");
     return $result;
 }
예제 #17
0
 public function getDefaultRoleID()
 {
     $roleRec = Openbiz::getObject("system.do.RoleDO")->fetchOne("[default]='1'", "[Id] DESC");
     if ($roleRec) {
         $Id = $roleRec['Id'];
     }
     return (int) $Id;
 }
예제 #18
0
 public function getSelectFrom()
 {
     $formname = $this->getFormObj()->parentFormName;
     if (!$formname) {
         $formname = "extend.widget.ExtendSettingListEditForm";
     }
     return Openbiz::getObject($formname)->parentFormElementMeta['ATTRIBUTES']['ACCESSSELECTFROM'];
 }
예제 #19
0
 public function getDefaultMainForm(&$xmlArr)
 {
     $formObj = Openbiz::getObject("contact.widget.ViewSelectorLeftWidget");
     $targetForm = $formObj->getViewMode();
     $newForm = array("ATTRIBUTES" => array("NAME" => $targetForm), "VALUE" => null);
     $newArr = array($xmlArr, $newForm);
     return $newArr;
 }
예제 #20
0
 public function Report()
 {
     //send an email to admin includes error messages;
     $system_uuid = Openbiz::getService("system.lib.CubiService")->getSystemUUID();
     $report = array("system_uuid" => $system_uuid, "error_info" => $this->errors["system"], "server_info" => $_SERVER, "php_version" => phpversion(), "php_extension" => get_loaded_extensions());
     $reportId = Openbiz::getObject("common.lib.ErrorReportService")->report($report);
     $this->notices = array("status" => "REPORTED", "report_id" => $reportId);
     $this->ReRender();
 }
예제 #21
0
 public function postLoadingModule($moduelLoader)
 {
     $roleRec = Openbiz::getObject("system.do.RoleDO")->fetchOne("[name]='Cubi Member'");
     $roleId = $roleRec['Id'];
     $actionRec = Openbiz::getObject("system.do.AclActionDO")->fetchOne("[module]='chart' AND [resource]='Chart' AND [action]='View_Chart'");
     $actionId = $actionRec["Id"];
     $aclRecord = array("role_id" => $roleId, "action_id" => $actionId, "access_level" => 1);
     Openbiz::getObject("system.do.AclRoleActionDO")->insertRecord($aclRecord);
 }
예제 #22
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 (Openbiz\Validation\Exception $e) {
         $this->processFormObjError($e->errors);
         return;
     }
     $recArr['create_by'] = "0";
     $recArr['update_by'] = "0";
     $password = Openbiz::$app->getClientProxy()->GetFormInputs("fld_password");
     $recArr['password'] = hash(HASH_ALG, $password);
     $this->_doInsert($recArr);
     //set default user role to member
     $userinfo = $this->getActiveRecord();
     $userRoleObj = Openbiz::getObject('system.do.UserRoleDO');
     foreach (Openbiz::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 = Openbiz::getObject('system.do.UserGroupDO');
     foreach (Openbiz::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
     $eventlog = Openbiz::getService(OPENBIZ_EVENTLOG_SERVICE);
     $logComment = array($userinfo['username'], $_SERVER['REMOTE_ADDR']);
     $eventlog->log("USER_MANAGEMENT", "MSG_USER_REGISTERED", $logComment);
     //send user email
     $emailObj = Openbiz::getService(CUBI_USER_EMAIL_SERVICE);
     $emailObj->UserWelcomeEmail($userinfo['Id']);
     //init profile for future use like redirect to my account view
     $profile = Openbiz::$app->InituserProfile($userinfo['username']);
     return $userinfo;
 }
예제 #23
0
 public function getLocationInfo($id)
 {
     $locationRec = Openbiz::getObject("backup.do.BackupDeviceDO")->fetchById($id);
     if ($locationRec) {
         $this->locationId = $locationRec["Id"];
         $this->locationName = $locationRec["name"];
         $this->folder = Expression::evaluateExpression($locationRec['location'], null);
         $this->folder = Expression::evaluateExpression($locationRec['location'], null);
     }
 }
예제 #24
0
 public function isModuleInstalled($module)
 {
     $do = Openbiz::getObject($this->moduleDO);
     $modRec = $do->fetchOne("[name]='{$module}'");
     if ($modRec) {
         return $modRec['version'];
     } else {
         return false;
     }
 }
예제 #25
0
 public function observe($event)
 {
     $triggerObj = $event->getTarget();
     $triggerEvent = $event->getName();
     $params = $event->getParams();
     // get eventlog service
     $eventLog = Openbiz::getService(OPENBIZ_EVENTLOG_SERVICE);
     // log message
     $eventLog->Log($triggerEvent, "triggered by " . $triggerObj->objectName);
 }
예제 #26
0
 protected function _getProviderInfo()
 {
     $SmsProviderDO = Openbiz::getObject($this->providerDo);
     $recObj = $SmsProviderDO->fetchOne("[Id]={$this->providerId}");
     $recArr = array();
     if ($recObj) {
         $recArr = $recObj->toArray();
     }
     return $recArr;
 }
예제 #27
0
 public function MakePayment()
 {
     $rec = $this->readInputRecord();
     $orderId = $rec['order_id'];
     $title = $rec['title'];
     $amount = $rec['amount'];
     $providerType = $rec['provider_type'];
     Openbiz::getService($this->paymentService)->goPayment($orderId, $amount, $providerType, $title);
     return true;
 }
예제 #28
0
 public function closeTutorial()
 {
     $tutorailId = $this->recordId;
     $rec = $this->readInputs();
     if ($rec['chk_show_on_next']) {
         $showOnNextLogin = 1;
     } else {
         $showOnNextLogin = 0;
     }
     Openbiz::getService("help.lib.TutorialService")->SetTutorialShown($tutorailId, $showOnNextLogin);
     $this->close();
 }
예제 #29
0
 public function postUnloadModule($moduleLoader)
 {
     $roleRec = Openbiz::getObject("system.do.RoleDO")->fetchOne("[name]='{$this->roleName}'");
     $memberRoleId = $roleRec['Id'];
     $roleRec->delete();
     $actionList = Openbiz::getObject("system.do.AclActionDO")->directfetch("[module]='{$this->moduleName}'");
     foreach ($actionList as $actionRec) {
         $actionId = $actionRec["Id"];
         Openbiz::getObject("system.do.AclRoleActionDO")->deleteRecords("[action_id]='{$actionId}' AND [role_id]='{$memberRoleId}'");
     }
     Openbiz::getObject("system.do.AclActionDO")->deleteRecords("[module]='{$this->moduleName}'");
 }
예제 #30
0
 public function SetDefault($role_id = null)
 {
     if ($role_id == null) {
         $role_id = (int) Openbiz::$app->getClientProxy()->getFormInputs('_selectedId');
     }
     $user_id = (int) Openbiz::getObject('system.form.UserDetailForm')->recordId;
     $roleDo = Openbiz::getObject("system.do.UserRoleDO", 1);
     $roleDo->updateRecords("[default]=0", "[user_id]='{$user_id}'");
     $roleDo->updateRecords("[default]=1", "[user_id]='{$user_id}' and [role_id]='{$role_id}'");
     $this->recordId = $role_id;
     $this->UpdateForm();
 }