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


PHP UserRights::IsActionAllowed方法代码示例

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


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

示例1: GetHeader

 public function GetHeader()
 {
     $sData = '';
     $oSet = new DBObjectSet($this->oSearch);
     $this->aStatusInfo['status'] = 'running';
     $this->aStatusInfo['position'] = 0;
     $this->aStatusInfo['total'] = $oSet->Count();
     $aSelectedClasses = $this->oSearch->GetSelectedClasses();
     foreach ($aSelectedClasses as $sAlias => $sClassName) {
         if (UserRights::IsActionAllowed($sClassName, UR_ACTION_BULK_READ, $oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) {
             $aAuthorizedClasses[$sAlias] = $sClassName;
         }
     }
     $aAliases = array_keys($aAuthorizedClasses);
     $aData = array();
     foreach ($this->aStatusInfo['fields'] as $sExtendedAttCode) {
         if (preg_match('/^([^\\.]+)\\.(.+)$/', $sExtendedAttCode, $aMatches)) {
             $sAlias = $aMatches[1];
             $sAttCode = $aMatches[2];
         } else {
             $sAlias = reset($aAliases);
             $sAttCode = $sExtendedAttCode;
         }
         if (!in_array($sAlias, $aAliases)) {
             throw new Exception("Invalid alias '{$sAlias}' for the column '{$sExtendedAttCode}'. Availables aliases: '" . implode("', '", $aAliases) . "'");
         }
         $sClass = $aSelectedClasses[$sAlias];
         switch ($sAttCode) {
             case 'id':
                 if (count($aSelectedClasses) > 1) {
                     $aData[] = $sAlias . '.id';
                     //@@@
                 } else {
                     $aData[] = 'id';
                     //@@@
                 }
                 break;
             default:
                 $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
                 if (count($aSelectedClasses) > 1) {
                     $aData[] = $sAlias . '.' . $oAttDef->GetLabel();
                 } else {
                     $aData[] = $oAttDef->GetLabel();
                 }
         }
     }
     $sData .= "<table class=\"listResults\">\n";
     $sData .= "<thead>\n";
     $sData .= "<tr>\n";
     foreach ($aData as $sLabel) {
         $sData .= "<th>" . $sLabel . "</th>\n";
     }
     $sData .= "</tr>\n";
     $sData .= "</thead>\n";
     $sData .= "<tbody>\n";
     return $sData;
 }
开发者ID:henryavila,项目名称:itop,代码行数:57,代码来源:htmlbulkexport.class.inc.php

示例2: GetClassesSelect

 /**
  * Helper function to build a select from the list of valid classes for a given action
  * @param string $sName The name of the select in the HTML form
  * @param string $sDefaulfValue The defaut value (i.e the value selected by default)
  * @param integer $iWidthPx The width (in pixels) of the drop-down list
  * @param integer $iActionCode The ActionCode (from UserRights) to check for authorization for the classes
  * @return string The HTML fragment corresponding to the select tag
  */
 function GetClassesSelect($sName, $sDefaultValue, $iWidthPx, $iActionCode = null)
 {
     $sHtml = "<select id=\"select_{$sName}\" name=\"{$sName}\">";
     $sHtml .= "<option tyle=\"width: " . $iWidthPx . "px;\" title=\"Select the class you want to load\" value=\"\">" . Dict::S('UI:CSVImport:ClassesSelectOne') . "</option>\n";
     $aValidClasses = array();
     $aClassCategories = array('bizmodel');
     if (UserRights::IsAdministrator()) {
         $aClassCategories = array('bizmodel', 'application', 'addon/authentication');
     }
     foreach ($aClassCategories as $sClassCategory) {
         foreach (MetaModel::GetClasses($sClassCategory) as $sClassName) {
             if ((is_null($iActionCode) || UserRights::IsActionAllowed($sClassName, $iActionCode)) && !MetaModel::IsAbstract($sClassName)) {
                 $sSelected = $sClassName == $sDefaultValue ? " selected" : "";
                 $sDescription = MetaModel::GetClassDescription($sClassName);
                 $sDisplayName = MetaModel::GetName($sClassName);
                 $aValidClasses[$sDisplayName] = "<option style=\"width: " . $iWidthPx . "px;\" title=\"{$sDescription}\" value=\"{$sClassName}\"{$sSelected}>{$sDisplayName}</option>";
             }
         }
     }
     ksort($aValidClasses);
     $sHtml .= implode("\n", $aValidClasses);
     $sHtml .= "</select>";
     return $sHtml;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:32,代码来源:csvimport.php

示例3: ReadParameters

 public function ReadParameters()
 {
     parent::ReadParameters();
     $sQueryId = utils::ReadParam('query', null, true);
     $sFields = utils::ReadParam('fields', null, true, 'raw_data');
     if (($sFields === null || $sFields === '') && $sQueryId === null) {
         throw new BulkExportMissingParameterException('fields');
     } else {
         if ($sQueryId !== null && $sQueryId !== null) {
             $oSearch = DBObjectSearch::FromOQL('SELECT QueryOQL WHERE id = :query_id', array('query_id' => $sQueryId));
             $oQueries = new DBObjectSet($oSearch);
             if ($oQueries->Count() > 0) {
                 $oQuery = $oQueries->Fetch();
                 if ($sFields === null || $sFields === '') {
                     // No 'fields' parameter supplied, take the fields from the query phrasebook definition
                     $sFields = trim($oQuery->Get('fields'));
                     if ($sFields === '') {
                         throw new BulkExportMissingParameterException('fields');
                     }
                 }
             } else {
                 throw BulkExportException('Invalid value for the parameter: query. There is no Query Phrasebook with id = ' . $sQueryId, Dict::Format('Core:BulkExport:InvalidParameter_Query', $sQueryId));
             }
         }
     }
     // Interpret (and check) the list of fields
     //
     $aSelectedClasses = $this->oSearch->GetSelectedClasses();
     $aAliases = array_keys($aSelectedClasses);
     $aAuthorizedClasses = array();
     foreach ($aSelectedClasses as $sAlias => $sClassName) {
         if (UserRights::IsActionAllowed($sClassName, UR_ACTION_BULK_READ) == UR_ALLOWED_YES) {
             $aAuthorizedClasses[$sAlias] = $sClassName;
         }
     }
     $aFields = explode(',', $sFields);
     $this->aStatusInfo['fields'] = array();
     foreach ($aFields as $sFieldSpec) {
         // Trim the values since it's natural to write: fields=name, first_name, org_name instead of fields=name,first_name,org_name
         $sExtendedAttCode = trim($sFieldSpec);
         if (preg_match('/^([^\\.]+)\\.(.+)$/', $sExtendedAttCode, $aMatches)) {
             $sAlias = $aMatches[1];
             $sAttCode = $aMatches[2];
         } else {
             $sAlias = reset($aAliases);
             $sAttCode = $sExtendedAttCode;
         }
         if (!array_key_exists($sAlias, $aSelectedClasses)) {
             throw new Exception("Invalid alias '{$sAlias}' for the column '{$sExtendedAttCode}'. Availables aliases: '" . implode("', '", $aAliases) . "'");
         }
         $sClass = $aSelectedClasses[$sAlias];
         if (!array_key_exists($sAlias, $aAuthorizedClasses)) {
             throw new Exception("You do not have enough permissions to bulk read data of class '{$sClass}' (alias: {$sAlias})");
         }
         if ($this->bLocalizeOutput) {
             try {
                 $sLabel = MetaModel::GetLabel($sClass, $sAttCode);
             } catch (Exception $e) {
                 throw new Exception("Wrong field specification '{$sFieldSpec}': " . $e->getMessage());
             }
         } else {
             $sLabel = $sAttCode;
         }
         if (count($aAuthorizedClasses) > 1) {
             $sColLabel = $sAlias . '.' . $sLabel;
         } else {
             $sColLabel = $sLabel;
         }
         $this->aStatusInfo['fields'][] = array('sFieldSpec' => $sExtendedAttCode, 'sAlias' => $sAlias, 'sClass' => $sClass, 'sAttCode' => $sAttCode, 'sLabel' => $sLabel, 'sColLabel' => $sColLabel);
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:71,代码来源:tabularbulkexport.class.inc.php

示例4: DisplayDetails

/**
 * Displays the details of an object
 * @param $oP WebPage Page for the output
 * @param $sClass string The name of the class of the object
 * @param $oObj DBObject The object to display
 * @param $id mixed Identifier of the object (name or ID)
 */
function DisplayDetails($oP, $sClass, $oObj, $id)
{
    $sClassLabel = MetaModel::GetName($sClass);
    $oSearch = new DBObjectSearch($sClass);
    $oBlock = new DisplayBlock($oSearch, 'search', false);
    $oBlock->Display($oP, 0);
    // The object could be listed, check if it is actually allowed to view it
    $oSet = CMDBObjectSet::FromObject($oObj);
    if (UserRights::IsActionAllowed($sClass, UR_ACTION_READ, $oSet) == UR_ALLOWED_NO) {
        throw new SecurityException('User not allowed to view this object', array('class' => $sClass, 'id' => $id));
    }
    $oP->set_title(Dict::Format('UI:DetailsPageTitle', $oObj->GetRawName(), $sClassLabel));
    // Set title will take care of the encoding
    $oObj->DisplayDetails($oP);
}
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:22,代码来源:UI.php

示例5: GetNextChunk

 public function GetNextChunk(&$aStatus)
 {
     $sRetCode = 'run';
     $iPercentage = 0;
     $iCount = 0;
     $sData = '';
     $oSet = new DBObjectSet($this->oSearch);
     $oSet->SetLimit($this->iChunkSize, $this->aStatusInfo['position']);
     $bLocalize = $this->aStatusInfo['localize'];
     $aClasses = $this->oSearch->GetSelectedClasses();
     $aAuthorizedClasses = array();
     foreach ($aClasses as $sAlias => $sClassName) {
         if (UserRights::IsActionAllowed($sClassName, UR_ACTION_BULK_READ, $oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) {
             $aAuthorizedClasses[$sAlias] = $sClassName;
         }
     }
     $aAttribs = array();
     $aList = array();
     $aList[$sAlias] = MetaModel::GetZListItems($sClassName, 'details');
     $iPreviousTimeLimit = ini_get('max_execution_time');
     $iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
     while ($aObjects = $oSet->FetchAssoc()) {
         set_time_limit($iLoopTimeLimit);
         if (count($aAuthorizedClasses) > 1) {
             $sData .= "<Row>\n";
         }
         foreach ($aAuthorizedClasses as $sAlias => $sClassName) {
             $oObj = $aObjects[$sAlias];
             if (is_null($oObj)) {
                 $sData .= "<{$sClassName} alias=\"{$sAlias}\" id=\"null\">\n";
             } else {
                 $sClassName = get_class($oObj);
                 $sData .= "<{$sClassName} alias=\"{$sAlias}\" id=\"" . $oObj->GetKey() . "\">\n";
             }
             foreach (MetaModel::ListAttributeDefs($sClassName) as $sAttCode => $oAttDef) {
                 if (is_null($oObj)) {
                     $sData .= "<{$sAttCode}>null</{$sAttCode}>\n";
                 } else {
                     if ($oAttDef->IsWritable()) {
                         $sValue = $oObj->GetAsXML($sAttCode, $bLocalize);
                         $sData .= "<{$sAttCode}>{$sValue}</{$sAttCode}>\n";
                     }
                 }
             }
             $sData .= "</{$sClassName}>\n";
         }
         if (count($aAuthorizedClasses) > 1) {
             $sData .= "</Row>\n";
         }
         $iCount++;
     }
     set_time_limit($iPreviousTimeLimit);
     $this->aStatusInfo['position'] += $this->iChunkSize;
     if ($this->aStatusInfo['total'] == 0) {
         $iPercentage = 100;
     } else {
         $iPercentage = floor(min(100.0, 100.0 * $this->aStatusInfo['position'] / $this->aStatusInfo['total']));
     }
     if ($iCount < $this->iChunkSize) {
         $sRetCode = 'done';
     }
     $aStatus = array('code' => $sRetCode, 'message' => Dict::S('Core:BulkExport:RetrievingData'), 'percentage' => $iPercentage);
     return $sData;
 }
开发者ID:henryavila,项目名称:itop,代码行数:64,代码来源:xmlbulkexport.class.inc.php

示例6: DoCheckToDelete

 protected function DoCheckToDelete(&$oDeletionPlan)
 {
     parent::DoCheckToDelete($oDeletionPlan);
     // Plugins
     //
     foreach (MetaModel::EnumPlugins('iApplicationObjectExtension') as $oExtensionInstance) {
         $aNewIssues = $oExtensionInstance->OnCheckToDelete($this);
         if (count($aNewIssues) > 0) {
             $this->m_aDeleteIssues = array_merge($this->m_aDeleteIssues, $aNewIssues);
         }
     }
     // User rights
     //
     $bDeleteAllowed = UserRights::IsActionAllowed(get_class($this), UR_ACTION_DELETE, DBObjectSet::FromObject($this));
     if (!$bDeleteAllowed) {
         // Security issue
         $this->m_bSecurityIssue = true;
         $this->m_aDeleteIssues[] = Dict::S('UI:Delete:NotAllowedToDelete');
     }
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:20,代码来源:cmdbabstract.class.inc.php

示例7: IsEnabled

 /**
  * Overload the check of the "enable" state of this menu to take into account
  * derived classes of objects
  */
 public function IsEnabled()
 {
     // Enable this menu, only if the current user has enough rights to create such an object, or an object of
     // any child class
     $aSubClasses = MetaModel::EnumChildClasses($this->sClass, ENUM_CHILD_CLASSES_ALL);
     // Including the specified class itself
     $bActionIsAllowed = false;
     foreach ($aSubClasses as $sCandidateClass) {
         if (!MetaModel::IsAbstract($sCandidateClass) && UserRights::IsActionAllowed($sCandidateClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES) {
             $bActionIsAllowed = true;
             break;
             // Enough for now
         }
     }
     return $bActionIsAllowed;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:20,代码来源:menunode.class.inc.php

示例8: Display

    /**
     * Get the HTML fragment corresponding to the ext key editing widget
     * @param WebPage $oP The web page used for all the output
     * @param Hash $aArgs Extra context arguments
     * @return string The HTML fragment to be inserted into the page
     */
    public function Display(WebPage $oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName, $sFormPrefix = '', $aArgs = array(), $bSearchMode = null, $sDisplayStyle = 'select', $bSearchMultiple = true)
    {
        if (!is_null($bSearchMode)) {
            $this->bSearchMode = $bSearchMode;
        }
        $sTitle = addslashes($sTitle);
        $oPage->add_linked_script('../js/extkeywidget.js');
        $oPage->add_linked_script('../js/forms-json-utils.js');
        $bCreate = !$this->bSearchMode && !MetaModel::IsAbstract($this->sTargetClass) && (UserRights::IsActionAllowed($this->sTargetClass, UR_ACTION_BULK_MODIFY) && $bAllowTargetCreation);
        $bExtensions = true;
        $sMessage = Dict::S('UI:Message:EmptyList:UseSearchForm');
        $sAttrFieldPrefix = $this->bSearchMode ? '' : 'attr_';
        $sHTMLValue = "<span style=\"white-space:nowrap\">";
        // no wrap
        $sFilter = addslashes($oAllowedValues->GetFilter()->ToOQL());
        if ($this->bSearchMode) {
            $sWizHelper = 'null';
            $sWizHelperJSON = "''";
            $sJSSearchMode = 'true';
        } else {
            if (isset($aArgs['wizHelper'])) {
                $sWizHelper = $aArgs['wizHelper'];
            } else {
                $sWizHelper = 'oWizardHelper' . $sFormPrefix;
            }
            $sWizHelperJSON = $sWizHelper . '.UpdateWizardToJSON()';
            $sJSSearchMode = 'false';
        }
        if (is_null($oAllowedValues)) {
            throw new Exception('Implementation: null value for allowed values definition');
        } elseif ($oAllowedValues->Count() < $iMaxComboLength) {
            // Discrete list of values, use a SELECT or RADIO buttons depending on the config
            switch ($sDisplayStyle) {
                case 'radio':
                case 'radio_horizontal':
                case 'radio_vertical':
                    $sValidationField = "<span id=\"v_{$this->iId}\"></span>";
                    $sHTMLValue = '';
                    $bVertical = $sDisplayStyle != 'radio_horizontal';
                    $bExtensions = false;
                    $oAllowedValues->Rewind();
                    $aAllowedValues = array();
                    while ($oObj = $oAllowedValues->Fetch()) {
                        $aAllowedValues[$oObj->GetKey()] = $oObj->GetName();
                    }
                    $sHTMLValue = $oPage->GetRadioButtons($aAllowedValues, $value, $this->iId, "{$sAttrFieldPrefix}{$sFieldName}", $bMandatory, $bVertical, $sValidationField);
                    $aEventsList[] = 'change';
                    break;
                case 'select':
                case 'list':
                default:
                    $sSelectMode = 'true';
                    $sHelpText = '';
                    //$this->oAttDef->GetHelpOnEdition();
                    if ($this->bSearchMode) {
                        if ($bSearchMultiple) {
                            $sHTMLValue = "<select class=\"multiselect\" multiple title=\"{$sHelpText}\" name=\"{$sAttrFieldPrefix}{$sFieldName}[]\" id=\"{$this->iId}\">\n";
                        } else {
                            $sHTMLValue = "<select title=\"{$sHelpText}\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"{$this->iId}\">\n";
                            $sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : Dict::S('UI:SearchValue:Any');
                            $sHTMLValue .= "<option value=\"\">{$sDisplayValue}</option>\n";
                        }
                    } else {
                        $sHTMLValue = "<select title=\"{$sHelpText}\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"{$this->iId}\">\n";
                        $sHTMLValue .= "<option value=\"\">" . Dict::S('UI:SelectOne') . "</option>\n";
                    }
                    $oAllowedValues->Rewind();
                    while ($oObj = $oAllowedValues->Fetch()) {
                        $key = $oObj->GetKey();
                        $display_value = $oObj->GetName();
                        if ($oAllowedValues->Count() == 1 && $bMandatory == 'true') {
                            // When there is only once choice, select it by default
                            $sSelected = ' selected';
                        } else {
                            $sSelected = is_array($value) && in_array($key, $value) || $value == $key ? ' selected' : '';
                        }
                        $sHTMLValue .= "<option value=\"{$key}\"{$sSelected}>{$display_value}</option>\n";
                    }
                    $sHTMLValue .= "</select>\n";
                    if ($this->bSearchMode && $bSearchMultiple) {
                        $aOptions = array('header' => true, 'checkAllText' => Dict::S('UI:SearchValue:CheckAll'), 'uncheckAllText' => Dict::S('UI:SearchValue:UncheckAll'), 'noneSelectedText' => Dict::S('UI:SearchValue:Any'), 'selectedText' => Dict::S('UI:SearchValue:NbSelected'), 'selectedList' => 1);
                        $sJSOptions = json_encode($aOptions);
                        $oPage->add_ready_script("\$('.multiselect').multiselect({$sJSOptions});");
                    }
                    $oPage->add_ready_script(<<<EOF
\t\toACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sTargetClass}', '{$sFilter}', '{$sTitle}', true, {$sWizHelper}, '{$this->sAttCode}', {$sJSSearchMode});
\t\toACWidget_{$this->iId}.emptyHtml = "<div style=\\"background: #fff; border:0; text-align:center; vertical-align:middle;\\"><p>{$sMessage}</p></div>";
\t\t\$('#{$this->iId}').bind('update', function() { oACWidget_{$this->iId}.Update(); } );
\t\t\$('#{$this->iId}').bind('change', function() { \$(this).trigger('extkeychange') } );

EOF
);
            }
            // Switch
//.........这里部分代码省略.........
开发者ID:henryavila,项目名称:itop,代码行数:101,代码来源:ui.extkeywidget.class.inc.php

示例9: GetPopupMenuItems

 /**
  * Merge standard menu items with plugin provided menus items
  */
 public static function GetPopupMenuItems($oPage, $iMenuId, $param, &$aActions, $sTableId = null, $sDataTableId = null)
 {
     // 1st - add standard built-in menu items
     //
     switch ($iMenuId) {
         case iPopupMenuExtension::MENU_OBJLIST_TOOLKIT:
             // $param is a DBObjectSet
             $oAppContext = new ApplicationContext();
             $sContext = $oAppContext->GetForLink();
             $sDataTableId = is_null($sDataTableId) ? '' : $sDataTableId;
             $sUIPage = cmdbAbstractObject::ComputeStandardUIPage($param->GetFilter()->GetClass());
             $sOQL = addslashes($param->GetFilter()->ToOQL(true));
             $sFilter = urlencode($param->GetFilter()->serialize());
             $sUrl = utils::GetAbsoluteUrlAppRoot() . "pages/{$sUIPage}?operation=search&filter=" . $sFilter . "&{$sContext}";
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/tabularfieldsselector.js');
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.dragtable.js');
             $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/dragtable.css');
             $aResult = array(new SeparatorPopupMenuItem(), new URLPopupMenuItem('UI:Menu:EMail', Dict::S('UI:Menu:EMail'), "mailto:?body=" . urlencode($sUrl) . ' '));
             if (UserRights::IsActionAllowed($param->GetFilter()->GetClass(), UR_ACTION_BULK_READ, $param) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) {
                 // Bulk export actions
                 $aResult[] = new JSPopupMenuItem('UI:Menu:CSVExport', Dict::S('UI:Menu:CSVExport'), "ExportListDlg('{$sOQL}', '{$sDataTableId}', 'csv', " . json_encode(Dict::S('UI:Menu:CSVExport')) . ")");
                 $aResult[] = new JSPopupMenuItem('UI:Menu:ExportXLSX', Dict::S('ExcelExporter:ExportMenu'), "ExportListDlg('{$sOQL}', '{$sDataTableId}', 'xlsx', " . json_encode(Dict::S('ExcelExporter:ExportMenu')) . ")");
                 $aResult[] = new JSPopupMenuItem('UI:Menu:ExportPDF', Dict::S('UI:Menu:ExportPDF'), "ExportListDlg('{$sOQL}', '{$sDataTableId}', 'pdf', " . json_encode(Dict::S('UI:Menu:ExportPDF')) . ")");
             }
             $aResult[] = new JSPopupMenuItem('UI:Menu:AddToDashboard', Dict::S('UI:Menu:AddToDashboard'), "DashletCreationDlg('{$sOQL}')");
             $aResult[] = new JSPopupMenuItem('UI:Menu:ShortcutList', Dict::S('UI:Menu:ShortcutList'), "ShortcutListDlg('{$sOQL}', '{$sDataTableId}', '{$sContext}')");
             break;
         case iPopupMenuExtension::MENU_OBJDETAILS_ACTIONS:
             // $param is a DBObject
             $oObj = $param;
             $sOQL = "SELECT " . get_class($oObj) . " WHERE id=" . $oObj->GetKey();
             $oFilter = DBObjectSearch::FromOQL($sOQL);
             $sFilter = $oFilter->serialize();
             $sUrl = ApplicationContext::MakeObjectUrl(get_class($oObj), $oObj->GetKey());
             $sUIPage = cmdbAbstractObject::ComputeStandardUIPage(get_class($oObj));
             $oAppContext = new ApplicationContext();
             $sContext = $oAppContext->GetForLink();
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/tabularfieldsselector.js');
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.dragtable.js');
             $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/dragtable.css');
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/tabularfieldsselector.js');
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.dragtable.js');
             $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/dragtable.css');
             $aResult = array(new SeparatorPopupMenuItem(), new URLPopupMenuItem('UI:Menu:EMail', Dict::S('UI:Menu:EMail'), "mailto:?subject=" . urlencode($oObj->GetRawName()) . "&body=" . urlencode($sUrl) . ' '), new JSPopupMenuItem('UI:Menu:CSVExport', Dict::S('UI:Menu:CSVExport'), "ExportListDlg('{$sOQL}', '', 'csv', " . json_encode(Dict::S('UI:Menu:CSVExport')) . ")"), new JSPopupMenuItem('UI:Menu:ExportXLSX', Dict::S('ExcelExporter:ExportMenu'), "ExportListDlg('{$sOQL}', '', 'xlsx', " . json_encode(Dict::S('ExcelExporter:ExportMenu')) . ")"));
             break;
         case iPopupMenuExtension::MENU_DASHBOARD_ACTIONS:
             // $param is a Dashboard
             $oAppContext = new ApplicationContext();
             $aParams = $oAppContext->GetAsHash();
             $sMenuId = ApplicationMenu::GetActiveNodeId();
             $sDlgTitle = addslashes(Dict::S('UI:ImportDashboardTitle'));
             $sDlgText = addslashes(Dict::S('UI:ImportDashboardText'));
             $sCloseBtn = addslashes(Dict::S('UI:Button:Cancel'));
             $aResult = array(new SeparatorPopupMenuItem(), new URLPopupMenuItem('UI:ExportDashboard', Dict::S('UI:ExportDashBoard'), utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=export_dashboard&id=' . $sMenuId), new JSPopupMenuItem('UI:ImportDashboard', Dict::S('UI:ImportDashBoard'), "UploadDashboard({dashboard_id: '{$sMenuId}', title: '{$sDlgTitle}', text: '{$sDlgText}', close_btn: '{$sCloseBtn}' })"));
             break;
         default:
             // Unknown type of menu, do nothing
             $aResult = array();
     }
     foreach ($aResult as $oMenuItem) {
         $aActions[$oMenuItem->GetUID()] = $oMenuItem->GetMenuItem();
     }
     // Invoke the plugins
     //
     foreach (MetaModel::EnumPlugins('iPopupMenuExtension') as $oExtensionInstance) {
         if (is_object($param) && !$param instanceof DBObject) {
             $tmpParam = clone $param;
             // In case the parameter is an DBObjectSet, clone it to prevent alterations
         } else {
             $tmpParam = $param;
         }
         foreach ($oExtensionInstance->EnumItems($iMenuId, $tmpParam) as $oMenuItem) {
             if (is_object($oMenuItem)) {
                 $aActions[$oMenuItem->GetUID()] = $oMenuItem->GetMenuItem();
                 foreach ($oMenuItem->GetLinkedScripts() as $sLinkedScript) {
                     $oPage->add_linked_script($sLinkedScript);
                 }
             }
         }
     }
 }
开发者ID:henryavila,项目名称:itop,代码行数:84,代码来源:utils.inc.php

示例10: strlen

     $oP->add_comment("Separator: " . $sSep);
     $oP->add_comment("Qualifier: " . $sQualifier);
     $oP->add_comment("Charset Encoding:" . $sCharSet);
     if (strlen($sDateFormat) > 0) {
         $oP->add_comment("Date format: '{$sDateFormat}'");
     } else {
         $oP->add_comment("Date format: <none>");
     }
     $oP->add_comment("Localize: " . ($bLocalize ? 'yes' : 'no'));
     $oP->add_comment("Data Size: " . strlen($sCSVData));
 }
 //////////////////////////////////////////////////
 //
 // Security
 //
 if (!UserRights::IsActionAllowed($sClass, UR_ACTION_BULK_MODIFY)) {
     throw new SecurityException(Dict::Format('UI:Error:BulkModifyNotAllowedOn_Class', $sClass));
 }
 //////////////////////////////////////////////////
 //
 // Create an index of the known column names (in lower case)
 // If data is localized, an array of <TranslatedName> => array of <ExtendedAttCode> (several leads to ambiguity)
 // Otherwise             an array of <ExtendedAttCode> => array of <ExtendedAttCode> (1 element by construction)
 //
 // Examples (localized in french):
 //   'lieu' => 'location_id'
 //   'lieu->name' => 'location_id->name'
 //
 // Note: it may happen that an external field has the same label as the external key
 //       in that case, we consider that the external key has precedence
 //
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:31,代码来源:import.php

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

示例12: GetHeader

 public function GetHeader()
 {
     $oSet = new DBObjectSet($this->oSearch);
     $this->aStatusInfo['status'] = 'retrieving';
     $this->aStatusInfo['tmp_file'] = $this->MakeTmpFile('data');
     $this->aStatusInfo['position'] = 0;
     $this->aStatusInfo['total'] = $oSet->Count();
     $aSelectedClasses = $this->oSearch->GetSelectedClasses();
     foreach ($aSelectedClasses as $sAlias => $sClassName) {
         if (UserRights::IsActionAllowed($sClassName, UR_ACTION_BULK_READ, $oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) {
             $aAuthorizedClasses[$sAlias] = $sClassName;
         }
     }
     $aAliases = array_keys($aAuthorizedClasses);
     $aTableHeaders = array();
     foreach ($this->aStatusInfo['fields'] as $sExtendedAttCode) {
         if (preg_match('/^([^\\.]+)\\.(.+)$/', $sExtendedAttCode, $aMatches)) {
             $sAlias = $aMatches[1];
             $sAttCode = $aMatches[2];
         } else {
             $sAlias = reset($aAliases);
             $sAttCode = $sExtendedAttCode;
         }
         if (!in_array($sAlias, $aAliases)) {
             throw new Exception("Invalid alias '{$sAlias}' for the column '{$sExtendedAttCode}'. Availables aliases: '" . implode("', '", $aAliases) . "'");
         }
         $sClass = $aSelectedClasses[$sAlias];
         $sFullAlias = '';
         if (count($aSelectedClasses) > 1) {
             $sFullAlias = $sAlias . '.';
         }
         switch ($sAttCode) {
             case 'id':
                 $aTableHeaders[] = array('label' => $sFullAlias . 'id', 'type' => '0');
                 break;
             default:
                 $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
                 $sType = 'string';
                 if ($oAttDef instanceof AttributeDateTime) {
                     $sType = 'datetime';
                 }
                 $sLabel = $sAttCode;
                 if ($this->aStatusInfo['localize']) {
                     $sLabel = $oAttDef->GetLabel();
                 }
                 $aTableHeaders[] = array('label' => $sFullAlias . $sLabel, 'type' => $sType);
         }
     }
     $sRow = json_encode($aTableHeaders);
     $hFile = @fopen($this->aStatusInfo['tmp_file'], 'ab');
     if ($hFile === false) {
         throw new Exception('ExcelBulkExport: Failed to open temporary data file: "' . $this->aStatusInfo['tmp_file'] . '" for writing.');
     }
     fwrite($hFile, $sRow . "\n");
     fclose($hFile);
     return '';
 }
开发者ID:henryavila,项目名称:itop,代码行数:57,代码来源:excelbulkexport.class.inc.php

示例13: GetFieldsList

 protected function GetFieldsList($oSet, $bFieldsAdvanced = false, $bLocalize = true, $aFields = null)
 {
     $this->aFieldsList = array();
     $oAppContext = new ApplicationContext();
     $aClasses = $oSet->GetFilter()->GetSelectedClasses();
     $this->aAuthorizedClasses = array();
     foreach ($aClasses as $sAlias => $sClassName) {
         if (UserRights::IsActionAllowed($sClassName, UR_ACTION_READ, $oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) {
             $this->aAuthorizedClasses[$sAlias] = $sClassName;
         }
     }
     $aAttribs = array();
     $this->aTableHeaders = array();
     foreach ($this->aAuthorizedClasses as $sAlias => $sClassName) {
         $aList[$sAlias] = array();
         foreach (MetaModel::ListAttributeDefs($sClassName) as $sAttCode => $oAttDef) {
             if (is_null($aFields) || count($aFields) == 0) {
                 // Standard list of attributes (no link sets)
                 if ($oAttDef->IsScalar() && ($oAttDef->IsWritable() || $oAttDef->IsExternalField())) {
                     $sAttCodeEx = $oAttDef->IsExternalField() ? $oAttDef->GetKeyAttCode() . '->' . $oAttDef->GetExtAttCode() : $sAttCode;
                     if ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) {
                         if ($bFieldsAdvanced) {
                             $aList[$sAlias][$sAttCodeEx] = $oAttDef;
                             if ($oAttDef->IsExternalKey(EXTKEY_RELATIVE)) {
                                 $sRemoteClass = $oAttDef->GetTargetClass();
                                 foreach (MetaModel::GetReconcKeys($sRemoteClass) as $sRemoteAttCode) {
                                     $this->aFieldsList[$sAlias][$sAttCode . '->' . $sRemoteAttCode] = MetaModel::GetAttributeDef($sRemoteClass, $sRemoteAttCode);
                                 }
                             }
                         }
                     } else {
                         // Any other attribute
                         $this->aFieldsList[$sAlias][$sAttCodeEx] = $oAttDef;
                     }
                 }
             } else {
                 // User defined list of attributes
                 if (in_array($sAttCode, $aFields) || in_array($sAlias . '.' . $sAttCode, $aFields)) {
                     $this->aFieldsList[$sAlias][$sAttCode] = $oAttDef;
                 }
             }
         }
         if ($bFieldsAdvanced) {
             $this->aTableHeaders['id'] = '0';
         }
         foreach ($this->aFieldsList[$sAlias] as $sAttCodeEx => $oAttDef) {
             $sLabel = $bLocalize ? MetaModel::GetLabel($sClassName, $sAttCodeEx, isset($aParams['showMandatoryFields'])) : $sAttCodeEx;
             if ($oAttDef instanceof AttributeDateTime) {
                 $this->aTableHeaders[$sLabel] = 'datetime';
             } else {
                 $this->aTableHeaders[$sLabel] = 'string';
             }
         }
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:55,代码来源:excelexporter.class.inc.php

示例14: array

             }
         }
     }
 }
 // Read query parameters
 //
 $aArgs = array();
 foreach ($oFilter->GetQueryParams() as $sParam => $foo) {
     $value = utils::ReadParam('arg_' . $sParam, null, true, 'raw_data');
     if (!is_null($value)) {
         $aArgs[$sParam] = $value;
     }
 }
 $oFilter->SetInternalParams($aArgs);
 foreach ($oFilter->GetSelectedClasses() as $sAlias => $sClass) {
     if ((UserRights::IsActionAllowed($sClass, UR_ACTION_BULK_READ) && UR_ALLOWED_YES) == 0) {
         throw new Exception("The current user does not have permission for exporting data of class {$sClass}");
     }
 }
 if ($oFilter) {
     $oSet = new CMDBObjectSet($oFilter, array(), $aArgs);
     $oSet->OptimizeColumnLoad($aAliasToFields);
     switch ($sFormat) {
         case 'html':
             $oP = new NiceWebPage("iTop - Export");
             $oP->add_style('body { overflow: auto; }');
             // Show scroll bars if needed
             // Integration within MS-Excel web queries + HTTPS + IIS:
             // MS-IIS set these header values with no-cache... while Excel fails to do the job if using HTTPS
             // Then the fix is to force the reset of header values Pragma and Cache-control
             header("Pragma:", true);
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:31,代码来源:export.php

示例15: GetInteractiveFieldsWidget

    protected function GetInteractiveFieldsWidget(WebPage $oP, $sWidgetId)
    {
        $oSet = new DBObjectSet($this->oSearch);
        $aSelectedClasses = $this->oSearch->GetSelectedClasses();
        $aAuthorizedClasses = array();
        foreach ($aSelectedClasses as $sAlias => $sClassName) {
            if (UserRights::IsActionAllowed($sClassName, UR_ACTION_BULK_READ, $oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) {
                $aAuthorizedClasses[$sAlias] = $sClassName;
            }
        }
        $aAllFieldsByAlias = array();
        foreach ($aAuthorizedClasses as $sAlias => $sClass) {
            $aAllFields = array();
            if (count($aAuthorizedClasses) > 1) {
                $sShortAlias = $sAlias . '.';
            } else {
                $sShortAlias = '';
            }
            if ($this->IsValidField($sClass, 'id')) {
                $aAllFields[] = array('code' => $sShortAlias . 'id', 'unique_label' => $sShortAlias . Dict::S('Core:BulkExport:Identifier'), 'label' => $sShortAlias . 'id', 'subattr' => array(array('code' => $sShortAlias . 'id', 'unique_label' => $sShortAlias . Dict::S('Core:BulkExport:Identifier'), 'label' => $sShortAlias . 'id'), array('code' => $sShortAlias . 'friendlyname', 'unique_label' => $sShortAlias . Dict::S('Core:BulkExport:Friendlyname'), 'label' => $sShortAlias . Dict::S('Core:BulkExport:Friendlyname'))));
            }
            foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
                if ($this->IsSubAttribute($sClass, $sAttCode, $oAttDef)) {
                    continue;
                }
                if ($this->IsValidField($sClass, $sAttCode, $oAttDef)) {
                    $sShortLabel = $oAttDef->GetLabel();
                    $sLabel = $sShortAlias . $oAttDef->GetLabel();
                    $aSubAttr = $this->GetSubAttributes($sClass, $sAttCode, $oAttDef);
                    $aValidSubAttr = array();
                    foreach ($aSubAttr as $aSubAttDef) {
                        if ($this->IsValidField($sClass, $aSubAttDef['code'], $aSubAttDef['attdef'])) {
                            $aValidSubAttr[] = array('code' => $sShortAlias . $aSubAttDef['code'], 'label' => $aSubAttDef['label'], 'unique_label' => $aSubAttDef['unique_label']);
                        }
                    }
                    $aAllFields[] = array('code' => $sShortAlias . $sAttCode, 'label' => $sShortLabel, 'unique_label' => $sLabel, 'subattr' => $aValidSubAttr);
                }
            }
            usort($aAllFields, array(get_class($this), 'SortOnLabel'));
            if (count($aAuthorizedClasses) > 1) {
                $sKey = MetaModel::GetName($sClass) . ' (' . $sAlias . ')';
            } else {
                $sKey = MetaModel::GetName($sClass);
            }
            $aAllFieldsByAlias[$sKey] = $aAllFields;
        }
        $oP->add('<div id="' . $sWidgetId . '"></div>');
        $JSAllFields = json_encode($aAllFieldsByAlias);
        $oSet = new DBObjectSet($this->oSearch);
        $iCount = $oSet->Count();
        $iPreviewLimit = 3;
        $oSet->SetLimit($iPreviewLimit);
        $aSampleData = array();
        while ($aRow = $oSet->FetchAssoc()) {
            $aSampleRow = array();
            foreach ($aAuthorizedClasses as $sAlias => $sClass) {
                if (count($aAuthorizedClasses) > 1) {
                    $sShortAlias = $sAlias . '.';
                } else {
                    $sShortAlias = '';
                }
                if ($this->IsValidField($sClass, 'id')) {
                    $aSampleRow[$sShortAlias . 'id'] = $this->GetSampleKey($aRow[$sAlias]);
                }
                foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
                    if ($this->IsValidField($sClass, $sAttCode, $oAttDef)) {
                        $aSampleRow[$sShortAlias . $sAttCode] = $this->GetSampleData($aRow[$sAlias], $sAttCode);
                    }
                }
            }
            $aSampleData[] = $aSampleRow;
        }
        $sJSSampleData = json_encode($aSampleData);
        $aLabels = array('preview_header' => Dict::S('Core:BulkExport:DragAndDropHelp'), 'empty_preview' => Dict::S('Core:BulkExport:EmptyPreview'), 'columns_order' => Dict::S('Core:BulkExport:ColumnsOrder'), 'columns_selection' => Dict::S('Core:BulkExport:AvailableColumnsFrom_Class'), 'check_all' => Dict::S('Core:BulkExport:CheckAll'), 'uncheck_all' => Dict::S('Core:BulkExport:UncheckAll'), 'no_field_selected' => Dict::S('Core:BulkExport:NoFieldSelected'));
        $sJSLabels = json_encode($aLabels);
        $oP->add_ready_script(<<<EOF
\$('#{$sWidgetId}').tabularfieldsselector({fields: {$JSAllFields}, value_holder: '#tabular_fields', advanced_holder: '#tabular_advanced', sample_data: {$sJSSampleData}, total_count: {$iCount}, preview_limit: {$iPreviewLimit}, labels: {$sJSLabels} });
EOF
);
    }
开发者ID:henryavila,项目名称:itop,代码行数:80,代码来源:tabularbulkexport.class.inc.php


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