/**
	 * @param Array keys
	 * @param Boolean forLookup
	 * @param String _table
	 * @param String _field
	 * @param String pageType
	 * @return Array
	 */
	public function GetAddedDataLookupQuery($keys, $forLookup, $_table, $_field, $pageType)
	{	
		$lookupMainSettings = getLookupMainTableSettings($this->tName, $_table, $_field, $pageType);
		if(!$lookupMainSettings)
			return array();

		global $conn;		
		$LookupSQL = "";
		$mainField = $_field;	
		$mainTable = $lookupMainSettings->getTableName();
		$linkFieldName = $lookupMainSettings->getLinkField($mainField);
		$dispfield = $lookupMainSettings->getDisplayField($mainField);
		
		$nLookupType = $lookupMainSettings->getLookupType($mainField);
		if($nLookupType == LT_QUERY)
		{
			if($lookupMainSettings->getCustomDisplay($mainField))
				$this->pSet->getSQLQuery()->AddCustomExpression($dispfield, $this->pSet, $mainTable, $mainField);
			$lookupQueryObj = $this->pSet->getSQLQuery()->CloneObject();
		}
		else
		{
			$LookupSQL = "select ";
			$LookupSQL .= GetFullFieldName($linkFieldName, $this->tName, true);
			if($linkFieldName != $dispfield)
				$LookupSQL .= "," . $this->pSet->getLWDisplayField($mainField, true);
			$LookupSQL.=" from ".AddTableWrappers($this->strOriginalTableName);
		}
			
		$data = 0;
		$lookupIndexes = array("linkFieldIndex" => 0, "displayFieldIndex" => 0);
		if(count($keys))
		{
			$where = KeyWhere($keys);
			if($nLookupType == LT_QUERY)
				$LookupSQL = $lookupQueryObj->toSql(whereAdd($lookupQueryObj->m_where->toSql($lookupQueryObj), $where));
			else 
				$LookupSQL.=" where ".$where;
			$lookupIndexes = GetLookupFieldsIndexes($lookupMainSettings, $mainField);
			LogInfo($LookupSQL);
			if($forLookup)
			{
				$rs=db_query($LookupSQL,$conn);
				$data = $this->cipherer->DecryptFetchedArray($rs);
			}
			else if($LookupSQL)
			{
				$rs = db_query($LookupSQL,$conn);
				$data = db_fetch_numarray($rs);
				$data[$lookupIndexes["linkFieldIndex"]] = $this->cipherer->DecryptField($linkFieldName, $data[$lookupIndexes["linkFieldIndex"]]);
				if($nLookupType == LT_QUERY)
					$data[$lookupIndexes["displayFieldIndex"]] = $this->cipherer->DecryptField($dispfield, $data[$lookupIndexes["displayFieldIndex"]]);		
			}
		}

		return array($data, array("linkField" => $linkFieldName, "displayField" => $dispfield
			, "linkFieldIndex" => $lookupIndexes["linkFieldIndex"], "displayFieldIndex" => $lookupIndexes["displayFieldIndex"]));
	}	
Beispiel #2
0
 /**
  * @param Boolean forLookup
  * @param String mainTableShortName
  * @param String mainField
  * @param String pageType
  * @return Array
  */
 protected function GetAddedDataLookupQuery($forLookup, $mainTableShortName, $mainField, $pageType)
 {
     $lookupMainSettings = getLookupMainTableSettings($this->tName, $mainTableShortName, $mainField, $pageType);
     if (!$lookupMainSettings) {
         return array();
     }
     $LookupSQL = "";
     $mainTable = $lookupMainSettings->getTableName();
     $linkFieldName = $lookupMainSettings->getLinkField($mainField);
     $dispfield = $lookupMainSettings->getDisplayField($mainField);
     if ($lookupMainSettings->getCustomDisplay($mainField)) {
         $this->pSet->getSQLQuery()->AddCustomExpression($dispfield, $this->pSet, $mainTable, $mainField);
     }
     $lookupQueryObj = $this->pSet->getSQLQuery()->CloneObject();
     $data = array();
     $lookupIndexes = array("linkFieldIndex" => 0, "displayFieldIndex" => 0);
     if (count($this->keys)) {
         $where = KeyWhere($this->keys);
         $LookupSQL = $lookupQueryObj->toSql(whereAdd($lookupQueryObj->m_where->toSql($lookupQueryObj), $where));
         $lookupIndexes = GetLookupFieldsIndexes($lookupMainSettings, $mainField);
         LogInfo($LookupSQL);
         if ($forLookup) {
             $data = $this->cipherer->DecryptFetchedArray($this->connection->query($LookupSQL)->fetchAssoc());
         } else {
             if ($LookupSQL) {
                 $data = $this->connection->query($LookupSQL)->fetchNumeric();
                 $data[$lookupIndexes["linkFieldIndex"]] = $this->cipherer->DecryptField($linkFieldName, $data[$lookupIndexes["linkFieldIndex"]]);
                 $data[$lookupIndexes["displayFieldIndex"]] = $this->cipherer->DecryptField($dispfield, $data[$lookupIndexes["displayFieldIndex"]]);
             }
         }
     }
     return array($data, array("linkField" => $linkFieldName, "displayField" => $dispfield, "linkFieldIndex" => $lookupIndexes["linkFieldIndex"], "displayFieldIndex" => $lookupIndexes["displayFieldIndex"]));
 }
Beispiel #3
0
 protected static function readMainTableSettingsFromRequest($table)
 {
     $mainTableShortName = GetTableURL(postvalue("table"));
     return getLookupMainTableSettings($table, $mainTableShortName, postvalue("field"));
 }
include("classes/searchcontrol.php");
include("classes/searchclause.php");
include("classes/panelsearchcontrol.php");
include('include/lookuplinks.php');

InitLookupLinks();

$lookupInPage = false;
$lookupInRegisterPage = false;
if(postvalue("mode") == "lookup")
{
	$mainTableShortName = postvalue("table");
	
		if(postvalue("pageType") == "register")
		$mainTableShortName = "webreport_users";
	$lookupMainSettings = getLookupMainTableSettings($strTableName, $mainTableShortName, postvalue("field"));
	if($lookupMainSettings)
	{
		$lookupInPage = true;
	}
}

RunnerPage::reloginAndLogoutProcess('S');

if(!isLogged() && !$lookupInRegisterPage)
{ 
	redirectToLogin();
}

   // check user permissions
$permissionGranted = false;
	if(!$defvalues)
		$defvalues=array();
//	clear key fields
	$defvalues["id"]="";
//call CopyOnLoad event
	if($eventObj->exists("CopyOnLoad"))
		$eventObj->CopyOnLoad($defvalues,$strWhere, $pageObject);
}
else
{
}




$lookupMainSettings = getLookupMainTableSettings($strTableName, postvalue("table"), postvalue("field"));
if($lookupMainSettings)
{
	$mainField = postvalue("field");
	if($lookupMainSettings->useCategory($mainField) && !isset($avalues[$lookupMainSettings->getCategoryFilter($mainField)]))
	{
		$defvalues[$lookupMainSettings->getCategoryFilter($mainField)] = postvalue("category");
	}
}


if($readavalues)
{
	$defvalues["id"]=@$avalues["id"];
	$defvalues["username"]=@$avalues["username"];
	$defvalues["password"]=@$avalues["password"];
Beispiel #6
0
 protected static function readMainTableSettingsFromRequest($table)
 {
     $mainTableShortName = postvalue("table");
     $lookupMainSettings = getLookupMainTableSettings($table, $mainTableShortName, postvalue("field"));
 }