<?php

function set_template($notification, $type,$active, $subject='', $body='')
{
	$sql = "UPDATE `".TB_PREF."notification_templates` SET  `subject`=".db_escape($subject).", "
                . "`body`=".db_escape($body) . ", `active`=".db_escape($active) . "where notification=".db_escape($notification)." and type=".db_escape($type);
	return db_query($sql, "cannot set notification template");
}
function get_template($notification, $type)
{
	$sql = "SELECT *
	 FROM ".TB_PREF."notification_templates  WHERE type=".db_escape($type)." AND notification=".db_escape($notification);

	$result = db_query($sql,"could not get notification template");

	return db_fetch($result);
}

function template_notification($notification, $type)
{
	$sql = "SELECT active
	 FROM ".TB_PREF."notification_templates  WHERE type=".db_escape($type)." AND notification=".db_escape($notification);

	$result = db_query($sql,"could not get notification template");

	return db_fetch($result)['active'];
}
