当前位置: 首页>>代码示例>>PHP>>正文


PHP DBObjectSearch::FromOQL方法代码示例

本文整理汇总了PHP中DBObjectSearch::FromOQL方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObjectSearch::FromOQL方法的具体用法?PHP DBObjectSearch::FromOQL怎么用?PHP DBObjectSearch::FromOQL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBObjectSearch的用法示例。


在下文中一共展示了DBObjectSearch::FromOQL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DisplayBareProperties

 function DisplayBareProperties(WebPage $oPage, $bEditMode = false, $sPrefix = '', $aExtraParams = array())
 {
     $aFieldsMap = parent::DisplayBareProperties($oPage, $bEditMode, $sPrefix, $aExtraParams);
     if (!$bEditMode) {
         $sUrl = utils::GetAbsoluteUrlAppRoot() . 'webservices/export-v2.php?format=spreadsheet&login_mode=basic&query=' . $this->GetKey();
         $sOql = $this->Get('oql');
         $sMessage = null;
         try {
             $oSearch = DBObjectSearch::FromOQL($sOql);
             $aParameters = $oSearch->GetQueryParams();
             foreach ($aParameters as $sParam => $val) {
                 $sUrl .= '&arg_' . $sParam . '=["' . $sParam . '"]';
             }
             $oPage->p(Dict::S('UI:Query:UrlForExcel') . ':<br/><textarea cols="80" rows="3" READONLY>' . $sUrl . '</textarea>');
             if (count($aParameters) == 0) {
                 $oBlock = new DisplayBlock($oSearch, 'list');
                 $aExtraParams = array('table_id' => 'query_preview_' . $this->getKey());
                 $sBlockId = 'block_query_preview_' . $this->GetKey();
                 // make a unique id (edition occuring in the same DOM)
                 $oBlock->Display($oPage, $sBlockId, $aExtraParams);
             }
         } catch (OQLException $e) {
             $sMessage = '<div class="message message_error" style="padding-left: 30px;"><div style="padding: 10px;">' . Dict::Format('UI:RunQuery:Error', $e->getHtmlDesc()) . '</div></div>';
             $oPage->p($sMessage);
         }
     }
     return $aFieldsMap;
 }
开发者ID:henryavila,项目名称:itop,代码行数:28,代码来源:query.class.inc.php

示例2: GetRuleResultFilter

function GetRuleResultFilter($iRuleId, $oDefinitionFilter, $oAppContext)
{
    $oRule = MetaModel::GetObject('AuditRule', $iRuleId);
    $sOql = $oRule->Get('query');
    $oRuleFilter = DBObjectSearch::FromOQL($sOql);
    FilterByContext($oRuleFilter, $oAppContext);
    // Not needed since this filter is a subset of the definition filter, but may speedup things
    if ($oRule->Get('valid_flag') == 'false') {
        // The query returns directly the invalid elements
        $oFilter = $oRuleFilter->Intersect($oDefinitionFilter);
    } else {
        // The query returns only the valid elements, all the others are invalid
        $aValidRows = $oRuleFilter->ToDataArray(array('id'));
        $aValidIds = array();
        foreach ($aValidRows as $aRow) {
            $aValidIds[] = $aRow['id'];
        }
        $oFilter = $oDefinitionFilter->DeepClone();
        if (count($aValidIds) > 0) {
            $aInDefSet = array();
            foreach ($oDefinitionFilter->ToDataArray(array('id')) as $aRow) {
                $aInDefSet[] = $aRow['id'];
            }
            $aInvalids = array_diff($aInDefSet, $aValidIds);
            if (count($aInvalids) > 0) {
                $oFilter->AddCondition('id', $aInvalids, 'IN');
            } else {
                $oFilter->AddCondition('id', 0, '=');
            }
        }
    }
    return $oFilter;
}
开发者ID:henryavila,项目名称:itop,代码行数:33,代码来源:audit.php

示例3: ComputeSLT

 /**
  * Determines the shortest SLT, for this ticket, for the given metric. Returns null is no SLT was found
  * @param string $sMetric Type of metric 'TTO', 'TTR', etc as defined in the SLT class
  * @return hash Array with 'SLT' => name of the SLT selected, 'value' => duration in seconds of the SLT metric, null if no SLT applies to this ticket
  */
 protected static function ComputeSLT($oTicket, $sMetric = 'TTO')
 {
     $iDeadline = null;
     if (MetaModel::IsValidClass('SLT')) {
         $sType = get_class($oTicket);
         if ($sType == 'Incident') {
             $sRequestType = 'incident';
         } else {
             $sRequestType = $oTicket->Get('request_type');
         }
         $aArgs = $oTicket->ToArgs();
         $aArgs['metric'] = $sMetric;
         $aArgs['request_type'] = $sRequestType;
         //echo "<p>Managing:".$sMetric."-".$this->Get('request_type')."-".$this->Get('importance')."</p>\n";
         $oSLTSet = new DBObjectSet(DBObjectSearch::FromOQL(RESPONSE_TICKET_SLT_QUERY), array(), $aArgs);
         $iMinDuration = PHP_INT_MAX;
         $sSLTName = '';
         while ($oSLT = $oSLTSet->Fetch()) {
             $iDuration = (int) $oSLT->Get('value');
             $sUnit = $oSLT->Get('unit');
             switch ($sUnit) {
                 case 'days':
                     $iDuration = $iDuration * 24;
                     // 24 hours in 1 days
                     // Fall though
                 // 24 hours in 1 days
                 // Fall though
                 case 'hours':
                     $iDuration = $iDuration * 60;
                     // 60 minutes in 1 hour
                     // Fall though
                 // 60 minutes in 1 hour
                 // Fall though
                 case 'minutes':
                     $iDuration = $iDuration * 60;
             }
             if ($iDuration < $iMinDuration) {
                 $iMinDuration = $iDuration;
                 $sSLTName = $oSLT->GetName();
             }
         }
         if ($iMinDuration == PHP_INT_MAX) {
             $iDeadline = null;
         } else {
             // Store $sSLTName to keep track of which SLT has been used
             $iDeadline = $iMinDuration;
         }
     }
     return $iDeadline;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:55,代码来源:main.itop-tickets.php

示例4: Process

 public function Process($iTimeLimit)
 {
     $sNow = date('Y-m-d H:i:s');
     // Criteria: planned, and expected to occur... ASAP or in the past
     $sOQL = "SELECT AsyncTask WHERE (status = 'planned') AND (ISNULL(planned) OR (planned < '{$sNow}'))";
     $iProcessed = 0;
     while (time() < $iTimeLimit) {
         // Next one ?
         $oSet = new CMDBObjectSet(DBObjectSearch::FromOQL($sOQL), array('created' => true), array(), null, 1);
         $oTask = $oSet->Fetch();
         if (is_null($oTask)) {
             // Nothing to be done
             break;
         }
         $iProcessed++;
         if ($oTask->Process()) {
             $oTask->DBDelete();
         }
     }
     return "processed {$iProcessed} tasks";
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:21,代码来源:asynctask.class.inc.php

示例5: Process

 public function Process($iTimeLimit)
 {
     $sDateLimit = date('Y-m-d H:i:s', time() - 24 * 3600);
     // Every BulkExportResult older than one day will be deleted
     $sOQL = "SELECT BulkExportResult WHERE created < '{$sDateLimit}'";
     $iProcessed = 0;
     while (time() < $iTimeLimit) {
         // Next one ?
         $oSet = new CMDBObjectSet(DBObjectSearch::FromOQL($sOQL), array('created' => true), array(), null, 1);
         $oSet->OptimizeColumnLoad(array('temp_file_path'));
         $oResult = $oSet->Fetch();
         if (is_null($oResult)) {
             // Nothing to be done
             break;
         }
         $iProcessed++;
         @unlink($oResult->Get('temp_file_path'));
         $oResult->DBDelete();
     }
     return "Cleaned {$iProcessed} old export results(s).";
 }
开发者ID:henryavila,项目名称:itop,代码行数:21,代码来源:bulkexport.class.inc.php

示例6: Process

 public function Process($iTimeLimit)
 {
     $oMyChange = new CMDBChange();
     $oMyChange->Set("date", time());
     $oMyChange->Set("userinfo", "Automatic updates");
     $iChangeId = $oMyChange->DBInsertNoReload();
     $aReport = array();
     $oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT ResponseTicket WHERE status = \'new\' AND tto_escalation_deadline <= NOW()'));
     while (time() < $iTimeLimit && ($oToEscalate = $oSet->Fetch())) {
         $oToEscalate->ApplyStimulus('ev_timeout');
         //$oToEscalate->Set('tto_escalation_deadline', null);
         $oToEscalate->DBUpdateTracked($oMyChange, true);
         $aReport['reached TTO ESCALATION deadline'][] = $oToEscalate->Get('ref');
     }
     $oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT ResponseTicket WHERE status = \'assigned\' AND ttr_escalation_deadline <= NOW()'));
     while (time() < $iTimeLimit && ($oToEscalate = $oSet->Fetch())) {
         $oToEscalate->ApplyStimulus('ev_timeout');
         //$oToEscalate->Set('ttr_escalation_deadline', null);
         $oToEscalate->DBUpdateTracked($oMyChange, true);
         $aReport['reached TTR ESCALATION deadline'][] = $oToEscalate->Get('ref');
     }
     $oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT ResponseTicket WHERE status = \'resolved\' AND closure_deadline <= NOW()'));
     while (time() < $iTimeLimit && ($oToEscalate = $oSet->Fetch())) {
         $oToEscalate->ApplyStimulus('ev_close');
         //$oToEscalate->Set('closure_deadline', null);
         $oToEscalate->DBUpdateTracked($oMyChange, true);
         $aReport['reached closure deadline'][] = $oToEscalate->Get('ref');
     }
     $aStringReport = array();
     foreach ($aReport as $sOperation => $aTicketRefs) {
         if (count($aTicketRefs) > 0) {
             $aStringReport[] = $sOperation . ': ' . count($aTicketRefs) . ' {' . implode(', ', $aTicketRefs) . '}';
         }
     }
     if (count($aStringReport) == 0) {
         return "No ticket to process";
     } else {
         return "Some tickets reached the limit - " . implode('; ', $aStringReport);
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:40,代码来源:main.itop-tickets.php

示例7: AfterDatabaseCreation

 /**
  * Handler called after the creation/update of the database schema
  * @param $oConfiguration Config The new configuration of the application
  * @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
  * @param $sCurrentVersion string Current version number of the module
  */
 public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
 {
     // For each record having item_org_id unset,
     //    get the org_id from the container object
     //
     // Prerequisite: change null into 0 (workaround to the fact that we cannot use IS NULL in OQL)
     SetupPage::log_info("Initializing attachment/item_org_id - null to zero");
     $sTableName = MetaModel::DBGetTable('Attachment');
     $sRepair = "UPDATE `{$sTableName}` SET `item_org_id` = 0 WHERE `item_org_id` IS NULL";
     CMDBSource::Query($sRepair);
     SetupPage::log_info("Initializing attachment/item_org_id - zero to the container");
     $oSearch = DBObjectSearch::FromOQL("SELECT Attachment WHERE item_org_id = 0");
     $oSet = new DBObjectSet($oSearch);
     $iUpdated = 0;
     while ($oAttachment = $oSet->Fetch()) {
         $oContainer = MetaModel::GetObject($oAttachment->Get('item_class'), $oAttachment->Get('item_id'), false, true);
         if ($oContainer) {
             $oAttachment->SetItem($oContainer, true);
             $iUpdated++;
         }
     }
     SetupPage::log_info("Initializing attachment/item_org_id - {$iUpdated} records have been adjusted");
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:29,代码来源:module.attachments.php

示例8: RenderOQLSearch

 public static function RenderOQLSearch($sOql, $sTitle, $sUsageId, $bSearchPane, $bSearchOpen, WebPage $oPage, $aExtraParams = array())
 {
     $sUsageId = utils::GetSafeId($sUsageId);
     $oSearch = DBObjectSearch::FromOQL($sOql);
     $sIcon = MetaModel::GetClassIcon($oSearch->GetClass());
     if ($bSearchPane) {
         $aParams = array_merge(array('open' => $bSearchOpen, 'table_id' => $sUsageId), $aExtraParams);
         $oBlock = new DisplayBlock($oSearch, 'search', false, $aParams);
         $oBlock->Display($oPage, 0);
     }
     $oPage->add("<p class=\"page-header\">{$sIcon} " . Dict::S($sTitle) . "</p>");
     $aParams = array_merge(array('table_id' => $sUsageId), $aExtraParams);
     $oBlock = new DisplayBlock($oSearch, 'list', false, $aParams);
     $oBlock->Display($oPage, $sUsageId);
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:15,代码来源:menunode.class.inc.php

示例9: array_unshift

             // No accelerator query
             array_unshift($aSearchClasses, $sClassName);
         }
     }
 }
 $aSearchClasses = array_values($aSearchClasses);
 // renumbers the array starting from zero, removing the missing indexes
 $fStarted = microtime(true);
 $iFoundInThisRound = 0;
 for ($iPos = $iCurrentPos; $iPos < count($aSearchClasses); $iPos++) {
     if ($iFoundInThisRound && microtime(true) - $fStarted >= $sMaxChunkDuration) {
         break;
     }
     $sClassSpec = $aSearchClasses[$iPos];
     if (substr($sClassSpec, 0, 7) == 'SELECT ') {
         $oFilter = DBObjectSearch::FromOQL($sClassSpec);
         $sClassName = $oFilter->GetClass();
         $sNeedleFormat = isset($aAccelerators[$sClassName]['needle']) ? $aAccelerators[$sClassName]['needle'] : '%$needle$%';
         $sNeedle = str_replace('$needle$', $sFullText, $sNeedleFormat);
         $aParams = array('needle' => $sNeedle);
     } else {
         $sClassName = $sClassSpec;
         $oFilter = new DBObjectSearch($sClassName);
         $aParams = array();
         foreach ($aFullTextNeedles as $sSearchText) {
             $oFilter->AddCondition_FullText($sSearchText);
         }
     }
     // Skip abstract classes
     if (MetaModel::IsAbstract($sClassName)) {
         continue;
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:31,代码来源:ajax.render.php

示例10: Process

 public function Process($iTimeLimit)
 {
     $aList = array();
     foreach (MetaModel::GetClasses() as $sClass) {
         foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
             if ($oAttDef instanceof AttributeStopWatch) {
                 foreach ($oAttDef->ListThresholds() as $iThreshold => $aThresholdData) {
                     $iPercent = $aThresholdData['percent'];
                     // could be different than the index !
                     $sNow = date('Y-m-d H:i:s');
                     $sExpression = "SELECT {$sClass} WHERE {$sAttCode}_laststart AND {$sAttCode}_{$iThreshold}_triggered = 0 AND {$sAttCode}_{$iThreshold}_deadline < '{$sNow}'";
                     $oFilter = DBObjectSearch::FromOQL($sExpression);
                     $oSet = new DBObjectSet($oFilter);
                     while (time() < $iTimeLimit && ($oObj = $oSet->Fetch())) {
                         $sClass = get_class($oObj);
                         $aList[] = $sClass . '::' . $oObj->GetKey() . ' ' . $sAttCode . ' ' . $iThreshold;
                         // Execute planned actions
                         //
                         foreach ($aThresholdData['actions'] as $aActionData) {
                             $sVerb = $aActionData['verb'];
                             $aParams = $aActionData['params'];
                             $aValues = array();
                             foreach ($aParams as $def) {
                                 if (is_string($def)) {
                                     // Old method (pre-2.1.0) non typed parameters
                                     $aValues[] = $def;
                                 } else {
                                     $sParamType = array_key_exists('type', $def) ? $def['type'] : 'string';
                                     switch ($sParamType) {
                                         case 'int':
                                             $value = (int) $def['value'];
                                             break;
                                         case 'float':
                                             $value = (double) $def['value'];
                                             break;
                                         case 'bool':
                                             $value = (bool) $def['value'];
                                             break;
                                         case 'reference':
                                             $value = ${$def['value']};
                                             break;
                                         case 'string':
                                         default:
                                             $value = (string) $def['value'];
                                     }
                                     $aValues[] = $value;
                                 }
                             }
                             $aCallSpec = array($oObj, $sVerb);
                             call_user_func_array($aCallSpec, $aValues);
                         }
                         // Mark the threshold as "triggered"
                         //
                         $oSW = $oObj->Get($sAttCode);
                         $oSW->MarkThresholdAsTriggered($iThreshold);
                         $oObj->Set($sAttCode, $oSW);
                         if ($oObj->IsModified()) {
                             CMDBObject::SetTrackInfo("Automatic - threshold triggered");
                             $oMyChange = CMDBObject::GetCurrentChange();
                             $oObj->DBUpdateTracked($oMyChange, true);
                         }
                         // Activate any existing trigger
                         //
                         $sClassList = implode("', '", MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
                         $oTriggerSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnThresholdReached AS t WHERE t.target_class IN ('{$sClassList}') AND stop_watch_code=:stop_watch_code AND threshold_index = :threshold_index"), array(), array('stop_watch_code' => $sAttCode, 'threshold_index' => $iThreshold));
                         while ($oTrigger = $oTriggerSet->Fetch()) {
                             $oTrigger->DoActivate($oObj->ToArgs('this'));
                         }
                     }
                 }
             }
         }
     }
     $iProcessed = count($aList);
     return "Triggered {$iProcessed} threshold(s):" . implode(", ", $aList);
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:76,代码来源:ormstopwatch.class.inc.php

示例11: GetContextDefinitions

 /**
  * Get the context definitions from the parameters / configuration. The format of the "key" string is:
  * <module>/relation_context/<class>/<relation>/<direction>
  * The values will be retrieved for the given class and all its parents and merged together as a single array.
  * Entries with an invalid query are removed from the list.
  * @param string $sContextKey The key to fetch the queries in the configuration. Example: itop-tickets/relation_context/UserRequest/impacts/down
  * @param bool $bDevelopParams Whether or not to substitute the parameters inside the queries with the supplied "context params"
  * @param array $aContextParams Arguments for the queries (via ToArgs()) if $bDevelopParams == true
  * @return multitype:multitype:string
  */
 public static function GetContextDefinitions($sContextKey, $bDevelopParams = true, $aContextParams = array())
 {
     $aContextDefs = array();
     $aLevels = explode('/', $sContextKey);
     if (count($aLevels) < 5) {
         IssueLog::Warning("GetContextDefinitions: invalid 'sContextKey' = '{$sContextKey}'. 5 levels of / are expected !");
     } else {
         $sLeafClass = $aLevels[2];
         if (!MetaModel::IsValidClass($sLeafClass)) {
             IssueLog::Warning("GetContextDefinitions: invalid 'sLeafClass' = '{$sLeafClass}'. A valid class name is expected in 3rd position inside '{$sContextKey}' !");
         } else {
             $aRelationContext = MetaModel::GetConfig()->GetModuleSetting($aLevels[0], $aLevels[1], array());
             foreach (MetaModel::EnumParentClasses($sLeafClass, ENUM_PARENT_CLASSES_ALL) as $sClass) {
                 if (isset($aRelationContext[$sClass][$aLevels[3]][$aLevels[4]]['items'])) {
                     $aContextDefs = array_merge($aContextDefs, $aRelationContext[$sClass][$aLevels[3]][$aLevels[4]]['items']);
                 }
             }
             // Check if the queries are valid
             foreach ($aContextDefs as $sKey => $sDefs) {
                 $sOQL = $aContextDefs[$sKey]['oql'];
                 try {
                     // Expand the parameters. If anything goes wrong, then the query is considered as invalid and removed from the list
                     $oSearch = DBObjectSearch::FromOQL($sOQL);
                     $aContextDefs[$sKey]['oql'] = $oSearch->ToOQL($bDevelopParams, $aContextParams);
                 } catch (Exception $e) {
                     IssueLog::Warning('Invalid OQL query: ' . $sOQL . ' in the parameter ' . $sContextKey);
                     unset($aContextDefs[$sKey]);
                 }
             }
         }
     }
     return $aContextDefs;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:43,代码来源:displayablegraph.class.inc.php

示例12: UpdateAttachments

 protected static function UpdateAttachments($oObject, $oChange = null)
 {
     self::$m_bIsModified = false;
     if (utils::ReadParam('attachment_plugin', 'not-in-form') == 'not-in-form') {
         // Workaround to an issue in iTop < 2.0
         // Leave silently if there is no trace of the attachment form
         return;
     }
     $iTransactionId = utils::ReadParam('transaction_id', null);
     if (!is_null($iTransactionId)) {
         $aActions = array();
         $aAttachmentIds = utils::ReadParam('attachments', array());
         // Get all current attachments
         $oSearch = DBObjectSearch::FromOQL("SELECT Attachment WHERE item_class = :class AND item_id = :item_id");
         $oSet = new DBObjectSet($oSearch, array(), array('class' => get_class($oObject), 'item_id' => $oObject->GetKey()));
         while ($oAttachment = $oSet->Fetch()) {
             // Remove attachments that are no longer attached to the current object
             if (!in_array($oAttachment->GetKey(), $aAttachmentIds)) {
                 $oAttachment->DBDelete();
                 $aActions[] = self::GetActionDescription($oAttachment, false);
             }
         }
         // Attach new (temporary) attachements
         $sTempId = session_id() . '_' . $iTransactionId;
         // The object is being created from a form, check if there are pending attachments
         // for this object, but deleting the "new" ones that were already removed from the form
         $aRemovedAttachmentIds = utils::ReadParam('removed_attachments', array());
         $sOQL = 'SELECT Attachment WHERE temp_id = :temp_id';
         $oSearch = DBObjectSearch::FromOQL($sOQL);
         foreach ($aAttachmentIds as $iAttachmentId) {
             $oSet = new DBObjectSet($oSearch, array(), array('temp_id' => $sTempId));
             while ($oAttachment = $oSet->Fetch()) {
                 if (in_array($oAttachment->GetKey(), $aRemovedAttachmentIds)) {
                     $oAttachment->DBDelete();
                     // temporary attachment removed, don't even mention it in the history
                 } else {
                     $oAttachment->SetItem($oObject);
                     $oAttachment->Set('temp_id', '');
                     $oAttachment->DBUpdate();
                     // temporary attachment confirmed, list it in the history
                     $aActions[] = self::GetActionDescription($oAttachment, true);
                 }
             }
         }
         if (count($aActions) > 0) {
             if ($oChange == null) {
                 // Let's create a change if non is supplied
                 $oChange = MetaModel::NewObject("CMDBChange");
                 $oChange->Set("date", time());
                 $sUserString = CMDBChange::GetCurrentUserName();
                 $oChange->Set("userinfo", $sUserString);
                 $iChangeId = $oChange->DBInsert();
             }
             foreach ($aActions as $sActionDescription) {
                 self::RecordHistory($oChange, $oObject, $sActionDescription);
             }
             self::$m_bIsModified = true;
         }
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:60,代码来源:main.attachments.php

示例13: DoUpdateObjectFromPostedForm

 /**
  * 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);
         }
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:55,代码来源:portalwebpage.class.inc.php

示例14: DeleteConnectedNetworkDevice

 protected function DeleteConnectedNetworkDevice()
 {
     // The device might be already deleted (reentrance in the current procedure when both device are NETWORK devices!)
     $oDevice = MetaModel::GetObject('ConnectableCI', $this->Get('connectableci_id'), false);
     if (is_object($oDevice) && get_class($oDevice) == 'NetworkDevice') {
         // Track and delete the counterpart link
         $sOQL = "SELECT  lnkConnectableCIToNetworkDevice WHERE connectableci_id = :device AND networkdevice_id = :network AND network_port = :nwport AND device_port = :devport";
         $oConnectionSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL), array(), array('network' => $this->Get('connectableci_id'), 'device' => $this->Get('networkdevice_id'), 'devport' => $this->Get('network_port'), 'nwport' => $this->Get('device_port')));
         // There should be one link - do it in a safe manner anyway
         while ($oConnection = $oConnectionSet->Fetch()) {
             $oConnection->DBDelete();
         }
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:14,代码来源:model.itop-config-mgmt.php

示例15: DoJob3

 /**
  * Do the synchronization job #3: Delete replica depending on the obsolescence scheme
  * @param integer $iMaxReplica Limit the number of replicas to process 
  * @param integer $iCurrPos Current position where to resume the processing 
  * @return true if the process must be continued
  */
 protected function DoJob3($iMaxReplica = null, $iCurrPos = -1)
 {
     $sDeletePolicy = $this->m_oDataSource->Get('delete_policy');
     if ($sDeletePolicy != 'update_then_delete') {
         // Job complete!
         $this->m_oStatLog->Set('status_curr_job', 0);
         $this->m_oStatLog->Set('status_curr_pos', -1);
         return false;
     }
     $bFirstPass = $iCurrPos == -1;
     // Get all the replicas that are to be deleted
     //
     $oDeletionDate = $this->m_oLastFullLoadStartDate;
     $iDeleteRetention = $this->m_oDataSource->Get('delete_policy_retention');
     // Duration in seconds
     if ($iDeleteRetention > 0) {
         $sInterval = "-{$iDeleteRetention} seconds";
         $oDeletionDate->Modify($sInterval);
     }
     $sDeletionDate = $oDeletionDate->Format('Y-m-d H:i:s');
     if ($bFirstPass) {
         $this->m_oStatLog->AddTrace("Deletion date: {$sDeletionDate}");
     }
     $sSelectToDelete = "SELECT SynchroReplica WHERE id > :curr_pos AND sync_source_id = :source_id AND status IN ('obsolete') AND status_last_seen < :last_import";
     $oSetScope = new DBObjectSet(DBObjectSearch::FromOQL($sSelectToDelete), array(), array('source_id' => $this->m_oDataSource->GetKey(), 'last_import' => $sDeletionDate, 'curr_pos' => $iCurrPos));
     $iCountScope = $oSetScope->Count();
     if ($iMaxReplica) {
         // Consider a given subset, starting from replica iCurrPos, limited to the count of iMaxReplica
         // The replica have to be ordered by id
         $oSetToProcess = new DBObjectSet(DBObjectSearch::FromOQL($sSelectToDelete), array('id' => true), array('source_id' => $this->m_oDataSource->GetKey(), 'last_import' => $sDeletionDate, 'curr_pos' => $iCurrPos));
         $oSetToProcess->SetLimit($iMaxReplica);
     } else {
         $oSetToProcess = $oSetScope;
     }
     $iLastReplicaProcessed = -1;
     while ($oReplica = $oSetToProcess->Fetch()) {
         $iLastReplicaProcessed = $oReplica->GetKey();
         $this->m_oStatLog->AddTrace("Destination object to be DELETED", $oReplica);
         $oReplica->DeleteDestObject($this->m_oChange, $this->m_oStatLog);
     }
     if ($iMaxReplica) {
         if ($iMaxReplica < $iCountScope) {
             // Continue with this job!
             $this->m_oStatLog->Set('status_curr_pos', $iLastReplicaProcessed);
             return true;
         }
     }
     // Job complete!
     $this->m_oStatLog->Set('status_curr_job', 0);
     $this->m_oStatLog->Set('status_curr_pos', -1);
     return false;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:58,代码来源:synchrodatasource.class.inc.php


注:本文中的DBObjectSearch::FromOQL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。