• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP DBObjectSearch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: 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


示例3: CreateTicket

/**
 * Create a User Request ticket from the basic information retrieved from an email
 * @param string $sSenderEmail eMail address of the sender (From), used to lookup a contact in iTop
 * @param string $sSubject eMail's subject, will be turned into the title of the ticket
 * @param string $sBody Body of the email, will be fitted into the ticket's description
 * @return UserRequest The created ticket, or  null if the creation failed for some reason...
 */
function CreateTicket($sSenderEmail, $sSubject, $sBody)
{
    $oTicket = null;
    try {
        $oContactSearch = new DBObjectSearch('Contact');
        // Can be either a Person or a Team, but must be a valid Contact
        $oContactSearch->AddCondition('email', $sSenderEmail, '=');
        $oSet = new DBObjectSet($oContactSearch);
        if ($oSet->Count() == 1) {
            $oContact = $oSet->Fetch();
            $oOrganization = MetaModel::GetObject('Organization', $oContact->Get('org_id'));
            $oTicket = new UserRequest();
            $oTicket->Set('title', $sSubject);
            $oTicket->Set('description', $sBody);
            $oTicket->Set('org_id', $oOrganization->GetKey());
            $oTicket->Set('caller_id', $oContact->GetKey());
            $oTicket->Set('impact', DEFAULT_IMPACT);
            $oTicket->Set('urgency', DEFAULT_URGENCY);
            $oTicket->Set('product', DEFAULT_PRODUCT);
            $oTicket->Set('service_id', DEFAULT_SERVICE_ID);
            //  Can be replaced by a search for a valid service for this 'org_id'
            $oTicket->Set('servicesubcategory_id', DEFAULT_SUBSERVICE_ID);
            // Same as above...
            $oTicket->Set('workgroup_id', DEFAULT_WORKGROUP_ID);
            // Same as above...
            // Record the change information about the object
            $oMyChange = MetaModel::NewObject("CMDBChange");
            $oMyChange->Set("date", time());
            $sUserString = $oContact->GetName() . ', submitted by email';
            $oMyChange->Set("userinfo", $sUserString);
            $iChangeId = $oMyChange->DBInsert();
            $oTicket->DBInsertTracked($oMyChange);
        } else {
            echo "No contact found in iTop having the email: {$sSenderEmail}, email message ignored.\n";
        }
    } catch (Exception $e) {
        echo "Error: exception " . $e->getMessage();
        $oTicket = null;
    }
    return $oTicket;
}
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:48,代码来源:createfrommail.php


示例4: 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


示例5: 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


示例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: ReloadState

 public function ReloadState()
 {
     if ($this->sToken == null) {
         throw new Exception('ExcelExporter not initialized with a token, cannot reload state');
     }
     if (!file_exists($this->GetStateFile())) {
         throw new Exception("ExcelExporter: missing status file '" . $this->GetStateFile() . "', cannot reload state.");
     }
     $sJson = file_get_contents($this->GetStateFile());
     $aState = json_decode($sJson, true);
     if ($aState === null) {
         throw new Exception("ExcelExporter:corrupted status file '" . $this->GetStateFile() . "', not a JSON, cannot reload state.");
     }
     $this->sState = $aState['state'];
     $this->aStatistics = $aState['statistics'];
     $this->oSearch = DBObjectSearch::unserialize($aState['filter']);
     $this->iPosition = $aState['position'];
     $this->iChunkSize = $aState['chunk_size'];
     $this->aObjectsIDs = $aState['object_ids'];
     $this->sOutputFilePath = $aState['output_file_path'];
     $this->bAdvancedMode = $aState['advanced_mode'];
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:22,代码来源:excelexporter.class.inc.php


示例8: 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


示例9: CheckParameters

/**
 * Checks the parameters and returns the appropriate exporter (if any)
 * @param string $sExpression The OQL query to export or null
 * @param string $sQueryId The entry in the query phrasebook if $sExpression is null
 * @param string $sFormat The code of export format: csv, pdf, html, xlsx
 * @throws MissingQueryArgument
 * @return Ambigous <iBulkExport, NULL>
 */
function CheckParameters($sExpression, $sQueryId, $sFormat)
{
    $oExporter = null;
    if ($sExpression === null && $sQueryId === null) {
        ReportErrorAndUsage("Missing parameter. The parameter 'expression' or 'query' must be specified.");
    }
    // Either $sExpression or $sQueryId must be specified
    if ($sExpression === null) {
        $oSearch = DBObjectSearch::FromOQL('SELECT QueryOQL WHERE id = :query_id', array('query_id' => $sQueryId));
        $oQueries = new DBObjectSet($oSearch);
        if ($oQueries->Count() > 0) {
            $oQuery = $oQueries->Fetch();
            $sExpression = $oQuery->Get('oql');
            $sFields = $oQuery->Get('fields');
            if (strlen($sFields) == 0) {
                $sFields = trim($oQuery->Get('fields'));
            }
        } else {
            ReportErrorAndExit("Invalid query phrasebook identifier: '{$sQueryId}'");
        }
    }
    if ($sFormat === null) {
        ReportErrorAndUsage("Missing parameter 'format'.");
    }
    // Check if the supplied query is valid (and all the parameters are supplied
    try {
        $oSearch = DBObjectSearch::FromOQL($sExpression);
        $aArgs = array();
        foreach ($oSearch->GetQueryParams() as $sParam => $foo) {
            $value = utils::ReadParam('arg_' . $sParam, null, true, 'raw_data');
            if (!is_null($value)) {
                $aArgs[$sParam] = $value;
            } else {
                throw new MissingQueryArgument("Missing parameter '--arg_{$sParam}'");
            }
        }
        $oSearch->SetInternalParams($aArgs);
        $sFormat = utils::ReadParam('format', 'html', true, 'raw_data');
        $oExporter = BulkExport::FindExporter($sFormat, $oSearch);
        if ($oExporter == null) {
            $aSupportedFormats = BulkExport::FindSupportedFormats();
            ReportErrorAndExit("Invalid output format: '{$sFormat}'. The supported formats are: " . implode(', ', array_keys($aSupportedFormats)));
        }
    } catch (MissingQueryArgument $e) {
        ReportErrorAndUsage("Invalid OQL query: '{$sExpression}'.\n" . $e->getMessage());
    } catch (OQLException $e) {
        ReportErrorAndExit("Invalid OQL query: '{$sExpression}'.\n" . $e->getMessage());
    } catch (Exception $e) {
        ReportErrorAndExit($e->getMessage());
    }
    $oExporter->SetFormat($sFormat);
    $oExporter->SetChunkSize(EXPORTER_DEFAULT_CHUNK_SIZE);
    $oExporter->SetObjectList($oSearch);
    $oExporter->ReadParameters();
    return $oExporter;
}
开发者ID:henryavila,项目名称:itop,代码行数:64,代码来源:export-v2.php


示例10: GetDescription

 /**
  * Describe (as a text string) the modifications corresponding to this change
  */
 public function GetDescription()
 {
     // Temporary, until we change the options of GetDescription() -needs a more global revision
     $bIsHtml = true;
     $sResult = '';
     $sTargetObjectClass = 'Attachment';
     $iTargetObjectKey = $this->Get('attachment_id');
     $sFilename = htmlentities($this->Get('filename'), ENT_QUOTES, 'UTF-8');
     $oTargetSearch = new DBObjectSearch($sTargetObjectClass);
     $oTargetSearch->AddCondition('id', $iTargetObjectKey, '=');
     $oMonoObjectSet = new DBObjectSet($oTargetSearch);
     if ($oMonoObjectSet->Count() > 0) {
         $oAttachment = $oMonoObjectSet->Fetch();
         $oDoc = $oAttachment->Get('contents');
         $sPreview = $oDoc->IsPreviewAvailable() ? 'data-preview="true"' : '';
         $sResult = Dict::Format('Attachments:History_File_Added', '<span class="attachment-history-added attachment"><a ' . $sPreview . ' target="_blank" href="' . $oDoc->GetDownloadURL($sTargetObjectClass, $iTargetObjectKey, 'contents') . '">' . $sFilename . '</a></span>');
     } else {
         $sResult = Dict::Format('Attachments:History_File_Added', '<span class="attachment-history-deleted">' . $sFilename . '</span>');
     }
     return $sResult;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:24,代码来源:main.attachments.php


示例11: __construct

 /**
  *	throws an exception in case of a wrong syntax
  */
 public function __construct($sOQL, ModelReflection $oModelReflection)
 {
     $this->oFilter = DBObjectSearch::FromOQL($sOQL);
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:7,代码来源:modelreflection.class.inc.php


示例12: DBObjectSearch

            $oFilter = new DBObjectSearch($sClass);
            foreach ($aFullTextNeedles as $sSearchText) {
                $oFilter->AddCondition_FullText($sSearchText);
            }
            $oSet = new DBObjectSet($oFilter);
            $oPage->add("<div class=\"page_header\">\n");
            $oPage->add("<h2>" . MetaModel::GetClassIcon($sClass) . "&nbsp;<span class=\"hilite\">" . Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', $oSet->Count(), Metamodel::GetName($sClass)) . "</h2>\n");
            $oPage->add("</div>\n");
            if ($oSet->Count() > 0) {
                $aLeafs = array();
                while ($oObj = $oSet->Fetch()) {
                    if (get_class($oObj) == $sClass) {
                        $aLeafs[] = $oObj->GetKey();
                    }
                }
                $oLeafsFilter = new DBObjectSearch($sClass);
                if (count($aLeafs) > 0) {
                    $oLeafsFilter->AddCondition('id', $aLeafs, 'IN');
                    $oBlock = new DisplayBlock($oLeafsFilter, 'list', false);
                    $sBlockId = 'global_search_' . $sClass;
                    $oPage->add('<div id="' . $sBlockId . '">');
                    $oBlock->RenderContent($oPage, array('table_id' => $sBlockId, 'currentId' => $sBlockId));
                    $oPage->add('</div>');
                    $oPage->P('&nbsp;');
                    // Some space ?
                    // Hide "no object found"
                    $oPage->add_ready_script('$("#no_object_found").hide();');
                }
            }
            $oPage->add_ready_script(<<<EOF
\$('#full_text_indicator').hide();
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:31,代码来源:ajax.render.php


示例13: PopulateChildMenus

 public function PopulateChildMenus()
 {
     // Load user shortcuts in DB
     //
     $oBMSearch = new DBObjectSearch('Shortcut');
     $oBMSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
     $oBMSet = new DBObjectSet($oBMSearch, array('friendlyname' => true));
     // ascending on friendlyname
     $fRank = 1;
     while ($oShortcut = $oBMSet->Fetch()) {
         $sName = $this->GetMenuId() . '_' . $oShortcut->GetKey();
         $oShortcutMenu = new ShortcutMenuNode($sName, $oShortcut, $this->GetIndex(), $fRank++);
     }
     // Complete the tree
     //
     parent::PopulateChildMenus();
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:17,代码来源:menunode.class.inc.php


示例14: 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


示例15: GetAllowedValuesAsObjectSet

 public function GetAllowedValuesAsObjectSet($aArgs = array(), $sContains = '')
 {
     $oValSetDef = $this->GetValuesDef();
     if (array_key_exists('this', $aArgs)) {
         // Hierarchical keys have one more constraint: the "parent value" cannot be
         // "under" themselves
         $iRootId = $aArgs['this']->GetKey();
         if ($iRootId > 0) {
             $aValuesSetDef = $this->GetValuesDef();
             $sClass = $this->m_sTargetClass;
             $oFilter = DBObjectSearch::FromOQL("SELECT {$sClass} AS node JOIN {$sClass} AS root ON node." . $this->GetCode() . " NOT BELOW root.id WHERE root.id = {$iRootId}");
             $oValSetDef->AddCondition($oFilter);
         }
     }
     $oSet = $oValSetDef->ToObjectSet($aArgs, $sContains);
     return $oSet;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:17,代码来源:attributedef.class.inc.php


示例16: 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


示例17: 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


示例18: DisplayHierarchy

 /**
  * Display the hierarchy of the 'target' class
  */
 public function DisplayHierarchy(WebPage $oPage, $sFilter, $currValue, $oObj)
 {
     $sDialogTitle = addslashes(Dict::Format('UI:HierarchyOf_Class', MetaModel::GetName($this->sTargetClass)));
     $oPage->add('<div id="dlg_tree_' . $this->iId . '"><div class="wizContainer" style="vertical-align:top;"><div style="overflow:auto;background:#fff;margin-bottom:5px;" id="tree_' . $this->iId . '">');
     $oPage->add('<table style="width:100%"><tr><td>');
     if (is_null($sFilter)) {
         throw new Exception('Implementation: null value for allowed values definition');
     }
     try {
         $oFilter = DBObjectSearch::FromOQL($sFilter);
         $oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
         $oSet = new DBObjectSet($oFilter, array(), array('this' => $oObj));
     } catch (MissingQueryArgument $e) {
         // When used in a search form the $this parameter may be missing, in this case return all possible values...
         // TODO check if we can improve this behavior...
         $sOQL = 'SELECT ' . $this->m_sTargetClass;
         $oFilter = DBObjectSearch::FromOQL($sOQL);
         $oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
         $oSet = new DBObjectSet($oFilter);
     }
     $sHKAttCode = MetaModel::IsHierarchicalClass($this->sTargetClass);
     $this->DumpTree($oPage, $oSet, $sHKAttCode, $currValue);
     $oPage->add('</td></tr></table>');
     $oPage->add('</div>');
     $oPage->add("<input type=\"button\" id=\"btn_cancel_{$this->iId}\" value=\"" . Dict::S('UI:Button:Cancel') . "\" onClick=\"\$('#dlg_tree_{$this->iId}').dialog('close');\">&nbsp;&nbsp;");
     $oPage->add("<input type=\"button\" id=\"btn_ok_{$this->iId}\" value=\"" . Dict::S('UI:Button:Ok') . "\"  onClick=\"oACWidget_{$this->iId}.DoHKOk();\">");
     $oPage->add('</div></div>');
     $oPage->add_ready_script("\$('#tree_{$this->iId} ul').treeview();\n");
     $oPage->add_ready_script("\$('#dlg_tree_{$this->iId}').dialog({ width: 'auto', height: 'auto', autoOpen: true, modal: true, title: '{$sDialogTitle}', resizeStop: oACWidget_{$this->iId}.OnHKResize, close: oACWidget_{$this->iId}.OnHKClose });\n");
 }
开发者ID:henryavila,项目名称:itop,代码行数:33,代码来源:ui.extkeywidget.class.inc.php


示例19: GetSQLQuery

 protected function GetSQLQuery($aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart, $bGetCount, $aGroupByExpr = null)
 {
     // Hide objects that are not visible to the current user
     //
     $oSearch = $this;
     if (!$this->IsAllDataAllowed() && !$this->IsDataFiltered()) {
         $oVisibleObjects = UserRights::GetSelectFilter($this->GetClass(), $this->GetModifierProperties('UserRightsGetSelectFilter'));
         if ($oVisibleObjects === false) {
             // Make sure this is a valid search object, saying NO for all
             $oVisibleObjects = DBObjectSearch::FromEmptySet($this->GetClass());
         }
         if (is_object($oVisibleObjects)) {
             $oSearch = $this->Intersect($oVisibleObjects);
             $oSearch->SetDataFiltered();
         } else {
             // should be true at this point, meaning that no additional filtering
             // is required
         }
     }
     // Compute query modifiers properties (can be set in the search itself, by the context, etc.)
     //
     $aModifierProperties = MetaModel::MakeModifierProperties($oSearch);
     // Create a unique cache id
     //
     if (self::$m_bQueryCacheEnabled || self::$m_bTraceQueries) {
         // Need to identify the query
         $sOqlQuery = $oSearch->ToOql();
         if (count($aModifierProperties)) {
             array_multisort($aModifierProperties);
             $sModifierProperties = json_encode($aModifierProperties);
         } else {
             $sModifierProperties = '';
         }
         $sRawId = $sOqlQuery . $sModifierProperties;
         if (!is_null($aAttToLoad)) {
             $sRawId .= json_encode($aAttToLoad);
         }
         if (!is_null($aGroupByExpr)) {
             foreach ($aGroupByExpr as $sAlias => $oExpr) {
                 $sRawId .= 'g:' . $sAlias . '!' . $oExpr->Render();
             }
         }
         $sRawId .= $bGetCount;
         $sOqlId = md5($sRawId);
     } else {
         $sOqlQuery = "SELECTING... " . $oSearch->GetClass();
         $sOqlId = "query id ? n/a";
     }
     // Query caching
     //
     if (self::$m_bQueryCacheEnabled) {
         // Warning: using directly the query string as the key to the hash array can FAIL if the string
         // is long and the differences are only near the end... so it's safer (but not bullet proof?)
         // to use a hash (like md5) of the string as the key !
         //
         // Example of two queries that were found as similar by the hash array:
         // SELECT SLT JOIN lnkSLTToSLA AS L1 ON L1.slt_id=SLT.id JOIN SLA ON L1.sla_id = SLA.id JOIN lnkContractToSLA AS L2 ON L2.sla_id = SLA.id JOIN CustomerContract ON L2.contract_id = CustomerContract.id WHERE SLT.ticket_priority = 1 AND SLA.service_id = 3 AND SLT.metric = 'TTO' AND CustomerContract.customer_id = 2
         // and
         // SELECT SLT JOIN lnkSLTToSLA AS L1 ON L1.slt_id=SLT.id JOIN SLA ON L1.sla_id = SLA.id JOIN lnkContractToSLA AS L2 ON L2.sla_id = SLA.id JOIN CustomerContract ON L2.contract_id = Cus 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP DBObjectSet类代码示例发布时间:2022-05-23
下一篇:
PHP DBObject类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap