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


PHP DBObjectSearch::AddCondition方法代码示例

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


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

示例1: FromObjectSet

 /**
  * Constructs a DisplayBlock object from a DBObjectSet already in memory
  * @param $oSet DBObjectSet
  * @return DisplayBlock The DisplayBlock object, or null if the creation failed
  */
 public static function FromObjectSet(DBObjectSet $oSet, $sStyle, $aParams = array())
 {
     $oDummyFilter = new DBObjectSearch($oSet->GetClass());
     $aKeys = array();
     while ($oObject = $oSet->Fetch()) {
         $aKeys[] = $oObject->GetKey();
     }
     $oSet->Rewind();
     if (count($aKeys) > 0) {
         $oDummyFilter->AddCondition('id', $aKeys, 'IN');
     } else {
         $oDummyFilter->AddCondition('id', 0, '=');
     }
     $oBlock = new DisplayBlock($oDummyFilter, $sStyle, false, $aParams);
     // DisplayBlocks built this way are synchronous
     return $oBlock;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:22,代码来源:displayblock.class.inc.php

示例2: FilterByContext

/**
 * Adds the context parameters to the audit query
 */
function FilterByContext(DBSearch &$oFilter, ApplicationContext $oAppContext)
{
    $sObjClass = $oFilter->GetClass();
    $aContextParams = $oAppContext->GetNames();
    $aCallSpec = array($sObjClass, 'MapContextParam');
    if (is_callable($aCallSpec)) {
        foreach ($aContextParams as $sParamName) {
            $sValue = $oAppContext->GetCurrentValue($sParamName, null);
            if ($sValue != null) {
                $sAttCode = call_user_func($aCallSpec, $sParamName);
                // Returns null when there is no mapping for this parameter
                if ($sAttCode != null && MetaModel::IsValidAttCode($sObjClass, $sAttCode)) {
                    // Check if the condition points to a hierarchical key
                    if ($sAttCode == 'id') {
                        // Filtering on the objects themselves
                        $sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($sObjClass);
                        if ($sHierarchicalKeyCode !== false) {
                            $oRootFilter = new DBObjectSearch($sObjClass);
                            $oRootFilter->AddCondition($sAttCode, $sValue);
                            $oFilter->AddCondition_PointingTo($oRootFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW);
                            // Use the 'below' operator by default
                            $bConditionAdded = true;
                        }
                    } else {
                        $oAttDef = MetaModel::GetAttributeDef($sObjClass, $sAttCode);
                        $bConditionAdded = false;
                        if ($oAttDef->IsExternalKey()) {
                            $sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($oAttDef->GetTargetClass());
                            if ($sHierarchicalKeyCode !== false) {
                                $oRootFilter = new DBObjectSearch($oAttDef->GetTargetClass());
                                $oRootFilter->AddCondition('id', $sValue);
                                $oHKFilter = new DBObjectSearch($oAttDef->GetTargetClass());
                                $oHKFilter->AddCondition_PointingTo($oRootFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW);
                                // Use the 'below' operator by default
                                $oFilter->AddCondition_PointingTo($oHKFilter, $sAttCode);
                                $bConditionAdded = true;
                            }
                        }
                    }
                    if (!$bConditionAdded) {
                        $oFilter->AddCondition($sAttCode, $sValue);
                    }
                }
            }
        }
    }
}
开发者ID:henryavila,项目名称:itop,代码行数:50,代码来源:audit.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: DisplayPreferences


//.........这里部分代码省略.........
\t{
\t\t// paginated display, restore the selection
\t\tvar pager = \$('#user_prefs form .pager');
\t\t\$(':input[name=selectionMode]', pager).val('positive');
\t\tfor (i=0; i<aChecked.length; i++)
\t\t{
\t\t\tpager.append('<input type="hidden" name="storedSelection[]" id="'+aChecked[i]+'" value="'+aChecked[i]+'"/>');
\t\t}
\t\t\$('#user_prefs table.listResults').trigger('load_selection');
\t\t
\t}
\telse
\t{
\t\t\$('#user_prefs form :checkbox[name^=selectObject]').each( function()
\t\t\t{
\t\t\t\tif (\$.inArray(\$(this).val(), aChecked) > -1)
\t\t\t\t{
\t\t\t\t\t\$(this).attr('checked', true);
\t\t\t\t\t\$(this).trigger('change');
\t\t\t\t}
\t\t\t});
\t}
EOF
);
    }
    //////////////////////////////////////////////////////////////////////////
    //
    // Shortcuts
    //
    //////////////////////////////////////////////////////////////////////////
    $oP->add('<fieldset><legend>' . Dict::S('Menu:MyShortcuts') . '</legend>');
    //$oP->p(Dict::S('UI:Menu:MyShortcuts+'));
    $oBMSearch = new DBObjectSearch('Shortcut');
    $oBMSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
    //$aExtraParams = array('menu' => false, 'toolkit_menu' => false, 'display_limit' => false, 'localize_values' => $bLocalize, 'zlist' => 'details');
    $aExtraParams = array();
    $oBlock = new DisplayBlock($oBMSearch, 'list', false, $aExtraParams);
    $oBlock->Display($oP, 'shortcut_list', array('view_link' => false, 'menu' => false, 'toolkit_menu' => false, 'selection_mode' => true, 'selection_type' => 'multiple', 'cssCount' => '#shortcut_selection_count', 'table_id' => 'user_prefs_shortcuts'));
    $oP->add('<p>');
    $oSet = new DBObjectSet($oBMSearch);
    if ($oSet->Count() > 0) {
        $sButtons = '<img src="../images/tv-item-last.gif">';
        $sButtons .= '&nbsp;';
        $sButtons .= '<button id="shortcut_btn_rename">' . Dict::S('UI:Button:Rename') . '</button>';
        $sButtons .= '&nbsp;';
        $sButtons .= '<button id="shortcut_btn_delete">' . Dict::S('UI:Button:Delete') . '</button>';
        // Selection count updated by the pager, and used to enable buttons
        $oP->add('<input type="hidden" id="shortcut_selection_count"/>');
        $oP->add('</fieldset>');
        $sConfirmDelete = addslashes(Dict::S('UI:ShortcutDelete:Confirm'));
        $oP->add_ready_script(<<<EOF
function OnShortcutBtnRename()
{
\tvar oParams = \$('#datatable_shortcut_list').datatable('GetMultipleSelectionParams');
\toParams.operation = 'shortcut_rename_dlg';

\t\$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data){
\t\t\$('body').append(data);
\t});
\treturn false;
}

function OnShortcutBtnDelete()
{
\tif (confirm('{$sConfirmDelete}'))
\t{
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:67,代码来源:preferences.php

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

示例6: DBObjectSet

                $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();
\$('#full_text_progress,#full_text_progress_placeholder').hide(500);
EOF
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:31,代码来源:ajax.render.php

示例7: implode

                    $sDefaultKeys = '"' . implode('", "', $aDefaultKeys) . '"';
                }
                $oPage->add_ready_script(<<<EOF
\t\t\$('select[name^=field]').change( DoCheckMapping );
\t\taDefaultKeys = new Array({$sDefaultKeys});
\t\tDoCheckMapping();
EOF
);
            }
            break;
        case 'get_csv_template':
            $sClassName = utils::ReadParam('class_name');
            $sFormat = utils::ReadParam('format', 'csv');
            if (MetaModel::IsValidClass($sClassName)) {
                $oSearch = new DBObjectSearch($sClassName);
                $oSearch->AddCondition('id', 0, '=');
                // Make sure we create an empty set
                $oSet = new CMDBObjectSet($oSearch);
                $sResult = cmdbAbstractObject::GetSetAsCSV($oSet, array('showMandatoryFields' => true));
                $sClassDisplayName = MetaModel::GetName($sClassName);
                $sDisposition = utils::ReadParam('disposition', 'inline');
                if ($sDisposition == 'attachment') {
                    switch ($sFormat) {
                        case 'xlsx':
                            $oPage = new ajax_page("");
                            $oPage->SetContentType('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
                            $oPage->SetContentDisposition('attachment', $sClassDisplayName . '.xlsx');
                            require_once APPROOT . '/application/excelexporter.class.inc.php';
                            $writer = new XLSXWriter();
                            $writer->setAuthor(UserRights::GetUserFriendlyName());
                            $aHeaders = array(0 => explode(',', $sResult));
开发者ID:henryavila,项目名称:itop,代码行数:31,代码来源:ajax.csvimport.php

示例8: ListClosedTickets

/**
 * Lists all the currently closed tickets
 * @param WebPage $oP The current web page
 * @return void
 */
function ListClosedTickets(WebPage $oP)
{
    $aAttSpecs = explode(',', PORTAL_TICKETS_SEARCH_CRITERIA);
    // Remove the caller_id form the search criteria if the user is not a Portal Power User
    // since the user is only allowed to see her/his own tickets
    foreach ($aAttSpecs as $idx => $sAttCode) {
        if ($sAttCode == 'caller_id' && !IsPowerUser()) {
            unset($aAttSpecs[$idx]);
        }
    }
    $aClasses = GetTicketClasses();
    $sMainClass = reset($aClasses);
    $oP->DisplaySearchForm($sMainClass, $aAttSpecs, array('operation' => 'show_closed'), 'search_', false);
    $oUserOrg = GetUserOrg();
    $oP->add("<h1>" . Dict::S('Portal:ClosedRequests') . "</h1>\n");
    $aClassToSet = array();
    foreach (GetTicketClasses() as $sClass) {
        $oSearch = $oP->PostedParamsToFilter($sClass, $aAttSpecs, 'search_');
        if (is_null($oSearch)) {
            $oSearch = new DBObjectSearch($sClass);
        }
        $oSearch->AddCondition('org_id', $oUserOrg->GetKey());
        $oSearch->AddCondition('status', 'closed');
        $iUser = UserRights::GetContactId();
        if ($iUser > 0 && !IsPowerUser()) {
            $oSearch->AddCondition('caller_id', $iUser);
        }
        $aClassToSet[$sClass] = new CMDBObjectSet($oSearch);
    }
    DisplayRequestLists($oP, $aClassToSet);
}
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:36,代码来源:index.php

示例9: Load

 /**
  * Loads the preferences for the current user, creating the record in the database
  * if needed
  */
 protected static function Load()
 {
     if (self::$oUserPrefs != null) {
         return;
     }
     $oSearch = new DBObjectSearch('appUserPreferences');
     $oSearch->AddCondition('userid', UserRights::GetUserId(), '=');
     $oSet = new DBObjectSet($oSearch);
     $oObj = $oSet->Fetch();
     if ($oObj == null) {
         // No prefs (yet) for this user, create the object
         $oObj = new appUserPreferences();
         $oObj->Set('userid', UserRights::GetUserId());
         $oObj->Set('preferences', array());
         // Default preferences: an empty array
         try {
             $oObj->DBInsert();
         } catch (Exception $e) {
             // Ignore errors
         }
     }
     self::$oUserPrefs = $oObj;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:27,代码来源:user.preferences.class.inc.php

示例10: GetCreationForm

 public static function GetCreationForm($sOQL = null, $sTableSettings = null)
 {
     $oForm = new DesignerForm();
     // Find a unique default name
     // -> The class of the query + an index if necessary
     if ($sOQL == null) {
         $sDefault = '';
     } else {
         $oBMSearch = new DBObjectSearch('Shortcut');
         $oBMSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
         $oBMSet = new DBObjectSet($oBMSearch);
         $aNames = $oBMSet->GetColumnAsArray('name');
         $oSearch = DBObjectSearch::FromOQL($sOQL);
         $sDefault = utils::MakeUniqueName($oSearch->GetClass(), $aNames);
     }
     $oField = new DesignerTextField('name', Dict::S('Class:Shortcut/Attribute:name'), $sDefault);
     $oField->SetMandatory(true);
     $oForm->AddField($oField);
     /*
     $oField = new DesignerComboField('auto_reload', Dict::S('Class:ShortcutOQL/Attribute:auto_reload'), 'none');
     $oAttDef = MetaModel::GetAttributeDef(__class__, 'auto_reload');
     $oField->SetAllowedValues($oAttDef->GetAllowedValues());
     $oField->SetMandatory(true);
     $oForm->AddField($oField);
     */
     $oField = new DesignerBooleanField('auto_reload', Dict::S('Class:ShortcutOQL/Attribute:auto_reload'), false);
     $oForm->AddField($oField);
     $oField = new DesignerTextField('auto_reload_sec', Dict::S('Class:ShortcutOQL/Attribute:auto_reload_sec'), MetaModel::GetConfig()->GetStandardReloadInterval());
     $oField->SetValidationPattern('^$|^0*([5-9]|[1-9][0-9]+)$');
     // Can be empty, or a number > 4
     $oField->SetMandatory(false);
     $oForm->AddField($oField);
     $oField = new DesignerHiddenField('oql', '', $sOQL);
     $oForm->AddField($oField);
     $oField = new DesignerHiddenField('table_settings', '', $sTableSettings);
     $oForm->AddField($oField);
     return $oForm;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:38,代码来源:shortcut.class.inc.php

示例11: Display


//.........这里部分代码省略.........
\t\t\t\t'html'
\t\t\t);

\t\t\treturn false;
\t\t}
\t\t
\t\tfunction DoAddObjects(currentFormId)
\t\t{
\t\t\tvar theMap = { 'class': '{$this->m_sClass}',
\t\t\t\t\t\t   'linkageAttr': '{$this->m_sLinkageAttr}',
\t\t\t\t\t\t   'linkedClass': '{$this->m_sLinkedClass}',
\t\t\t\t\t\t   'objectId': '{$this->m_iObjectId}'
\t\t\t\t\t\t }
\t\t\t
\t\t\t// Gather the parameters from the search form
\t\t\t\$('#'+currentFormId+' :input').each(
\t\t\t\tfunction(i)
\t\t\t\t{
\t\t\t\t\tif ( (this.name != '') && ((this.type != 'checkbox') || (this.checked)) ) 
\t\t\t\t\t{
\t\t\t\t\t\t//console.log(this.type);
\t\t\t\t\t\tarrayExpr = /\\[\\]\$/;
\t\t\t\t\t\tif (arrayExpr.test(this.name))
\t\t\t\t\t\t{
\t\t\t\t\t\t\t// Array
\t\t\t\t\t\t\tif (theMap[this.name] == undefined)
\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\ttheMap[this.name] = new Array();
\t\t\t\t\t\t\t}
\t\t\t\t\t\t\ttheMap[this.name].push(this.value);
\t\t\t\t\t\t}
\t\t\t\t\t\telse
\t\t\t\t\t\t{
\t\t\t\t\t\t\ttheMap[this.name] = this.value;
\t\t\t\t\t\t}
\t\t\t\t\t}
\t\t\t\t}
\t\t\t);
\t\t\ttheMap['operation'] = 'doAddObjects';
\t\t\t
\t\t\t// Run the query and display the results
\t\t\t\$.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap, 
\t\t\t\tfunction(data)
\t\t\t\t{
\t\t\t\t\t//console.log('Data: ' + data);
\t\t\t\t\tif (data != '')
\t\t\t\t\t{
\t\t\t\t\t\t\$('#empty_row').remove();
\t\t\t\t\t}
\t\t\t\t\t\$('.listResults tbody').append(data);
\t\t\t\t\t\$('.listResults').trigger('update');
\t\t\t\t\t\$('.listResults').tablesorter( { headers: {0: false}}, widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables
\t\t\t\t},
\t\t\t\t'html'
\t\t\t);
\t\t\t\$('#ModalDlg').dialog('close');
\t\t\treturn false;
\t\t}
\t\t
\t\tfunction InitForm()
\t\t{
\t\t\t// make sure that the form is clean
\t\t\t\$('.selection').each( function() { this.checked = false; });
\t\t\t\$('#btnRemove').attr('disabled','disabled');
\t\t\t\$('#linksToRemove').val('');
\t\t}
\t\t
\t\tfunction SubmitHook() 
\t\t{
\t\t\tvar the_form = this;
\t\t\tSearchObjectsToAdd(the_form.id);
\t\t\treturn false;
\t\t}
EOF
);
        $oP->add_ready_script("InitForm();");
        $oFilter = new DBObjectSearch($this->m_sClass);
        $oFilter->AddCondition($this->m_sLinkageAttr, $this->m_iObjectId, '=');
        $oSet = new DBObjectSet($oFilter);
        $aForm = array();
        while ($oCurrentLink = $oSet->Fetch()) {
            $aRow = array();
            $key = $oCurrentLink->GetKey();
            $oLinkedObj = MetaModel::GetObject($this->m_sLinkedClass, $oCurrentLink->Get($this->m_sLinkingAttCode));
            $aForm[$key] = $this->GetFormRow($oP, $oLinkedObj, $oCurrentLink);
        }
        //var_dump($aTableLabels);
        //var_dump($aForm);
        $this->DisplayFormTable($oP, $this->m_aTableConfig, $aForm);
        $oP->add("<span style=\"float:left;\">&nbsp;&nbsp;&nbsp;<img src=\"../images/tv-item-last.gif\">&nbsp;&nbsp;<input id=\"btnRemove\" type=\"button\" value=\"" . Dict::S('UI:RemoveLinkedObjectsOf_Class') . "\" onClick=\"RemoveSelected();\" >");
        $oP->add("&nbsp;&nbsp;&nbsp;<input id=\"btnAdd\" type=\"button\" value=\"" . Dict::Format('UI:AddLinkedObjectsOf_Class', MetaModel::GetName($this->m_sLinkedClass)) . "\" onClick=\"AddObjects();\"></span>\n");
        $oP->add("<span style=\"float:right;\"><input id=\"btnCancel\" type=\"button\" value=\"" . Dict::S('UI:Button:Cancel') . "\" onClick=\"BackToDetails('" . $sTargetClass . "', " . $this->m_iObjectId . ");\">");
        $oP->add("&nbsp;&nbsp;&nbsp;<input id=\"btnOk\" type=\"submit\" value=\"" . Dict::S('UI:Button:Ok') . "\"></span>\n");
        $oP->add("<span style=\"clear:both;\"><p>&nbsp;</p></span>\n");
        $oP->add("</div>\n");
        $oP->add("</form>\n");
        if (isset($aExtraParams['StartWithAdd']) && $aExtraParams['StartWithAdd']) {
            $oP->add_ready_script("AddObjects();");
        }
    }
开发者ID:henryavila,项目名称:itop,代码行数:101,代码来源:uilinkswizard.class.inc.php

示例12: Process

 public function Process(CMDBChange $oChange = null)
 {
     // Note: $oChange can be null, in which case the aim is to check what would be done
     // Debug...
     //
     if (false) {
         echo "<pre>\n";
         echo "Attributes:\n";
         print_r($this->m_aAttList);
         echo "ExtKeys:\n";
         print_r($this->m_aExtKeys);
         echo "Reconciliation:\n";
         print_r($this->m_aReconcilKeys);
         echo "Synchro scope:\n";
         print_r($this->m_sSynchroScope);
         echo "Synchro changes:\n";
         print_r($this->m_aOnDisappear);
         //echo "Data:\n";
         //print_r($this->m_aData);
         echo "</pre>\n";
         exit;
     }
     $aResult = array();
     if (!is_null($this->m_sDateFormat) && strlen($this->m_sDateFormat) > 0) {
         // Translate dates from the source data
         //
         foreach ($this->m_aAttList as $sAttCode => $iCol) {
             $oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
             if ($oAttDef instanceof AttributeDateTime) {
                 foreach ($this->m_aData as $iRow => $aRowData) {
                     $sNewDate = utils::StringToTime($this->m_aData[$iRow][$iCol], $this->m_sDateFormat);
                     if ($sNewDate !== false) {
                         // Todo - improve the reporting
                         $this->m_aData[$iRow][$iCol] = $sNewDate;
                     } else {
                         // Leave the cell unchanged
                         $aResult[$iRow]["__STATUS__"] = new RowStatus_Issue(Dict::S('UI:CSVReport-Row-Issue-DateFormat'));
                         $aResult[$iRow][$sAttCode] = new CellStatus_Issue(null, $this->m_aData[$iRow][$iCol], Dict::S('UI:CSVReport-Row-Issue-DateFormat'));
                     }
                 }
             }
         }
     }
     // Compute the results
     //
     if (!is_null($this->m_sSynchroScope)) {
         $aVisited = array();
     }
     $iPreviousTimeLimit = ini_get('max_execution_time');
     $iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
     foreach ($this->m_aData as $iRow => $aRowData) {
         set_time_limit($iLoopTimeLimit);
         if (isset($aResult[$iRow]["__STATUS__"])) {
             // An issue at the earlier steps - skip the rest
             continue;
         }
         try {
             $oReconciliationFilter = new DBObjectSearch($this->m_sClass);
             $bSkipQuery = false;
             foreach ($this->m_aReconcilKeys as $sAttCode) {
                 $valuecondition = null;
                 if (array_key_exists($sAttCode, $this->m_aExtKeys)) {
                     if ($this->IsNullExternalKeySpec($aRowData, $sAttCode)) {
                         $oExtKey = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
                         if ($oExtKey->IsNullAllowed()) {
                             $valuecondition = $oExtKey->GetNullValue();
                             $aResult[$iRow][$sAttCode] = new CellStatus_Void($oExtKey->GetNullValue());
                         } else {
                             $aResult[$iRow][$sAttCode] = new CellStatus_NullIssue();
                         }
                     } else {
                         // The value has to be found or verified
                         list($sQuery, $aMatches) = $this->ResolveExternalKey($aRowData, $sAttCode, $aResult[$iRow]);
                         if (count($aMatches) == 1) {
                             $oRemoteObj = reset($aMatches);
                             // first item
                             $valuecondition = $oRemoteObj->GetKey();
                             $aResult[$iRow][$sAttCode] = new CellStatus_Void($oRemoteObj->GetKey());
                         } elseif (count($aMatches) == 0) {
                             $aResult[$iRow][$sAttCode] = new CellStatus_SearchIssue();
                         } else {
                             $aResult[$iRow][$sAttCode] = new CellStatus_Ambiguous(null, count($aMatches), $sQuery);
                         }
                     }
                 } else {
                     // The value is given in the data row
                     $iCol = $this->m_aAttList[$sAttCode];
                     if ($sAttCode == 'id') {
                         $valuecondition = $aRowData[$iCol];
                     } else {
                         $oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
                         $valuecondition = $oAttDef->MakeValueFromString($aRowData[$iCol], $this->m_bLocalizedValues);
                     }
                 }
                 if (is_null($valuecondition)) {
                     $bSkipQuery = true;
                 } else {
                     $oReconciliationFilter->AddCondition($sAttCode, $valuecondition, '=');
                 }
             }
//.........这里部分代码省略.........
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:101,代码来源:bulkchange.class.inc.php

示例13: DisplayAsBlock

 protected function DisplayAsBlock(WebPage $oPage, DBObjectSet $oValue, $aArgs = array(), $sFormPrefix, $oCurrentObj, $bDisplayMenu)
 {
     $oLinksetDef = MetaModel::GetAttributeDef($this->sClass, $this->sAttCode);
     $sTargetClass = $oLinksetDef->GetLinkedClass();
     if ($oCurrentObj && $oCurrentObj->IsNew() && $bDisplayMenu) {
         $oPage->p(Dict::Format('UI:BeforeAdding_Class_ObjectsSaveThisObject', MetaModel::GetName($sTargetClass)));
     } else {
         $oFilter = new DBObjectSearch($sTargetClass);
         $oFilter->AddCondition($oLinksetDef->GetExtKeyToMe(), $oCurrentObj->GetKey(), '=');
         $aDefaults = array($oLinksetDef->GetExtKeyToMe() => $oCurrentObj->GetKey());
         $oAppContext = new ApplicationContext();
         foreach ($oAppContext->GetNames() as $sKey) {
             // The linked object inherits the parent's value for the context
             if (MetaModel::IsValidAttCode($this->sClass, $sKey) && $oCurrentObj) {
                 $aDefaults[$sKey] = $oCurrentObj->Get($sKey);
             }
         }
         $aParams = array('target_attr' => $oLinksetDef->GetExtKeyToMe(), 'object_id' => $oCurrentObj ? $oCurrentObj->GetKey() : null, 'menu' => $bDisplayMenu, 'default' => $aDefaults, 'table_id' => $this->sClass . '_' . $this->sAttCode);
         $oBlock = new DisplayBlock($oFilter, 'list', false);
         $oBlock->Display($oPage, $this->sInputid, $aParams);
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:22,代码来源:ui.linksdirectwidget.class.inc.php

示例14: GetOrganization

 /**
  * Search for an organization with the given code in the database
  *
  * @param string $Id The organization Id to look for
  * @return cmdbOrganization the organization if it exists, null otherwise
  */
 protected function GetOrganization($sId)
 {
     $oOrg = null;
     $oFilter = new DBObjectSearch('Organization');
     $oFilter->AddCondition('id', $sId, '=');
     $oSet = new CMDBObjectSet($oFilter);
     if ($oSet->Count() > 0) {
         $oOrg = $oSet->Fetch();
         // Let's take the first one found
     }
     return $oOrg;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:18,代码来源:data.generator.class.inc.php

示例15: GetObjectByColumn

 public static function GetObjectByColumn($sClass, $sAttCode, $value, $bMustBeFoundUnique = true)
 {
     if (!isset(self::$m_aCacheObjectByColumn[$sClass][$sAttCode][$value])) {
         self::_check_subclass($sClass);
         $oObjSearch = new DBObjectSearch($sClass);
         $oObjSearch->AddCondition($sAttCode, $value, '=');
         $oSet = new DBObjectSet($oObjSearch);
         if ($oSet->Count() == 1) {
             self::$m_aCacheObjectByColumn[$sClass][$sAttCode][$value] = $oSet->fetch();
         } else {
             if ($bMustBeFoundUnique) {
                 throw new CoreException('Failed to get an object by column', array('class' => $sClass, 'attcode' => $sAttCode, 'value' => $value, 'matches' => $oSet->Count()));
             }
             self::$m_aCacheObjectByColumn[$sClass][$sAttCode][$value] = null;
         }
     }
     return self::$m_aCacheObjectByColumn[$sClass][$sAttCode][$value];
 }
开发者ID:henryavila,项目名称:itop,代码行数:18,代码来源:metamodel.class.php


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