Exemple #1
2
 /**
  * Static function for create list page
  * Read params from setting 
  * Create object of class in accordance with mode displaying page
  * @param String strTableName
  * @param Array options
  */
 static function &createListPage($strTableName, $options)
 {
     global $isGroupSecurity;
     $gSettings = new ProjectSettings($strTableName, $options['pageType']);
     $gQuery = $gSettings->getSQLQuery();
     $params = $options;
     $params['tName'] = $strTableName;
     $params['origTName'] = $gSettings->getOriginalTableName();
     $params['gPageSize'] = $gSettings->getInitialPageSize();
     $params['gOrderIndexes'] = $gSettings->getOrderIndexes();
     $params['gstrOrderBy'] = $gQuery->OrderByToSql();
     $params['gsqlHead'] = $gQuery->HeadToSql();
     $params['gsqlFrom'] = $gQuery->FromToSql();
     $params['gsqlWhereExpr'] = $gQuery->WhereToSql();
     $params['gsqlGroupBy'] = $gQuery->GroupByToSql();
     $params['gsqlHaving'] = $gQuery->Having()->toSql($gQuery);
     $params['nSecOptions'] = $gSettings->getAdvancedSecurityType();
     $params['nLoginMethod'] = GetGlobalData("nLoginMethod", 0);
     $params['recsPerRowList'] = isMobile() ? 1 : $gSettings->getRecordsPerRowList();
     $params['mainTableOwnerID'] = $gSettings->getTableOwnerIdField();
     $params['exportTo'] = $gSettings->hasExportPage();
     $params['printFriendly'] = $gSettings->hasPrintPage();
     $params['deleteRecs'] = $gSettings->hasDelete();
     $params["isGroupSecurity"] = $isGroupSecurity;
     $params['arrKeyFields'] = $gSettings->getTableKeys();
     $params["isUseInlineAdd"] = $gSettings->hasInlineAdd();
     $params["isUseInlineEdit"] = $gSettings->hasInlineEdit();
     $params["panelSearchFields"] = $gSettings->getPanelSearchFields();
     $params['listGridLayout'] = $gSettings->getListGridLayout();
     $params['createLoginPage'] = GetGlobalData("createLoginPage", false);
     $params['noRecordsFirstPage'] = $gSettings->noRecordsOnFirstPage();
     $params['totalsFields'] = $gSettings->getTotalsFields();
     $params['listAjax'] = $gSettings->ajaxBasedListPage();
     $params['arrRecsPerPage'] = $gSettings->getRecordsPerPageArray();
     $params['isScrollGridBody'] = $gSettings->getScrollGridBody();
     $params['viewPDF'] = $gSettings->isViewPagePDF() || $gSettings->isPrinterPagePDF();
     $params['audit'] = GetAuditObject($table);
     $params['listFields'] = array();
     $allfields = $gSettings->getListFields();
     foreach ($allfields as $f) {
         if (!$gSettings->appearOnListPage($f)) {
             continue;
         }
         $params['listFields'][] = array("fName" => $f, "goodFieldName" => GoodFieldName($f), "valueFieldName" => GoodFieldName($f) . "_value", "viewFormat" => $gSettings->getViewFormat($f), "editFormat" => $gSettings->getEditFormat($f));
     }
     // choose class by mode
     if ($params["mode"] == LIST_SIMPLE) {
         $pageObject = new ListPage_Simple($params);
     } else {
         if ($params["mode"] == LIST_AJAX) {
             $pageObject = new ListPage_Ajax($params);
         } else {
             if ($params["mode"] == LIST_LOOKUP) {
                 $pageObject = new ListPage_Lookup($params);
             } else {
                 if ($params["mode"] == LIST_DETAILS || $params["mode"] == LIST_DASHDETAILS) {
                     $pageObject = new ListPage_DPInline($params);
                 } else {
                     if ($params["mode"] == RIGHTS_PAGE) {
                         $pageObject = new RightsPage($params);
                     } else {
                         if ($params["mode"] == MEMBERS_PAGE) {
                             $pageObject = new MembersPage($params);
                         } else {
                             if ($params["mode"] == LIST_DASHBOARD) {
                                 $pageObject = new ListPage_Dashboard($params);
                             }
                         }
                     }
                 }
             }
         }
     }
     $pageObject->init();
     return $pageObject;
 }
Exemple #2
0
 static function readSelectedRecordsFromRequest($table)
 {
     if (!$_REQUEST["selection"]) {
         return array();
     }
     $selected_recs = array();
     $pSet = new ProjectSettings($table);
     $keyFields = $pSet->getTableKeys();
     foreach (@$_REQUEST["selection"] as $keyblock) {
         $arr = explode("&", refine($keyblock));
         if (count($arr) < count($keyFields)) {
             continue;
         }
         $keys = array();
         foreach ($arr as $i => $value) {
             $keys[$keyFields[$i]] = urldecode($value);
         }
         $selected_recs[] = $keys;
     }
     return $selected_recs;
 }
Exemple #3
0
require_once "include/" . $table . "_variables.php";
$pSet = new ProjectSettings(GetTableByShort($table), $pageType);
$cipherer = new RunnerCipherer(GetTableByShort($table), $pSet);
$_connection = $cman->byTable($strTableName);
if (!$pSet->checkFieldPermissions($field)) {
    $returnJSON = array("success" => false, "error" => 'Error: You have not permission for read this text');
    echo printJSON($returnJSON);
    return;
}
if (!$gQuery->HasGroupBy()) {
    // Do not select any fields except current (full text) field.
    // If query has 'group by' clause then other fields are used in it and we may not simply cut 'em off.
    // Just don't do anything in that case.
    $gQuery->RemoveAllFieldsExcept($pSet->getFieldIndex($field));
}
$keysArr = $pSet->getTableKeys();
$keys = array();
foreach ($keysArr as $ind => $k) {
    $keys[$k] = postvalue("key" . ($ind + 1));
}
$where = KeyWhere($keys);
$sql = $gQuery->gSQLWhere($where);
$qResult = $_connection->query($sql);
if (!$qResult || !($data = $cipherer->DecryptFetchedArray($qResult->fetchAssoc()))) {
    $returnJSON = array("success" => false, "error" => 'Error: Wrong SQL query');
    echo printJSON($returnJSON);
    return;
}
$fieldValue = $data[$field];
$sessionPrefix = $pSet->getOriginalTableName();
if ($mode == LIST_DASHBOARD) {
		$grouptotals_count[$arr['name']] = 0;
		foreach ($rpt_array['totals'] as $fld){
		    if ($fld['show']) {
			$grouptotals_sum[$arr['name']][fldname($fld)] = 0;
		    }
		}
	    }
	}

	//display data
	if ($PageSize < 0 || $groupno >= $pagestart && $groupno <= $pageend) {
	    $row["row_data"] = true;
	    /////////////////////////////////
	    $keylink = "";
	    $arrKeys = $gSettings->getTableKeys();
	    if (!is_wr_project()) {
		$arrKeysTbl = DBGetTableKeys($rpt_array['tables'][0]);
		$arrKeys = array();
		foreach ($arrKeysTbl as $i => $k){
		    $arrKeys[$i] = $rpt_array['tables'][0] . "." . $arrKeys[$i];
		}
	    }
	    for ($j = 0; $j < count($arrKeys); $j++){
		$keylink.="&key" . ($j + 1) . "=" . runner_htmlspecialchars(rawurlencode(db_fld_value($data, $arrKeys[$j])));
	    }
	    $arrFields = array();
	    foreach ($rpt_array['totals'] as $f_key => $fld){
		if ($fld["show"]) {
		    $value = "";
		    if ($fld["view_format"] == FORMAT_DATABASE_IMAGE && is_wr_project()) {
Exemple #5
0
 /**
  * Static function for create list page
  * Read params from setting 
  * Create object of class in accordance with mode displaying page 
  */
 function &createListPage($table, $options)
 {
     global $bSubqueriesSupported, $strTableName, $conn, $locale_info, $isGroupSecurity;
     $gSettings = new ProjectSettings($strTableName, $options['pageType']);
     $gQuery = $gSettings->getSQLQuery();
     $params = array();
     $params = $options;
     $params['origTName'] = $gSettings->getOriginalTableName();
     $params['sessionPrefix'] = $strTableName;
     $params['tName'] = $table;
     $params['conn'] =& $conn;
     $params['gPageSize'] = $gSettings->getInitialPageSize();
     $params['gOrderIndexes'] = $gSettings->getOrderIndexes();
     $params['gstrOrderBy'] = $gQuery->OrderByToSql();
     $params['gsqlHead'] = $gQuery->HeadToSql();
     $params['gsqlFrom'] = $gQuery->FromToSql();
     $params['gsqlWhereExpr'] = $gQuery->WhereToSql();
     $params['gsqlGroupBy'] = $gQuery->GroupByToSql();
     $params['gsqlHaving'] = $gQuery->Having()->toSql($gQuery);
     $params['locale_info'] =& $locale_info;
     $params["subQueriesSupp"] = $bSubqueriesSupported;
     $params['nSecOptions'] = $gSettings->getAdvancedSecurityType();
     $params['nLoginMethod'] = GetGlobalData("nLoginMethod", 0);
     $params['recsPerRowList'] = $gSettings->getRecordsPerRowList();
     $params['dbType'] = GetGlobalData("dbType", 0);
     $params['mainTableOwnerID'] = $gSettings->getTableOwnerIdField();
     $params['moveNext'] = $gSettings->useMoveNext();
     $params['exportTo'] = $gSettings->hasExportPage();
     $params['printFriendly'] = $gSettings->hasPrintPage();
     $params['deleteRecs'] = $gSettings->hasDelete();
     $params['rowHighlite'] = $gSettings->highlightRows();
     $params["isGroupSecurity"] = $isGroupSecurity;
     $params['arrKeyFields'] = $gSettings->getTableKeys();
     $params["isUseInlineAdd"] = $gSettings->hasInlineAdd();
     $params["isUseInlineEdit"] = $gSettings->hasInlineEdit();
     $params["isUseInlineJs"] = $params["isUseInlineAdd"] || $params["isUseInlineEdit"];
     $params["panelSearchFields"] = $gSettings->getPanelSearchFields();
     $params['isVerLayout'] = $gSettings->isVerticalLayoutList();
     $params['isDisplayLoading'] = $gSettings->displayLoading();
     $params['createLoginPage'] = GetGlobalData("createLoginPage", false);
     $params['subQueriesSupAccess'] = $gSettings->tableSupportsSubqueries();
     $params['noRecordsFirstPage'] = $gSettings->noRecordsOnFirstPage();
     $params['totalsFields'] = $gSettings->getTotalsFields();
     $params['listIcons'] = $gSettings->iconsOnList();
     $params['edit'] = $gSettings->hasEditPage();
     $params['inlineEdit'] = $gSettings->hasInlineEdit();
     $params['iCopy'] = $gSettings->hasCopyPage();
     $params['iView'] = $gSettings->hasViewPage();
     $params['listAjax'] = $gSettings->ajaxBasedListPage();
     $params['arrRecsPerPage'] = $gSettings->getRecordsPerPageArray();
     $params['isScrollGridBody'] = $gSettings->getScrollGridBody();
     $params['audit'] = GetAuditObject($table);
     $params['listFields'] = array();
     $allfields = $gSettings->getListFields();
     foreach ($allfields as $f) {
         if (!$gSettings->appearOnListPage($f)) {
             continue;
         }
         $params['listFields'][] = array("fName" => $f, "goodFieldName" => GoodFieldName($f), "valueFieldName" => GoodFieldName($f) . "_value", "viewFormat" => $gSettings->getViewFormat($f), "editFormat" => $gSettings->getEditFormat($f));
     }
     // choose class by mode
     if ($params["mode"] == LIST_SIMPLE) {
         $pageObject = new ListPage_Simple($params);
     } else {
         if ($params["mode"] == LIST_AJAX) {
             $pageObject = new ListPage_Ajax($params);
         } else {
             if ($params["mode"] == LIST_LOOKUP) {
                 $pageObject = new ListPage_Lookup($params);
             } else {
                 if ($params["mode"] == LIST_DETAILS) {
                     $pageObject = new ListPage_DPInline($params);
                 } else {
                     if ($params["mode"] == RIGHTS_PAGE) {
                         $pageObject = new RightsPage($params);
                     } else {
                         if ($params["mode"] == MEMBERS_PAGE) {
                             $pageObject = new MembersPage($params);
                         }
                     }
                 }
             }
         }
     }
     return $pageObject;
 }
Exemple #6
0
function KeyWhere(&$keys, $table = "")
{
    global $strTableName;
    if (!$table) {
        $table = $strTableName;
    }
    $strWhere = "";
    $pSet = new ProjectSettings($table);
    $cipherer = new RunnerCipherer($table);
    $keyFields = $pSet->getTableKeys();
    foreach ($keyFields as $kf) {
        if (strlen($strWhere)) {
            $strWhere .= " and ";
        }
        $value = $cipherer->MakeDBValue($kf, $keys[$kf], "", "", true);
        $valueisnull = $value === "null";
        if ($valueisnull) {
            $strWhere .= GetFullFieldNameForInsert($pSet, $kf) . " is null";
        } else {
            $strWhere .= GetFullFieldName($kf, $table, false) . "=" . $cipherer->MakeDBValue($kf, $keys[$kf], "", "", true);
        }
    }
    return $strWhere;
}
/**
 *  DEPRECATED. Use RunnerPage::keysSQLExpression instead
 *	Construct WHERE clause with key values
 * 
 * @param &Array	$keys
 * @param String	$table Teh data source table name OPTIONAL
 * 
 * @return String
 * @intellisense
 * @deprecated
 */
function KeyWhere(&$keys, $table = "")
{
    global $strTableName, $cman;
    if (!$table) {
        $table = $strTableName;
    }
    $strWhere = "";
    $pSet = new ProjectSettings($table);
    $cipherer = new RunnerCipherer($table);
    $connection = $cman->byTable($table);
    $keyFields = $pSet->getTableKeys();
    foreach ($keyFields as $kf) {
        if (strlen($strWhere)) {
            $strWhere .= " and ";
        }
        $value = $cipherer->MakeDBValue($kf, $keys[$kf], "", true);
        if ($connection->dbType == nDATABASE_Oracle) {
            $valueisnull = $value === "null" || $value == "''";
        } else {
            $valueisnull = $value === "null";
        }
        if ($valueisnull) {
            $strWhere .= RunnerPage::_getFieldSQL($kf, $connection, $pSet) . " is null";
        } else {
            $strWhere .= RunnerPage::_getFieldSQLDecrypt($kf, $connection, $pSet, $cipherer) . "=" . $cipherer->MakeDBValue($kf, $keys[$kf], "", true);
        }
    }
    return $strWhere;
}