Exemplo n.º 1
0
 /**
  * PUBLIC fetchIcon()
  *
  * Fetches the icon for the object depending on the summary state
  *
  * @author 	Lars Michelsen <*****@*****.**>
  */
 public function fetchIcon()
 {
     // Set the paths of this iconset
     if (NagVisStatefulObject::$iconPath === null) {
         NagVisStatefulObject::$iconPath = path('sys', 'global', 'icons');
         NagVisStatefulObject::$iconPathLocal = path('sys', 'local', 'icons');
     }
     // Read the filetype of the iconset
     global $CORE;
     $fileType = $CORE->getIconsetFiletype($this->iconset);
     if ($this->sum[STATE] !== null) {
         $stateLow = strtolower(state_str($this->sum[STATE]));
         switch ($stateLow) {
             case 'unknown':
             case 'unreachable':
             case 'down':
             case 'critical':
             case 'warning':
                 if ($this->sum[ACK]) {
                     $icon = $this->iconset . '_' . $stateLow . '_ack.' . $fileType;
                 } elseif ($this->sum[DOWNTIME]) {
                     $icon = $this->iconset . '_' . $stateLow . '_dt.' . $fileType;
                 } elseif ($this->isStale(true)) {
                     $icon = $this->iconset . '_' . $stateLow . '_stale.' . $fileType;
                 } else {
                     $icon = $this->iconset . '_' . $stateLow . '.' . $fileType;
                 }
                 break;
             case 'up':
             case 'ok':
                 if ($this->sum[DOWNTIME]) {
                     $icon = $this->iconset . '_' . $stateLow . '_dt.' . $fileType;
                 } elseif ($this->isStale(true)) {
                     $icon = $this->iconset . '_' . $stateLow . '_stale.' . $fileType;
                 } else {
                     $icon = $this->iconset . '_' . $stateLow . '.' . $fileType;
                 }
                 break;
             case 'unchecked':
             case 'pending':
                 $icon = $this->iconset . '_' . $stateLow . '.' . $fileType;
                 break;
             default:
                 $icon = $this->iconset . '_error.' . $fileType;
                 break;
         }
         //Checks whether the needed file exists
         if (@file_exists(NagVisStatefulObject::$iconPath . $icon) || @file_exists(NagVisStatefulObject::$iconPathLocal . $icon)) {
             $this->icon = $icon;
         } else {
             $this->icon = $this->iconset . '_error.' . $fileType;
         }
     } else {
         $this->icon = $this->iconset . '_error.' . $fileType;
     }
 }