<?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\module\social
 * @copyright Copyright (c) 2017 clearFusionCMS. All rights reserved.
 * @link http://clearfusioncms.com
 */

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

	/**#@+
	 * Action codes.
	 */
	const CREATE = 8000;
	const UPDATE = 8010;
	const DELETE = 8020;
	/**#@-*/

	/**
	 * Record a create event.
	 *
	 * @param int $id The item ID.
	 * @param string $title The title of the item.
	 */
	static function create($id, $title) {
		self::record(self::CREATE, 'social', $id, ['title' => $title]);
	}

	/**
	 * Record an update to the given item.
	 *
	 * @param int $id The item ID.
	 * @param string $title The title of the item.
	 * @param array $prevData The previous data.
	 */
	static function update($id, $title, $prevData) {
		self::record(self::UPDATE, 'social', $id, ['title' => $title], $prevData);
	}

	/**
	 * Record a delete event.
	 *
	 * @param int $id The item ID.
	 * @param array $prevData The previous data.
	 */
	static function delete($id, $prevData) {
		self::record(self::DELETE, 'social', $id, ['title' => $prevData['screenname']], $prevData);
	}
}
