public function reorderWidgets()
 {
     $sortorder = BizSystem::clientProxy()->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 = BizSystem::getObject($this->userWidgetDOName);
     $userWidgetTable = $userWidgetDo->m_MainTable;
     $db = $userWidgetDo->getDbConnection();
     $myProfile = BizSystem::getUserProfile();
     $myUserId = $myProfile['Id'];
     $currentView = BizSystem::instance()->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++;
     }
 }
Example #2
0
 protected function addWidget($widgetName)
 {
     // add widget to user_widget table
     $userWidgetDo = BizSystem::getObject($this->userWidgetDOName);
     $userWidgetTable = $userWidgetDo->m_MainTable;
     $db = $userWidgetDo->getDbConnection();
     $myProfile = BizSystem::getUserProfile();
     $myUserId = $myProfile['Id'];
     $currentView = BizSystem::instance()->getCurrentViewName();
     $searchRule = "[user_id]={$myUserId} and [widget]='{$widgetName}' and [view]='{$currentView}'";
     $record = $userWidgetDo->fetchOne($searchRule);
     if ($record) {
         BizSystem::clientProxy()->showClientAlert("The widget {$widgetName} is already on the page.");
     } else {
         $data = array('user_id' => $myUserId, 'widget' => $widgetName, 'view' => $currentView, 'ordering' => 0);
         $db->insert($userWidgetTable, $data);
     }
 }
Example #3
0
 public function login()
 {
     $username = $_GET['username'];
     $password = $_GET['password'];
     $svcobj = BizSystem::getService(AUTH_SERVICE);
     if ($svcobj->authenticateUser($username, $password)) {
         // after authenticate user: 1. init profile
         $profile = BizSystem::instance()->InitUserProfile($username);
         // after authenticate user: 2. insert login event
         $eventlog = BizSystem::getService(EVENTLOG_SERVICE);
         $logComment = array($username, $_SERVER['REMOTE_ADDR']);
         $eventlog->log("LOGIN", "MSG_LOGIN_SUCCESSFUL", $logComment);
         // after authenticate user: 3. update login time in user record
         $userObj = BizSystem::getObject('system.do.UserDO');
         $userRec = $userObj->fetchOne("[username]='{$username}'");
         $userRec['lastlogin'] = date("Y-m-d H:i:s");
         $userId = $userRec['Id'];
         $userRec->save();
     }
     $result = array("user_id" => $userId);
     return $result;
 }
Example #4
0
 /**
  * Evaluate macro, this method can only be used to get profile in 2.0
  * For example, @macro_var:macro_key. i.e. @profile:ROLE
  *
  * @param string $var, macro name
  * @param string $key, macro key
  * @return string
  */
 public static function getMacroValue($var, $key)
 {
     if ($var == "profile") {
         return BizSystem::instance()->getUserProfile($key);
     }
     return null;
 }
Example #5
0
 /**
  * Get append scripts
  *
  * @return string
  */
 public function getAppendedScripts()
 {
     $currentView = BizSystem::instance()->getCurrentViewName();
     $initScripts = "<script>var APP_URL='" . APP_URL . "'; var APP_CONTROLLER='" . APP_URL . "/bin/controller.php';</script>\n";
     $initScripts .= "<script>var APP_VIEWNAME='" . $currentView . "';</script>\n";
     $extraScripts = implode("", $this->_extraScripts);
     $extraScript_array = explode("</script>", $extraScripts);
     /*if (defined("RESOURCE_PHP")) {
           $js_scripts = RESOURCE_PHP."?f=";
           foreach ($extraScript_array as $script)
           {
               // extract src part from each line
               if (preg_match('/.+src="([^"]+)".+/', $script, $matches) > 0 && !empty($matches[1])) {
                   if (substr($js_scripts, -2)=='f=') $js_scripts .= $matches[1];
                   else $js_scripts .= ','.$matches[1];
               }
           }
           return $initScripts."<script type=\"text/javascript\" src=\"".$js_scripts."\"></script>";
       }*/
     $cleanScript_array = array();
     foreach ($extraScript_array as $script) {
         if (in_array($script . "</script>", $cleanScript_array) == FALSE and strlen($script) != 0) {
             $cleanScript_array[] = $script . "</script>";
         }
     }
     return $initScripts . implode("\n", $cleanScript_array);
 }
Example #6
0
 /**
  * Allow view access
  *
  * @param string $viewName
  * @param <type> $role
  * @return boolean
  */
 public function allowViewAccess($viewName, $role = null)
 {
     if ($role != null) {
         $roles[] = $role;
     } else {
         //global $g_BizSystem;
         $bizSystem = BizSystem::instance();
         // TODO: get user profile
         $userProfile = $bizSystem->getUserProfile();
         //print_r($profile);
         if ($userProfile && isset($userProfile['roleNames'])) {
             $roles = $userProfile['roleNames'];
         } else {
             $roles[] = "";
         }
     }
     $view = $this->getMatchView($viewName);
     if (!$view) {
         return true;
     }
     $roleList = $view->getRoleList();
     if (!$roleList) {
         return true;
     }
     foreach ($roles as $r) {
         if ($roleList->get($r)) {
             return true;
         }
     }
     return false;
 }
Example #7
0
 /**
  * Dispatch request as RPC (remote procedure call)
  */
 private function _dispatchRPC()
 {
     if ($this->_hasContainerView()) {
         BizSystem::instance()->setCurrentViewName($this->_getContainerViewName());
     }
     $retval = $this->invoke();
     print $retval . " ";
     // why use space on end of data?
     exit;
 }
Example #8
0
/**
 * Search for the php file required to load the class
 *
 * @package openbiz.bin
 * @param string $className
 * @return void
 * */
function __autoload_openbiz($className)
{
    BizClassLoader::autoload($className);
}
if (!function_exists("__autoload")) {
    spl_autoload_register("__autoload_openbiz");
}
//include_once("BizSystem.php");
$g_BizSystem = BizSystem::instance();
/**
 * User error handler function
 *
 * @package openbiz.bin
 */
function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
    //include_once(OPENBIZ_BIN.'ErrorHandler.php');
    OB_ErrorHandler::ErrorHandler($errno, $errmsg, $filename, $linenum, $vars);
}
/**
 * User exception handler function
 * @package openbiz.bin
 * @param <type> $exc
 */
Example #9
0
 /**
  * Set view history data of given bizform into session file
  *
  * @param string $formName - name of bizform
  * @param array $historyInfo - view history data represented by an associated array
  * @return void
  **/
 public function setViewHistory($formName, $historyInfo)
 {
     $view = BizSystem::instance()->getCurrentViewName();
     $view_form = $formName;
     //$view."_".$formname;
     if (!$historyInfo) {
         unset($this->_viewHistory[$view_form]);
     } else {
         $this->_viewHistory[$view_form] = $historyInfo;
     }
 }
Example #10
0
 protected function getRedirectPage()
 {
     $view = BizSystem::instance()->getSessionContext()->getVar("LIC_SOURCE_URL");
     return array($view, "");
 }