Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1155214
systemconfiguration.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Sep 16, 6:31 AM
Size
6 KB
Mime Type
text/x-php
Expires
Thu, Sep 18, 6:31 AM (8 m, 7 s)
Engine
blob
Format
Raw Data
Handle
745709
Attached To
rINP In-Portal
systemconfiguration.php
View Options
<?php
// file pending deletion, not in use
/*$pathtoroot="";
for ($i=0;$i+1<(count(explode("/",$GLOBALS["SCRIPT_NAME"]))-2);$i++)
$pathtoroot.="../";
require_once($pathtoroot.'kernel/utilities/sessionutils.php');
require_once($pathtoroot.'kernel/utilities/dbutils.php');
require_once($pathtoroot.'kernel/utilities/errorutils.php');
class SystemConfiguration
{
function SystemConfiguration()
{
$adodbConnection = &GetADODBConnection(); // create a connection
$sql = sprintf("SELECT DefaultLanguage, DefaultTheme, DBSchemaVersion, SystemSecurityContextId FROM SystemConfiguration");
$result = $adodbConnection->Execute($sql);
if ($result === false)
{
AddError(DB_ERROR,$adodbConnection->ErrorMsg(),'',"","SystemConfiguration","SystemConfiguration");
return false;
}
$this->m_DefaultLanguage = $result->fields[0];
$this->m_DefaultTheme = $result->fields[1];
$this->m_DBSchemaVersion = $result->fields[2];
$this->m_SystemSecurityContextId = $result->fields[3];
//get module list
$m_ModuleList=array();
$i=0;
$sql = sprintf("SELECT Name,Path,Version,Loaded FROM Modules");
$result = $adodbConnection->Execute($sql);
if ($result === false)
{
AddError(DB_ERROR,$adodbConnection->ErrorMsg(),'',"","SystemConfiguration","SystemConfiguration");
return false;
}
else
while($result)
{ if($result->fileds[0] != "In-portal")
{ $this->m_ModuleList[$i]['Name']=$result->fileds[0];
$this->m_ModuleList[$i]['Path']=$result->fileds[1];
$this->m_ModuleList[$i]['Version']=$result->fileds[2];
$this->m_ModuleList[$i]['Loaded']=$result->fileds[3];
$i++;
}
$result->MoveNext();
}
}
//Required attributes accessors YOU MUST USE THIS FUNCTIONS
//TO READ AND WRITE ATTRIBUTES VALUES
function GetDefaultLanguage()
{
return $this->m_DefaultLanguage;
}
function SetDefaultLanguage($value)
{
$this->m_DefaultLanguage = $value;
$this->m_dirtyFieldsMap['DefaultLanguage'] = $value;
}
function GetDefaultTheme()
{
return $this->m_DefaultTheme;
}
function SetDefaultTheme($value)
{
$this->m_DefaultTheme = $value;
$this->m_dirtyFieldsMap['DefaultTheme'] = $value;
}
function GetDBSchemaVersion()
{
return $this->m_DBSchemaVersion;
}
function SetDBSchemaVersion($value)
{
$this->m_DBSchemaVersion = $value;
$this->m_dirtyFieldsMap['DBSchemaVersion'] = $value;
}
function GetSystemSecurityContext()
{
return $this->m_SystemSecurityContextId;
}
function SetSystemSecurityContext($value)
{
$this->m_SystemSecurityContextId = $value;
$this->m_dirtyFieldsMap['SystemSecurityContextId'] = $value;
}
function Update($adodbConnection)
{
if(count($this->m_dirtyFieldsMap) == 0)
return true;
$adodbConnection = &GetADODBConnection();
$sql = 'UPDATE SystemConfiguration SET ';
$first = 1;
foreach ($this->m_dirtyFieldsMap as $key => $value)
{
if($first)
{
$sql = sprintf("%s %s=%s",$sql,$key,$adodbConnection->qstr($value));
$first = 0;
}
else
{
$sql = sprintf("%s, %s=%s",$sql,$key,$adodbConnection->qstr($value));
}
}
if ($adodbConnection->Execute($sql) === false)
{
AddError(DB_ERROR,$adodbConnection->ErrorMsg(),'',"","SystemConfiguration","Update");
return false;
}
return true;
}
function GetValue($variableName)
{
$adodbConnection = &GetADODBConnection(); // create a connection
$sql = sprintf("SELECT VariableValue FROM ConfigurationValues WHERE VariableName = '%s'",$variableName);
$result = $adodbConnection->Execute($sql);
if ($result === false)
{
AddError(DB_ERROR,$adodbConnection->ErrorMsg(),'',"","SystemConfiguration","GetValue");
return false;
}
return $result->fields[0];
}
function SetValue($variableName, $variableValue)
{
$adodbConnection = &GetADODBConnection(); // create a connection
if($variableValue == NULL) //Remove field
{
$sql = sprintf("DELETE FROM ConfigurationValues WHERE VariableName = '%s'",$variableName);
$adodbConnection->Execute($sql);
return true;
}
//Befoe insert may be field already exists - try to update it
$sql = sprintf("SELECT * FROM ConfigurationValues WHERE VariableName = '%s'",$variableName);
$result = $adodbConnection->Execute($sql);
if ($result === false)
{
AddError("error.DatabaseError",NULL,$adodbConnection->ErrorMsg(),"","SystemConfiguration","SetValue");
return false;
}
if(!$result->EOF) //Field alredy exists - just update it;s value
{
$sql = sprintf("UPDATE ConfigurationValues SET VariableValue = '$variableValue' WHERE VariableName = '%s'",$variableName);
$adodbConnection->Execute($sql);
if ($result === false)
{
AddError("error.DatabaseError",NULL,$adodbConnection->ErrorMsg(),"","SystemConfiguration","SetValue");
return false;
}
return true;
}
//Does not exists - insert
if($result->EOF) //Field alredy exists - just update it;s value
{
$sql = sprintf("INSERT INTO ConfigurationValues (VariableName,VariableValue) VALUES('%s','%s')", $variableName,$variableValue);
$adodbConnection->Execute($sql);
if ($result === false)
{
AddError("error.DatabaseError",NULL,$adodbConnection->ErrorMsg(),"","SystemConfiguration","SetValue");
return false;
}
return true;
}
}
function GetModuleList()
{ return $this->m_ModuleList;
}
//Common DB operation class variables
var $m_dirtyFieldsMap = array();
//Required attributes
var $m_DefaultLanguage;
var $m_DefaultTheme;
var $m_DBSchemaVersion;
var $m_SystemSecurityContextId;
var $m_ModuleList;
}*/
?>
Event Timeline
Log In to Comment