示例#1
0
 /**
  * Set the defvalues property
  */
 protected function prepareDefvalues()
 {
     if ((array_key_exists("copyid1", $_REQUEST) || array_key_exists("editid1", $_REQUEST)) && $this->mode != ADD_DASHBOARD) {
         //	copy record
         $copykeys = array();
         $keyFields = $this->pSet->getTableKeys();
         $prefix = array_key_exists("copyid1", $_REQUEST) ? "copyid" : "editid";
         foreach ($keyFields as $idx => $k) {
             $copykeys[$k] = postvalue($prefix . ($idx + 1));
         }
         $strWhere = KeyWhere($copykeys);
         if ($this->pSet->getAdvancedSecurityType() != ADVSECURITY_ALL) {
             $strWhere = whereAdd($strWhere, SecuritySQL("Search", $this->tName));
         }
         $strSQL = $this->gQuery->gSQLWhere($strWhere);
         $this->defvalues = $this->cipherer->DecryptFetchedArray($this->connection->query($strSQL)->fetchAssoc());
         if (!$this->defvalues) {
             $this->defvalues = array();
         }
         // clear key fields
         foreach ($keyFields as $idx => $k) {
             $this->defvalues[$k] = "";
         }
         foreach ($this->addFields as $f) {
             if ($this->pSet->getEditFormat($f) == EDIT_FORMAT_FILE) {
                 //#10023
                 $this->defvalues[$f] = $this->getControl($f, $this->id)->getFieldValueCopy($this->defvalues[$f]);
             }
         }
         // call CopyOnLoad event
         if ($this->eventsObject->exists("CopyOnLoad")) {
             $this->eventsObject->CopyOnLoad($this->defvalues, $strWhere, $this);
         }
     } else {
         foreach ($this->addFields as $f) {
             $defaultValue = GetDefaultValue($f, PAGE_ADD);
             if (strlen($defaultValue)) {
                 $this->defvalues[$f] = $defaultValue;
             }
         }
     }
     $securityType = $this->pSet->getAdvancedSecurityType();
     if (!$this->isAdminTable() && ($securityType == ADVSECURITY_EDIT_OWN || $securityType == ADVSECURITY_VIEW_OWN)) {
         $tableOwnerIdField = $this->pSet->getTableOwnerIdField();
         // insert default owner id value if exists
         if ($this->checkIfToAddOwnerIdValue($tableOwnerIdField, '')) {
             $this->defvalues[$tableOwnerIdField] = prepare_for_db($tableOwnerIdField, $_SESSION["_" . $this->tName . "_OwnerID"]);
         }
     }
     $masterTables = $this->pSet->getMasterTablesArr($this->tName);
     // set default values for the foreign keys
     foreach ($masterTables as $mTableData) {
         if (@$_SESSION[$this->sessionPrefix . "_mastertable"] == $mTableData["mDataSourceTable"]) {
             foreach ($mTableData["detailKeys"] as $idx => $dk) {
                 $masterkeyIdx = "masterkey" . ($idx + 1);
                 if (postvalue($masterkeyIdx)) {
                     $_SESSION[$this->sessionPrefix . "_" . $masterkeyIdx] = postvalue($masterkeyIdx);
                 }
                 if ($this->masterPageType != PAGE_ADD) {
                     $this->defvalues[$dk] = @$_SESSION[$this->sessionPrefix . "_" . $masterkeyIdx];
                 }
             }
         }
     }
     $lookupMainSettings = getLookupMainTableSettings($this->tName, $this->mainTable, $this->mainField);
     if ($lookupMainSettings) {
         if ($lookupMainSettings->useCategory($this->mainField) && !isset($this->newRecordData[$lookupMainSettings->getCategoryFilter($this->mainField)])) {
             $this->defvalues[$lookupMainSettings->getCategoryFilter($this->mainField)] = $this->category;
         }
     }
     if ($this->readAddValues) {
         foreach ($this->addFields as $fName) {
             $editFormat = $this->pSet->getEditFormat($fName);
             if ($editFormat != EDIT_FORMAT_DATABASE_FILE && $editFormat != EDIT_FORMAT_DATABASE_IMAGE && $editFormat != EDIT_FORMAT_FILE) {
                 $this->defvalues[$fName] = @$this->newRecordData[$fName];
             }
         }
     }
 }
	function getDefaultValue($field)
	{
		$editPage = $this->_editPage;
		if(!$this->isSeparate($field))
			$editPage = $this->getDefaultEditPageType($this->getTableType());;
		return GetDefaultValue($field, $editPage, $this->_table);
	}
 function getDefaultValue($field, $table = "")
 {
     $tableName = $table ? $table : $this->_table;
     $editPage = $this->_editPage;
     if (!$this->isSeparate($field)) {
         $editPage = $this->getDefaultEditPageType($this->getTableType());
     }
     return GetDefaultValue($field, $editPage, $tableName);
 }