本文整理汇总了PHP中Computer::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Computer::find方法的具体用法?PHP Computer::find怎么用?PHP Computer::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAgentsFromActors
/**
* Get Computers from Actors defined in taskjobs
* TODO: this method should be rewritten to call directly a getAgents() method in the
* corresponding itemtype classes.
*/
public function getAgentsFromActors($actors = array())
{
$agents = array();
$computers = array();
$computer = new Computer();
$agent = new PluginFusioninventoryAgent();
$pfToolbox = new PluginFusioninventoryToolbox();
foreach ($actors as $actor) {
$itemtype = key($actor);
$itemid = $actor[$itemtype];
$item = getItemForItemtype($itemtype);
$dbresult = $item->getFromDB($itemid);
// If this item doesn't exists, we continue to the next actor item.
// TODO: remove this faulty actor from the list of job actor.
if ($dbresult === false) {
continue;
}
switch ($itemtype) {
case 'Computer':
$computers[$itemid] = 1;
break;
case 'PluginFusioninventoryDeployGroup':
$group_targets = $pfToolbox->executeAsFusioninventoryUser('PluginFusioninventoryDeployGroup::getTargetsForGroup', array($itemid));
foreach ($group_targets as $computerid) {
$computers[$computerid] = 1;
}
break;
case 'Group':
//find computers by user associated with this group
$group_users = new Group_User();
$members = array();
//array_keys($group_users->find("groups_id = '$items_id'"));
$members = $group_users->getGroupUsers($itemid);
foreach ($members as $member) {
$computers_from_user = $computer->find("users_id = '{$member['id']}'");
foreach ($computers_from_user as $computer_entry) {
$computers[$computer_entry['id']] = 1;
}
}
//find computers directly associated with this group
$computer_from_group = $computer->find("groups_id = '{$itemid}'");
foreach ($computer_from_group as $computer_entry) {
$computers[$computer_entry['id']] = 1;
}
break;
/**
* TODO: The following should be replaced with Dynamic groups
*/
/**
* TODO: The following should be replaced with Dynamic groups
*/
case 'PluginFusioninventoryAgent':
switch ($itemid) {
case "dynamic":
break;
case "dynamic-same-subnet":
break;
default:
$agents[$itemid] = 1;
break;
}
break;
}
}
//Get agents from the computer's ids list
foreach ($agent->getAgentsFromComputers(array_keys($computers)) as $agent_entry) {
$agents[$agent_entry['id']] = 1;
}
// Return the list of agent's ids.
// (We used hash keys to avoid duplicates in the list)
return array_keys($agents);
}
示例2: prepareRun
function prepareRun($taskjobs_id)
{
global $DB;
$task = new PluginFusioninventoryTask();
$job = new PluginFusioninventoryTaskjob();
$joblog = new PluginFusioninventoryTaskjoblog();
$jobstate = new PluginFusioninventoryTaskjobstate();
$agent = new PluginFusioninventoryAgent();
$uniqid = uniqid();
$job->getFromDB($taskjobs_id);
$task->getFromDB($job->fields['plugin_fusioninventory_tasks_id']);
$communication = $task->fields['communication'];
$actions = importArrayFromDB($job->fields['action']);
$definitions = importArrayFromDB($job->fields['definition']);
$taskvalid = 0;
$computers = array();
foreach ($actions as $action) {
$itemtype = key($action);
$items_id = current($action);
switch ($itemtype) {
case 'Computer':
$computers[] = $items_id;
break;
case 'Group':
$computer_object = new Computer();
//find computers by user associated with this group
$group_users = new Group_User();
$group = new Group();
$group->getFromDB($items_id);
$members = array();
$computers_a_1 = array();
$computers_a_2 = array();
//array_keys($group_users->find("groups_id = '$items_id'"));
$members = $group_users->getGroupUsers($items_id);
foreach ($members as $member) {
$computers = $computer_object->find("users_id = '{$member['id']}'");
foreach ($computers as $computer) {
$computers_a_1[] = $computer['id'];
}
}
//find computers directly associated with this group
$computers = $computer_object->find("groups_id = '{$items_id}'");
foreach ($computers as $computer) {
$computers_a_2[] = $computer['id'];
}
//merge two previous array and deduplicate entries
$computers = array_unique(array_merge($computers_a_1, $computers_a_2));
break;
case 'PluginFusioninventoryDeployGroup':
$group = new PluginFusioninventoryDeployGroup();
$group->getFromDB($items_id);
switch ($group->getField('type')) {
case 'STATIC':
$query = "SELECT items_id\n FROM glpi_plugin_fusioninventory_deploygroups_staticdatas\n WHERE groups_id = '{$items_id}'\n AND itemtype = 'Computer'";
$res = $DB->query($query);
while ($row = $DB->fetch_assoc($res)) {
$computers[] = $row['items_id'];
}
break;
case 'DYNAMIC':
$query = "SELECT fields_array\n FROM glpi_plugin_fusioninventory_deploygroups_dynamicdatas\n WHERE groups_id = '{$items_id}'\n LIMIT 1";
$res = $DB->query($query);
$row = $DB->fetch_assoc($res);
if (isset($_GET)) {
$get_tmp = $_GET;
}
if (isset($_SESSION["glpisearchcount"]['Computer'])) {
unset($_SESSION["glpisearchcount"]['Computer']);
}
if (isset($_SESSION["glpisearchcount2"]['Computer'])) {
unset($_SESSION["glpisearchcount2"]['Computer']);
}
$_GET = importArrayFromDB($row['fields_array']);
$_GET["glpisearchcount"] = count($_GET['field']);
if (isset($_GET['field2'])) {
$_GET["glpisearchcount2"] = count($_GET['field2']);
}
$pfSearch = new PluginFusioninventorySearch();
Search::manageGetValues('Computer');
$glpilist_limit = $_SESSION['glpilist_limit'];
$_SESSION['glpilist_limit'] = 999999999;
$result = $pfSearch->constructSQL('Computer', $_GET);
$_SESSION['glpilist_limit'] = $glpilist_limit;
while ($data = $DB->fetch_array($result)) {
$computers[] = $data['id'];
}
if (count($get_tmp) > 0) {
$_GET = $get_tmp;
}
break;
}
break;
}
}
$c_input = array();
$c_input['plugin_fusioninventory_taskjobs_id'] = $taskjobs_id;
$c_input['state'] = 0;
$c_input['plugin_fusioninventory_agents_id'] = 0;
$c_input['execution_id'] = $task->fields['execution_id'];
$pfCollect = new PluginFusioninventoryCollect();
//.........这里部分代码省略.........
示例3: prepareRun
function prepareRun($taskjob_id, $definitions_filter = NULL)
{
global $DB;
$task = new PluginFusioninventoryTask();
$job = new PluginFusioninventoryTaskjob();
$joblog = new PluginFusioninventoryTaskjoblog();
$jobstate = new PluginFusioninventoryTaskjobstate();
$agent = new PluginFusioninventoryAgent();
$agentmodule = new PluginFusioninventoryAgentmodule();
$job->getFromDB($taskjob_id);
$task->getFromDB($job->fields['plugin_fusioninventory_tasks_id']);
$communication = $task->fields['communication'];
$actions = importArrayFromDB($job->fields['action']);
$definitions = importArrayFromDB($job->fields['definition']);
$taskvalid = 0;
$computers = array();
foreach ($actions as $action) {
$itemtype = key($action);
$items_id = current($action);
switch ($itemtype) {
case 'Computer':
if ($this->definitionFiltered("Computer", $definitions_filter)) {
break;
}
$computers[] = $items_id;
break;
case 'Group':
if ($this->definitionFiltered("Group", $definitions_filter)) {
break;
}
$computer_object = new Computer();
//find computers by user associated with this group
$group_users = new Group_User();
$group = new Group();
$group->getFromDB($items_id);
$members = array();
$computers_a_1 = array();
$computers_a_2 = array();
//array_keys($group_users->find("groups_id = '$items_id'"));
$members = $group_users->getGroupUsers($items_id);
foreach ($members as $member) {
$computers = $computer_object->find("users_id = '{$member['id']}' " . " AND `is_deleted`='0' AND `is_template`='0'");
foreach ($computers as $computer) {
$computers_a_1[] = $computer['id'];
}
}
//find computers directly associated with this group
$computers = $computer_object->find("groups_id = '{$items_id}' " . " AND `is_deleted`='0' AND `is_template`='0'");
foreach ($computers as $computer) {
$computers_a_2[] = $computer['id'];
}
//merge two previous array and deduplicate entries
$computers = array_unique(array_merge($computers_a_1, $computers_a_2));
break;
case 'PluginFusioninventoryDeployGroup':
$group = new PluginFusioninventoryDeployGroup();
$group->getFromDB($items_id);
switch ($group->getField('type')) {
case 'STATIC':
if ($this->definitionFiltered("PluginFusioninventoryDeployGroupStatic", $definitions_filter)) {
break;
}
$query = "SELECT items_id\n FROM glpi_plugin_fusioninventory_deploygroups_staticdatas\n WHERE groups_id = '{$items_id}'\n AND itemtype = 'Computer'";
$res = $DB->query($query);
while ($row = $DB->fetch_assoc($res)) {
$computers[] = $row['items_id'];
}
break;
case 'DYNAMIC':
if ($this->definitionFiltered("PluginFusioninventoryDeployGroupDynamic", $definitions_filter)) {
break;
}
//$definitions_filter is NULL = update by crontask !
if ($definitions_filter != NULL) {
$where = " AND `can_update_group`='1'";
} else {
$where = "";
}
$query = "SELECT fields_array\n FROM glpi_plugin_fusioninventory_deploygroups_dynamicdatas\n WHERE groups_id = '{$items_id}' {$where}\n LIMIT 1";
$res = $DB->query($query);
$row = $DB->fetch_assoc($res);
//No dynamic groups have been found : break
if ($DB->numrows($res) == 0) {
break;
}
if (isset($_GET)) {
$get_tmp = $_GET;
}
if (isset($_SESSION["glpisearchcount"]['Computer'])) {
unset($_SESSION["glpisearchcount"]['Computer']);
}
if (isset($_SESSION["glpisearchcount2"]['Computer'])) {
unset($_SESSION["glpisearchcount2"]['Computer']);
}
$_GET = importArrayFromDB($row['fields_array']);
$_GET["glpisearchcount"] = count($_GET['field']);
if (isset($_GET['field2'])) {
$_GET["glpisearchcount2"] = count($_GET['field2']);
}
$pfSearch = new PluginFusioninventorySearch();
//.........这里部分代码省略.........
示例4: IgnoreNetworkDiscoveryImport
/**
* @test
* network discovery
*/
public function IgnoreNetworkDiscoveryImport()
{
global $DB;
$DB->connect();
$a_inventory = array('DNSHOSTNAME' => 'pctest', 'ENTITY' => 0, 'IP' => '192.168.20.3');
$pfCommunicationNetworkDiscovery = new PluginFusioninventoryCommunicationNetworkDiscovery();
$computer = new Computer();
$pfUnmanaged = new PluginFusioninventoryUnmanaged();
$pfIgnoredimportdevice = new PluginFusioninventoryIgnoredimportdevice();
$GLPIlog = new GLPIlogs();
$_SESSION['plugin_fusinvsnmp_taskjoblog']['taskjobs_id'] = 1;
$_SESSION['plugin_fusinvsnmp_taskjoblog']['items_id'] = '1';
$_SESSION['plugin_fusinvsnmp_taskjoblog']['itemtype'] = 'Computer';
$_SESSION['plugin_fusinvsnmp_taskjoblog']['state'] = 0;
$_SESSION['plugin_fusinvsnmp_taskjoblog']['comment'] = '';
$pfCommunicationNetworkDiscovery->sendCriteria($a_inventory);
$a_computers = $computer->find();
$this->assertEquals(0, count($a_computers), 'Computer may not be added');
$a_unknown = $pfUnmanaged->find();
$this->assertEquals(0, count($a_unknown), 'Unmanaged may not be added');
$a_ignored = $pfIgnoredimportdevice->find();
$this->assertEquals(1, count($a_ignored), 'May have only one ignored device import');
}