Exemplo n.º 1
0
     // Can be useful in case a user got some corrupted prefs...
     appUserPreferences::ClearPreferences();
     break;
 case 'on_form_cancel':
     // Called when a creation/modification form is cancelled by the end-user
     // Let's take this opportunity to inform the plug-ins so that they can perform some cleanup
     $iTransactionId = utils::ReadParam('transaction_id', 0);
     $sTempId = session_id() . '_' . $iTransactionId;
     foreach (MetaModel::EnumPlugins('iApplicationUIExtension') as $oExtensionInstance) {
         $oExtensionInstance->OnFormCancel($sTempId);
     }
     $sObjClass = utils::ReadParam('obj_class', '', false, 'class');
     $iObjKey = (int) utils::ReadParam('obj_key', 0, false, 'integer');
     $sToken = utils::ReadParam('token', 0, false, 'raw_data');
     if ($sObjClass != '' && $iObjKey != 0 && $sToken != '') {
         $bReleaseLock = iTopOwnershipLock::ReleaseLock($sObjClass, $iObjKey, $sToken);
     }
     break;
 case 'reload_dashboard':
     $oPage->SetContentType('text/html');
     $sDashboardId = utils::ReadParam('dashboard_id', '', false, 'raw_data');
     $aExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data');
     ApplicationMenu::LoadAdditionalMenus();
     $idx = ApplicationMenu::GetMenuIndexById($sDashboardId);
     $oMenu = ApplicationMenu::GetMenuNode($idx);
     $oDashboard = $oMenu->GetDashboard();
     $oDashboard->Render($oPage, false, $aExtraParams);
     $oPage->add_ready_script("\$('.dashboard_contents table.listResults').tableHover(); \$('.dashboard_contents table.listResults').tablesorter( { widgets: ['myZebra', 'truncatedList']} );");
     break;
 case 'dashboard_editor':
     $sId = utils::ReadParam('id', '', false, 'raw_data');
 /**
  * Updates the object form POSTED arguments, and writes it into the DB (applies a stimuli if requested)
  * @param DBObject $oObj The object to update
  * $param array $aAttList If set, this will limit the list of updated attributes	 
  * @return void
  */
 public function DoUpdateObjectFromPostedForm(DBObject $oObj, $aAttList = null)
 {
     $sTransactionId = utils::ReadPostedParam('transaction_id', '');
     if (!utils::IsTransactionValid($sTransactionId)) {
         throw new TransactionException();
     }
     $sClass = get_class($oObj);
     $sStimulus = trim(utils::ReadPostedParam('apply_stimulus', ''));
     $sTargetState = '';
     if (!empty($sStimulus)) {
         // Compute the target state
         $aTransitions = $oObj->EnumTransitions();
         if (!isset($aTransitions[$sStimulus])) {
             throw new ApplicationException(Dict::Format('UI:Error:Invalid_Stimulus_On_Object_In_State', $sStimulus, $oObj->GetName(), $oObj->GetStateLabel()));
         }
         $sTargetState = $aTransitions[$sStimulus]['target_state'];
     }
     $oObj->UpdateObjectFromPostedForm('', $aAttList, $sTargetState);
     // Optional: apply a stimulus
     //
     if (!empty($sStimulus)) {
         if (!$oObj->ApplyStimulus($sStimulus)) {
             throw new Exception("Cannot apply stimulus '{$sStimulus}' to {$oObj->GetName()}");
         }
     }
     if ($oObj->IsModified()) {
         // Record the change
         //
         $oObj->DBUpdate();
         // Trigger ?
         //
         $aClasses = MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL);
         $sClassList = implode(", ", CMDBSource::Quote($aClasses));
         $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnPortalUpdate AS t WHERE t.target_class IN ({$sClassList})"));
         while ($oTrigger = $oSet->Fetch()) {
             $oTrigger->DoActivate($oObj->ToArgs('this'));
         }
         $this->p("<h1>" . Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName()) . "</h1>\n");
     }
     $bLockEnabled = MetaModel::GetConfig()->Get('concurrent_lock_enabled');
     if ($bLockEnabled) {
         // Release the concurrent lock, if any
         $sOwnershipToken = utils::ReadPostedParam('ownership_token', null, false, 'raw_data');
         if ($sOwnershipToken !== null) {
             // We're done, let's release the lock
             iTopOwnershipLock::ReleaseLock(get_class($oObj), $oObj->GetKey(), $sOwnershipToken);
         }
     }
 }
Exemplo n.º 3
0
                     // Found issues, explain and give the user a second chance
                     //
                     $oObj->DisplayStimulusForm($oP, $sStimulus);
                     $sIssueDesc = Dict::Format('UI:ObjectCouldNotBeWritten', $sIssues);
                     $oP->add_ready_script("alert('" . addslashes($sIssueDesc) . "');");
                 } else {
                     $sMessage = Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName());
                     $sSeverity = 'ok';
                     utils::RemoveTransaction($sTransactionId);
                     $bLockEnabled = MetaModel::GetConfig()->Get('concurrent_lock_enabled');
                     if ($bLockEnabled) {
                         // Release the concurrent lock, if any
                         $sOwnershipToken = utils::ReadPostedParam('ownership_token', null, false, 'raw_data');
                         if ($sOwnershipToken !== null) {
                             // We're done, let's release the lock
                             iTopOwnershipLock::ReleaseLock(get_class($oObj), $oObj->GetKey(), $sOwnershipToken);
                         }
                     }
                 }
             }
         } else {
             $sMessage = implode('</p><p>', $aErrors);
             $sSeverity = 'error';
         }
     }
     if ($bDisplayDetails) {
         ReloadAndDisplay($oP, $oObj, 'apply_stimulus', $sMessage, $sSeverity);
     }
 } else {
     $oP->set_title(Dict::S('UI:ErrorPageTitle'));
     $oP->P(Dict::S('UI:ObjectDoesNotExist'));