示例#1
0
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the Zurmo
 * logo and Zurmo copyright notice. If the display of the logo is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display the words
 * "Copyright Zurmo Inc. 2014. All rights reserved".
 ********************************************************************************/
require_once '../../config/debug.php';
require_once '../common/bootstrap.php';
if (!($argc == 1 || $argc == 3 && $argv[1] == '-n' && is_numeric($argv[2]))) {
    echo "\nAuditLog - Displays the audit log.\nUsage:   php AuditLog.php [-n #]\nOptions: -n # Displays the tail of the log up to # entries.\n";
    exit;
}
$count = $argc == 3 ? intval($argv[2]) : null;
try {
    RedBeanDatabase::setup(Yii::app()->db->connectionString, Yii::app()->db->username, Yii::app()->db->password);
} catch (Exception $e) {
    echo "Could not open the database.\n";
    exit;
}
try {
    Yii::app()->user->userModel = User::getByUsername('super');
} catch (Exception $e) {
    echo "Super user does not exist.\n";
    exit;
}
$AuditEventsList = $count === null ? AuditEvent::getAll() : AuditEvent::getTailEvents($count);
foreach ($AuditEventsList as $auditEvent) {
    $moduleName = $auditEvent->moduleName;
    echo $moduleName::stringifyAuditEvent($auditEvent) . "\n";
}
echo '(' . count($AuditEventsList) . " events)\n";
示例#2
0
 public function testLogAuditEventsForIsActive()
 {
     $user = new User();
     $user->username = '******';
     $user->title->value = 'Mr.';
     $user->firstName = 'My';
     $user->lastName = 'testlogauditforisactive';
     $user->setPassword('testlogauditforisactive');
     $this->assertTrue($user->save());
     unset($user);
     $user = User::getByUsername('testlogauditforisactive');
     $this->assertEquals(1, $user->isActive);
     unset($user);
     AuditEvent::deleteAll();
     //Change the user's status to inactive and confirm new audit event is created
     $user = User::getByUsername('testlogauditforisactive');
     $user->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB, RIGHT::DENY);
     $this->assertTrue($user->save());
     $this->assertEquals(0, $user->isActive);
     $auditEvents = AuditEvent::getAll();
     $this->assertCount(1, $auditEvents);
     $this->assertContains('Item Modified', strval($auditEvents[0]));
     unset($user);
     //Now change the user's status back to active and confirm new audit event is created
     $user = User::getByUsername('testlogauditforisactive');
     $user->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB, RIGHT::ALLOW);
     $this->assertTrue($user->save());
     $this->assertEquals(1, $user->isActive);
     $auditEvents = AuditEvent::getAll();
     $this->assertCount(2, $auditEvents);
     $this->assertContains('Item Modified', strval($auditEvents[1]));
     unset($user);
 }