function items($name = '', $payload = '')
 {
     // Protect this handler
     if (!$this->authorized()) {
         redirect('auth/login');
     }
     $data['profile_items'] = array();
     $data['name'] = 'No item';
     if ($name) {
         $name = rawurldecode($name);
         $profile_item_obj = new Profile_model();
         $data['profile_name'] = $name;
         if ($payload) {
             $payload = rawurldecode($payload);
             $items = $profile_item_obj->retrieve_many('payload_name = ? GROUP BY serial_number', array($payload));
             $data['name'] = $payload;
         } else {
             $items = $profile_item_obj->retrieve_many('profile_name = ? GROUP BY serial_number', array($name));
             $data['name'] = $name;
         }
         foreach ($items as $item) {
             $machine = new Machine_model($item->serial_number);
             $instance['serial'] = $item->serial_number;
             $instance['hostname'] = $machine->computer_name;
             $instance['payload'] = $item->profile_name;
             $data['profile_items'][] = $instance;
         }
     }
     $obj = new View();
     $obj->view('profile/profileitem_detail', $data);
 }
Exemple #2
0
		  <tr>
			<th data-colname='machine#computer_name' class="col-md-4">Profile Name</th>
			<th data-colname='profile#payload_name' class="col-md-8">Payloads</th>
			<!--<th data-colname='profile#profile_UUID'>UUID</th>
			<th data-colname='profile#profile_name'>Profile Name</th>
			<th data-colname='profile#payload_name'>Payload Name</th>
			<th data-colname='profile#payload_display'>Display Name</th>
			<th data-colname='profile#payload_data'>Data</th>
			<th data-colname='profile#profile_removal_allowed'>Removable?</th>
			<th data-sort="desc" data-colname='profile#timestamp'>Detected</th>-->
		  </tr>
		</thead>

		<tbody>
	<?php 
$profile_item_obj = new Profile_model();
$items = $profile_item_obj->select('profile_name, (select COUNT(DISTINCT serial_number) from profile p2 where profile.profile_name = p2.profile_name) AS num_profiles, payload_name, serial_number, GROUP_CONCAT(payload_data) as payload_data', '1 GROUP BY profile_name, payload_name, serial_number');
$profile = array();
$profilecount = array();
$payloaddata = array();
foreach ($items as $item) {
    $name = $item['profile_name'];
    $version = $item['payload_name'];
    $serialnumber = $item['serial_number'];
    $profiles = $item['num_profiles'];
    $profile[$name][$version] = $profiles;
    $payloaddata[$name][$version] = $profile_item_obj->json_to_html($item['payload_data']);
    $profilecount[$name] = $profiles;
}
?>
	
<p>
<table class="profile table table-striped table-bordered">
	<thead>
		<tr>
      <th data-i18n="name">Name</th>
      <th data-i18n="payload">Payload</th>
		</tr>
	</thead>
	<tbody>
	<?php 
$profile_item_obj = new Profile_model();
$items = $profile_item_obj->select('profile_name, payload_name, serial_number, GROUP_CONCAT(payload_data) as payload_data', 'serial_number=? GROUP BY profile_name, payload_name, serial_number', array($serial_number));
$payloaddata = array();
$profile = array();
foreach ($items as $item) {
    $name = $item['profile_name'];
    $version = $item['payload_name'];
    $serialnumber = $item['serial_number'];
    $profile[$name][$version] = $profile;
    $payloaddata[$name][$version] = $profile_item_obj->json_to_html($item['payload_data']);
}
?>
    
    <?php 
foreach ($profile as $name => $value) {
    ?>
    <?php 
    $name_url = url('module/profile/items/' . rawurlencode($name));
    ?>
    
    <tr>