~dangarner/xibo/client-132

« back to all changes in this revision

Viewing changes to server/lib/service/xmdssoap.class.php

  • Committer: Dan Garner
  • Date: 2011-02-28 16:05:59 UTC
  • mfrom: (194.14.7 1.2.2-pre)
  • Revision ID: dan@xibo.org.uk-20110228160559-e02vb9em6vyvfsh2
MergedĀ lp:~dangarner/xibo/1.2.2-pre

Show diffs side-by-side

added added

removed removed

Lines of Context:
848
848
    }
849
849
 
850
850
    /**
 
851
     * Store the media inventory for a client
 
852
     * @param <type> $hardwareKey
 
853
     * @param <type> $inventory
 
854
     */
 
855
    public function MediaInventory($version, $serverKey, $hardwareKey, $inventory)
 
856
    {
 
857
        $db =& $this->db;
 
858
 
 
859
        // Sanitize
 
860
        $serverKey      = Kit::ValidateParam($serverKey, _STRING);
 
861
        $hardwareKey    = Kit::ValidateParam($hardwareKey, _STRING);
 
862
        $version        = Kit::ValidateParam($version, _STRING);
 
863
        $inventory      = Kit::ValidateParam($inventory, _HTMLSTRING);
 
864
 
 
865
        // Make sure we are talking the same language
 
866
        if (!$this->CheckVersion($version))
 
867
            throw new SoapFault('Receiver', "Your client is not of the correct version for communication with this server. You can get the latest from http://www.xibo.org.uk");
 
868
 
 
869
        // Auth this request...
 
870
        if (!$this->AuthDisplay($hardwareKey))
 
871
            throw new SoapFault('Receiver', 'This display client is not licensed');
 
872
 
 
873
        if ($this->isAuditing == 1) Debug::LogEntry ($db, 'audit', $inventory, 'xmds', 'MediaInventory', '', $this->displayId);
 
874
 
 
875
        // Check that the $inventory contains something
 
876
        if ($inventory == '')
 
877
            throw new SoapFault('Receiver', 'Inventory Cannot be Empty');
 
878
 
 
879
        // Load the XML into a DOMDocument
 
880
        $document = new DOMDocument("1.0");
 
881
        $document->loadXML($inventory);
 
882
 
 
883
        // Assume we are complete (but we are getting some)
 
884
        $mediaInventoryComplete = 1;
 
885
 
 
886
        foreach ($document->documentElement->childNodes as $node)
 
887
        {
 
888
            // Make sure we dont consider any text nodes
 
889
            if ($node->nodeType == XML_TEXT_NODE) continue;
 
890
 
 
891
            $mediaId = $node->getAttribute('id');
 
892
            $complete = $node->getAttribute('complete');
 
893
            $md5 = $node->getAttribute('md5');
 
894
            $lastChecked = $node->getAttribute('lastChecked');
 
895
 
 
896
            // Check the MD5?
 
897
 
 
898
            // If this item is a 0 then set not complete
 
899
            if ($complete == 0)
 
900
                $mediaInventoryComplete = 2;
 
901
        }
 
902
 
 
903
        // Touch the display record
 
904
        $displayObject = new Display($db);
 
905
        $displayObject->Touch($hardwareKey, '', $mediaInventoryComplete, $inventory);
 
906
 
 
907
        return true;
 
908
    }
 
909
 
 
910
    /**
851
911
     * Authenticates the display
852
912
     * @param <type> $hardwareKey
853
913
     * @return <type>