1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153:
<?php
class CommentsConfig extends AbstractConfigData
{
const COMMENTS_ENABLED = 'comments';
const COMMENTS_UNAUTHORIZED_MODULE = 'comments_unauthorized_modules';
const AUTHORIZATIONS = 'authorizations';
const NUMBER_COMMENTS_DISPLAY = 'number_comments_per_page';
const FORBIDDEN_TAGS = 'forbidden_tags';
const MAX_LINKS_COMMENT = 'max_links_comment';
const ORDER_DISPLAY_COMMENTS = 'order_display_comments';
const ASC_ORDER = 'ASC';
const DESC_ORDER = 'DESC';
public function are_comments_enabled()
{
return $this->get_property(self::COMMENTS_ENABLED);
}
public function set_comments_enabled($enabled)
{
$this->set_property(self::COMMENTS_ENABLED, $enabled);
}
public function get_comments_unauthorized_modules()
{
return $this->get_property(self::COMMENTS_UNAUTHORIZED_MODULE);
}
public function set_comments_unauthorized_modules(array $modules)
{
$this->set_property(self::COMMENTS_UNAUTHORIZED_MODULE, $modules);
}
public function module_comments_is_enabled($module_id)
{
return $this->are_comments_enabled() && !in_array($module_id, $this->get_comments_unauthorized_modules());
}
public function get_authorizations()
{
return $this->get_property(self::AUTHORIZATIONS);
}
public function set_authorizations(Array $array)
{
$this->set_property(self::AUTHORIZATIONS, $array);
}
public function get_number_comments_display()
{
return $this->get_property(self::NUMBER_COMMENTS_DISPLAY);
}
public function set_number_comments_display($number)
{
$this->set_property(self::NUMBER_COMMENTS_DISPLAY, $number);
}
public function get_forbidden_tags()
{
return $this->get_property(self::FORBIDDEN_TAGS);
}
public function set_forbidden_tags(array $forbidden_tags)
{
$this->set_property(self::FORBIDDEN_TAGS, $forbidden_tags);
}
public function get_max_links_comment()
{
return $this->get_property(self::MAX_LINKS_COMMENT);
}
public function set_max_links_comment($number)
{
$this->set_property(self::MAX_LINKS_COMMENT, $number);
}
public function get_order_display_comments()
{
$order_display_comments = $this->get_property(self::ORDER_DISPLAY_COMMENTS);
switch ($order_display_comments) {
case self::ASC_ORDER:
case self::DESC_ORDER:
$valid_order = $order_display_comments;
break;
default:
$valid_order = self::ASC_ORDER;
break;
}
return $valid_order;
}
public function set_order_display_comments($order)
{
$this->set_property(self::ORDER_DISPLAY_COMMENTS, $order);
}
public function get_approbation_comments()
{
return $this->get_property(self::APPROBATION_COMMENTS);
}
public function set_approbation_comments($approbation)
{
$this->set_property(self::APPROBATION_COMMENTS, $approbation);
}
public function get_default_values()
{
return array(
self::COMMENTS_ENABLED => true,
self::COMMENTS_UNAUTHORIZED_MODULE => array(),
self::AUTHORIZATIONS => array('r1' => 7, 'r0' => 3, 'r-1' => 3),
self::NUMBER_COMMENTS_DISPLAY => 15,
self::FORBIDDEN_TAGS => array(),
self::MAX_LINKS_COMMENT => 2,
self::ORDER_DISPLAY_COMMENTS => self::DESC_ORDER
);
}
public static function load()
{
return ConfigManager::load(__CLASS__, 'kernel', 'comments-config');
}
public static function save()
{
ConfigManager::save('kernel', self::load(), 'comments-config');
}
}
?>