• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP getSonsOf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中getSonsOf函数的典型用法代码示例。如果您正苦于以下问题:PHP getSonsOf函数的具体用法?PHP getSonsOf怎么用?PHP getSonsOf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: testSonsAncestors

 /**
  * @covers ::getSonsOf
  * @covers ::getAncestorsOf
  */
 public function testSonsAncestors()
 {
     $ent0 = getItemByTypeName('Entity', '_test_root_entity');
     $this->assertEquals('Root entity > _test_root_entity', $ent0->getField('completename'));
     $ent1 = getItemByTypeName('Entity', '_test_child_1');
     $this->assertEquals('Root entity > _test_root_entity > _test_child_1', $ent1->getField('completename'));
     $ent2 = getItemByTypeName('Entity', '_test_child_2');
     $this->assertEquals('Root entity > _test_root_entity > _test_child_2', $ent2->getField('completename'));
     $this->assertEquals([0], array_keys(getAncestorsOf('glpi_entities', $ent0->getID())));
     $this->assertEquals([0], array_values(getAncestorsOf('glpi_entities', $ent0->getID())));
     $this->assertEquals([$ent0->getID(), $ent1->getID(), $ent2->getID()], array_keys(getSonsOf('glpi_entities', $ent0->getID())));
     $this->assertEquals([$ent0->getID(), $ent1->getID(), $ent2->getID()], array_values(getSonsOf('glpi_entities', $ent0->getID())));
     $this->assertEquals([0, $ent0->getID()], array_keys(getAncestorsOf('glpi_entities', $ent1->getID())));
     $this->assertEquals([0, $ent0->getID()], array_values(getAncestorsOf('glpi_entities', $ent1->getID())));
     $this->assertEquals([$ent1->getID()], array_keys(getSonsOf('glpi_entities', $ent1->getID())));
     $this->assertEquals([$ent1->getID()], array_values(getSonsOf('glpi_entities', $ent1->getID())));
     $this->assertEquals([0, $ent0->getID()], array_keys(getAncestorsOf('glpi_entities', $ent2->getID())));
     $this->assertEquals([0, $ent0->getID()], array_values(getAncestorsOf('glpi_entities', $ent2->getID())));
     $this->assertEquals([$ent2->getID()], array_keys(getSonsOf('glpi_entities', $ent2->getID())));
     $this->assertEquals([$ent2->getID()], array_values(getSonsOf('glpi_entities', $ent2->getID())));
 }
开发者ID:btry,项目名称:glpi,代码行数:25,代码来源:EntityTest.php


示例2: queryAccountsList

 public static function queryAccountsList($values)
 {
     global $DB;
     $ID = $values["id"];
     $aeskey = $values["aeskey"];
     $PluginAccountsHash = new PluginAccountsHash();
     $PluginAccountsHash->getFromDB($ID);
     $hash = $PluginAccountsHash->fields["hash"];
     if ($PluginAccountsHash->isRecursive()) {
         $entities = getSonsOf('glpi_entities', $PluginAccountsHash->getEntityID());
     } else {
         $entities = $PluginAccountsHash->getEntityID();
     }
     if ($aeskey) {
         $query = "SELECT `glpi_plugin_accounts_accounts`.*,\n                  `glpi_plugin_accounts_accounttypes`.`name` AS type\n                  FROM `glpi_plugin_accounts_accounts`\n                  LEFT JOIN `glpi_plugin_accounts_accounttypes`\n                  ON (`glpi_plugin_accounts_accounts`.`plugin_accounts_accounttypes_id` = `glpi_plugin_accounts_accounttypes`.`id`)\n                  WHERE `is_deleted`= '0'";
         $query .= getEntitiesRestrictRequest(" AND ", "glpi_plugin_accounts_accounts", '', $entities, $PluginAccountsHash->maybeRecursive());
         $query .= " ORDER BY `type`,`name`";
         foreach ($DB->request($query) as $data) {
             $accounts[] = $data;
         }
         $list = array();
         if (!empty($accounts)) {
             foreach ($accounts as $account) {
                 $ID = $account["id"];
                 $list[$ID]["id"] = $account["id"];
                 $list[$ID]["name"] = $account["name"];
                 if (Session::isMultiEntitiesMode()) {
                     $list[$ID]["entities_id"] = Dropdown::getDropdownName("glpi_entities", $account["entities_id"]);
                 }
                 $list[$ID]["type"] = $account["type"];
                 $list[$ID]["login"] = $account["login"];
                 $list[$ID]["password"] = $account["encrypted_password"];
             }
         }
     }
     return $list;
 }
开发者ID:puchadesc,项目名称:accounts,代码行数:37,代码来源:report.class.php


示例3: constructEntryValues

 /**
  * @param $itemtype
  * @param $type
  * @param $begin              (default '')
  * @param $end                (default '')
  * @param $param              (default '')
  * @param $value              (default '')
  * @param $value2             (default '')
  */
 static function constructEntryValues($itemtype, $type, $begin = "", $end = "", $param = "", $value = "", $value2 = "")
 {
     global $DB;
     if (!($item = getItemForItemtype($itemtype))) {
         return;
     }
     $table = $item->getTable();
     $fkfield = $item->getForeignKeyField();
     if (!($userlinkclass = getItemForItemtype($item->userlinkclass))) {
         return;
     }
     $userlinktable = $userlinkclass->getTable();
     if (!($grouplinkclass = getItemForItemtype($item->grouplinkclass))) {
         return;
     }
     $grouplinktable = $grouplinkclass->getTable();
     if (!($supplierlinkclass = getItemForItemtype($item->supplierlinkclass))) {
         return;
     }
     $supplierlinktable = $supplierlinkclass->getTable();
     $tasktable = getTableForItemType($item->getType() . 'Task');
     $closed_status = $item->getClosedStatusArray();
     $solved_status = array_merge($closed_status, $item->getSolvedStatusArray());
     $query = "";
     $WHERE = "WHERE NOT `{$table}`.`is_deleted` " . getEntitiesRestrictRequest("AND", $table);
     $LEFTJOIN = "";
     $LEFTJOINUSER = "LEFT JOIN `{$userlinktable}`\n                              ON (`{$userlinktable}`.`{$fkfield}` = `{$table}`.`id`)";
     $LEFTJOINGROUP = "LEFT JOIN `{$grouplinktable}`\n                              ON (`{$grouplinktable}`.`{$fkfield}` = `{$table}`.`id`)";
     $LEFTJOINSUPPLIER = "LEFT JOIN `{$supplierlinktable}`\n                              ON (`{$supplierlinktable}`.`{$fkfield}` = `{$table}`.`id`)";
     switch ($param) {
         case "technicien":
             $LEFTJOIN = $LEFTJOINUSER;
             $WHERE .= " AND (`{$userlinktable}`.`users_id` = '{$value}'\n                               AND `{$userlinktable}`.`type`='" . CommonITILActor::ASSIGN . "')";
             break;
         case "technicien_followup":
             $WHERE .= " AND `{$tasktable}`.`users_id` = '{$value}'";
             $LEFTJOIN = " LEFT JOIN `{$tasktable}`\n                              ON (`{$tasktable}`.`{$fkfield}` = `{$table}`.`id`)";
             break;
         case "user":
             $LEFTJOIN = $LEFTJOINUSER;
             $WHERE .= " AND (`{$userlinktable}`.`users_id` = '{$value}'\n                               AND `{$userlinktable}`.`type` ='" . CommonITILActor::REQUESTER . "')";
             break;
         case "usertitles_id":
             $LEFTJOIN = $LEFTJOINUSER;
             $LEFTJOIN .= " LEFT JOIN `glpi_users`\n                              ON (`glpi_users`.`id` = `{$userlinktable}`.`users_id`)";
             $WHERE .= " AND (`glpi_users`.`usertitles_id` = '{$value}'\n                                AND `{$userlinktable}`.`type` = '" . CommonITILActor::REQUESTER . "')";
             break;
         case "usercategories_id":
             $LEFTJOIN = $LEFTJOINUSER;
             $LEFTJOIN .= " LEFT JOIN `glpi_users`\n                              ON (`glpi_users`.`id` = `{$userlinktable}`.`users_id`)";
             $WHERE .= " AND (`glpi_users`.`usercategories_id` = '{$value}'\n                                AND `{$userlinktable}`.`type` = '" . CommonITILActor::REQUESTER . "')";
             break;
         case "itilcategories_tree":
             if ($value == $value2) {
                 $categories = array($value);
             } else {
                 $categories = getSonsOf("glpi_itilcategories", $value);
             }
             $condition = implode("','", $categories);
             $WHERE .= " AND `{$table}`.`itilcategories_id` IN ('{$condition}')";
             break;
         case 'locations_tree':
             if ($value == $value2) {
                 $categories = array($value);
             } else {
                 $categories = getSonsOf('glpi_locations', $value);
             }
             $condition = implode("','", $categories);
             $WHERE .= " AND `{$table}`.`locations_id` IN ('{$condition}')";
             break;
         case 'group_tree':
         case 'groups_tree_assign':
             $grptype = $param == 'group_tree' ? CommonITILActor::REQUESTER : CommonITILActor::ASSIGN;
             if ($value == $value2) {
                 $groups = array($value);
             } else {
                 $groups = getSonsOf("glpi_groups", $value);
             }
             $condition = implode("','", $groups);
             $LEFTJOIN = $LEFTJOINGROUP;
             $WHERE .= " AND (`{$grouplinktable}`.`groups_id` IN ('{$condition}')\n                                AND `{$grouplinktable}`.`type` = '{$grptype}')";
             break;
         case "group":
             $LEFTJOIN = $LEFTJOINGROUP;
             $WHERE .= " AND (`{$grouplinktable}`.`groups_id` = '{$value}'\n                               AND `{$grouplinktable}`.`type` = '" . CommonITILActor::REQUESTER . "')";
             break;
         case "groups_id_assign":
             $LEFTJOIN = $LEFTJOINGROUP;
             $WHERE .= " AND (`{$grouplinktable}`.`groups_id` = '{$value}'\n                               AND `{$grouplinktable}`.`type` = '" . CommonITILActor::ASSIGN . "')";
             break;
         case "suppliers_id_assign":
//.........这里部分代码省略.........
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:stat.class.php


示例4: generateContactsCfg

   function generateContactsCfg($file=0, $tag='') {
      global $DB;

      $pmEntity      = new PluginMonitoringEntity();
      $calendar      = new Calendar();

      PluginMonitoringToolbox::logIfExtradebug(
         'pm-shinken',
         "Starting generateContactsCfg ($tag) ...\n"
      );

      $a_users_used = array();
      $a_contacts = array();
      // Add default contact 'monitoring' for fake hosts
//      $a_calendars = current($calendar->find("", "", 1));
//      $cal = '24x7';
//      if (isset($a_calendars['name'])) {
//         $cal = $a_calendars['name'];
//      }
//      $a_contacts[-1] = array(
//          'contact_name'                   => 'monitoring',
//          'alias'                          => 'monitoring',
//          'host_notifications_enabled'     => '0',
//          'service_notifications_enabled'  => '0',
//          'service_notification_period'    => $cal,
//          'host_notification_period'       => $cal,
//          'service_notification_options' => '',
//          'host_notification_options'    => '',
//          'service_notification_commands'  => '',
//          'host_notification_commands'     => '',
//          'email'                          => '',
//          'pager'                          => '',
//      );


      $a_entities_allowed = $pmEntity->getEntitiesByTag($tag);
      $a_entities_list = array();
      foreach ($a_entities_allowed as $entity) {
         $a_entities_list = getSonsOf("glpi_entities", $entity);
      }
	  // Always add root entity
      $a_entities_list[] = '0';
      $where = '';
      if (! isset($a_entities_allowed['-1'])) {
         $where = getEntitiesRestrictRequest("WHERE", "glpi_plugin_monitoring_contacts_items", '', $a_entities_list);
      }


      $i=0;

      $query = "SELECT * FROM `glpi_plugin_monitoring_contacts_items` $where";
      // Toolbox::logInFile("pm-shinken", "- Contacts query: $query\n");
      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         if ($data['users_id'] > 0) {
            if ((!isset($a_users_used[$data['users_id']]))) {
               $a_contacts = $this->_addContactUser($a_contacts, $data['users_id'], $i);
               $i++;
               $a_users_used[$data['users_id']] = 1;
            }
         } else if ($data['groups_id'] > 0) {
            $queryg = "SELECT * FROM `glpi_groups_users`
               WHERE `groups_id`='".$data['groups_id']."'";
            $resultg = $DB->query($queryg);
            while ($datag=$DB->fetch_array($resultg)) {
               if ((!isset($a_users_used[$datag['users_id']]))) {
                  $a_contacts = $this->_addContactUser($a_contacts, $datag['users_id'], $i);
                  $i++;
                  $a_users_used[$datag['users_id']] = 1;
               }
            }
         }
      }
      // Add user monitoring
      $user = new User();
      $a_monit_user = current($user->find("`name`='monitoring'", '', 1));
      if ((!isset($a_users_used[$a_monit_user['id']]))) {
         $a_contacts = $this->_addContactUser($a_contacts, $a_monit_user['id'], $i);
      }

      PluginMonitoringToolbox::logIfExtradebug(
         'pm-shinken',
         "End generateContactsCfg\n"
      );

      if ($file == "1") {
         $config = "# Generated by plugin monitoring for GLPI\n# on ".date("Y-m-d H:i:s")."\n\n";

         foreach ($a_contacts as $data) {
            $config .= $this->writeFile("contact", $data);
         }
         return array('contacts.cfg', $config);

      } else {
         return $a_contacts;
      }
   }
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:97,代码来源:shinken.class.php


示例5: testTree

   /**
    * sons / ancestors for CommonTreeDropdown
    */
   public function testTree() {

      $entity = $this->sharedFixture['entity'][0];
      $loc = new Location();

      // A
      $id[0] = $loc->add(array('entities_id'  => $entity,
                               'locations_id' => 0,
                               'name'         => 'A'));
      $this->assertGreaterThan(0, $id[0]);

      // A > AA
      $id[1] = $loc->add(array('entities_id'  => $entity,
                               'locations_id' => $id[0],
                               'name'         => 'AA'));
      $this->assertGreaterThan(0, $id[1]);
      $this->assertTrue($loc->getFromDB($id[1]));
      $this->assertEquals('A > AA', $loc->fields['completename']);

      // A > BB
      $id[2] = $loc->add(array('entities_id'  => $entity,
                               'locations_id' => $id[0],
                               'name'         => 'BB'));
      $this->assertGreaterThan(0, $id[2]);
      $this->assertTrue($loc->getFromDB($id[2]));
      $this->assertEquals('A > BB', $loc->fields['completename']);

      // Sons of A (A, AA, BB)
      $sons = getSonsOf('glpi_locations',$id[0]);
      $this->assertEquals(3, count($sons));
      $this->assertArrayHasKey($id[0], $sons);
      $this->assertArrayHasKey($id[1], $sons);
      $this->assertArrayHasKey($id[2], $sons);

      // Ancestors of A (none)
      $parent = getAncestorsOf('glpi_locations', $id[0]);
      $this->assertEquals(0, count($parent));

      // Ancestors of AA (A)
      $parent = getAncestorsOf('glpi_locations', $id[1]);
      $this->assertEquals(1, count($parent));
      $this->assertArrayHasKey($id[0], $parent);

      // Ancestors of BB (none)
      $parent = getAncestorsOf('glpi_locations', $id[2]);
      $this->assertEquals(1, count($parent));
      $this->assertArrayHasKey($id[0], $parent);

      // B
      $id[3] = $loc->add(array('entities_id'  => $entity,
                               'locations_id' => 0,
                               'name'         => 'B'));
      $this->assertGreaterThan(0, $id[3]);

      // B > CC
      $id[4] = $loc->add(array('entities_id'  => $entity,
                               'locations_id' => $id[3],
                               'name'         => 'CC'));
      $this->assertGreaterThan(0, $id[4]);
      $this->assertTrue($loc->getFromDB($id[4]));
      $this->assertEquals('B > CC', $loc->fields['completename']);

      $sons = getSonsOf('glpi_locations',$id[3]);
      $this->assertEquals(2, count($sons));
      $this->assertArrayHasKey($id[4], $sons);

      // B > CC > XXX
      $id[5] = $loc->add(array('entities_id'  => $entity,
                               'locations_id' => $id[4],
                               'name'         => 'XXX'));
      $this->assertGreaterThan(0, $id[5]);
      $this->assertTrue($loc->getFromDB($id[5]));
      $this->assertEquals('B > CC > XXX', $loc->fields['completename']);

      // B > CC => A > CC
      $res = $loc->update(array('id'           => $id[4],
                                'locations_id' => $id[0]));
      $this->assertTrue($res);
      $this->assertTrue($loc->getFromDB($id[4]));
      $this->assertEquals('A > CC', $loc->fields['completename']);

      // B > CC > XXX => A > CC > XXX
      $this->assertTrue($loc->getFromDB($id[5]));
      $this->assertEquals('A > CC > XXX', $loc->fields['completename']);

      // New parent of CC (A)
      $parent = getAncestorsOf('glpi_locations', $id[4]);
      $this->assertEquals(1, count($parent));
      $this->assertArrayHasKey($id[0], $parent);

      // New sons of B (only B)
      $sons = getSonsOf('glpi_locations',$id[3]);
      $this->assertEquals(1, count($sons));
      $this->assertArrayHasKey($id[3], $sons);

      // New sons of A (A, AA, BB, CC)
      $sons = getSonsOf('glpi_locations',$id[0]);
//.........这里部分代码省略.........
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:101,代码来源:TreeCache.php


示例6: showListForItem

 /**
  * Display tickets for an item
  *
  * Will also display tickets of linked items
  *
  * @param $item CommonDBTM object
  *
  * @return nothing (display a table)
  **/
 static function showListForItem(CommonDBTM $item)
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRightsOr(self::$rightname, array(self::READALL, self::READMY, self::READASSIGN, CREATE))) {
         return false;
     }
     if ($item->isNewID($item->getID())) {
         return false;
     }
     $restrict = '';
     $order = '';
     $options['reset'] = 'reset';
     switch ($item->getType()) {
         case 'User':
             $restrict = "(`glpi_tickets_users`.`users_id` = '" . $item->getID() . "' " . " AND `glpi_tickets_users`.`type` = " . CommonITILActor::REQUESTER . ")";
             $order = '`glpi_tickets`.`date_mod` DESC';
             $options['reset'] = 'reset';
             $options['criteria'][0]['field'] = 4;
             // status
             $options['criteria'][0]['searchtype'] = 'equals';
             $options['criteria'][0]['value'] = $item->getID();
             $options['criteria'][0]['link'] = 'AND';
             break;
         case 'SLT':
             $restrict = "`slts_tto_id` = '" . $item->getID() . "'\n                           OR `slts_ttr_id` = '" . $item->getID() . "'";
             $order = '`glpi_tickets`.`due_date` DESC';
             $options['criteria'][0]['field'] = 30;
             $options['criteria'][0]['searchtype'] = 'equals';
             $options['criteria'][0]['value'] = $item->getID();
             $options['criteria'][0]['link'] = 'AND';
             break;
         case 'Supplier':
             $restrict = "(`glpi_suppliers_tickets`.`suppliers_id` = '" . $item->getID() . "' " . "  AND `glpi_suppliers_tickets`.`type` = " . CommonITILActor::ASSIGN . ")";
             $order = '`glpi_tickets`.`date_mod` DESC';
             $options['criteria'][0]['field'] = 6;
             $options['criteria'][0]['searchtype'] = 'equals';
             $options['criteria'][0]['value'] = $item->getID();
             $options['criteria'][0]['link'] = 'AND';
             break;
         case 'Group':
             // Mini search engine
             if ($item->haveChildren()) {
                 $tree = Session::getSavedOption(__CLASS__, 'tree', 0);
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr class='tab_bg_1'><th>" . __('Last tickets') . "</th></tr>";
                 echo "<tr class='tab_bg_1'><td class='center'>";
                 echo __('Child groups') . "&nbsp;";
                 Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)'));
             } else {
                 $tree = 0;
             }
             echo "</td></tr></table>";
             if ($tree) {
                 $restrict = "IN (" . implode(',', getSonsOf('glpi_groups', $item->getID())) . ")";
             } else {
                 $restrict = "='" . $item->getID() . "'";
             }
             $restrict = "(`glpi_groups_tickets`.`groups_id` {$restrict}" . " AND `glpi_groups_tickets`.`type` = " . CommonITILActor::REQUESTER . ")";
             $order = '`glpi_tickets`.`date_mod` DESC';
             $options['criteria'][0]['field'] = 71;
             $options['criteria'][0]['searchtype'] = $tree ? 'under' : 'equals';
             $options['criteria'][0]['value'] = $item->getID();
             $options['criteria'][0]['link'] = 'AND';
             break;
         default:
             $restrict = "(`glpi_items_tickets`.`items_id` = '" . $item->getID() . "' " . " AND `glpi_items_tickets`.`itemtype` = '" . $item->getType() . "')";
             // you can only see your tickets
             if (!Session::haveRight(self::$rightname, self::READALL)) {
                 $restrict .= " AND (`glpi_tickets`.`users_id_recipient` = '" . Session::getLoginUserID() . "'\n                                   OR (`glpi_tickets_users`.`tickets_id` = '" . $item->getID() . "'\n                                       AND `glpi_tickets_users`.`users_id`\n                                            = '" . Session::getLoginUserID() . "'))";
             }
             $order = '`glpi_tickets`.`date_mod` DESC';
             $options['criteria'][0]['field'] = 12;
             $options['criteria'][0]['searchtype'] = 'equals';
             $options['criteria'][0]['value'] = 'all';
             $options['criteria'][0]['link'] = 'AND';
             $options['metacriteria'][0]['itemtype'] = $item->getType();
             $options['metacriteria'][0]['field'] = Search::getOptionNumber($item->getType(), 'id');
             $options['metacriteria'][0]['searchtype'] = 'equals';
             $options['metacriteria'][0]['value'] = $item->getID();
             $options['metacriteria'][0]['link'] = 'AND';
             break;
     }
     $query = "SELECT " . self::getCommonSelect() . "\n                FROM `glpi_tickets` " . self::getCommonLeftJoin() . "\n                WHERE {$restrict} " . getEntitiesRestrictRequest("AND", "glpi_tickets") . "\n                ORDER BY {$order}\n                LIMIT " . intval($_SESSION['glpilist_limit']);
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $colspan = 11;
     if (count($_SESSION["glpiactiveentities"]) > 1) {
         $colspan++;
     }
     // Ticket for the item
     echo "<div class='firstbloc'>";
//.........这里部分代码省略.........
开发者ID:glpi-project,项目名称:glpi,代码行数:101,代码来源:ticket.class.php


示例7: showMergeCandidates

 /**
  * Show softwares candidates to be merged with the current
  *
  * @return nothing
  **/
 function showMergeCandidates()
 {
     global $DB, $CFG_GLPI;
     $ID = $this->getField('id');
     $this->check($ID, "w");
     $rand = mt_rand();
     echo "<div class='center'>";
     $sql = "SELECT `glpi_softwares`.`id`,\n                     `glpi_softwares`.`name`,\n                     `glpi_entities`.`completename` AS entity\n              FROM `glpi_softwares`\n              LEFT JOIN `glpi_entities` ON (`glpi_softwares`.`entities_id` = `glpi_entities`.`id`)\n              WHERE (`glpi_softwares`.`id` != '{$ID}'\n                     AND `glpi_softwares`.`name` = '" . addslashes($this->fields["name"]) . "'\n                     AND `glpi_softwares`.`is_deleted` = '0'\n                     AND `glpi_softwares`.`is_template` = '0' " . getEntitiesRestrictRequest('AND', 'glpi_softwares', 'entities_id', getSonsOf("glpi_entities", $this->fields["entities_id"]), false) . ")\n              ORDER BY `entity`";
     $req = $DB->request($sql);
     if ($nb = $req->numrows()) {
         $link = Toolbox::getItemTypeFormURL('Software');
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $paramsma = array('num_displayed' => $nb, 'specific_actions' => array('mergesoftware' => __('Merge')));
         Html::showMassiveActions(__CLASS__, $paramsma);
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr><th width='10'>";
         echo Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
         echo "<th>" . __('Name') . "</th>";
         echo "<th>" . __('Entity') . "</th>";
         echo "<th>" . _n('Installation', 'Installations', 2) . "</th>";
         echo "<th>" . _n('License', 'Licenses', 2) . "</th></tr>";
         foreach ($req as $data) {
             echo "<tr class='tab_bg_2'>";
             echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
             echo "<td><a href='" . $link . "?id=" . $data["id"] . "'>" . $data["name"] . "</a></td>";
             echo "<td>" . $data["entity"] . "</td>";
             echo "<td class='right'>" . Computer_SoftwareVersion::countForSoftware($data["id"]) . "</td>";
             echo "<td class='right'>" . SoftwareLicense::countForSoftware($data["id"]) . "</td></tr>\n";
         }
         echo "</table>\n";
         echo "<input type='hidden' name='id' value='{$ID}'>";
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     } else {
         _e('No item found');
     }
     echo "</div>";
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:45,代码来源:software.class.php


示例8: haveVisibilityAccess

 /**
  * Is the login user have access to reminder based on visibility configuration
  *
  * @return boolean
  **/
 function haveVisibilityAccess()
 {
     // No public reminder right : no visibility check
     if (!Session::haveRight('reminder_public', 'r')) {
         return false;
     }
     // Author
     if ($this->fields['users_id'] == Session::getLoginUserID()) {
         return true;
     }
     // Users
     if (isset($this->users[Session::getLoginUserID()])) {
         return true;
     }
     // Groups
     if (count($this->groups) && isset($_SESSION["glpigroups"]) && count($_SESSION["glpigroups"])) {
         foreach ($this->groups as $key => $data) {
             foreach ($data as $group) {
                 if (in_array($group['groups_id'], $_SESSION["glpigroups"])) {
                     // All the group
                     if ($group['entities_id'] < 0) {
                         return true;
                     }
                     // Restrict to entities
                     $entities = array($group['entities_id']);
                     if ($group['is_recursive']) {
                         $entities = getSonsOf('glpi_entities', $group['entities_id']);
                     }
                     if (Session::haveAccessToOneOfEntities($entities, true)) {
                         return true;
                     }
                 }
             }
         }
     }
     // Entities
     if (count($this->entities) && isset($_SESSION["glpiactiveentities"]) && count($_SESSION["glpiactiveentities"])) {
         foreach ($this->entities as $key => $data) {
             foreach ($data as $entity) {
                 $entities = array($entity['entities_id']);
                 if ($entity['is_recursive']) {
                     $entities = getSonsOf('glpi_entities', $entity['entities_id']);
                 }
                 if (Session::haveAccessToOneOfEntities($entities, true)) {
                     return true;
                 }
             }
         }
     }
     // Profiles
     if (count($this->profiles) && isset($_SESSION["glpiactiveprofile"]) && isset($_SESSION["glpiactiveprofile"]['id'])) {
         if (isset($this->profiles[$_SESSION["glpiactiveprofile"]['id']])) {
             foreach ($this->profiles[$_SESSION["glpiactiveprofile"]['id']] as $profile) {
                 // All the profile
                 if ($profile['entities_id'] < 0) {
                     return true;
                 }
                 // Restrict to entities
                 $entities = array($profile['entities_id']);
                 if ($profile['is_recursive']) {
                     $entities = getSonsOf('glpi_entities', $profile['entities_id']);
                 }
                 if (Session::haveAccessToOneOfEntities($entities, true)) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:gaforeror,项目名称:glpi,代码行数:75,代码来源:reminder.class.php


示例9: getDataForGroup

 /**
  * Retrieve list of member of a Group
  *
  * @since version 0.83
  *
  * @param $group              Group object
  * @param $members   Array    filled on output of member (filtered)
  * @param $ids       Array    of ids (not filtered)
  * @param $crit      String   filter (is_manager, is_userdelegate) (default '')
  * @param $tree      Boolean  true to include member of sub-group (default 0)
  *
  * @return String tab of entity for restriction
  **/
 static function getDataForGroup(Group $group, &$members, &$ids, $crit = '', $tree = 0)
 {
     global $DB;
     // Entity restriction for this group, according to user allowed entities
     if ($group->fields['is_recursive']) {
         $entityrestrict = getSonsOf('glpi_entities', $group->fields['entities_id']);
         // active entity could be a child of object entity
         if ($_SESSION['glpiactive_entity'] != $group->fields['entities_id'] && in_array($_SESSION['glpiactive_entity'], $entityrestrict)) {
             $entityrestrict = getSonsOf('glpi_entities', $_SESSION['glpiactive_entity']);
         }
     } else {
         $entityrestrict = $group->fields['entities_id'];
     }
     if ($tree) {
         $restrict = "IN (" . implode(',', getSonsOf('glpi_groups', $group->getID())) . ")";
     } else {
         $restrict = "='" . $group->getID() . "'";
     }
     // All group members
     $query = "SELECT DISTINCT `glpi_users`.`id`,\n                       `glpi_groups_users`.`id` AS linkID,\n                       `glpi_groups_users`.`groups_id`,\n                       `glpi_groups_users`.`is_dynamic` AS is_dynamic,\n                       `glpi_groups_users`.`is_manager` AS is_manager,\n                       `glpi_groups_users`.`is_userdelegate` AS is_userdelegate\n                FROM `glpi_groups_users`\n                INNER JOIN `glpi_users`\n                        ON (`glpi_users`.`id` = `glpi_groups_users`.`users_id`)\n                INNER JOIN `glpi_profiles_users`\n                        ON (`glpi_profiles_users`.`users_id`=`glpi_users`.`id`)\n                WHERE `glpi_groups_users`.`groups_id` {$restrict} " . getEntitiesRestrictRequest('AND', 'glpi_profiles_users', '', $entityrestrict, 1) . "\n                ORDER BY `glpi_users`.`realname`,\n                         `glpi_users`.`firstname`,\n                         `glpi_users`.`name`";
     $result = $DB->query($query);
     if ($DB->numrows($result) > 0) {
         while ($data = $DB->fetch_assoc($result)) {
             // Add to display list, according to criterion
             if (empty($crit) || $data[$crit]) {
                 $members[] = $data;
             }
             // Add to member list (member of sub-group are not member)
             if ($data['groups_id'] == $group->getID()) {
                 $ids[] = $data['id'];
             }
         }
     }
     return $entityrestrict;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:48,代码来源:group_user.class.php


示例10: dropdownConnect

 /**
  * Make a select box for  connected port
  *
  * @param $ID                 ID of the current port to connect
  * @param $options   array    of possible options:
  *    - name : string / name of the select (default is networkports_id)
  *    - comments : boolean / is the comments displayed near the dropdown (default true)
  *    - entity : integer or array / restrict to a defined entity or array of entities
  *                   (default -1 : no restriction)
  *    - entity_sons : boolean / if entity restrict specified auto select its sons
  *                   only available if entity is a single value not an array (default false)
  *
  * @return nothing (print out an HTML select box)
  **/
 static function dropdownConnect($ID, $options = array())
 {
     global $CFG_GLPI;
     $p['name'] = 'networkports_id';
     $p['comments'] = 1;
     $p['entity'] = -1;
     $p['entity_sons'] = false;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     // Manage entity_sons
     if (!($p['entity'] < 0) && $p['entity_sons']) {
         if (is_array($p['entity'])) {
             echo "entity_sons options is not available with entity option as array";
         } else {
             $p['entity'] = getSonsOf('glpi_entities', $p['entity']);
         }
     }
     echo "<input type='hidden' name='NetworkPortConnect_networkports_id_1'value='{$ID}'>";
     $rand = Dropdown::showItemTypes('NetworkPortConnect_itemtype', $CFG_GLPI["networkport_types"]);
     $params = array('itemtype' => '__VALUE__', 'entity_restrict' => $p['entity'], 'networkports_id' => $ID, 'comments' => $p['comments'], 'myname' => $p['name'], 'instantiation_type' => get_called_class());
     Ajax::updateItemOnSelectEvent("dropdown_NetworkPortConnect_itemtype{$rand}", "show_" . $p['name'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownConnectNetworkPortDeviceType.php", $params);
     echo "<span id='show_" . $p['name'] . "{$rand}'>&nbsp;</span>\n";
     return $rand;
 }
开发者ID:stweil,项目名称:glpi,代码行数:41,代码来源:networkportinstantiation.class.php


示例11: getSqlCriteriasRestriction

 /**
  * Get SQL code associated with the criteria
  *
  * @see plugins/reports/inc/PluginReportsAutoCriteria::getSqlCriteriasRestriction()
  **/
 public function getSqlCriteriasRestriction($link = 'AND')
 {
     if ($this->getParameterValue() || $this->searchzero) {
         if (!$this->childrens) {
             return $link . " " . $this->getSqlField() . "='" . $this->getParameterValue() . "' ";
         }
         if ($this->getParameterValue()) {
             return $link . " " . $this->getSqlField() . " IN (" . implode(',', getSonsOf($this->getTable(), $this->getParameterValue())) . ") ";
         }
         // 0 + its child means ALL
     }
     // Zero => means ALL => no criteria
     return '';
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:19,代码来源:dropdowncriteria.class.php


示例12: match

 /**
  * Try to match a definied rule
  *
  * @param &$criterion         RuleCriteria object
  * @param $field              the field to match
  * @param &$criterias_results
  * @param &$regex_result
  *
  * @return true if the field match the rule, false if it doesn't match
  **/
 static function match(RuleCriteria &$criterion, $field, &$criterias_results, &$regex_result)
 {
     $condition = $criterion->fields['condition'];
     $pattern = $criterion->fields['pattern'];
     $criteria = $criterion->fields['criteria'];
     //If pattern is wildcard, don't check the rule and return true
     //or if the condition is "already present in GLPI" : will be processed later
     if ($pattern == Rule::RULE_WILDCARD || $condition == Rule::PATTERN_FIND) {
         return true;
     }
     $pattern = trim($pattern);
     switch ($condition) {
         case Rule::PATTERN_EXISTS:
             return !empty($field);
         case Rule::PATTERN_DOES_NOT_EXISTS:
             return empty($field);
         case Rule::PATTERN_IS:
             if (is_array($field)) {
                 // Special case (used only by UNIQUE_PROFILE, for now)
                 // $pattern is an ID
                 if (in_array($pattern, $field)) {
                     $criterias_results[$criteria] = $pattern;
                     return true;
                 }
             } else {
                 //Perform comparison with fields in lower case
                 $field = Toolbox::strtolower($field);
                 $pattern = Toolbox::strtolower($pattern);
                 if ($field == $pattern) {
                     $criterias_results[$criteria] = $pattern;
                     return true;
                 }
             }
             return false;
         case Rule::PATTERN_IS_NOT:
             //Perform comparison with fields in lower case
             $field = Toolbox::strtolower($field);
             $pattern = Toolbox::strtolower($pattern);
             if ($field != $pattern) {
                 $criterias_results[$criteria] = $pattern;
                 return true;
             }
             return false;
         case Rule::PATTERN_UNDER:
             $table = getTableNameForForeignKeyField($criteria);
             $values = getSonsOf($table, $pattern);
             if (isset($values[$field])) {
                 return true;
             }
             return false;
         case Rule::PATTERN_NOT_UNDER:
             $table = getTableNameForForeignKeyField($criteria);
             $values = getSonsOf($table, $pattern);
             if (isset($values[$field])) {
                 return false;
             }
             return true;
         case Rule::PATTERN_END:
             $value = "/" . $pattern . "\$/i";
             if (preg_match($value, $field) > 0) {
                 $criterias_results[$criteria] = $pattern;
                 return true;
             }
             return false;
         case Rule::PATTERN_BEGIN:
             if (empty($pattern)) {
                 return false;
             }
             $value = mb_stripos($field, $pattern, 0, 'UTF-8');
             if ($value !== false && $value == 0) {
                 $criterias_results[$criteria] = $pattern;
                 return true;
             }
             return false;
         case Rule::PATTERN_CONTAIN:
             if (empty($pattern)) {
                 return false;
             }
             $value = mb_stripos($field, $pattern, 0, 'UTF-8');
             if ($value !== false && $value >= 0) {
                 $criterias_results[$criteria] = $pattern;
                 return true;
             }
             return false;
         case Rule::PATTERN_NOT_CONTAIN:
             if (empty($pattern)) {
                 return false;
             }
             $value = mb_stripos($field, $pattern, 0, 'UTF-8');
             if ($value === false) {
//.........这里部分代码省略.........
开发者ID:korial29,项目名称:glpi,代码行数:101,代码来源:rulecriteria.class.php


示例13: dropdown

 /**
  * Print a select with contracts
  *
  * Print a select named $name with contracts options and selected value $value
  * @param $options   array of possible options:
  *    - name          : string / name of the select (default is contracts_id)
  *    - value         : integer / preselected value (default 0)
  *    - entity        : integer or array / restrict to a defined entity or array of entities
  *                      (default -1 : no restriction)
  *    - rand          : (defauolt mt_rand)
  *    - entity_sons   : boolean / if entity restrict specified auto select its sons
  *                      only available if entity is a single value not an array (default false)
  *    - used          : array / Already used items ID: not to display in dropdown (default empty)
  *    - nochecklimit  : boolean / disable limit for nomber of device (for supplier, default false)
  *    - on_change     : string / value to transmit to "onChange"
  *    - display       : boolean / display or return string (deault true)
  *
  * @return Nothing (display)
  **/
 static function dropdown($options = array())
 {
     global $DB;
     //$name,$entity_restrict=-1,$alreadyused=array(),$nochecklimit=false
     $p['name'] = 'contracts_id';
     $p['value'] = '';
     $p['entity'] = '';
     $p['rand'] = mt_rand();
     $p['entity_sons'] = false;
     $p['used'] = array();
     $p['nochecklimit'] = false;
     $p['on_change'] = '';
     $p['display'] = true;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     if (!($p['entity'] < 0) && $p['entity_sons']) {
         if (is_array($p['entity'])) {
             // no translation needed (only for dev)
             echo "entity_sons options is not available with array of entity";
         } else {
             $p['entity'] = getSonsOf('glpi_entities', $p['entity']);
         }
     }
     $entrest = "";
     $idrest = "";
     if ($p['entity'] >= 0) {
         $entrest = getEntitiesRestrictRequest("AND", "glpi_contracts", "entities_id", $p['entity'], true);
     }
     if (count($p['used'])) {
         $idrest = " AND `glpi_contracts`.`id` NOT IN (" . implode(",", $p['used']) . ") ";
     }
     $query = "SELECT `glpi_contracts`.*\n                FROM `glpi_contracts`\n                LEFT JOIN `glpi_entities` ON (`glpi_contracts`.`entities_id` = `glpi_entities`.`id`)\n                WHERE `glpi_contracts`.`is_deleted` = '0' {$entrest} {$idrest}\n                ORDER BY `glpi_entities`.`completename`,\n                         `glpi_contracts`.`name` ASC,\n                         `glpi_contracts`.`begin_date` DESC";
     $result = $DB->query($query);
     $values = array(0 => Dropdown::EMPTY_VALUE);
     $group = '';
     $prev = -1;
     while ($data = $DB->fetch_assoc($result)) {
         if ($p['nochecklimit'] || $data["max_links_allowed"] == 0 || $data["max_links_allowed"] > countElementsInTable("glpi_contracts_items", "contracts_id\n                                                                     = '" . $data['id'] . "'")) {
             if ($data["entities_id"] != $prev) {
                 $group = Dropdown::getDropdownName("glpi_entities", $data["entities_id"]);
                 $prev = $data["entities_id"];
             }
             $name = $data["name"];
             if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                 $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
             }
             $tmp = sprintf(__('%1$s - %2$s'), $name, $data["num"]);
             $tmp = sprintf(__('%1$s - %2$s'), $tmp, Html::convDateTime($data["begin_date"]));
             $values[$group][$data['id']] = $tmp;
         }
     }
     return Dropdown::showFromArray($p['name'], $values, array('value' => $p['value'], 'on_change' => $p['on_change'], 'display' => $p['display']));
 }
开发者ID:jose-martins,项目名称:glpi,代码行数:75,代码来源:contract.class.php


示例14: addItem

 function addItem($displayviews_id)
 {
     global $DB, $CFG_GLPI;
     $this->get 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getSortOrder函数代码示例发布时间:2022-05-15
下一篇:
PHP getSoName函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap