Esempio n. 1
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;
 }
Esempio n. 2
0
 public function setSearchRule()
 {
     $url = $this->GetURL();
     if (!$url) {
         return;
     }
     $this->encodedURL = base64_encode('/' . $url);
     $this->tutorialId = Openbiz::getService("help.lib.TutorialService")->getTutorialId('/' . $url);
     //search cat_id from mapping table
     $mappingObj = Openbiz::getObject($this->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 = Openbiz::getObject($this->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->searchRule = "[category_id]='{$cat_id}'";
 }
Esempio n. 3
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;
         }
     }
 }
 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 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}'");
 }
 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();
 }
Esempio n. 7
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;
 }
Esempio n. 8
0
 public function getDefaultRoleID()
 {
     $roleRec = Openbiz::getObject("system.do.RoleDO")->fetchOne("[default]='1'", "[Id] DESC");
     if ($roleRec) {
         $Id = $roleRec['Id'];
     }
     return (int) $Id;
 }
Esempio n. 9
0
 public function getSelectFrom()
 {
     $formname = $this->getFormObj()->parentFormName;
     if (!$formname) {
         $formname = "extend.widget.ExtendSettingListEditForm";
     }
     return Openbiz::getObject($formname)->parentFormElementMeta['ATTRIBUTES']['ACCESSSELECTFROM'];
 }
Esempio n. 10
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;
 }
Esempio n. 11
0
 public function UpdateRecord()
 {
     $result = parent::UpdateRecord();
     $mappingObj = Openbiz::getObject($this->categoryMappingDO, 1);
     $Id = $this->recordId;
     $mappingObj->deleteRecords("[cat_id]='{$Id}'");
     return $result;
 }
Esempio n. 12
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();
 }
Esempio n. 13
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);
 }
Esempio n. 14
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;
 }
Esempio n. 15
0
 protected function _getProviderInfo()
 {
     $SmsProviderDO = Openbiz::getObject($this->providerDo);
     $recObj = $SmsProviderDO->fetchOne("[Id]={$this->providerId}");
     $recArr = array();
     if ($recObj) {
         $recArr = $recObj->toArray();
     }
     return $recArr;
 }
Esempio n. 16
0
 public function isModuleInstalled($module)
 {
     $do = Openbiz::getObject($this->moduleDO);
     $modRec = $do->fetchOne("[name]='{$module}'");
     if ($modRec) {
         return $modRec['version'];
     } else {
         return false;
     }
 }
Esempio n. 17
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);
     }
 }
 public function fetchData()
 {
     $result = parent::fetchData();
     $prtFormName = Openbiz::getObject($this->parentFormName)->parentFormName;
     if ($prtFormName == 'account.form.AccountEditShippingAddressForm' || $prtFormName == 'account.form.AccountEditBillingAddressForm') {
         $account_id = Openbiz::getObject(Openbiz::getObject($this->parentFormName)->parentFormName)->recordId;
         $result['account_id'] = $account_id;
         $productRec = Openbiz::getObject("account.do.AccountPickDO")->fetchById($account_id);
         $result['account_name'] = $productRec['name'];
     }
     return $result;
 }
 public function allowAccess()
 {
     $result = parent::allowAccess();
     $do = Openbiz::getObject("myaccount.do.PreferenceDO");
     $rs = $do->fetchOne("[user_id]='0' AND  [section]='Register' AND [name]='find_password'");
     $value = $rs->value;
     if ($value == 0 || $value == null) {
         return 0;
     } else {
         return $result;
     }
 }
 public function fetchData()
 {
     $profileId = Openbiz::$app->getUserProfile("profile_Id");
     $contactRec = Openbiz::getObject("contact.do.ContactDO")->fetchById($profileId);
     $contactRec['fullname'] = $contactRec['display_name'];
     if ($contactRec && $contactRec['display_name'] != 'System, Admin') {
         $result = $contactRec->toArray();
     } else {
         $result = array();
     }
     return $result;
 }
Esempio n. 21
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();
 }
 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}'");
 }
Esempio n. 23
0
 private function getFormReferences()
 {
     $user_id = Openbiz::$app->getUserProfile("Id");
     $searchRule = "[user_id]='{$user_id}'";
     $do = Openbiz::getObject($this->userWidgetDO);
     $formRecs = $do->directfetch($searchRule);
     $formRefXML = array();
     foreach ($formRecs as $form) {
         $formRefXML[] = array("ATTRIBUTES" => array("NAME" => $form['widget']), "VALUE" => null);
     }
     return $formRefXML;
 }
Esempio n. 24
0
 /**
  * Fetch record
  * 
  * @param string $doName data object name
  * @param string $searchRule rule of search
  * @return mixed
  */
 public function fetchRecord($doName, $searchRule)
 {
     $do = Openbiz::getObject($doName);
     if (!$do) {
         throw new Exception("System cannot get object of {$doName}.");
         return;
     }
     $r = $do->directFetch($searchRule, 1);
     if (count($r) > 0) {
         return $r[0];
     }
     return null;
 }
Esempio n. 25
0
 public function processOptions($option_str, $setting_id, $lang = null)
 {
     $optDO = Openbiz::getObject($this->settingOptionDO);
     $optionArr = explode(";", $option_str);
     $i = 1;
     $setting_id = (int) $setting_id;
     $optDO->deleteRecords("[setting_id]='{$setting_id}' AND lang='{$lang}'");
     foreach ($optionArr as $option) {
         $optRec = array("setting_id" => (int) $setting_id, "lang" => $lang, "text" => $option, "value" => $i);
         $optDO->insertRecord($optRec);
         $i++;
     }
 }
Esempio n. 26
0
 public function getDefaultMainForm(&$xmlArr)
 {
     $newForm = array("ATTRIBUTES" => array("NAME" => $this->formSelector), "VALUE" => null);
     $xmlArr = $newForm;
     $formObj = Openbiz::getObject($this->formSelector);
     if (!$formObj) {
         return;
     }
     $targetForm = $formObj->getViewMode();
     $newForm = array("ATTRIBUTES" => array("NAME" => $targetForm), "VALUE" => null);
     $newArr = array($xmlArr, $newForm);
     return $newArr;
 }
 public function reorderWidgets()
 {
     $sortorder = Openbiz::$app->getClientProxy()->getFormInputs('_widgets');
     // get the widgets ordering of columns
     parse_str($sortorder, $output);
     $columns = array();
     $columnCounts = array();
     $n = 0;
     foreach ($output as $k => $val) {
         if (strpos($k, 'column') === 0) {
             $columns[$n] = explode(",", $val);
             $columnCounts[$n] = count($columns[$n]);
             $n++;
         }
     }
     //print_r($columns);
     // update ordering of all user_widget records
     $userWidgetDo = Openbiz::getObject($this->userWidgetDOName);
     $userWidgetTable = $userWidgetDo->mainTableName;
     $db = $userWidgetDo->getDbConnection();
     $myProfile = Openbiz::$app->getUserProfile();
     $myUserId = $myProfile['Id'];
     $currentView = Openbiz::$app->getCurrentViewName();
     $m = 1;
     foreach ($columns as $column) {
         $n = 1;
         foreach ($column as $widgetName) {
             if (empty($widgetName)) {
                 continue;
             }
             // remove "_widget" from the widget name
             $widgetName = str_replace("_widget", "", $widgetName);
             // find the widget by name in the current view, set the new order
             $searchRule = "[user_id]={$myUserId} and [widget]='{$widgetName}' and [view]='{$currentView}'";
             $record = $userWidgetDo->fetchOne($searchRule);
             $ordering = $n * 10;
             if ($record) {
                 // update the order
                 $data = array('column' => $m, 'ordering' => $ordering);
                 $db->update($userWidgetTable, $data, "id=" . $record['Id']);
             } else {
                 // insert a record with the order
                 $data = array('user_id' => $myUserId, 'widget' => $widgetName, 'view' => $currentView, 'column' => $m, 'ordering' => $ordering);
                 $db->insert($userWidgetTable, $data);
             }
             $n++;
         }
         $m++;
     }
 }
Esempio n. 28
0
 protected function getProviderObj($type)
 {
     $providerRec = Openbiz::getObject($this->providerDO)->fetchOne("[type]='{$type}'");
     $driver = $providerRec['driver'];
     $driverFile = Openbiz::$app->getModulePath() . '/' . str_replace(".", "/", $driver) . '.php';
     $driverName = explode(".", $driver);
     $driverName = $driverName[count($driverName) - 1];
     if (!is_file($driverFile)) {
         return false;
     }
     require_once $driverFile;
     $obj = new $driverName();
     return $obj;
 }
 public function allowUninstall($repo_id, $app_id)
 {
     $svc = Openbiz::getService("market.lib.PackageService");
     $repoInfo = Openbiz::getObject("market.repository.do.RepositoryDO")->fetchById($repo_id);
     $repo_uri = $repoInfo->repository_uri;
     $repo_uid = $repoInfo->repository_uid;
     //get app module
     $appInfo = $svc->discoverAppInfo($repo_uri, $app_id);
     $app_uid = $appInfo['package_id'];
     if (preg_match("/com.application/si", strtolower($app_uid))) {
         return true;
     } else {
         return false;
     }
 }
 public static function FetchContacts($credential, $provider)
 {
     $dataSource = Openbiz::getObject($provider);
     $result = $dataSource->FetchContacts($credential);
     $svcobj = Openbiz::getService("service.chineseService");
     for ($i = 0; $i < count($result); $i++) {
         if ($svcobj->isChinese($result[$i]['display_name'])) {
             $fast_index = $svcobj->Chinese2Pinyin($result[$i]['display_name']);
         } else {
             $fast_index = $result[$i]['display_name'];
         }
         $result[$i]['fast_index'] = substr($fast_index, 0, 1);
     }
     return $result;
 }