<?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
 */

/**
 * cfCtntPermAudit Class
 *
 * Static class to provide content permission audit trail logging.
 *
 * @package clearFusionCMS
 */
abstract class cfCtntPermAudit extends cfAudit {

	/**#@+
	 * Action codes.
	 */
	const CREATED = 1900;
	const UPDATED = 1910;
	const DELETED = 1920;
	/**#@-*/

	/**
	 * Record a content permission create event.
	 *
	 * @param string $perm The permission.
	 * @param string $name The name of the permission.
	 */
	static function created($perm, $name) {
		self::record(self::CREATED, 'cfCtntPerm', 0, [
			'perm' => $perm,
			'name' => $name
		]);
	}

	/**
	 * Record a content permission update event.
	 *
	 * @param string $perm The permission.
	 * @param string $name The name of the permission.
	 * @parma string $prev The previous name.
	 */
	static function update($perm, $name, $prev) {
		self::record(self::UPDATED, 'cfCtntPerm', 0, [
			'perm' => $perm,
			'name' => $name
		], [
			'description' => $prev
		]);
	}

	/**
	 * Record a content permission delete event.
	 *
	 * @param string $perm The permission.
	 * @param string $name The name of the permission.
	 * @parma string $prev The previous name.
	 */
	static function delete($perm, $name, $prev) {
		self::record(self::DELETED, 'cfCtntPerm', 0, [
			'perm' => $perm,
			'name' => $name
		], [
			'description' => $prev
		]);
	}
}
