mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Read-only mode - draft
SVN:trunk[961]
This commit is contained in:
@@ -661,6 +661,15 @@ EOF
|
||||
}
|
||||
$sLogOffMenu .= "</ul>\n</li>\n</ul></span>\n";
|
||||
|
||||
if (MetaModel::DBIsReadOnly())
|
||||
{
|
||||
$sApplicationMode = Dict::S('UI:ApplicationReadOnly');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sApplicationMode = '';
|
||||
}
|
||||
|
||||
//$sLogOffMenu = "<span id=\"logOffBtn\" style=\"height:55px;padding:0;margin:0;\"><img src=\"../images/onOffBtn.png\"></span>";
|
||||
|
||||
echo '<div id="left-pane" class="ui-layout-west">';
|
||||
@@ -687,8 +696,8 @@ EOF
|
||||
|
||||
echo '<div class="ui-layout-center">';
|
||||
echo ' <div id="top-bar" style="width:100%">';
|
||||
echo ' <div id="global-search"><form action="../pages/UI.php"><table><tr><td id="g-search-input"><input type="text" name="text" value="'.$sText.'"'.$sOnClick.'/></td>';
|
||||
echo '<td><input type="image" src="../images/searchBtn.png"/></a></td>';
|
||||
echo ' <div id="global-search"><form action="../pages/UI.php"><table><tr><td></td><td id="g-search-input"><input type="text" name="text" value="'.$sText.'"'.$sOnClick.'/></td>';
|
||||
echo '<td><input type="image" src="../images/searchBtn.png"/></a></td><td>'.$sApplicationMode.'</td>';
|
||||
echo '<td><a style="background:transparent;" href="http://www.combodo.com/itop-help" target="_blank"><img style="border:0;padding-left:20px;padding-right:10px;" title="'.Dict::S('UI:Help').'" src="../images/help.png"/></td>';
|
||||
echo '<td style="padding-right:20px;padding-left:10px;">'.$sLogOffMenu.'</td><td><input type="hidden" name="operation" value="full_text"/></td></tr></table></form></div>';
|
||||
//echo '<td> <input type="hidden" name="operation" value="full_text"/></td></tr></table></form></div>';
|
||||
|
||||
@@ -134,6 +134,14 @@ class Config
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => false,
|
||||
),
|
||||
'read_only' => array(
|
||||
'type' => 'bool',
|
||||
'description' => 'Freeze the data for administration purposes - administrators can still do anything... in appearance!',
|
||||
'default' => false,
|
||||
'value' => '',
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => false,
|
||||
),
|
||||
);
|
||||
|
||||
public function IsProperty($sPropCode)
|
||||
|
||||
@@ -849,7 +849,14 @@ abstract class DBObject
|
||||
|
||||
$sInsertSQL = "INSERT INTO `$sTable` (".join(",", $aFieldsToWrite).") VALUES (".join(", ", $aValuesToWrite).")";
|
||||
|
||||
$iNewKey = CMDBSource::InsertInto($sInsertSQL);
|
||||
if (MetaModel::DBIsReadOnly())
|
||||
{
|
||||
$iNewKey = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$iNewKey = CMDBSource::InsertInto($sInsertSQL);
|
||||
}
|
||||
// Note that it is possible to have a key defined here, and the autoincrement expected, this is acceptable in a non root class
|
||||
if (empty($this->m_iKey))
|
||||
{
|
||||
@@ -1009,7 +1016,10 @@ abstract class DBObject
|
||||
$oFilter->AddCondition('id', $this->m_iKey, '=');
|
||||
|
||||
$sSQL = MetaModel::MakeUpdateQuery($oFilter, $aChanges);
|
||||
CMDBSource::Query($sSQL);
|
||||
if (!MetaModel::DBIsReadOnly())
|
||||
{
|
||||
CMDBSource::Query($sSQL);
|
||||
}
|
||||
}
|
||||
|
||||
$this->DBWriteLinks();
|
||||
@@ -1053,7 +1063,10 @@ abstract class DBObject
|
||||
$this->OnDelete();
|
||||
|
||||
$sSQL = MetaModel::MakeDeleteQuery($oFilter);
|
||||
CMDBSource::Query($sSQL);
|
||||
if (!MetaModel::DBIsReadOnly())
|
||||
{
|
||||
CMDBSource::Query($sSQL);
|
||||
}
|
||||
|
||||
$this->AfterDelete();
|
||||
|
||||
|
||||
@@ -1401,6 +1401,7 @@ abstract class MetaModel
|
||||
|
||||
public static function Init_OverloadStateAttribute($sStateCode, $sAttCode, $iFlags)
|
||||
{
|
||||
// Warning: this is not sufficient: the flags have to be copied to the states that are inheriting from this state
|
||||
$sTargetClass = self::GetCallersPHPClass("Init");
|
||||
self::$m_aStates[$sTargetClass][$sStateCode]['attribute_list'][$sAttCode] = $iFlags;
|
||||
}
|
||||
@@ -2535,6 +2536,12 @@ abstract class MetaModel
|
||||
return $aDataDump;
|
||||
}
|
||||
|
||||
// Temporary - investigate the cost of such a limitation
|
||||
public static function DBIsReadOnly()
|
||||
{
|
||||
return self::$m_oConfig->Get('read_only');
|
||||
}
|
||||
|
||||
protected static function MakeDictEntry($sKey, $sValueFromOldSystem, $sDefaultValue, &$bNotInDico)
|
||||
{
|
||||
$sValue = Dict::S($sKey, 'x-no-nothing');
|
||||
@@ -3505,14 +3512,20 @@ abstract class MetaModel
|
||||
public static function BulkDelete(DBObjectSearch $oFilter)
|
||||
{
|
||||
$sSQL = self::MakeDeleteQuery($oFilter);
|
||||
CMDBSource::Query($sSQL);
|
||||
if (!self::DBIsReadOnly())
|
||||
{
|
||||
CMDBSource::Query($sSQL);
|
||||
}
|
||||
}
|
||||
|
||||
public static function BulkUpdate(DBObjectSearch $oFilter, array $aValues)
|
||||
{
|
||||
// $aValues is an array of $sAttCode => $value
|
||||
$sSQL = self::MakeUpdateQuery($oFilter, $aValues);
|
||||
CMDBSource::Query($sSQL);
|
||||
if (!self::DBIsReadOnly())
|
||||
{
|
||||
CMDBSource::Query($sSQL);
|
||||
}
|
||||
}
|
||||
|
||||
// Links
|
||||
|
||||
@@ -372,6 +372,11 @@ class UserRights
|
||||
|
||||
public static function CanChangePassword()
|
||||
{
|
||||
if (MetaModel::DBIsReadOnly())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_null(self::$m_oUser))
|
||||
{
|
||||
return self::$m_oUser->CanChangePassword();
|
||||
@@ -554,6 +559,14 @@ class UserRights
|
||||
|
||||
if (self::IsAdministrator($oUser)) return true;
|
||||
|
||||
if (MetaModel::DBIsReadOnly())
|
||||
{
|
||||
if ($iActionCode == UR_ACTION_MODIFY) return false;
|
||||
if ($iActionCode == UR_ACTION_DELETE) return false;
|
||||
if ($iActionCode == UR_ACTION_BULK_MODIFY) return false;
|
||||
if ($iActionCode == UR_ACTION_BULK_DELETE) return false;
|
||||
}
|
||||
|
||||
if (MetaModel::HasCategory($sClass, 'bizmodel'))
|
||||
{
|
||||
// #@# Temporary?????
|
||||
@@ -584,6 +597,14 @@ class UserRights
|
||||
|
||||
if (self::IsAdministrator($oUser)) return true;
|
||||
|
||||
if (MetaModel::DBIsReadOnly())
|
||||
{
|
||||
if ($iActionCode == UR_ACTION_MODIFY) return false;
|
||||
if ($iActionCode == UR_ACTION_DELETE) return false;
|
||||
if ($iActionCode == UR_ACTION_BULK_MODIFY) return false;
|
||||
if ($iActionCode == UR_ACTION_BULK_DELETE) return false;
|
||||
}
|
||||
|
||||
if (MetaModel::HasCategory($sClass, 'bizmodel'))
|
||||
{
|
||||
if (is_null($oUser))
|
||||
@@ -606,6 +627,14 @@ class UserRights
|
||||
|
||||
if (self::IsAdministrator($oUser)) return true;
|
||||
|
||||
if (MetaModel::DBIsReadOnly())
|
||||
{
|
||||
if ($iActionCode == UR_ACTION_MODIFY) return false;
|
||||
if ($iActionCode == UR_ACTION_DELETE) return false;
|
||||
if ($iActionCode == UR_ACTION_BULK_MODIFY) return false;
|
||||
if ($iActionCode == UR_ACTION_BULK_DELETE) return false;
|
||||
}
|
||||
|
||||
// this module is forbidden for non admins
|
||||
if (MetaModel::HasCategory($sClass, 'addon/userrights')) return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user