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


PHP Entity::can方法代码示例

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


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

示例1: showHelpdeskOptions

 /**
  * @since version 0.84 (before in entitydata.class)
  *
  * @param $entity Entity object
  **/
 static function showHelpdeskOptions(Entity $entity)
 {
     global $CFG_GLPI;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, READ) || !Session::haveRightsOr(self::$rightname, array(self::READHELPDESK, self::UPDATEHELPDESK))) {
         return false;
     }
     $canedit = Session::haveRight(self::$rightname, self::UPDATEHELPDESK) && Session::haveAccessToEntity($ID);
     echo "<div class='spaced'>";
     if ($canedit) {
         echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . _n('Ticket template', 'Ticket templates', 1) . "</td>";
     echo "<td colspan='2'>";
     $toadd = array();
     if ($ID != 0) {
         $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     $options = array('value' => $entity->fields["tickettemplates_id"], 'entity' => $ID, 'toadd' => $toadd);
     TicketTemplate::dropdown($options);
     if ($entity->fields["tickettemplates_id"] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         $tt = new TicketTemplate();
         $tid = self::getUsedConfig('tickettemplates_id', $ID, '', 0);
         if (!$tid) {
             echo Dropdown::EMPTY_VALUE;
         } else {
             if ($tt->getFromDB($tid)) {
                 echo $tt->getLink();
             }
         }
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Calendar') . "</td>";
     echo "<td colspan='2'>";
     $options = array('value' => $entity->fields["calendars_id"], 'emptylabel' => __('24/7'));
     if ($ID != 0) {
         $options['toadd'] = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     Calendar::dropdown($options);
     if ($entity->fields["calendars_id"] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         $calendar = new Calendar();
         $cid = self::getUsedConfig('calendars_id', $ID, '', 0);
         if (!$cid) {
             _e('24/7');
         } else {
             if ($calendar->getFromDB($cid)) {
                 echo $calendar->getLink();
             }
         }
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Tickets default type') . "</td>";
     echo "<td colspan='2'>";
     $toadd = array();
     if ($ID != 0) {
         $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     Ticket::dropdownType('tickettype', array('value' => $entity->fields["tickettype"], 'toadd' => $toadd));
     if ($entity->fields['tickettype'] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         echo Ticket::getTicketTypeName(self::getUsedConfig('tickettype', $ID, '', Ticket::INCIDENT_TYPE));
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td  colspan='2'>" . __('Automatic assignment of tickets') . "</td>";
     echo "<td colspan='2'>";
     $autoassign = self::getAutoAssignMode();
     if ($ID == 0) {
         unset($autoassign[self::CONFIG_PARENT]);
     }
     Dropdown::showFromArray('auto_assign_mode', $autoassign, array('value' => $entity->fields["auto_assign_mode"]));
     if ($entity->fields['auto_assign_mode'] == self::CONFIG_PARENT && $ID != 0) {
         $auto_assign_mode = self::getUsedConfig('auto_assign_mode', $entity->fields['entities_id']);
         echo "<font class='green'>&nbsp;&nbsp;";
         echo $autoassign[$auto_assign_mode];
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr><th colspan='4'>" . __('Automatic closing configuration') . "</th></tr>";
     echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Automatic closing of solved tickets after') . "</td>";
     echo "<td colspan='2'>";
     $autoclose = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), self::CONFIG_NEVER => __('Never'), 0 => __('Immediatly'));
     if ($ID == 0) {
         unset($autoclose[self::CONFIG_PARENT]);
     }
     Dropdown::showNumber('autoclose_delay', array('value' => $entity->fields['autoclose_delay'], 'min' => 1, 'max' => 99, 'step' => 1, 'toadd' => $autoclose, 'unit' => 'day'));
     if ($entity->fields['autoclose_delay'] == self::CONFIG_PARENT && $ID != 0) {
         $autoclose_mode = self::getUsedConfig('autoclose_delay', $entity->fields['entities_id'], '', self::CONFIG_NEVER);
         echo "<br><font class='green'>&nbsp;&nbsp;";
         if ($autoclose_mode >= 0) {
//.........这里部分代码省略.........
开发者ID:korial29,项目名称:glpi,代码行数:101,代码来源:entity.class.php

示例2: showForEntity

 /**
  * Show users of an entity
  *
  * @param $entity Entity object
  **/
 static function showForEntity(Entity $entity)
 {
     global $DB;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, READ)) {
         return false;
     }
     $canedit = $entity->canEdit($ID);
     $canshowuser = User::canView();
     $nb_per_line = 3;
     $rand = mt_rand();
     if ($canedit) {
         $headerspan = $nb_per_line * 2;
     } else {
         $headerspan = $nb_per_line;
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='entityuser_form{$rand}' id='entityuser_form{$rand}' method='post' action='";
         echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='6'>" . __('Add an authorization to a user') . "</tr>";
         echo "<tr class='tab_bg_1'><td class='tab_bg_2 center'>" . __('User') . "&nbsp;";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         User::dropdown(array('right' => 'all'));
         echo "</td><td class='tab_bg_2 center'>" . self::getTypeName(1) . "</td><td>";
         Profile::dropdownUnder(array('value' => Profile::getDefault()));
         echo "</td><td class='tab_bg_2 center'>" . __('Recursive') . "</td><td>";
         Dropdown::showYesNo("is_recursive", 0);
         echo "</td><td class='tab_bg_2 center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     $query = "SELECT DISTINCT `glpi_profiles`.`id`, `glpi_profiles`.`name`\n                FROM `glpi_profiles_users`\n                LEFT JOIN `glpi_profiles`\n                     ON (`glpi_profiles_users`.`profiles_id` = `glpi_profiles`.`id`)\n                LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n                     AND `glpi_users`.`is_deleted` = '0'";
     $result = $DB->query($query);
     $nb = $DB->numrows($result);
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<thead><tr>";
     echo "<th class='noHover' colspan='{$headerspan}'>";
     printf(__('%1$s (%2$s)'), _n('User', 'Users', Session::getPluralNumber()), __('D=Dynamic, R=Recursive'));
     echo "</th></tr></thead>";
     if ($nb) {
         Session::initNavigateListItems('User', sprintf(__('%1$s = %2$s'), Entity::getTypeName(1), $entity->getName()));
         while ($data = $DB->fetch_assoc($result)) {
             echo "<tbody><tr class='noHover'>";
             $reduce_header = 0;
             if ($canedit && $nb) {
                 echo "<th width='10'>";
                 echo Html::checkAllAsCheckbox("profile" . $data['id'] . "_{$rand}");
                 echo "</th>";
                 $reduce_header++;
             }
             echo "<th colspan='" . ($headerspan - $reduce_header) . "'>";
             printf(__('%1$s: %2$s'), __('Profile'), $data["name"]);
             echo "</th></tr></tbody>";
             echo "<tbody id='profile" . $data['id'] . "_{$rand}'>";
             $query = "SELECT `glpi_users`.*,\n                             `glpi_profiles_users`.`id` AS linkID,\n                             `glpi_profiles_users`.`is_recursive`,\n                             `glpi_profiles_users`.`is_dynamic`\n                      FROM `glpi_profiles_users`\n                      LEFT JOIN `glpi_users`\n                           ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                      WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n                            AND `glpi_users`.`is_deleted` = '0'\n                            AND `glpi_profiles_users`.`profiles_id` = '" . $data['id'] . "'\n                      ORDER BY `glpi_profiles_users`.`profiles_id`,\n                               `glpi_users`.`name`,\n                               `glpi_users`.`realname`,\n                               `glpi_users`.`firstname`";
             $result2 = $DB->query($query);
             if ($DB->numrows($result2) > 0) {
                 $i = 0;
                 while ($data2 = $DB->fetch_assoc($result2)) {
                     Session::addToNavigateListItems('User', $data2["id"]);
                     if ($i % $nb_per_line == 0) {
                         if ($i != 0) {
                             echo "</tr>";
                         }
                         echo "<tr class='tab_bg_1'>";
                     }
                     if ($canedit) {
                         echo "<td width='10'>";
                         Html::showMassiveActionCheckBox(__CLASS__, $data2["linkID"]);
                         echo "</td>";
                     }
                     $username = formatUserName($data2["id"], $data2["name"], $data2["realname"], $data2["firstname"], $canshowuser);
                     if ($data2["is_dynamic"] || $data2["is_recursive"]) {
                         $username = sprintf(__('%1$s %2$s'), $username, "<span class='b'>(");
                         if ($data2["is_dynamic"]) {
                             $username = sprintf(__('%1$s%2$s'), $username, __('D'));
                         }
                         if ($data2["is_dynamic"] && $data2["is_recursive"]) {
                             $username = sprintf(__('%1$s%2$s'), $username, ", ");
                         }
                         if ($data2["is_recursive"]) {
                             $username = sprintf(__('%1$s%2$s'), $username, __('R'));
                         }
                         $username = sprintf(__('%1$s%2$s'), $username, ")</span>");
//.........这里部分代码省略.........
开发者ID:Ixertec,项目名称:glpi,代码行数:101,代码来源:profile_user.class.php

示例3: showNotificationOptions

 static function showNotificationOptions(Entity $entity)
 {
     $con_spotted = false;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, 'r')) {
         return false;
     }
     // Notification right applied
     $canedit = Session::haveRight('notification', 'w') && Session::haveAccessToEntity($ID);
     // Get data
     $entitynotification = new PluginAdditionalalertsOcsAlert();
     if (!$entitynotification->getFromDBbyEntity($ID)) {
         $entitynotification->getEmpty();
     }
     if ($canedit) {
         echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><td>" . __('New imported computers from OCS-NG', 'additionalalerts') . "</td><td>";
     $default_value = $entitynotification->fields['use_newocs_alert'];
     Alert::dropdownYesNo(array('name' => "use_newocs_alert", 'value' => $default_value, 'inherit_global' => 1));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td >" . __('OCS-NG Synchronization alerts', 'additionalalerts') . "</td><td>";
     Alert::dropdownIntegerNever('delay_ocs', $entitynotification->fields["delay_ocs"], array('max' => 99, 'inherit_global' => 1));
     echo "&nbsp;" . _n('Day', 'Days', 2) . "</td>";
     echo "</tr>";
     if ($canedit) {
         echo "<tr>";
         echo "<td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         if ($entitynotification->fields["id"]) {
             echo "<input type='hidden' name='id' value=\"" . $entitynotification->fields["id"] . "\">";
             echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         } else {
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         }
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
     } else {
         echo "</table>";
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:43,代码来源:ocsalert.class.php

示例4: showForEntity

 /**
  * Show users of an entity
  *
  * @param $entity Entity object
  **/
 static function showForEntity(Entity $entity)
 {
     global $DB, $CFG_GLPI, $LANG;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, "r")) {
         return false;
     }
     $canedit = $entity->can($ID, "w");
     $canshowuser = haveRight("user", "r");
     $nb_per_line = 3;
     $rand = mt_rand();
     if ($canedit) {
         echo "<form name='entityuser_form{$rand}' id='entityuser_form{$rand}' method='post' action='";
         echo getItemTypeFormURL(__CLASS__) . "'>";
         $headerspan = $nb_per_line * 2;
     } else {
         $headerspan = $nb_per_line;
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='5'>" . $LANG['setup'][605] . "</tr>";
         echo "<tr><td class='tab_bg_2 center'>" . $LANG['common'][34] . "&nbsp;:&nbsp;";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         User::dropdown(array('right' => 'all'));
         echo "</td><td class='tab_bg_2 center'>" . $LANG['profiles'][22] . "&nbsp;:&nbsp;";
         Profile::dropdownUnder(array('value' => Profile::getDefault()));
         echo "</td><td class='tab_bg_2 center'>" . $LANG['profiles'][28] . "&nbsp;:&nbsp;";
         Dropdown::showYesNo("is_recursive", 0);
         echo "</td><td class='tab_bg_2 center'>";
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table></div>";
     }
     echo "<div class='spaced'>";
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='{$headerspan}'>" . $LANG['Menu'][14] . " (D=" . $LANG['profiles'][29] . ", R=" . $LANG['profiles'][28] . ")</th></tr>";
     $query = "SELECT DISTINCT `glpi_profiles`.`id`, `glpi_profiles`.`name`\n                FROM `glpi_profiles_users`\n                LEFT JOIN `glpi_profiles`\n                     ON (`glpi_profiles_users`.`profiles_id` = `glpi_profiles`.`id`)\n                LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n                      AND `glpi_users`.`is_deleted` = '0'";
     $result = $DB->query($query);
     if ($DB->numrows($result) > 0) {
         initNavigateListItems('User', $LANG['entity'][0] . " = " . $entity->fields['name']);
         while ($data = $DB->fetch_array($result)) {
             echo "<tr><th colspan='{$headerspan}'>" . $LANG['profiles'][22] . "&nbsp;: " . $data["name"];
             echo "</th></tr>";
             $query = "SELECT `glpi_users`.*,\n                             `glpi_profiles_users`.`id` AS linkID,\n                             `glpi_profiles_users`.`is_recursive`,\n                             `glpi_profiles_users`.`is_dynamic`\n                      FROM `glpi_profiles_users`\n                      LEFT JOIN `glpi_users`\n                           ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                      WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n                            AND `glpi_users`.`is_deleted` = '0'\n                            AND `glpi_profiles_users`.`profiles_id` = '" . $data['id'] . "'\n                      ORDER BY `glpi_profiles_users`.`profiles_id`,\n                               `glpi_users`.`name`,\n                               `glpi_users`.`realname`,\n                               `glpi_users`.`firstname`";
             $result2 = $DB->query($query);
             if ($DB->numrows($result2) > 0) {
                 $i = 0;
                 while ($data2 = $DB->fetch_array($result2)) {
                     addToNavigateListItems('User', $data2["id"]);
                     if ($i % $nb_per_line == 0) {
                         if ($i != 0) {
                             echo "</tr>";
                         }
                         echo "<tr class='tab_bg_1'>";
                     }
                     if ($canedit) {
                         echo "<td width='10'>";
                         echo "<input type='checkbox' name='item[" . $data2["linkID"] . "]' value='1'>";
                         echo "</td>";
                     }
                     echo "<td>";
                     echo formatUserName($data2["id"], $data2["name"], $data2["realname"], $data2["firstname"], $canshowuser);
                     if ($data2["is_dynamic"] || $data2["is_recursive"]) {
                         echo "<strong>&nbsp;(";
                         if ($data2["is_dynamic"]) {
                             echo "D";
                         }
                         if ($data2["is_dynamic"] && $data2["is_recursive"]) {
                             echo ", ";
                         }
                         if ($data2["is_recursive"]) {
                             echo "R";
                         }
                         echo ")</strong>";
                     }
                     echo "</td>";
                     $i++;
                 }
                 while ($i % $nb_per_line != 0) {
                     echo "<td>&nbsp;</td>";
                     if ($canedit) {
                         echo "<td>&nbsp;</td>";
                     }
                     $i++;
                 }
                 echo "</tr>";
             } else {
                 echo "<tr colspan='{$headerspan}'>" . $LANG['common'][54] . "</tr>";
             }
         }
     }
     echo "</table>";
     if ($canedit) {
         openArrowMassive("entityuser_form{$rand}", true);
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:profile_user.class.php

示例5: showHelpdeskOptions

 static function showHelpdeskOptions(Entity $entity)
 {
     global $LANG, $CFG_GLPI;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, 'r') || !haveRight('entity_helpdesk', 'r')) {
         return false;
     }
     $canedit = haveRight('entity_helpdesk', 'w') && haveAccessToEntity($ID);
     // Get data
     $entdata = new EntityData();
     if (!$entdata->getFromDB($ID)) {
         $entdata->getEmpty();
     }
     echo "<div class='spaced'>";
     if ($canedit) {
         echo "<form method='post' name=form action='" . getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['buttons'][15] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     $options = array('value' => $entdata->fields["calendars_id"], 'emptylabel' => $LANG['common'][102]);
     if ($ID == 0) {
         $options['emptylabel'] = $LANG['sla'][10];
     }
     Dropdown::show('Calendar', $options);
     if ($entdata->fields["calendars_id"] == 0) {
         $calendar = new Calendar();
         if ($calendar->getFromDB(self::getUsedConfig('calendars_id', $ID))) {
             echo " - " . $calendar->getLink();
         }
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['entity'][28] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     $toadd = array();
     if ($ID != 0) {
         $toadd = array(0 => $LANG['common'][102]);
     }
     Ticket::dropdownType('tickettype', $entdata->fields["tickettype"], $toadd);
     if ($entdata->fields["calendars_id"] == 0) {
         $calendar = new Calendar();
         if ($calendar->getFromDB(self::getUsedConfig('calendars_id', $ID))) {
             echo " - " . $calendar->getLink();
         }
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td  colspan='2'>" . $LANG['setup'][52] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     $autoassign = array(-1 => $LANG['setup'][731], NO_AUTO_ASSIGN => $LANG['choice'][0], AUTO_ASSIGN_HARDWARE_CATEGORY => $LANG['setup'][51], AUTO_ASSIGN_CATEGORY_HARDWARE => $LANG['setup'][50]);
     Dropdown::showFromArray('auto_assign_mode', $autoassign, array('value' => $entdata->fields["auto_assign_mode"]));
     echo "</td></tr>";
     echo "<tr><th colspan='4'>" . $LANG['entity'][17] . "</th></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['entity'][18] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     Dropdown::showInteger('autoclose_delay', $entdata->fields['autoclose_delay'], 0, 99, 1, array(-1 => $LANG['setup'][731], -10 => $LANG['setup'][307]));
     /*
           Alert::dropdownIntegerNever('autoclose_delay', $entdata->fields['autoclose_delay'],
                                       array('max'            => 99,
                                             'inherit_global' => 1,
                                             'never_value'    => -10,));
     */
     echo "&nbsp;" . $LANG['stats'][31] . "</td></tr>";
     echo "<tr><th colspan='4'>" . $LANG['entity'][19] . "</th></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['entity'][19] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     /// no inquest case = rate 0
     $typeinquest = array(0 => $LANG['common'][102], 1 => $LANG['satisfaction'][9], 2 => $LANG['satisfaction'][10]);
     // No inherit from parent for root entity
     if ($entdata->fields['entities_id'] == 0) {
         unset($typeinquest[0]);
         if ($entdata->fields['inquest_config'] == 0) {
             $entdata->fields['inquest_config'] = 1;
         }
     }
     $rand = Dropdown::showFromArray('inquest_config', $typeinquest, $options = array('value' => $entdata->fields['inquest_config']));
     echo "</td></tr>\n";
     // Do not display for root entity in inherit case
     if ($entdata->fields['inquest_config'] == 0 && $entdata->fields['entities_id'] != 0) {
         $inquestconfig = self::getUsedConfig('inquest_config', $entdata->fields['entities_id']);
         $inquestrate = self::getUsedConfig('inquest_config', $entdata->fields['entities_id'], 'inquest_rate');
         echo "<tr><td colspan='4' class='green center'>" . $LANG['common'][102] . "&nbsp;:&nbsp;";
         if ($inquestrate == 0) {
             echo $LANG['crontask'][31];
         } else {
             echo $typeinquest[$inquestconfig];
             echo " - " . self::getUsedConfig('inquest_config', $entdata->fields['entities_id'], 'inquest_delay');
             echo "&nbsp;" . $LANG['stats'][31] . " - ";
             echo $inquestrate . "%";
             if ($inquestconfig == 2) {
                 echo " - " . self::getUsedConfig('inquest_config', $entdata->fields['entities_id'], 'inquest_URL');
             }
         }
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_1'><td colspan='4'>";
     $_REQUEST = array('inquest_config' => $entdata->fields['inquest_config'], 'entities_id' => $ID);
     $params = array('inquest_config' => '__VALUE__', 'entities_id' => $ID);
     echo "<div id='inquestconfig'>";
     include GLPI_ROOT . '/ajax/ticketsatisfaction.php';
     echo "</div>\n";
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:entitydata.class.php

示例6: testEntity

 /**
  * Entity right check
  */
 public function testEntity()
 {
     global $DB;
     $DB->connect();
     $ent0 = $this->sharedFixture['entity'][0];
     $ent1 = $this->sharedFixture['entity'][1];
     $ent2 = $this->sharedFixture['entity'][2];
     $ent3 = $this->sharedFixture['entity'][3];
     $ent4 = $this->sharedFixture['entity'][4];
     $entity = new Entity();
     $this->assertTrue(Session::changeActiveEntities("all"));
     $this->assertTrue($entity->can(0, READ), "Fail: can't read root entity");
     $this->assertTrue($entity->can($ent0, READ), "Fail: can't read entity 0");
     $this->assertTrue($entity->can($ent1, READ), "Fail: can't read entity 1");
     $this->assertTrue($entity->can($ent2, READ), "Fail: can't read entity 2");
     $this->assertTrue($entity->can($ent3, READ), "Fail: can't read entity 2.1");
     $this->assertTrue($entity->can($ent4, READ), "Fail: can't read entity 2.2");
     $this->assertTrue($entity->canEdit(0), "Fail: can't write root entity");
     $this->assertTrue($entity->canEdit($ent0), "Fail: can't write entity 0");
     $this->assertTrue($entity->canEdit($ent1), "Fail: can't write entity 1");
     $this->assertTrue($entity->canEdit($ent2), "Fail: can't write entity 2");
     $this->assertTrue($entity->canEdit($ent3), "Fail: can't write entity 2.1");
     $this->assertTrue($entity->canEdit($ent4), "Fail: can't write entity 2.2");
     $input = array('entities_id' => $ent1);
     $this->assertTrue($entity->can(-1, CREATE, $input), "Fail: can create entity in root");
     $input = array('entities_id' => $ent2);
     $this->assertTrue($entity->can(-1, CREATE, $input), "Fail: can't create entity in 2");
     $input = array('entities_id' => $ent3);
     $this->assertTrue($entity->can(-1, CREATE, $input), "Fail: can't create entity in 2.1");
     $input = array('entities_id' => 99999);
     $this->assertFalse($entity->can(-1, CREATE, $input), "Fail: can create entity in not existing entity");
     $input = array('entities_id' => -1);
     $this->assertFalse($entity->can(-1, CREATE, $input), "Fail: can create entity in not existing entity");
     $this->assertTrue(Session::changeActiveEntities($ent2, true));
     $this->assertTrue($entity->can(0, READ), "Fail: can't read root entity");
     $this->assertTrue($entity->can($ent0, READ), "Fail: can't read entity 0");
     $this->assertFalse($entity->can($ent1, READ), "Fail: can read entity 1");
     $this->assertTrue($entity->can($ent2, READ), "Fail: can't read entity 2");
     $this->assertTrue($entity->can($ent3, READ), "Fail: can't read entity 2.1");
     $this->assertTrue($entity->can($ent4, READ), "Fail: can't read entity 2.2");
     $this->assertFalse($entity->can(99999, READ), "Fail: can read not existing entity");
     $this->assertFalse($entity->canEdit(0), "Fail: can write root entity");
     $this->assertFalse($entity->canEdit($ent0), "Fail: can write entity 0");
     $this->assertFalse($entity->canEdit($ent1), "Fail: can write entity 1");
     $this->assertTrue($entity->canEdit($ent2), "Fail: can't write entity 2");
     $this->assertTrue($entity->canEdit($ent3), "Fail: can't write entity 2.1");
     $this->assertTrue($entity->canEdit($ent4), "Fail: can't write entity 2.2");
     $this->assertFalse($entity->canEdit(99999), "Fail: can write not existing entity");
     $input = array('entities_id' => $ent1);
     $this->assertFalse($entity->can(-1, CREATE, $input), "Fail: can create entity in root");
     $input = array('entities_id' => $ent2);
     $this->assertTrue($entity->can(-1, CREATE, $input), "Fail: can't create entity in 2");
     $input = array('entities_id' => $ent3);
     $this->assertTrue($entity->can(-1, CREATE, $input), "Fail: can't create entity in 2.1");
     $input = array('entities_id' => 99999);
     $this->assertFalse($entity->can(-1, CREATE, $input), "Fail: can create entity in not existing entity");
     $input = array('entities_id' => -1);
     $this->assertFalse($entity->can(-1, CREATE, $input), "Fail: can create entity in not existing entity");
     $this->assertTrue(Session::changeActiveEntities($ent2, false));
     $input = array('entities_id' => $ent1);
     $this->assertFalse($entity->can(-1, CREATE, $input), "Fail: can create entity in root");
     $input = array('entities_id' => $ent2);
     // next should be false (or not).... but check is done on glpiactiveprofile
     // will require to save current state in session - this is probably acceptable
     // this allow creation when no child defined yet (no way to select tree in this case)
     $this->assertTrue($entity->can(-1, CREATE, $input), "Fail: can't create entity in 2");
     $input = array('entities_id' => $ent3);
     $this->assertFalse($entity->can(-1, CREATE, $input), "Fail: can create entity in 2.1");
 }
开发者ID:btry,项目名称:glpi,代码行数:72,代码来源:CanCheck.php

示例7: showNotificationOptions

 static function showNotificationOptions(Entity $entity)
 {
     $con_spotted = false;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, 'r')) {
         return false;
     }
     // Notification right applied
     $canedit = Session::haveRight('notification', 'w') && Session::haveAccessToEntity($ID);
     // Get data
     $entitynotification = new PluginAdditionalalertsInfocomAlert();
     if (!$entitynotification->getFromDBbyEntity($ID)) {
         $entitynotification->getEmpty();
     }
     if ($canedit) {
         echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . __('Alarms options') . "</th></tr>";
     echo "<tr class='tab_bg_1'><td>" . PluginAdditionalalertsInfocomAlert::getTypeName(2) . "</td><td>";
     $default_value = $entitynotification->fields['use_infocom_alert'];
     Alert::dropdownYesNo(array('name' => "use_infocom_alert", 'value' => $default_value, 'inherit_global' => 1));
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr>";
         echo "<td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         if ($entitynotification->fields["id"]) {
             echo "<input type='hidden' name='id' value=\"" . $entitynotification->fields["id"] . "\">";
             echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         } else {
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         }
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
     } else {
         echo "</table>";
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:40,代码来源:infocomalert.class.php


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