~dangarner/xibo/server-122

« back to all changes in this revision

Viewing changes to server/lib/pages/display.class.php

  • Committer: Dan Garner
  • Date: 2011-02-28 15:12:31 UTC
  • mfrom: (210.3.7 1.2.2-pre)
  • Revision ID: dan@xibo.org.uk-20110228151231-4dxv7it2v1p7jtzu
MergedĀ lp:~dangarner/xibo/1.2.2-pre

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    private $email_alert;
38
38
    private $alert_timeout;
39
39
        private $ajax;
 
40
        private $mediaInventoryStatus;
 
41
        private $mediaInventoryXml;
40
42
 
41
43
        function __construct(database $db, user $user)
42
44
        {
71
73
            display.isAuditing,
72
74
            display.email_alert,
73
75
            display.alert_timeout,
74
 
            display.ClientAddress
 
76
            display.ClientAddress,
 
77
            display.MediaInventoryStatus,
 
78
            display.MediaInventoryXml
75
79
     FROM display
76
80
    WHERE display.displayid = %d
77
81
SQL;
95
99
                                $this->licensed                 = Kit::ValidateParam($row[4], _INT);
96
100
                                $this->inc_schedule     = Kit::ValidateParam($row[5], _INT);
97
101
                                $this->auditing                 = Kit::ValidateParam($row[6], _INT);
98
 
                $this->email_alert      = Kit::ValidateParam($row[7], _INT);
99
 
                $this->alert_timeout    = Kit::ValidateParam($row[8], _INT);
 
102
                            $this->email_alert      = Kit::ValidateParam($row[7], _INT);
 
103
                            $this->alert_timeout    = Kit::ValidateParam($row[8], _INT);
 
104
                            $this->mediaInventoryStatus = Kit::ValidateParam($row[9], _INT);
 
105
                            $this->mediaInventoryXml = Kit::ValidateParam($row[10], _HTMLSTRING);
100
106
                        }
101
107
                }
102
108
 
309
315
                        CASE WHEN display.licensed = 1 THEN '<img src="img/act.gif">' ELSE '<img src="img/disact.gif">' END AS licensed,
310
316
                        CASE WHEN display.email_alert = 1 THEN '<img src="img/act.gif">' ELSE '<img src="img/disact.gif">' END AS email_alert,
311
317
                        displaygroup.DisplayGroupID,
312
 
                        display.ClientAddress
 
318
                        display.ClientAddress,
 
319
                        CASE WHEN display.MediaInventoryStatus = 1 THEN '<img src="img/act.gif">'
 
320
                             WHEN display.MediaInventoryStatus = 2 THEN '<img src="img/warn.gif">'
 
321
                             ELSE '<img src="img/disact.gif">'
 
322
                        END AS MediaInventoryStatus,
 
323
                        display.MediaInventoryXml
313
324
                  FROM display
314
325
                    INNER JOIN lkdisplaydg ON lkdisplaydg.DisplayID = display.DisplayID
315
326
                    INNER JOIN displaygroup ON displaygroup.DisplayGroupID = lkdisplaydg.DisplayGroupID
341
352
                $msgGroupSecurity = __('Group Security');
342
353
                $msgClientAddress = __('IP Address');
343
354
                $msgDefault = __('Default Layout');
 
355
                $msgStatus = __('Status');
 
356
                $msgMediaInventory = __('Media Inventory');
344
357
 
345
358
                $output = <<<END
346
359
                <div class="info_table">
356
369
                        <th>$msgLogIn</th>
357
370
                        <th>$msgLastA</th>
358
371
                        <th>$msgClientAddress</th>
 
372
                        <th>$msgStatus</th>
359
373
                        <th>$msgAction</th>
360
374
                    </tr>
361
375
                    </thead>
385
399
                        // Do we want to make a VNC link out of the display name?
386
400
                        $vncTemplate = Config::GetSetting($db, 'SHOW_DISPLAY_AS_VNCLINK');
387
401
                        $linkTarget = Kit::ValidateParam(Config::GetSetting($db, 'SHOW_DISPLAY_AS_VNC_TGT'), _STRING);
 
402
                        $mediaInventoryStatusLight = Kit::ValidateParam($aRow[10], _STRING);
388
403
 
389
404
                        if ($vncTemplate != '' && $clientAddress != '')
390
405
                        {
424
439
                        <td>$loggedin</td>
425
440
                        <td>$lastaccessed</td>
426
441
                        <td>$clientAddress</td>
 
442
                        <td>$mediaInventoryStatusLight</td>
427
443
                        <td>$buttons</td>
428
444
END;
429
445
                }
720
736
        $response->SetFormSubmitResponse(__('Display Saved.'));
721
737
        $response->Respond();
722
738
    }
 
739
 
 
740
    /**
 
741
     * Shows the inventory XML for the display
 
742
     */
 
743
    public function MediaInventory()
 
744
    {
 
745
        $db =& $this->db;
 
746
        $response = new ResponseManager();
 
747
        $displayId = Kit::GetParam('DisplayId', _GET, _INT);
 
748
 
 
749
        if ($displayId == 0)
 
750
            trigger_error(__('No DisplayId Given'));
 
751
 
 
752
        // Get the media inventory xml for this display
 
753
        $SQL = "SELECT MediaInventoryXml FROM display WHERE DisplayId = %d";
 
754
        $SQL = sprintf($SQL, $displayId);
 
755
 
 
756
        if (!$mediaInventoryXml = $db->GetSingleValue($SQL, 'MediaInventoryXml', _HTMLSTRING))
 
757
        {
 
758
            trigger_error($db->error());
 
759
            trigger_error(__('Unable to get the Inventory for this Display'), E_USER_ERROR);
 
760
        }
 
761
 
 
762
        // Load the XML into a DOMDocument
 
763
        $document = new DOMDocument("1.0");
 
764
 
 
765
        if (!$document->loadXML($mediaInventoryXml))
 
766
            trigger_error(__('Invalid Media Inventory'), E_USER_ERROR);
 
767
 
 
768
        // Output a table
 
769
        $table = '<table><tr><th>Type</th><th>Id</th><th>Complete</th><th>Last Checked</th><th>MD5</th></tr>';
 
770
 
 
771
        foreach ($document->documentElement->childNodes as $node)
 
772
        {
 
773
            $type = $node->getAttribute('type');
 
774
            $id = $node->getAttribute('id');
 
775
            $complete = $node->getAttribute('complete');
 
776
            $lastChecked = $node->getAttribute('lastChecked');
 
777
            $md5 = $node->getAttribute('md5');
 
778
 
 
779
            if ($complete == 0)
 
780
                $complete = __('No');
 
781
            else
 
782
                $complete = __('Yes');
 
783
 
 
784
            $table .= sprintf('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>', $type, $id, $complete, $lastChecked, $md5);
 
785
        }
 
786
 
 
787
        $table .= '</table>';
 
788
 
 
789
        $response->SetFormRequestResponse($table, __('Media Inventory'), '550px', '350px');
 
790
        $response->AddButton(__('Close'), 'XiboDialogClose()');
 
791
        $response->Respond();
 
792
    }
723
793
}
724
794
?>