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


PHP WebPage::ReadAllParams方法代码示例

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


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

示例1: DoCreateRequest

/**
 * Validate the parameters and create the ticket object (based on the page's POSTed parameters)
 * @param WebPage $oP The current web page for the  output
 * @param Organization $oUserOrg The organization of the current user
 * @return void
 */
function DoCreateRequest($oP, $oUserOrg)
{
    $aParameters = $oP->ReadAllParams(PORTAL_ALL_PARAMS . ',template_id');
    $sTransactionId = utils::ReadPostedParam('transaction_id', '');
    if (!utils::IsTransactionValid($sTransactionId)) {
        $oP->add("<h1>" . Dict::S('UI:Error:ObjectAlreadyCreated') . "</h1>\n");
        //ShowOngoingTickets($oP);
        return;
    }
    // Validate the parameters
    // 1) ServiceCategory
    $oSearch = DBObjectSearch::FromOQL(PORTAL_VALIDATE_SERVICECATEGORY_QUERY);
    $oSearch->AllowAllData();
    // In case the user has the rights on his org only
    $oSet = new CMDBObjectSet($oSearch, array(), array('id' => $aParameters['service_id'], 'org_id' => $oUserOrg->GetKey()));
    if ($oSet->Count() != 1) {
        // Invalid service for the current user !
        throw new Exception("Invalid Service Category: id={$aParameters['service_id']} - count: " . $oSet->Count());
    }
    $oServiceCategory = $oSet->Fetch();
    // 2) Service Subcategory
    $oSearch = DBObjectSearch::FromOQL(PORTAL_VALIDATE_SERVICESUBCATEGORY_QUERY);
    RestrictSubcategories($oSearch);
    $oSearch->AllowAllData();
    // In case the user has the rights on his org only
    $oSet = new CMDBObjectSet($oSearch, array(), array('service_id' => $aParameters['service_id'], 'id' => $aParameters['servicesubcategory_id'], 'org_id' => $oUserOrg->GetKey()));
    if ($oSet->Count() != 1) {
        // Invalid subcategory
        throw new Exception("Invalid ServiceSubcategory: id={$aParameters['servicesubcategory_id']} for service category " . $oServiceCategory->GetName() . "({$aParameters['service_id']}) - count: " . $oSet->Count());
    }
    $oServiceSubCategory = $oSet->Fetch();
    $sClass = ComputeClass($oServiceSubCategory->GetKey());
    $oRequest = MetaModel::NewObject($sClass);
    $aAttList = array_merge(explode(',', GetConstant($sClass, 'FORM_ATTRIBUTES')), array('service_id', 'servicesubcategory_id'));
    $oRequest->UpdateObjectFromPostedForm('', $aAttList);
    $oRequest->Set('org_id', $oUserOrg->GetKey());
    $oRequest->Set('caller_id', UserRights::GetContactId());
    if (isset($aParameters['moreinfo'])) {
        // There is a template, insert it into the description
        $sLogAttCode = GetConstant($sClass, 'PUBLIC_LOG');
        $oRequest->Set($sLogAttCode, $aParameters['moreinfo']);
    }
    $sTypeAttCode = GetConstant($sClass, 'TYPE');
    if ($sTypeAttCode != '' && PORTAL_SET_TYPE_FROM != '') {
        $oRequest->Set($sTypeAttCode, $oServiceSubCategory->Get(PORTAL_SET_TYPE_FROM));
    }
    if (MetaModel::IsValidAttCode($sClass, 'origin')) {
        $oRequest->Set('origin', 'portal');
    }
    $oAttPlugin = new AttachmentPlugIn();
    $oAttPlugin->OnFormSubmit($oRequest);
    list($bRes, $aIssues) = $oRequest->CheckToWrite();
    if ($bRes) {
        if (isset($aParameters['template_id'])) {
            $oTemplate = MetaModel::GetObject('Template', $aParameters['template_id']);
            $sLogAttCode = GetConstant($sClass, 'PUBLIC_LOG');
            $oRequest->Set($sLogAttCode, $oTemplate->GetPostedValuesAsText($oRequest) . "\n");
            $oRequest->DBInsertNoReload();
            $oTemplate->RecordExtraDataFromPostedForm($oRequest);
        } else {
            $oRequest->DBInsertNoReload();
        }
        $oP->add("<h1>" . Dict::Format('UI:Title:Object_Of_Class_Created', $oRequest->GetName(), MetaModel::GetName($sClass)) . "</h1>\n");
        //DisplayObject($oP, $oRequest, $oUserOrg);
        ShowOngoingTickets($oP);
    } else {
        RequestCreationForm($oP, $oUserOrg);
        $sIssueDesc = Dict::Format('UI:ObjectCouldNotBeWritten', implode(', ', $aIssues));
        $oP->add_ready_script("alert('" . addslashes($sIssueDesc) . "');");
    }
}
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:77,代码来源:index.php


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