Compare commits

...

9 Commits

Author SHA1 Message Date
Denis Flaven
97adc9e43d The 'Search' dialog's title (which equals to the field's label) can contain single quotes. Escape them properly.
SVN:1.0.2[1131]
2011-03-16 09:13:43 +00:00
Denis Flaven
0f2b6136a3 Same fix as [1125] in the main trunk: Adjust the relative path to 'ajax.render.php' so that it can be called from the portal pages as well.
SVN:1.0.2[1127]
2011-03-11 15:40:36 +00:00
Denis Flaven
8efca80450 Same fix as [1125] in the main trunk: Adjust the relative path to 'ajax.render.php' so that it can be called from the portal pages as well.
SVN:1.0.2[1126]
2011-03-11 15:40:00 +00:00
Denis Flaven
390b29a3f6 Merged-in bug fixes from the main trunk: recursion issue and assertion failed message.
SVN:1.0.2[1081]
2011-02-09 09:50:17 +00:00
Romain Quetiez
024692c4c6 Fixed Trac #351 (re-integrated from trunk)
SVN:1.0.2[1077]
2011-02-07 16:43:59 +00:00
Romain Quetiez
4191636663 Login usage reporting (re-integrated from trunk)
SVN:1.0.2[1076]
2011-02-07 16:37:49 +00:00
Romain Quetiez
999546e355 Login usage reporting (re-integrated from trunk)
SVN:1.0.2[1075]
2011-02-07 16:33:05 +00:00
Romain Quetiez
f4bf026356 Created branch 1.0.2
SVN:1.0.2[1071]
2011-02-07 10:51:32 +00:00
Romain Quetiez
edd4f832cd Created branch 1.0.2
SVN:1.0.2[1069]
2011-02-07 10:47:11 +00:00
12 changed files with 80 additions and 31 deletions

View File

@@ -326,6 +326,16 @@ EOF
{
// User is Ok, let's save it in the session and proceed with normal login
UserRights::Login($sAuthUser, $sAuthentication); // Login & set the user's language
if (MetaModel::GetConfig()->Get('log_usage'))
{
$oLog = new EventLoginUsage();
$oLog->Set('userinfo', UserRights::GetUser());
$oLog->Set('user_id', UserRights::GetUserObject()->GetKey());
$oLog->Set('message', 'Successful login');
$oLog->DBInsertNoReload();
}
$_SESSION['auth_user'] = $sAuthUser;
$_SESSION['login_mode'] = $sLoginMode;
}

View File

@@ -155,14 +155,15 @@ EOF
$sHTMLValue .= "<input type=\"hidden\" id=\"$this->iId\" name=\"attr_{$this->sFieldPrefix}{$this->sAttCode}{$this->sNameSuffix}\" value=\"$this->value\" />\n";
// Scripts to start the autocomplete and bind some events to it
$sDialogTitle = addslashes($this->sTitle);
$oPage->add_ready_script(
<<<EOF
oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sClass}', '{$this->sAttCode}', '{$this->sNameSuffix}', $sSelectMode, oWizardHelper{$this->sFormPrefix});
oACWidget_{$this->iId}.emptyHtml = "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>$sMessage</p></div>";
$('#label_$this->iId').autocomplete('./ajax.render.php', { scroll:true, minChars:{$iMinChars}, formatItem:formatItem, autoFill:false, matchContains:true, keyHolder:'#{$this->iId}', extraParams:{operation:'autocomplete', sclass:'{$this->sClass}',attCode:'{$this->sAttCode}'}});
$('#label_$this->iId').autocomplete('../pages/ajax.render.php', { scroll:true, minChars:{$iMinChars}, formatItem:formatItem, autoFill:false, matchContains:true, keyHolder:'#{$this->iId}', extraParams:{operation:'autocomplete', sclass:'{$this->sClass}',attCode:'{$this->sAttCode}'}});
$('#label_$this->iId').blur(function() { $(this).search(); } );
$('#label_$this->iId').result( function(event, data, formatted) { OnAutoComplete('{$this->iId}', event, data, formatted); } );
$('#ac_dlg_$this->iId').dialog({ width: $(window).width()*0.8, height: $(window).height()*0.8, autoOpen: false, modal: true, title: '{$this->sTitle}', resizeStop: oACWidget_{$this->iId}.UpdateSizes, close: oACWidget_{$this->iId}.OnClose });
$('#ac_dlg_$this->iId').dialog({ width: $(window).width()*0.8, height: $(window).height()*0.8, autoOpen: false, modal: true, title: '$sDialogTitle', resizeStop: oACWidget_{$this->iId}.UpdateSizes, close: oACWidget_{$this->iId}.OnClose });
EOF
);
@@ -240,11 +241,12 @@ EOF
*/
public function GetObjectCreationForm(WebPage $oPage)
{
$sDialogTitle = addslashes($this->sTitle);
$oPage->add('<div id="ac_create_'.$this->iId.'"><div class="wizContainer" style="vertical-align:top;"><div id="dcr_'.$this->iId.'">');
$oPage->add("<h1>".MetaModel::GetClassIcon($this->sTargetClass)."&nbsp;".Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($this->sTargetClass))."</h1>\n");
cmdbAbstractObject::DisplayCreationForm($oPage, $this->sTargetClass, null, array(), array('formPrefix' => $this->iId, 'noRelations' => true));
$oPage->add('</div></div></div>');
$oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: $(window).width()*0.8, height: 'auto', autoOpen: false, modal: true, title: '$this->sTitle'});\n");
$oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: $(window).width()*0.8, height: 'auto', autoOpen: false, modal: true, title: '$sDialogTitle'});\n");
$oPage->add_ready_script("$('#dcr_{$this->iId} form').removeAttr('onsubmit');");
$oPage->add_ready_script("$('#dcr_{$this->iId} form').bind('submit.uilinksWizard', oACWidget_{$this->iId}.DoCreateObject);");
}
@@ -264,8 +266,6 @@ EOF
$oObj->DBInsertTracked($oMyChange);
return array('name' => $oObj->GetName(), 'id' => $oObj->GetKey());
//return array('name' => 'test', 'id' => '42');
}
}
?>

View File

@@ -132,7 +132,7 @@ class UILinksWizard
function AddObjects()
{
// TO DO: compute the list of objects already linked with the current Object
$.post( 'ajax.render.php', { 'operation': 'addObjects',
$.post( '../pages/ajax.render.php', { 'operation': 'addObjects',
'class': '{$this->m_sClass}',
'linkageAttr': '{$this->m_sLinkageAttr}',
'linkedClass': '{$this->m_sLinkedClass}',
@@ -175,7 +175,7 @@ class UILinksWizard
theMap['operation'] = 'searchObjectsToAdd';
// Run the query and display the results
$.post( 'ajax.render.php', theMap,
$.post( '../pages/ajax.render.php', theMap,
function(data)
{
$('#SearchResultsToAdd').html(data);
@@ -223,7 +223,7 @@ class UILinksWizard
theMap['operation'] = 'doAddObjects';
// Run the query and display the results
$.post( 'ajax.render.php', theMap,
$.post( '../pages/ajax.render.php', theMap,
function(data)
{
//console.log('Data: ' + data);

View File

@@ -865,8 +865,10 @@ class BulkChange
// Assumption: there is only one class of objects being loaded
// Then the last class found gives us the class for every object
$aDetails[] = array('date' => $sDate, 'user' => $sUser, 'class' => $sClass, 'created' => $iCreated, 'modified' => $iModified);
if ( ($iModified > 0) || ($iCreated > 0))
{
$aDetails[] = array('date' => $sDate, 'user' => $sUser, 'class' => $sClass, 'created' => $iCreated, 'modified' => $iModified);
}
}

View File

@@ -205,6 +205,14 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => true,
),
'log_usage' => array(
'type' => 'bool',
'description' => 'Log the usage of the application (i.e. the date/time and the user name of each login)',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
);
public function IsProperty($sPropCode)
@@ -333,7 +341,7 @@ class Config
'application/menunode.class.inc.php',
'application/user.preferences.class.inc.php',
'application/audit.rule.class.inc.php',
// Romain - That's dirty, because those 3 classes are in fact part of the core
// Romain - That's dirty, because those classes are in fact part of the core
// but I needed those classes to be derived from cmdbAbstractObject
// (to be managed via the GUI) and this class in not really known from
// the core, PLUS I needed the includes to be there also for the setup

View File

@@ -258,4 +258,35 @@ class EventWebService extends Event
}
}
class EventLoginUsage extends Event
{
public static function Init()
{
$aParams = array
(
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_event_loginusage",
"db_key_field" => "id",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeExternalKey("user_id", array("targetclass"=>"User", "jointype"=> "", "allowed_values"=>null, "sql"=>"user_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("contact_name", array("allowed_values"=>null, "extkey_attcode"=>"user_id", "target_attcode"=>"contactid", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("contact_email", array("allowed_values"=>null, "extkey_attcode"=>"user_id", "target_attcode"=>"email", "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'user_id', 'contact_name', 'contact_email', 'userinfo', 'message')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('date', 'user_id', 'contact_name', 'contact_email', 'userinfo')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('date', 'user_id', 'contact_name', 'contact_email')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
}
?>

View File

@@ -114,7 +114,7 @@ function ExtKeyWidget(id, sClass, sAttCode, sSuffix, bSelectMode, oWizHelper)
me.StopPendingRequest();
// Run the query and display the results
me.ajax_request = $.post( 'ajax.render.php', theMap,
me.ajax_request = $.post( '../pages/ajax.render.php', theMap,
function(data)
{
$(sSearchAreaId).html(data);
@@ -150,7 +150,7 @@ function ExtKeyWidget(id, sClass, sAttCode, sSuffix, bSelectMode, oWizHelper)
me.StopPendingRequest();
// Run the query and get the result back directly in JSON
me.ajax_request = $.post( 'ajax.render.php', theMap,
me.ajax_request = $.post( '../pages/ajax.render.php', theMap,
function(data)
{
$('#label_'+me.id).val(data.name);
@@ -205,7 +205,7 @@ function ExtKeyWidget(id, sClass, sAttCode, sSuffix, bSelectMode, oWizHelper)
me.StopPendingRequest();
// Run the query and get the result back directly in HTML
me.ajax_request = $.post( 'ajax.render.php', theMap,
me.ajax_request = $.post( '../pages/ajax.render.php', theMap,
function(data)
{
$('#ajax_'+me.id).html(data);
@@ -275,7 +275,7 @@ function ExtKeyWidget(id, sClass, sAttCode, sSuffix, bSelectMode, oWizHelper)
me.StopPendingRequest();
// Run the query and get the result back directly in JSON
me.ajax_request = $.post( 'ajax.render.php', theMap,
me.ajax_request = $.post( '../pages/ajax.render.php', theMap,
function(data)
{
if (me.bSelectMode)

View File

@@ -96,7 +96,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates)
$(sSearchAreaId).block();
// Run the query and display the results
$.post( 'ajax.render.php', theMap,
$.post( '../pages/ajax.render.php', theMap,
function(data)
{
$(sSearchAreaId).html(data);
@@ -147,7 +147,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates)
theMap['operation'] = 'doAddObjects';
$('#busy_'+me.iInputId).html('&nbsp;<img src="../images/indicator.gif"/>');
// Run the query and display the results
$.post( 'ajax.render.php', theMap,
$.post( '../pages/ajax.render.php', theMap,
function(data)
{
//console.log('Data: ' + data);

View File

@@ -21,7 +21,7 @@ function ReloadTruncatedList(divId, sSerializedFilter, sExtraParams)
console.log('Uh,uh, exception !');
}
}
aTruncatedLists[divId] = $.post('ajax.render.php?style=list',
aTruncatedLists[divId] = $.post('../pages/ajax.render.php?style=list',
{ operation: 'ajax', filter: sSerializedFilter, extra_params: sExtraParams },
function(data)
{
@@ -76,7 +76,7 @@ function ReloadBlock(divId, sStyle, sSerializedFilter, sExtraParams)
{
$('#'+divId).block();
//$('#'+divId).blockUI();
$.post('ajax.render.php?style='+sStyle,
$.post('../pages/ajax.render.php?style='+sStyle,
{ operation: 'ajax', filter: sSerializedFilter, extra_params: sExtraParams },
function(data){
$('#'+divId).empty();
@@ -136,7 +136,7 @@ function ReloadSearchForm(divId, sClassName, sBaseClass, sContext)
}
}
$.post('ajax.render.php?'+sContext,
$.post('../pages/ajax.render.php?'+sContext,
{ operation: 'search_form', className: sClassName, baseClass: sBaseClass, currentId: divId },
function(data) {
oDiv.empty();
@@ -182,7 +182,7 @@ function SetUserPreference(sPreferenceCode, sPrefValue, bPersistent)
oUserPreferences[sPreferenceCode] = sPrefValue;
if (bPersistent && (sPrefValue != sPreviousValue))
{
ajax_request = $.post('ajax.render.php',
ajax_request = $.post('../pages/ajax.render.php',
{ operation: 'set_pref', code: sPreferenceCode, value: sPrefValue} ); // Make it persistent
}
}

View File

@@ -9,7 +9,7 @@ function UpdateObjectList(sClass, sId, sExtKeyToRemote)
aRelatedObjectIds[0] = 0;
}
var oql = "SELECT "+sClass+" AS c WHERE c.id IN (" + aRelatedObjectIds.join(", ") + ")";
$.post("ajax.render.php?style=list&encoding=oql",
$.post("../pages/ajax.render.php?style=list&encoding=oql",
{ operation: "ajax", filter: oql },
function(data){
$("#related_objects_"+sId).empty();
@@ -42,7 +42,7 @@ function ManageObjects(sTitle, sClass, sId, sExtKeyToRemote)
function Manage_LoadSelect(sSelectedId, sFilter)
{
$('#'+sSelectedId).addClass('loading');
$.post('ajax.render.php',
$.post('../pages/ajax.render.php',
{ operation: 'combo_options', filter: sFilter },
function(data){
$('#'+sSelectedId).empty();

View File

@@ -133,7 +133,7 @@ function WizardHelper(sClass, sFormPrefix)
{
//console.log('data sent:', this.ToJSON());
//console.log('oWizard:', this);
$.post('ajax.render.php',
$.post('../pages/ajax.render.php',
{ operation: 'wizard_helper', json_obj: this.ToJSON() },
function(html){
$('#ajax_content').html(html);
@@ -149,7 +149,7 @@ function WizardHelper(sClass, sFormPrefix)
{
//console.log('data sent:', this.ToJSON());
//console.log('oWizard:', this);
$('#'+divId).load('ajax.render.php?operation=wizard_helper_preview',
$('#'+divId).load('../pages/ajax.render.php?operation=wizard_helper_preview',
{'json_obj': this.ToJSON()},
function(responseText, textStatus, XMLHttpRequest){
$('#wizStep'+ G_iCurrentStep).unblock( {fadeOut: 0} );

View File

@@ -59,12 +59,10 @@ function AddNodeDetails(&$oNode, $oObj)
* @param DBObject $oObj The current object
* @param string $sRelation The name of the relation to search with
*/
function GetRelatedObjectsAsXml(DBObject $oObj, $sRelationName, &$oLinks, &$oXmlDoc, &$oXmlNode)
function GetRelatedObjectsAsXml(DBObject $oObj, $sRelationName, &$oLinks, &$oXmlDoc, &$oXmlNode, $iDepth = 0)
{
$aResults = array();
$oObj->GetRelatedObjects($sRelationName, 1 /* iMaxDepth */, $aResults);
static $iDepth = 0;
$iDepth++;
if ($iDepth > MAX_RECURSION_DEPTH) return;
foreach($aResults as $sRelatedClass => $aObjects)
@@ -85,7 +83,7 @@ function GetRelatedObjectsAsXml(DBObject $oObj, $sRelationName, &$oLinks, &$oXml
AddNodeDetails($oLinkedNode, $oTargetObj);
$oSubLinks = $oXmlDoc->CreateElement('links');
// Recurse
GetRelatedObjectsAsXml($oTargetObj, $sRelationName, $oSubLinks, $oXmlDoc, $oLinkedNode);
GetRelatedObjectsAsXml($oTargetObj, $sRelationName, $oSubLinks, $oXmlDoc, $oLinkedNode, $iDepth++);
$oLinkingNode->AppendChild($oLinkedNode);
$oLinks->AppendChild($oLinkingNode);
}
@@ -139,7 +137,7 @@ try
$aResults = array();
$oObj->GetRelatedObjects($sRelation, MAX_RECURSION_DEPTH /* iMaxDepth */, $aResults);
$iBlock = 0;
$iBlock = 1; // Zero is not a valid blockid
foreach($aResults as $sClass => $aObjects)
{
$oSet = CMDBObjectSet::FromArray($sClass, $aObjects);
@@ -185,4 +183,4 @@ catch(Exception $e)
{
echo "Error: ".$e->getMessage();
}
?>
?>