mirror of
				https://github.com/ShaYmez/FreeSTAR-Status-Engine.git
				synced 2025-11-04 04:30:22 -05:00 
			
		
		
		
	Merge pull request #70 from thnilsen/add_services_to_panel
Add services to panel
This commit is contained in:
		
						commit
						554edc403a
					
				@ -123,7 +123,7 @@ class Constellation
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    $operator = ($future)?">=":"<=";
 | 
					    $operator = ($future)?">=":"<=";
 | 
				
			||||||
    $limit++;
 | 
					    $limit++;
 | 
				
			||||||
    $sql = $mysqli->prepare("SELECT *, status.id as status_id FROM status INNER JOIN users ON user_id=users.id WHERE `time` $operator ? AND `end_time` $operator ?  OR (`time`<=? AND `end_time` $operator ? ) ORDER BY `time` DESC LIMIT ? OFFSET ?");
 | 
					    $sql = $mysqli->prepare("SELECT users.id, status.type, status.title, status.text, status.time, status.end_time, users.username, status.id as status_id FROM status INNER JOIN users ON user_id=users.id WHERE `time` $operator ? AND `end_time` $operator ?  OR (`time`<=? AND `end_time` $operator ? ) ORDER BY `time` DESC LIMIT ? OFFSET ?");
 | 
				
			||||||
    $sql->bind_param("iiiiii",$timestamp, $timestamp, $timestamp, $timestamp, $limit, $offset);
 | 
					    $sql->bind_param("iiiiii",$timestamp, $timestamp, $timestamp, $timestamp, $limit, $offset);
 | 
				
			||||||
    $sql->execute();
 | 
					    $sql->execute();
 | 
				
			||||||
    $query = $sql->get_result();
 | 
					    $query = $sql->get_result();
 | 
				
			||||||
@ -136,6 +136,18 @@ class Constellation
 | 
				
			|||||||
    if ($query->num_rows){
 | 
					    if ($query->num_rows){
 | 
				
			||||||
      while(($result = $query->fetch_assoc()) && $limit-- > 0)
 | 
					      while(($result = $query->fetch_assoc()) && $limit-- > 0)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
 | 
					        // Add service id and service names to an array in the Incident class
 | 
				
			||||||
 | 
					        $stmt_service = $mysqli->prepare("SELECT services.id,services.name FROM services 
 | 
				
			||||||
 | 
					                                                 INNER JOIN services_status ON services.id = services_status.service_id 
 | 
				
			||||||
 | 
					                                                 WHERE services_status.status_id = ?");
 | 
				
			||||||
 | 
					        $stmt_service->bind_param("i", $result['status_id']);
 | 
				
			||||||
 | 
					        $stmt_service->execute();
 | 
				
			||||||
 | 
					        $query_service = $stmt_service->get_result();
 | 
				
			||||||
 | 
					        while($result_service = $query_service->fetch_assoc()) {
 | 
				
			||||||
 | 
					          $result['service_id'][] = $result_service['id'];
 | 
				
			||||||
 | 
					          $result['service_name'][] = $result_service['name'];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $array[] = new Incident($result);
 | 
					        $array[] = new Incident($result);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -13,6 +13,8 @@ class Incident implements JsonSerializable
 | 
				
			|||||||
  private $type;
 | 
					  private $type;
 | 
				
			||||||
  private $title;
 | 
					  private $title;
 | 
				
			||||||
  private $username;
 | 
					  private $username;
 | 
				
			||||||
 | 
					  private $service_id;
 | 
				
			||||||
 | 
					  private $service_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Constructs service from its data.
 | 
					   * Constructs service from its data.
 | 
				
			||||||
@ -34,6 +36,8 @@ class Incident implements JsonSerializable
 | 
				
			|||||||
    $this->title = $data['title'];
 | 
					    $this->title = $data['title'];
 | 
				
			||||||
    $this->text = $data['text'];
 | 
					    $this->text = $data['text'];
 | 
				
			||||||
    $this->username = $data['username'];
 | 
					    $this->username = $data['username'];
 | 
				
			||||||
 | 
					    $this->service_id = $data['service_id'];
 | 
				
			||||||
 | 
					    $this->service_name = $data['service_name'];
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
@ -170,6 +174,7 @@ class Incident implements JsonSerializable
 | 
				
			|||||||
    global $icons;
 | 
					    global $icons;
 | 
				
			||||||
    global $classes, $user;
 | 
					    global $classes, $user;
 | 
				
			||||||
    $admin = $admin && (($user->get_rank()<=1) || ($user->get_username() == $this->username));
 | 
					    $admin = $admin && (($user->get_rank()<=1) || ($user->get_username() == $this->username));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ?>
 | 
					    ?>
 | 
				
			||||||
     <article class="panel panel-<?php echo $classes[$this->type];?>">
 | 
					     <article class="panel panel-<?php echo $classes[$this->type];?>">
 | 
				
			||||||
        <div class="panel-heading icon">
 | 
					        <div class="panel-heading icon">
 | 
				
			||||||
@ -186,7 +191,12 @@ class Incident implements JsonSerializable
 | 
				
			|||||||
          <?php echo $this->text; ?>
 | 
					          <?php echo $this->text; ?>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <div class="panel-footer clearfix">
 | 
					        <div class="panel-footer clearfix">
 | 
				
			||||||
          <small><?php echo _("Posted by");?>: <?php echo $this->username; 
 | 
					          <small>
 | 
				
			||||||
 | 
					              <?php echo _("Impacted service(s): ");
 | 
				
			||||||
 | 
					              foreach ( $this->service_name as $key => $value ) {
 | 
				
			||||||
 | 
					                echo '<span class="label label-default">'.$value . '</span> ';
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (isset($this->end_date)){?> 
 | 
					          if (isset($this->end_date)){?> 
 | 
				
			||||||
            <span class="pull-right"><?php echo strtotime($this->end_date)>time()?_("Ending"):_("Ended");?>: <time class="pull-right timeago" datetime="<?php echo $this->end_date; ?>"><?php echo $this->end_date; ?></time></span>
 | 
					            <span class="pull-right"><?php echo strtotime($this->end_date)>time()?_("Ending"):_("Ended");?>: <time class="pull-right timeago" datetime="<?php echo $this->end_date; ?>"><?php echo $this->end_date; ?></time></span>
 | 
				
			||||||
            <?php } ?>
 | 
					            <?php } ?>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user