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


PHP MetaModel::GetObject方法代码示例

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


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

 public function DoActivate($aContextArgs)
 {
     // Find the related actions
     $oLinkedActions = $this->Get('action_list');
     while ($oLink = $oLinkedActions->Fetch()) {
         $iActionId = $oLink->Get('action_id');
         $oAction = MetaModel::GetObject('Action', $iActionId);
         if ($oAction->IsActive()) {
             $oAction->DoExecute($this, $aContextArgs);
         }
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:12,代码来源:trigger.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: 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

示例5: MakeValueLabel

 /**
  * Make the most relevant label, given the value of the expression
  * 	 
  * @param DBSearch oFilter The context in which this expression has been used	 	
  * @param string sValue The value returned by the query, for this expression	 	
  * @param string sDefault The default value if no relevant label could be computed	 	
  * @return The label
  */
 public function MakeValueLabel($oFilter, $sValue, $sDefault)
 {
     $sAttCode = $this->GetName();
     $sParentAlias = $this->GetParent();
     $aSelectedClasses = $oFilter->GetSelectedClasses();
     $sClass = $aSelectedClasses[$sParentAlias];
     $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
     // Set a default value for the general case
     $sRes = $oAttDef->GetAsHtml($sValue);
     // Exceptions...
     if ($oAttDef->IsExternalKey()) {
         $sObjClass = $oAttDef->GetTargetClass();
         $iObjKey = (int) $sValue;
         if ($iObjKey > 0) {
             $oObject = MetaModel::GetObject($sObjClass, $iObjKey);
             $sRes = $oObject->GetHyperlink();
         } else {
             // Undefined
             $sRes = DBObject::MakeHyperLink($sObjClass, 0);
         }
     } elseif ($oAttDef->IsExternalField()) {
         if (is_null($sValue)) {
             $sRes = Dict::S('UI:UndefinedObject');
         }
     }
     return $sRes;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:35,代码来源:expression.class.inc.php

示例6: GetUserOrg

/**
 * Get The organization of the current user (i.e. the organization of its contact)
 * @param WebPage $oP The current page, for errors output
 * @return Organization The user's org or null in case of problem...
 */
function GetUserOrg()
{
    $oOrg = null;
    $iContactId = UserRights::GetContactId();
    $oContact = MetaModel::GetObject('Contact', $iContactId, false);
    // false => Can fail
    if (is_object($oContact)) {
        $oOrg = MetaModel::GetObject('Organization', $oContact->Get('org_id'), false);
        // false => can fail
    } else {
        throw new Exception(Dict::S('Portal:ErrorNoContactForThisUser'));
    }
    return $oOrg;
}
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:19,代码来源:index.php

示例7: DoAddObjects

 public function DoAddObjects(WebPage $oP, $oFullSetFilter, $oCurrentObj)
 {
     $aLinkedObjectIds = utils::ReadMultipleSelection($oFullSetFilter);
     foreach ($aLinkedObjectIds as $iObjectId) {
         $oLinkedObj = MetaModel::GetObject($this->m_sRemoteClass, $iObjectId);
         if (is_object($oLinkedObj)) {
             $aRow = $this->GetFormRow($oP, $oLinkedObj, -$iObjectId, array(), $oCurrentObj);
             // Not yet created link get negative Ids
             $oP->add($this->DisplayFormRow($oP, $this->m_aTableConfig, $aRow, -$iObjectId));
         } else {
             $oP->p(Dict::Format('UI:Error:Object_Class_Id_NotFound', $this->m_sLinkedClass, $iObjectId));
         }
     }
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:14,代码来源:ui.linkswidget.class.inc.php

示例8: FindObjectFromArgs

 /**
  * Find the object of the specified Class/ID.
  * @param WebPage $oP The current page
  * @return DBObject The found object, or throws an exception in case of failure
  */
 public function FindObjectFromArgs($aAllowedClasses = null)
 {
     $sClass = utils::ReadParam('class', '', true, 'class');
     $iId = utils::ReadParam('id', 0, true, 'integer');
     if (empty($sClass)) {
         throw new Exception("Missing argument 'class'");
     }
     if (!MetaModel::IsValidClass($sClass)) {
         throw new Exception("Wrong value for argument 'class': {$sClass}");
     }
     if ($iId == 0) {
         throw new Exception("Missing argument 'id'");
     }
     if (!is_null($aAllowedClasses)) {
         $bAllowed = false;
         foreach ($aAllowedClasses as $sParentClass) {
             if (MetaModel::IsParentClass($sParentClass, $sClass)) {
                 $bAllowed = true;
             }
         }
         if (!$bAllowed) {
             throw new Exception("Class '{$sClass} not allowed in this implementation'");
         }
     }
     $oObj = MetaModel::GetObject($sClass, $iId, false);
     if (!is_object($oObj)) {
         throw new Exception("Could not find the object {$sClass}/{$iId}");
     }
     return $oObj;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:35,代码来源:portalwebpage.class.inc.php

示例9: DBCloneTracked_Internal

 protected function DBCloneTracked_Internal($newKey = null)
 {
     $newKey = parent::DBClone($newKey);
     $oClone = MetaModel::GetObject(get_class($this), $newKey);
     return $newKey;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:6,代码来源:cmdbobject.class.inc.php

示例10: GetRenderContent

 public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId)
 {
     $sHtml = '';
     $bTruncated = false;
     $oSet = new CMDBObjectSet($this->m_oFilter, array('date' => false));
     if ($this->iLimitStart > 0 || $this->iLimitCount > 0) {
         $oSet->SetLimit($this->iLimitCount, $this->iLimitStart);
         if ($this->iLimitCount - $this->iLimitStart < $oSet->Count()) {
             $bTruncated = true;
         }
     }
     $sHtml .= "<!-- filter: " . $this->m_oFilter->ToOQL() . "-->\n";
     switch ($this->m_sStyle) {
         case 'toggle':
             // First the latest change that the user is allowed to see
             do {
                 $oLatestChangeOp = $oSet->Fetch();
             } while (is_object($oLatestChangeOp) && $oLatestChangeOp->GetDescription() == '');
             if (is_object($oLatestChangeOp)) {
                 // There is one change in the list... only when the object has been created !
                 $sDate = $oLatestChangeOp->GetAsHTML('date');
                 $oChange = MetaModel::GetObject('CMDBChange', $oLatestChangeOp->Get('change'));
                 $sUserInfo = $oChange->GetAsHTML('userinfo');
                 $sHtml .= $oPage->GetStartCollapsibleSection(Dict::Format('UI:History:LastModified_On_By', $sDate, $sUserInfo));
                 $sHtml .= $this->GetHistoryTable($oPage, $oSet);
                 $sHtml .= $oPage->GetEndCollapsibleSection();
             }
             break;
         case 'table':
         default:
             if ($bTruncated) {
                 $sFilter = $this->m_oFilter->serialize();
                 $sHtml .= '<div id="history_container"><p>';
                 $sHtml .= Dict::Format('UI:TruncatedResults', $this->iLimitCount, $oSet->Count());
                 $sHtml .= ' ';
                 $sHtml .= '<a href="#" onclick="DisplayHistory(\'#history_container\', \'' . $sFilter . '\', 0, 0); return false;">' . Dict::S('UI:DisplayAll') . '</a>';
                 $sHtml .= $this->GetHistoryTable($oPage, $oSet);
                 $sHtml .= '</p></div>';
                 $oPage->add_ready_script("\$('#{$sId} table.listResults tr:last td').addClass('truncated');");
             } else {
                 $sHtml .= $this->GetHistoryTable($oPage, $oSet);
             }
     }
     return $sHtml;
 }
开发者ID:henryavila,项目名称:itop,代码行数:45,代码来源:displayblock.class.inc.php

示例11: GetObjectName

 /**
  * Get the display name of the selected object, to fill back the autocomplete
  */
 public function GetObjectName($iObjId)
 {
     $aModifierProps = array();
     $aModifierProps['UserRightsGetSelectFilter']['bSearchMode'] = $this->bSearchMode;
     $oObj = MetaModel::GetObject($this->sTargetClass, $iObjId, false, false, $aModifierProps);
     if ($oObj) {
         return $oObj->GetName();
     } else {
         return '';
     }
 }
开发者ID:henryavila,项目名称:itop,代码行数:14,代码来源:ui.extkeywidget.class.inc.php

示例12: SetDefaultOrgId

 /**
  * Give a default value for item_org_id (if relevant...)
  * @return void
  */
 public function SetDefaultOrgId()
 {
     // First check that the organization CAN be fetched from the target class
     //
     $sClass = $this->Get('item_class');
     $aCallSpec = array($sClass, 'MapContextParam');
     if (is_callable($aCallSpec)) {
         $sAttCode = call_user_func($aCallSpec, 'org_id');
         // Returns null when there is no mapping for this parameter
         if (MetaModel::IsValidAttCode($sClass, $sAttCode)) {
             // Second: check that the organization CAN be fetched from the current user
             //
             if (MetaModel::IsValidClass('Person')) {
                 $aCallSpec = array($sClass, 'MapContextParam');
                 if (is_callable($aCallSpec)) {
                     $sAttCode = call_user_func($aCallSpec, 'org_id');
                     // Returns null when there is no mapping for this parameter
                     if (MetaModel::IsValidAttCode($sClass, $sAttCode)) {
                         // OK - try it
                         //
                         $oCurrentPerson = MetaModel::GetObject('Person', UserRights::GetContactId(), false);
                         if ($oCurrentPerson) {
                             $this->Set('item_org_id', $oCurrentPerson->Get($sAttCode));
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:34,代码来源:model.itop-attachments.php

示例13: Display

    /**
     * Display the graph inside the given page, with the "filter" drawer above it
     * @param WebPage $oP
     * @param hash $aResults
     * @param string $sRelation
     * @param ApplicationContext $oAppContext
     * @param array $aExcludedObjects
     */
    function Display(WebPage $oP, $aResults, $sRelation, ApplicationContext $oAppContext, $aExcludedObjects = array(), $sObjClass = null, $iObjKey = null, $sContextKey, $aContextParams = array())
    {
        $aContextDefs = static::GetContextDefinitions($sContextKey, true, $aContextParams);
        $aExcludedByClass = array();
        foreach ($aExcludedObjects as $oObj) {
            if (!array_key_exists(get_class($oObj), $aExcludedByClass)) {
                $aExcludedByClass[get_class($oObj)] = array();
            }
            $aExcludedByClass[get_class($oObj)][] = $oObj->GetKey();
        }
        $oP->add("<div class=\"not-printable\">\n");
        $oP->add("<div id=\"ds_flash\" class=\"SearchDrawer\" style=\"display:none;\">\n");
        if (!$oP->IsPrintableVersion()) {
            $oP->add_ready_script(<<<EOF
\t\$( "#tabbedContent_0" ).tabs({ heightStyle: "fill" });
EOF
);
        }
        $oP->add_ready_script(<<<EOF
\t\$("#dh_flash").click( function() {
\t\t\$("#ds_flash").slideToggle('normal', function() { \$("#ds_flash").parent().resize(); \$("#dh_flash").trigger('toggle_complete'); } );
\t\t\$("#dh_flash").toggleClass('open');
\t});
    \$('#ReloadMovieBtn').button().button('disable');
EOF
);
        $aSortedElements = array();
        foreach ($aResults as $sClassIdx => $aObjects) {
            foreach ($aObjects as $oCurrObj) {
                $sSubClass = get_class($oCurrObj);
                $aSortedElements[$sSubClass] = MetaModel::GetName($sSubClass);
            }
        }
        asort($aSortedElements);
        $idx = 0;
        foreach ($aSortedElements as $sSubClass => $sClassName) {
            $oP->add("<span style=\"padding-right:2em; white-space:nowrap;\"><input type=\"checkbox\" id=\"exclude_{$idx}\" name=\"excluded[]\" value=\"{$sSubClass}\" checked onChange=\"\$('#ReloadMovieBtn').button('enable')\"><label for=\"exclude_{$idx}\">&nbsp;" . MetaModel::GetClassIcon($sSubClass) . "&nbsp;{$sClassName}</label></span> ");
            $idx++;
        }
        $oP->add("<p style=\"text-align:right\"><button type=\"button\" id=\"ReloadMovieBtn\" onClick=\"DoReload()\">" . Dict::S('UI:Button:Refresh') . "</button></p>");
        $oP->add("</div>\n");
        $oP->add("<div class=\"HRDrawer\"></div>\n");
        $oP->add("<div id=\"dh_flash\" class=\"DrawerHandle\">" . Dict::S('UI:ElementsDisplayed') . "</div>\n");
        $oP->add("</div>\n");
        // class="not-printable"
        $aAdditionalContexts = array();
        foreach ($aContextDefs as $sKey => $aDefinition) {
            $aAdditionalContexts[] = array('key' => $sKey, 'label' => Dict::S($aDefinition['dict']), 'oql' => $aDefinition['oql'], 'default' => array_key_exists('default', $aDefinition) && $aDefinition['default'] == 'yes');
        }
        $sDirection = utils::ReadParam('d', 'horizontal');
        $iGroupingThreshold = utils::ReadParam('g', 5);
        $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/fraphael.js');
        $oP->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/jquery.contextMenu.css');
        $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.contextMenu.js');
        $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/simple_graph.js');
        try {
            $this->InitFromGraphviz();
            $sExportAsPdfURL = '';
            $sExportAsPdfURL = utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=relation_pdf&relation=' . $sRelation . '&direction=' . ($this->bDirectionDown ? 'down' : 'up');
            $oAppcontext = new ApplicationContext();
            $sContext = $oAppContext->GetForLink();
            $sDrillDownURL = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=details&class=%1$s&id=%2$s&' . $sContext;
            $sExportAsDocumentURL = utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=relation_attachment&relation=' . $sRelation . '&direction=' . ($this->bDirectionDown ? 'down' : 'up');
            $sLoadFromURL = utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=relation_json&relation=' . $sRelation . '&direction=' . ($this->bDirectionDown ? 'down' : 'up');
            $sAttachmentExportTitle = '';
            if ($sObjClass != null && $iObjKey != null) {
                $oTargetObj = MetaModel::GetObject($sObjClass, $iObjKey, false);
                if ($oTargetObj) {
                    $sAttachmentExportTitle = Dict::Format('UI:Relation:AttachmentExportOptions_Name', $oTargetObj->GetName());
                }
            }
            $sId = 'graph';
            $sStyle = '';
            if ($oP->IsPrintableVersion()) {
                // Optimize for printing on A4/Letter vertically
                $sStyle = 'margin-left:auto; margin-right:auto;';
                $oP->add_ready_script("\$('.simple-graph').width(18/2.54*96).resizable({ stop: function() { \$(window).trigger('resized'); }});");
                // Default width about 18 cm, since most browsers assume 96 dpi
            }
            $oP->add('<div id="' . $sId . '" class="simple-graph" style="' . $sStyle . '"></div>');
            $aParams = array('source_url' => $sLoadFromURL, 'sources' => $this->bDirectionDown ? $this->aSourceObjects : $this->aSinkObjects, 'excluded' => $aExcludedByClass, 'grouping_threshold' => $iGroupingThreshold, 'export_as_pdf' => array('url' => $sExportAsPdfURL, 'label' => Dict::S('UI:Relation:ExportAsPDF')), 'export_as_attachment' => array('url' => $sExportAsDocumentURL, 'label' => Dict::S('UI:Relation:ExportAsAttachment'), 'obj_class' => $sObjClass, 'obj_key' => $iObjKey), 'drill_down' => array('url' => $sDrillDownURL, 'label' => Dict::S('UI:Relation:DrillDown')), 'labels' => array('export_pdf_title' => Dict::S('UI:Relation:PDFExportOptions'), 'export_as_attachment_title' => $sAttachmentExportTitle, 'export' => Dict::S('UI:Button:Export'), 'cancel' => Dict::S('UI:Button:Cancel'), 'title' => Dict::S('UI:RelationOption:Title'), 'untitled' => Dict::S('UI:RelationOption:Untitled'), 'include_list' => Dict::S('UI:RelationOption:IncludeList'), 'comments' => Dict::S('UI:RelationOption:Comments'), 'grouping_threshold' => Dict::S('UI:RelationOption:GroupingThreshold'), 'refresh' => Dict::S('UI:Button:Refresh'), 'check_all' => Dict::S('UI:SearchValue:CheckAll'), 'uncheck_all' => Dict::S('UI:SearchValue:UncheckAll'), 'none_selected' => Dict::S('UI:Relation:NoneSelected'), 'nb_selected' => Dict::S('UI:SearchValue:NbSelected'), 'additional_context_info' => Dict::S('UI:Relation:AdditionalContextInfo'), 'zoom' => Dict::S('UI:Relation:Zoom'), 'loading' => Dict::S('UI:Loading')), 'page_format' => array('label' => Dict::S('UI:Relation:PDFExportPageFormat'), 'values' => array('A3' => Dict::S('UI:PageFormat_A3'), 'A4' => Dict::S('UI:PageFormat_A4'), 'Letter' => Dict::S('UI:PageFormat_Letter'))), 'page_orientation' => array('label' => Dict::S('UI:Relation:PDFExportPageOrientation'), 'values' => array('P' => Dict::S('UI:PageOrientation_Portrait'), 'L' => Dict::S('UI:PageOrientation_Landscape'))), 'additional_contexts' => $aAdditionalContexts, 'context_key' => $sContextKey);
            if (!extension_loaded('gd')) {
                // PDF export requires GD
                unset($aParams['export_as_pdf']);
            }
            if (!extension_loaded('gd') || is_null($sObjClass) || is_null($iObjKey)) {
                // Export as Attachment requires GD (for building the PDF) AND a valid objclass/objkey couple
                unset($aParams['export_as_attachment']);
            }
            $oP->add_ready_script("\$('#{$sId}').simple_graph(" . json_encode($aParams) . ");");
        } catch (Exception $e) {
            $oP->add('<div>' . $e->getMessage() . '</div>');
//.........这里部分代码省略.........
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:101,代码来源:displayablegraph.class.inc.php

示例14: ProcessCSVData


//.........这里部分代码省略.........
            CMDBObject::SetTrackInfo($sUserString);
            CMDBObject::SetTrackOrigin('csv-interactive');
            $oMyChange = CMDBObject::GetCurrentChange();
        }
        $oBulk = new BulkChange($sClassName, $aData, $aAttributes, $aExtKeys, array_keys($aSearchKeys), empty($sSynchroScope) ? null : $sSynchroScope, $aSynchroUpdate, null, true);
        $oBulk->SetReportHtml();
        $oPage->add('<input type="hidden" name="csvdata_truncated" id="csvdata_truncated" value="' . htmlentities($sCSVDataTruncated, ENT_QUOTES, 'UTF-8') . '"/>');
        $aRes = $oBulk->Process($oMyChange);
        $sHtml = '<table id="bulk_preview" style="border-collapse: collapse;">';
        $sHtml .= '<tr><th style="padding:2px;border-right: 2px #fff solid;">Line</th>';
        $sHtml .= '<th style="padding:2px;border-right: 2px #fff solid;">Status</th>';
        $sHtml .= '<th style="padding:2px;border-right: 2px #fff solid;">Object</th>';
        foreach ($aFieldsMapping as $iNumber => $sAttCode) {
            if (!empty($sAttCode) && $sAttCode != ':none:' && $sAttCode != 'finalclass') {
                $sHtml .= "<th style=\"padding:2px;border-right: 2px #fff solid;\">" . MetaModel::GetLabel($sClassName, $sAttCode) . "</th>";
            }
        }
        $sHtml .= '<th>Message</th>';
        $sHtml .= '</tr>';
        $iErrors = 0;
        $iCreated = 0;
        $iModified = 0;
        $iUnchanged = 0;
        foreach ($aRes as $iLine => $aResRow) {
            $oStatus = $aResRow['__STATUS__'];
            $sUrl = '';
            $sMessage = '';
            $sCSSRowClass = '';
            $sCSSMessageClass = 'cell_ok';
            switch (get_class($oStatus)) {
                case 'RowStatus_NoChange':
                    $iUnchanged++;
                    $sFinalClass = $aResRow['finalclass'];
                    $oObj = MetaModel::GetObject($sFinalClass, $aResRow['id']->GetPureValue());
                    $sUrl = $oObj->GetHyperlink();
                    $sStatus = '<img src="../images/unchanged.png" title="' . Dict::S('UI:CSVReport-Icon-Unchanged') . '">';
                    $sCSSRowClass = 'row_unchanged';
                    break;
                case 'RowStatus_Modify':
                    $iModified++;
                    $sFinalClass = $aResRow['finalclass'];
                    $oObj = MetaModel::GetObject($sFinalClass, $aResRow['id']->GetPureValue());
                    $sUrl = $oObj->GetHyperlink();
                    $sStatus = '<img src="../images/modified.png" title="' . Dict::S('UI:CSVReport-Icon-Modified') . '">';
                    $sCSSRowClass = 'row_modified';
                    break;
                case 'RowStatus_Disappeared':
                    $iModified++;
                    $sFinalClass = $aResRow['finalclass'];
                    $oObj = MetaModel::GetObject($sFinalClass, $aResRow['id']->GetPureValue());
                    $sUrl = $oObj->GetHyperlink();
                    $sStatus = '<img src="../images/delete.png" title="' . Dict::S('UI:CSVReport-Icon-Missing') . '">';
                    $sCSSRowClass = 'row_modified';
                    if ($bSimulate) {
                        $sMessage = Dict::S('UI:CSVReport-Object-MissingToUpdate');
                    } else {
                        $sMessage = Dict::S('UI:CSVReport-Object-MissingUpdated');
                    }
                    break;
                case 'RowStatus_NewObj':
                    $iCreated++;
                    $sFinalClass = $aResRow['finalclass'];
                    $sStatus = '<img src="../images/added.png" title="' . Dict::S('UI:CSVReport-Icon-Created') . '">';
                    $sCSSRowClass = 'row_added';
                    if ($bSimulate) {
                        $sMessage = Dict::S('UI:CSVReport-Object-ToCreate');
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:67,代码来源:csvimport.php

示例15: CheckCredentials

 /**
  * Check the user's password against the LDAP server
  * Algorithm:
  * 1) Connect to the LDAP server, using a predefined account (or anonymously)
  * 2) Search for the specified user, based on a specific search query/pattern
  * 3) If exactly one user is found, continue, otherwise return false (wrong user or wrong query configured)
  * 3) Bind again to LDAP using the DN of the found user and the password
  * 4) If the bind is successful return true, otherwise return false (wrong password)
  * @param string $sPassword The user's password to validate against the LDAP server
  * @return boolean True if the password is Ok, false otherwise
  */
 public function CheckCredentials($sPassword)
 {
     $sLDAPHost = MetaModel::GetModuleSetting('authent-ldap', 'host', 'localhost');
     $iLDAPPort = MetaModel::GetModuleSetting('authent-ldap', 'port', 389);
     $sDefaultLDAPUser = MetaModel::GetModuleSetting('authent-ldap', 'default_user', '');
     $sDefaultLDAPPwd = MetaModel::GetModuleSetting('authent-ldap', 'default_pwd', '');
     $hDS = @ldap_connect($sLDAPHost, $iLDAPPort);
     if ($hDS === false) {
         $this->LogMessage("ldap_authentication: can not connect to the LDAP server '{$sLDAPHost}' (port: {$iLDAPPort}). Check the configuration file config-itop.php.");
         return false;
     }
     $aOptions = MetaModel::GetModuleSetting('authent-ldap', 'options', array());
     foreach ($aOptions as $name => $value) {
         ldap_set_option($hDS, $name, $value);
     }
     if ($bind = @ldap_bind($hDS, $sDefaultLDAPUser, $sDefaultLDAPPwd)) {
         // Search for the person, using the specified query expression
         $sLDAPUserQuery = MetaModel::GetModuleSetting('authent-ldap', 'user_query', '');
         $sBaseDN = MetaModel::GetModuleSetting('authent-ldap', 'base_dn', '');
         $sLogin = $this->Get('login');
         $iContactId = $this->Get('contactid');
         $sFirstName = '';
         $sLastName = '';
         $sEMail = '';
         if ($iContactId > 0) {
             $oPerson = MetaModel::GetObject('Person', $iContactId);
             if (is_object($oPerson)) {
                 $sFirstName = $oPerson->Get('first_name');
                 $sLastName = $oPerson->Get('name');
                 $sEMail = $oPerson->Get('email');
             }
         }
         // %1$s => login
         // %2$s => first name
         // %3$s => last name
         // %4$s => email
         $sQuery = sprintf($sLDAPUserQuery, $sLogin, $sFirstName, $sLastName, $sEMail);
         $hSearchResult = @ldap_search($hDS, $sBaseDN, $sQuery);
         $iCountEntries = $hSearchResult !== false ? @ldap_count_entries($hDS, $hSearchResult) : 0;
         switch ($iCountEntries) {
             case 1:
                 // Exactly one entry found, let's check the password by trying to bind with this user
                 $aEntry = ldap_get_entries($hDS, $hSearchResult);
                 $sUserDN = $aEntry[0]['dn'];
                 $bUserBind = @ldap_bind($hDS, $sUserDN, $sPassword);
                 if ($bUserBind !== false && !empty($sPassword)) {
                     ldap_unbind($hDS);
                     return true;
                     // Password Ok
                 }
                 $this->LogMessage("ldap_authentication: wrong password for user: '{$sUserDN}'.");
                 return false;
                 // Wrong password
                 break;
             case 0:
                 // User not found...
                 $this->LogMessage("ldap_authentication: no entry found with the query '{$sQuery}', base_dn = '{$sBaseDN}'. User not found in LDAP.");
                 break;
             default:
                 // More than one entry... maybe the query is not specific enough...
                 $this->LogMessage("ldap_authentication: several (" . ldap_count_entries($hDS, $hSearchResult) . ") entries match the query '{$sQuery}', base_dn = '{$sBaseDN}', check that the query defined in config-itop.php is specific enough.");
         }
         return false;
     } else {
         // Trace: invalid default user for LDAP initial binding
         $this->LogMessage("ldap_authentication: can not bind to the LDAP server '{$sLDAPHost}' (port: {$iLDAPPort}), user='{$sDefaultLDAPUser}', pwd='{$sDefaultLDAPPwd}'. Error: '" . ldap_error($hDS) . "'. Check the configuration file config-itop.php.");
         return false;
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:80,代码来源:model.authent-ldap.php


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