예제 #1
0
 public function getAudits($type = "", \DateTime $start_time = NULL, \DateTime $end_time = NULL)
 {
     if (!is_string($type) || !c\AuditTypes::isAuditType($type)) {
         if (self::DEBUG && !is_string($type)) {
             u\DebugUtility::out("Not a string");
         }
         throw new e\NoSuchTypeException(c\M::WRONG_AUDIT_TYPE);
     }
     $start = false;
     $end = false;
     if (isset($start_time)) {
         if (isset($end_time)) {
             if ($end_time < $start_time) {
                 throw new \Exception(c\M::SMALLER_END_TIME);
             }
             $end = true;
         }
         $start = true;
     }
     $a_std = new \stdClass();
     // unable to test with user, group, role
     if ($this->getType() == User::TYPE) {
         $a_std->username = $this->getName();
     } else {
         if ($this->getType() == Group::TYPE) {
             $a_std->groupname = $this->getName();
         } else {
             if ($this->getType() == Role::TYPE) {
                 $a_std->rolename = $this->getName();
             } else {
                 $a_std->identifier->id = $this->getId();
                 $a_std->identifier->type = $this->getType();
             }
         }
     }
     if ($type != "") {
         $a_std->auditType = $type;
     }
     $service = $this->getService();
     $service->readAudits($a_std);
     $audits = array();
     if ($service->isSuccessful()) {
         if (self::DEBUG) {
             u\DebugUtility::dump($service->getAudits());
         }
         $audit_stds = $service->getAudits()->audit;
         if (isset($audit_stds) && !is_array($audit_stds)) {
             $audit_stds = array($audit_stds);
         }
         $count = count($audit_stds);
         if ($count > 0) {
             foreach ($audit_stds as $audit_std) {
                 if (self::DEBUG && self::DUMP) {
                     u\DebugUtility::dump($audit_std);
                 }
                 $audit = new Audit($service, $audit_std);
                 if ($start && $audit->getDate() >= $start_time) {
                     if ($end && $audit->getDate() <= $end_time) {
                         $audits[] = $audit;
                     } else {
                         if (!$end) {
                             $audits[] = $audit;
                         }
                     }
                 } else {
                     if (!$start) {
                         if ($end && $audit->getDate() <= $end_time) {
                             $audits[] = $audit;
                         } else {
                             if (!$end) {
                                 $audits[] = $audit;
                             }
                         }
                     }
                 }
             }
             usort($audits, self::NAME_SPACE . "\\" . 'Audit::compare');
         }
     } else {
         echo $service->getMessage();
     }
     return $audits;
 }
require_once 'auth_tutorial7.php';
use cascade_ws_AOHS as aohs;
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    $page_id = "824b63c68b7ffe830539acf09bc3135b";
    $page = $cascade->getAsset(a\Page::TYPE, $page_id);
    $audits = $page->getAudits();
    //u\DebugUtility::dump( $audits );
    $audit0 = $audits[0];
    $audit1 = $audits[1];
    $audit0->display();
    $audit1->display();
    echo "Action: ", $audit0->getAction(), BR;
    echo "Audit asset: ", BR;
    u\DebugUtility::dump($audit0->getAuditedAsset());
    echo "Date: ", date_format($audit0->getDate(), 'Y-m-d H:i:s'), BR;
    echo "Identifier: ", BR;
    u\DebugUtility::dump($audit0->getIdentifier());
    echo "User: "******"cascade_ws_asset\\Audit");
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
} catch (\Error $er) {
    echo S_PRE . $er . E_PRE;
}
 public static function compareDescending(Audit $a1, Audit $a2)
 {
     if ($a1->getDate() == $a2->getDate()) {
         return 0;
     } else {
         if ($a1->getDate() < $a2->getDate()) {
             return 1;
         } else {
             return -1;
         }
     }
 }