<?php

/**
 * Helper class file for audit logging.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package clearFusionCMS
 * @copyright Copyright (c) 2016 clearFusionCMS. All rights reserved.
 * @link http://clearfusioncms.com
 */

/**
 * cfModuleAudit Class
 *
 * Static class to provide module audit trail logging.
 *
 * @package clearFusionCMS
 */
abstract class cfModuleAudit extends cfAudit {

	/**#@+
	 * Action codes.
	 */
	const INSTALLED = 1600;
	const REMOVED = 1610;
	const UPLOADEDCORE = 1620;
	const UPLOADEDMODULE = 1630;
	/**#@-*/

	/**
	 * Record a module install event.
	 *
	 * @param string $name The name of the module.
	 * @param string $ver The version of the module.
	 */
	static function installed($name, $ver) {
		self::record(self::INSTALLED, 'cfModule', 0, [
			'name' => $name,
			'ver' => $ver
		]);
	}

	/**
	 * Record a module install event.
	 *
	 * @param string $name The name of the module.
	 * @param string $ver The version of the module.
	 */
	static function removed($name, $ver) {
		self::record(self::REMOVED, 'cfModule', 0, [
			'name' => $name,
			'ver' => $ver
		]);
	}

	/**
	 * Record a core upload event.
	 *
	 * @param string $name The name of the module.
	 * @param string $ver The version of the module.
	 */
	static function uploadedCore() {
		self::record(self::UPLOADEDCORE, 'cfModule', 0);
	}

	/**
	 * Record a module upload event.
	 *
	 * @param string $name The name of the module.
	 */
	static function uploadedModule($name) {
		self::record(self::UPLOADEDMODULE, 'cfModule', 0, [
			'name' => $name
		]);
	}
}
