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


PHP UserRights::IsStimulusAllowed方法代码示例

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


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

示例1: IsEnabled

 /**
  * Tells whether the menu is enabled (i.e. displayed) for the current user
  * @return bool True if enabled, false otherwise
  */
 public function IsEnabled()
 {
     foreach ($this->m_aEnableClasses as $index => $sClass) {
         if ($sClass != null) {
             if (MetaModel::IsValidClass($sClass)) {
                 if ($this->m_aEnableStimuli[$index] != null) {
                     if (!UserRights::IsStimulusAllowed($sClass, $this->m_aEnableStimuli[$index])) {
                         return false;
                     }
                 }
                 if ($this->m_aEnableActions[$index] != null) {
                     $iResult = UserRights::IsActionAllowed($sClass, $this->m_aEnableActions[$index]);
                     if (!($iResult & $this->m_aEnableActionResults[$index])) {
                         return false;
                     }
                 }
             } else {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:27,代码来源:menunode.class.inc.php

示例2: DisplayModifyForm

    public function DisplayModifyForm(WebPage $oPage, $aExtraParams = array())
    {
        $sOwnershipToken = null;
        $iKey = $this->GetKey();
        $sClass = get_class($this);
        if ($iKey > 0) {
            // The concurrent access lock makes sense only for already existing objects
            $LockEnabled = MetaModel::GetConfig()->Get('concurrent_lock_enabled');
            if ($LockEnabled) {
                $sOwnershipToken = utils::ReadPostedParam('ownership_token', null, false, 'raw_data');
                if ($sOwnershipToken !== null) {
                    // We're probably inside something like "apply_modify" where the validation failed and we must prompt the user again to edit the object
                    // let's extend our lock
                    $aLockInfo = iTopOwnershipLock::ExtendLock($sClass, $iKey, $sOwnershipToken);
                    $sOwnershipDate = $aLockInfo['acquired'];
                } else {
                    $aLockInfo = iTopOwnershipLock::AcquireLock($sClass, $iKey);
                    if ($aLockInfo['success']) {
                        $sOwnershipToken = $aLockInfo['token'];
                        $sOwnershipDate = $aLockInfo['acquired'];
                    } else {
                        $oOwner = $aLockInfo['lock']->GetOwner();
                        // If the object is locked by the current user, it's worth trying again, since
                        // the lock may be released by 'onunload' which is called AFTER loading the current page.
                        //$bTryAgain = $oOwner->GetKey() == UserRights::GetUserId();
                        self::ReloadAndDisplay($oPage, $this, array('operation' => 'modify'));
                        return;
                    }
                }
            }
        }
        if (isset($aExtraParams['wizard_container']) && $aExtraParams['wizard_container']) {
            $sClassLabel = MetaModel::GetName($sClass);
            $oPage->set_title(Dict::Format('UI:ModificationPageTitle_Object_Class', $this->GetRawName(), $sClassLabel));
            // Set title will take care of the encoding
            $oPage->add("<div class=\"page_header\">\n");
            $oPage->add("<h1>" . $this->GetIcon() . "&nbsp;" . Dict::Format('UI:ModificationTitle_Class_Object', $sClassLabel, $this->GetName()) . "</h1>\n");
            $oPage->add("</div>\n");
            $oPage->add("<div class=\"wizContainer\">\n");
        }
        self::$iGlobalFormId++;
        $this->aFieldsMap = array();
        $sPrefix = '';
        if (isset($aExtraParams['formPrefix'])) {
            $sPrefix = $aExtraParams['formPrefix'];
        }
        $aFieldsComments = isset($aExtraParams['fieldsComments']) ? $aExtraParams['fieldsComments'] : array();
        $this->m_iFormId = $sPrefix . self::$iGlobalFormId;
        $oAppContext = new ApplicationContext();
        $sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
        $aDetails = array();
        $aFieldsMap = array();
        if (!isset($aExtraParams['action'])) {
            $sFormAction = utils::GetAbsoluteUrlAppRoot() . 'pages/' . $this->GetUIPage();
            // No parameter in the URL, the only parameter will be the ones passed through the form
        } else {
            $sFormAction = $aExtraParams['action'];
        }
        // Custom label for the apply button ?
        if (isset($aExtraParams['custom_button'])) {
            $sApplyButton = $aExtraParams['custom_button'];
        } else {
            if ($iKey > 0) {
                $sApplyButton = Dict::S('UI:Button:Apply');
            } else {
                $sApplyButton = Dict::S('UI:Button:Create');
            }
        }
        // Custom operation for the form ?
        if (isset($aExtraParams['custom_operation'])) {
            $sOperation = $aExtraParams['custom_operation'];
        } else {
            if ($iKey > 0) {
                $sOperation = 'apply_modify';
            } else {
                $sOperation = 'apply_new';
            }
        }
        if ($iKey > 0) {
            // The object already exists in the database, it's a modification
            $sButtons = "<input id=\"{$sPrefix}_id\" type=\"hidden\" name=\"id\" value=\"{$iKey}\">\n";
            $sButtons .= "<input type=\"hidden\" name=\"operation\" value=\"{$sOperation}\">\n";
            $sButtons .= "<button type=\"button\" class=\"action cancel\"><span>" . Dict::S('UI:Button:Cancel') . "</span></button>&nbsp;&nbsp;&nbsp;&nbsp;\n";
            $sButtons .= "<button type=\"submit\" class=\"action\"><span>{$sApplyButton}</span></button>\n";
        } else {
            // The object does not exist in the database it's a creation
            $sButtons = "<input type=\"hidden\" name=\"operation\" value=\"{$sOperation}\">\n";
            $sButtons .= "<button type=\"button\" class=\"action cancel\">" . Dict::S('UI:Button:Cancel') . "</button>&nbsp;&nbsp;&nbsp;&nbsp;\n";
            $sButtons .= "<button type=\"submit\" class=\"action\"><span>{$sApplyButton}</span></button>\n";
        }
        $aTransitions = $this->EnumTransitions();
        if (!isset($aExtraParams['custom_operation']) && count($aTransitions)) {
            // transitions are displayed only for the standard new/modify actions, not for modify_all or any other case...
            $oSetToCheckRights = DBObjectSet::FromObject($this);
            $aStimuli = Metamodel::EnumStimuli($sClass);
            foreach ($aTransitions as $sStimulusCode => $aTransitionDef) {
                $iActionAllowed = get_class($aStimuli[$sStimulusCode]) == 'StimulusUserAction' ? UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSetToCheckRights) : UR_ALLOWED_NO;
                switch ($iActionAllowed) {
                    case UR_ALLOWED_YES:
                        $sButtons .= "<button type=\"submit\" name=\"next_action\" value=\"{$sStimulusCode}\" class=\"action\"><span>" . $aStimuli[$sStimulusCode]->GetLabel() . "</span></button>\n";
//.........这里部分代码省略.........
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:101,代码来源:cmdbabstract.class.inc.php

示例3: GetRenderContent

 /**
  * Renders the "Actions" popup menu for the given set of objects
  * 
  * Note that the menu links containing (or ending) with a hash (#) will have their fragment
  * part (whatever is after the hash) dynamically replaced (by javascript) when the menu is
  * displayed, to correspond to the current hash/fragment in the page. This allows modifying
  * an object in with the same tab active by default as the tab that was active when selecting
  * the "Modify..." action.
  */
 public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId)
 {
     if ($this->m_sStyle == 'popup') {
         $this->m_sStyle = 'list';
     }
     $sHtml = '';
     $oAppContext = new ApplicationContext();
     $sContext = $oAppContext->GetForLink();
     if (!empty($sContext)) {
         $sContext = '&' . $sContext;
     }
     $sClass = $this->m_oFilter->GetClass();
     $oReflectionClass = new ReflectionClass($sClass);
     $oSet = new CMDBObjectSet($this->m_oFilter);
     $sFilter = $this->m_oFilter->serialize();
     $sFilterDesc = $this->m_oFilter->ToOql(true);
     $aActions = array();
     $sUIPage = cmdbAbstractObject::ComputeStandardUIPage($sClass);
     $sRootUrl = utils::GetAbsoluteUrlAppRoot();
     // 1:n links, populate the target object as a default value when creating a new linked object
     if (isset($aExtraParams['target_attr'])) {
         $aExtraParams['default'][$aExtraParams['target_attr']] = $aExtraParams['object_id'];
     }
     $sDefault = '';
     if (!empty($aExtraParams['default'])) {
         foreach ($aExtraParams['default'] as $sKey => $sValue) {
             $sDefault .= "&default[{$sKey}]={$sValue}";
         }
     }
     $bIsCreationAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_CREATE) == UR_ALLOWED_YES && $oReflectionClass->IsSubclassOf('cmdbAbstractObject');
     switch ($oSet->Count()) {
         case 0:
             // No object in the set, the only possible action is "new"
             if ($bIsCreationAllowed) {
                 $aActions['UI:Menu:New'] = array('label' => Dict::S('UI:Menu:New'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=new&class={$sClass}{$sContext}{$sDefault}");
             }
             break;
         case 1:
             $oObj = $oSet->Fetch();
             $id = $oObj->GetKey();
             $bLocked = false;
             if (MetaModel::GetConfig()->Get('concurrent_lock_enabled')) {
                 $aLockInfo = iTopOwnershipLock::IsLocked(get_class($oObj), $id);
                 if ($aLockInfo['locked']) {
                     $bLocked = true;
                     //$this->AddMenuSeparator($aActions);
                     //$aActions['concurrent_lock_unlock'] = array ('label' => Dict::S('UI:Menu:ReleaseConcurrentLock'), 'url' => "{$sRootUrl}pages/$sUIPage?operation=kill_lock&class=$sClass&id=$id{$sContext}");
                 }
             }
             $bRawModifiedAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY, $oSet) == UR_ALLOWED_YES && $oReflectionClass->IsSubclassOf('cmdbAbstractObject');
             $bIsModifyAllowed = !$bLocked && $bRawModifiedAllowed;
             $bIsDeleteAllowed = !$bLocked && UserRights::IsActionAllowed($sClass, UR_ACTION_DELETE, $oSet);
             // Just one object in the set, possible actions are "new / clone / modify and delete"
             if (!isset($aExtraParams['link_attr'])) {
                 if ($bIsModifyAllowed) {
                     $aActions['UI:Menu:Modify'] = array('label' => Dict::S('UI:Menu:Modify'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=modify&class={$sClass}&id={$id}{$sContext}#");
                 }
                 if ($bIsCreationAllowed) {
                     $aActions['UI:Menu:New'] = array('label' => Dict::S('UI:Menu:New'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=new&class={$sClass}{$sContext}{$sDefault}");
                 }
                 if ($bIsDeleteAllowed) {
                     $aActions['UI:Menu:Delete'] = array('label' => Dict::S('UI:Menu:Delete'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=delete&class={$sClass}&id={$id}{$sContext}");
                 }
                 // Transitions / Stimuli
                 if (!$bLocked) {
                     $aTransitions = $oObj->EnumTransitions();
                     if (count($aTransitions)) {
                         $this->AddMenuSeparator($aActions);
                         $aStimuli = Metamodel::EnumStimuli(get_class($oObj));
                         foreach ($aTransitions as $sStimulusCode => $aTransitionDef) {
                             $iActionAllowed = get_class($aStimuli[$sStimulusCode]) == 'StimulusUserAction' ? UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSet) : UR_ALLOWED_NO;
                             switch ($iActionAllowed) {
                                 case UR_ALLOWED_YES:
                                     $aActions[$sStimulusCode] = array('label' => $aStimuli[$sStimulusCode]->GetLabel(), 'url' => "{$sRootUrl}pages/UI.php?operation=stimulus&stimulus={$sStimulusCode}&class={$sClass}&id={$id}{$sContext}");
                                     break;
                                 default:
                                     // Do nothing
                             }
                         }
                     }
                 }
                 // Relations...
                 $aRelations = MetaModel::EnumRelationsEx($sClass);
                 if (count($aRelations)) {
                     $this->AddMenuSeparator($aActions);
                     foreach ($aRelations as $sRelationCode => $aRelationInfo) {
                         if (array_key_exists('down', $aRelationInfo)) {
                             $aActions[$sRelationCode . '_down'] = array('label' => $aRelationInfo['down'], 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=swf_navigator&relation={$sRelationCode}&direction=down&class={$sClass}&id={$id}{$sContext}");
                         }
                         if (array_key_exists('up', $aRelationInfo)) {
                             $aActions[$sRelationCode . '_up'] = array('label' => $aRelationInfo['up'], 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=swf_navigator&relation={$sRelationCode}&direction=up&class={$sClass}&id={$id}{$sContext}");
//.........这里部分代码省略.........
开发者ID:henryavila,项目名称:itop,代码行数:101,代码来源:displayblock.class.inc.php

示例4: ShowDetailsRequest

/**
 * Displays the details of a request
 * @param WebPage $oP The current web page
 * @param Object $oObj The target object
 * @return void
 */
function ShowDetailsRequest(WebPage $oP, $oObj)
{
    $sClass = get_class($oObj);
    $sLogAttCode = GetConstant($sClass, 'PUBLIC_LOG');
    $sUserCommentAttCode = GetConstant($sClass, 'USER_COMMENT');
    $bIsReopenButton = false;
    $bIsCloseButton = false;
    $bIsEscalateButton = false;
    $bEditAttachments = false;
    $aEditAtt = array();
    // List of attributes editable in the main form
    if (!MetaModel::DBIsReadOnly()) {
        switch ($oObj->GetState()) {
            case 'resolved':
                $aEditAtt = array();
                $aTransitions = $oObj->EnumTransitions();
                $oSet = DBObjectSet::FromObject($oObj);
                // Add the "Reopen" button if this is valid action
                if (array_key_exists('ev_reopen', $aTransitions) && UserRights::IsStimulusAllowed($sClass, 'ev_reopen', $oSet)) {
                    $bIsReopenButton = true;
                    MakeStimulusForm($oP, $oObj, 'ev_reopen', array($sLogAttCode));
                }
                // Add the "Close" button if this is valid action
                if (array_key_exists('ev_close', $aTransitions) && UserRights::IsStimulusAllowed($sClass, 'ev_close', $oSet)) {
                    $bIsCloseButton = true;
                    MakeStimulusForm($oP, $oObj, 'ev_close', array('user_satisfaction', $sUserCommentAttCode));
                }
                break;
            case 'closed':
                // By convention 'closed' is the final state of a ticket and nothing can be done in such a state
                break;
            default:
                // In all other states, the only possible action is to update the ticket (both the case log and the attachments)
                // This update is possible only if the case log field is not read-only or hidden in the current state
                $iFlags = $oObj->GetAttributeFlags($sLogAttCode);
                $bReadOnly = ($iFlags & (OPT_ATT_READONLY | OPT_ATT_HIDDEN)) != 0;
                if ($bReadOnly) {
                    $aEditAtt = array();
                    $bEditAttachments = false;
                } else {
                    $aEditAtt = array($sLogAttCode => '????');
                    $bEditAttachments = true;
                }
                break;
        }
    }
    // REFACTORISER LA MISE EN FORME
    $oP->add("<h1 id=\"title_request_details\">" . $oObj->GetIcon() . "&nbsp;" . Dict::Format('Portal:TitleRequestDetailsFor_Request', $oObj->GetName()) . "</h1>\n");
    $aAttList = json_decode(GetConstant($sClass, 'DETAILS_ZLIST'), true);
    switch ($oObj->GetState()) {
        case 'closed':
            $aAttList['centered'][] = 'user_satisfaction';
            $aAttList['centered'][] = $sUserCommentAttCode;
    }
    // Remove the edited attribute from the shown attributes
    //
    foreach ($aEditAtt as $sAttCode => $foo) {
        foreach ($aAttList as $col => $aColumn) {
            if (in_array($sAttCode, $aColumn)) {
                if (($index = array_search($sAttCode, $aColumn)) !== false) {
                    unset($aAttList[$col][$index]);
                }
            }
        }
    }
    $oP->add("<div class=\"wizContainer\" id=\"form_commment_request\">\n");
    $oP->WizardFormStart('request_form', null);
    $oP->add('<div id="request_details">');
    $oP->add('<table id="request_details_table">');
    $oP->add('<tr>');
    $oP->add('<td style="vertical-align:top;">');
    $oP->DisplayObjectDetails($oObj, $aAttList['col:left']);
    $oP->add('</td>');
    $oP->add('<td style="vertical-align:top;">');
    $oP->DisplayObjectDetails($oObj, $aAttList['col:right']);
    $oP->add('</td>');
    $oP->add('</tr>');
    if (array_key_exists('centered', $aAttList)) {
        $oP->add('<tr>');
        $oP->add('<td style="vertical-align:top;" colspan="2">');
        $oP->DisplayObjectDetails($oObj, $aAttList['centered']);
        $oP->add('</td>');
        $oP->add('</tr>');
    }
    // REFACTORISER
    $oP->add('<tr>');
    $oP->add('<td colspan="2" style="vertical-align:top;">');
    $oAttPlugin = new AttachmentPlugIn();
    if ($bEditAttachments) {
        $oAttPlugin->EnableDelete(false);
        $oAttPlugin->OnDisplayRelations($oObj, $oP, true);
    } else {
        $oAttPlugin->OnDisplayRelations($oObj, $oP, false);
    }
//.........这里部分代码省略.........
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:101,代码来源:index.php

示例5: DisplayModifyForm

    public function DisplayModifyForm(WebPage $oPage, $aExtraParams = array())
    {
        self::$iGlobalFormId++;
        $this->aFieldsMap = array();
        $sPrefix = '';
        if (isset($aExtraParams['formPrefix'])) {
            $sPrefix = $aExtraParams['formPrefix'];
        }
        $aFieldsComments = isset($aExtraParams['fieldsComments']) ? $aExtraParams['fieldsComments'] : array();
        $this->m_iFormId = $sPrefix . self::$iGlobalFormId;
        $sClass = get_class($this);
        $oAppContext = new ApplicationContext();
        $sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
        $iKey = $this->GetKey();
        $aDetails = array();
        $aFieldsMap = array();
        if (!isset($aExtraParams['action'])) {
            $sFormAction = $_SERVER['SCRIPT_NAME'];
            // No parameter in the URL, the only parameter will be the ones passed through the form
        } else {
            $sFormAction = $aExtraParams['action'];
        }
        // Custom label for the apply button ?
        if (isset($aExtraParams['custom_button'])) {
            $sApplyButton = $aExtraParams['custom_button'];
        } else {
            if ($iKey > 0) {
                $sApplyButton = Dict::S('UI:Button:Apply');
            } else {
                $sApplyButton = Dict::S('UI:Button:Create');
            }
        }
        // Custom operation for the form ?
        if (isset($aExtraParams['custom_operation'])) {
            $sOperation = $aExtraParams['custom_operation'];
        } else {
            if ($iKey > 0) {
                $sOperation = 'apply_modify';
            } else {
                $sOperation = 'apply_new';
            }
        }
        if ($iKey > 0) {
            // The object already exists in the database, it's a modification
            $sButtons = "<input id=\"{$sPrefix}_id\" type=\"hidden\" name=\"id\" value=\"{$iKey}\">\n";
            $sButtons .= "<input type=\"hidden\" name=\"operation\" value=\"{$sOperation}\">\n";
            $sButtons .= "<button type=\"button\" class=\"action cancel\"><span>" . Dict::S('UI:Button:Cancel') . "</span></button>&nbsp;&nbsp;&nbsp;&nbsp;\n";
            $sButtons .= "<button type=\"submit\" class=\"action\"><span>{$sApplyButton}</span></button>\n";
        } else {
            // The object does not exist in the database it's a creation
            $sButtons = "<input type=\"hidden\" name=\"operation\" value=\"{$sOperation}\">\n";
            $sButtons .= "<button type=\"button\" class=\"action cancel\">" . Dict::S('UI:Button:Cancel') . "</button>&nbsp;&nbsp;&nbsp;&nbsp;\n";
            $sButtons .= "<button type=\"submit\" class=\"action\"><span>{$sApplyButton}</span></button>\n";
        }
        $aTransitions = $this->EnumTransitions();
        if (!isset($aExtraParams['custom_operation']) && count($aTransitions)) {
            // transitions are displayed only for the standard new/modify actions, not for modify_all or any other case...
            $oSetToCheckRights = DBObjectSet::FromObject($this);
            $aStimuli = Metamodel::EnumStimuli($sClass);
            foreach ($aTransitions as $sStimulusCode => $aTransitionDef) {
                $iActionAllowed = get_class($aStimuli[$sStimulusCode]) == 'StimulusUserAction' ? UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSetToCheckRights) : UR_ALLOWED_NO;
                switch ($iActionAllowed) {
                    case UR_ALLOWED_YES:
                        $sButtons .= "<button type=\"submit\" name=\"next_action\" value=\"{$sStimulusCode}\" class=\"action\"><span>" . $aStimuli[$sStimulusCode]->GetLabel() . "</span></button>\n";
                        break;
                    default:
                        // Do nothing
                }
            }
        }
        $sButtonsPosition = MetaModel::GetConfig()->Get('buttons_position');
        $iTransactionId = isset($aExtraParams['transaction_id']) ? $aExtraParams['transaction_id'] : utils::GetNewTransactionId();
        $oPage->SetTransactionId($iTransactionId);
        $oPage->add("<form action=\"{$sFormAction}\" id=\"form_{$this->m_iFormId}\" enctype=\"multipart/form-data\" method=\"post\" onSubmit=\"return OnSubmit('form_{$this->m_iFormId}');\">\n");
        $sStatesSelection = '';
        if (!isset($aExtraParams['custom_operation']) && $this->IsNew()) {
            $aInitialStates = MetaModel::EnumInitialStates($sClass);
            //$aInitialStates = array('new' => 'foo', 'closed' => 'bar');
            if (count($aInitialStates) > 1) {
                $sStatesSelection = Dict::Format('UI:Create_Class_InState', MetaModel::GetName($sClass)) . '<select name="obj_state" class="state_select_' . $this->m_iFormId . '">';
                foreach ($aInitialStates as $sStateCode => $sStateData) {
                    $sSelected = '';
                    if ($sStateCode == $this->GetState()) {
                        $sSelected = ' selected';
                    }
                    $sStatesSelection .= '<option value="' . $sStateCode . '"' . $sSelected . '>' . MetaModel::GetStateLabel($sClass, $sStateCode) . '</option>';
                }
                $sStatesSelection .= '</select>';
                $oPage->add_ready_script("\$('.state_select_{$this->m_iFormId}').change( function() { oWizardHelper{$sPrefix}.ReloadObjectCreationForm('form_{$this->m_iFormId}', \$(this).val()); } );");
            }
        }
        $sConfirmationMessage = addslashes(Dict::S('UI:NavigateAwayConfirmationMessage'));
        $oPage->add_ready_script(<<<EOF
\t\$(window).unload(function() { return OnUnload('{$iTransactionId}') } );
\twindow.onbeforeunload = function() {
\t\tif (!window.bInSubmit && !window.bInCancel)
\t\t{
\t\t\treturn '{$sConfirmationMessage}';\t
\t\t}
\t\t// return nothing ! safer for IE
//.........这里部分代码省略.........
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:101,代码来源:cmdbabstract.class.inc.php

示例6: IsAllowed

 /**
  * Check if the speficied stimulus is allowed for the set of objects
  * @return UR_ALLOWED_YES, UR_ALLOWED_NO or UR_ALLOWED_DEPENDS
  */
 public function IsAllowed()
 {
     $sClass = $this->oFilter->GetClass();
     if (MetaModel::IsAbstract($sClass)) {
         return UR_ALLOWED_NO;
     }
     // Safeguard, not implemented if the base class of the set is abstract !
     $oSet = new DBObjectSet($this->oFilter);
     $iActionAllowed = UserRights::IsStimulusAllowed($sClass, $this->iActionCode, $oSet);
     if ($iActionAllowed == UR_ALLOWED_NO) {
         $this->iAllowedCount = 0;
         $this->aAllowedIDs = array();
     } else {
         // Hmmm, may not be needed right now because we limit the "multiple" action to object in
         // the same state... may be useful later on if we want to extend this behavior...
         // Check for each object if the action is allowed or not
         $this->aAllowedIDs = array();
         $oSet->Rewind();
         $iAllowedCount = 0;
         $iActionAllowed = UR_ALLOWED_DEPENDS;
         while ($oObj = $oSet->Fetch()) {
             $aTransitions = $oObj->EnumTransitions();
             if (array_key_exists($this->iActionCode, $aTransitions)) {
                 // Temporary optimization possible: since the current implementation
                 // of IsActionAllowed does not perform a 'per instance' check, we could
                 // skip this second validation phase and assume it would return UR_ALLOWED_YES
                 $oObjSet = DBObjectSet::FromArray($sClass, array($oObj));
                 if (!UserRights::IsStimulusAllowed($sClass, $this->iActionCode, $oObjSet)) {
                     $this->aAllowedIDs[$oObj->GetKey()] = false;
                 } else {
                     // Assume UR_ALLOWED_YES, since there is just one object !
                     $this->aAllowedIDs[$oObj->GetKey()] = true;
                     $this->iState = $oObj->GetState();
                     $this->iAllowedCount++;
                 }
             } else {
                 $this->aAllowedIDs[$oObj->GetKey()] = false;
             }
         }
     }
     if ($this->iAllowedCount == $oSet->Count()) {
         $iActionAllowed = UR_ALLOWED_YES;
     }
     if ($this->iAllowedCount == 0) {
         $iActionAllowed = UR_ALLOWED_NO;
     }
     return $iActionAllowed;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:52,代码来源:userrights.class.inc.php

示例7: DoExecute

 protected function DoExecute()
 {
     $sUser = 'Romain';
     echo "<p>Totor: " . (UserRights::CheckCredentials('Totor', 'toto') ? 'ok' : 'NO') . "</p>\n";
     echo "<p>Romain: " . (UserRights::CheckCredentials('Romain', 'toto') ? 'ok' : 'NO') . "</p>\n";
     echo "<p>User: " . UserRights::GetUser() . "</p>\n";
     echo "<p>On behalf of..." . UserRights::GetRealUser() . "</p>\n";
     echo "<p>Denis (impersonate) : " . (UserRights::Impersonate('Denis', 'tutu') ? 'ok' : 'NO') . "</p>\n";
     echo "<p>User: " . UserRights::GetUser() . "</p>\n";
     echo "<p>On behalf of..." . UserRights::GetRealUser() . "</p>\n";
     $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT bizOrganization"));
     echo "<p>IsActionAllowed..." . (UserRights::IsActionAllowed('bizOrganization', UR_ACTION_MODIFY, $oSet) == UR_ALLOWED_YES ? 'ok' : 'NO') . "</p>\n";
     echo "<p>IsStimulusAllowed..." . (UserRights::IsStimulusAllowed('bizOrganization', 'myStimulus', $oSet) == UR_ALLOWED_YES ? 'ok' : 'NO') . "</p>\n";
     echo "<p>IsActionAllowedOnAttribute..." . (UserRights::IsActionAllowedOnAttribute('bizOrganization', 'myattribute', UR_ACTION_MODIFY, $oSet) == UR_ALLOWED_YES ? 'ok' : 'NO') . "</p>\n";
     return true;
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:16,代码来源:testlist.inc.php


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