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: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479:
<?php
class UserAccountsConfig extends AbstractConfigData
{
const MEMBER_ACCOUNTS_VALIDATION_METHOD_PROPERTY = 'member_accounts_validation_method';
const WELCOME_MESSAGE_PROPERTY = 'welcome_message';
const REGISTRATION_ENABLED_PROPERTY = 'registration_enabled';
const REGISTRATION_AGREEMENT_PROPERTY = 'registration_agreement';
const UNACTIVATED_ACCOUNTS_TIMEOUT_PROPERTY = 'unactivated_accounts_timeout';
const ENABLE_AVATAR_UPLOAD_PROPERTY = 'enable_avatar_upload';
const ENABLE_AVATAR_AUTO_RESIZING = 'enable_avatar_auto_resizing';
const DEFAULT_AVATAR_ENABLED_PROPERTY = 'default_avatar_enabled';
const DEFAULT_AVATAR_URL_PROPERTY = 'default_avatar_url';
const MAX_AVATAR_WIDTH_PROPERTY = 'max_avatar_width';
const MAX_AVATAR_HEIGHT_PROPERTY = 'max_avatar_height';
const MAX_AVATAR_WEIGHT_PROPERTY = 'max_avatar_weight';
const AUTH_READ_MEMBERS = 'auth_read_members';
const AUTH_READ_MEMBERS_BIT = 1;
const DEFAULT_LANG = 'default_lang';
const DEFAULT_THEME = 'default_theme';
const MAX_PRIVATE_MESSAGES_NUMBER = 'max_pm_number';
const ALLOW_USERS_TO_CHANGE_DISPLAY_NAME = 'allow_users_to_change_display_name';
const ALLOW_USERS_TO_CHANGE_EMAIL = 'allow_users_to_change_email';
const AUTOMATIC_USER_ACCOUNTS_VALIDATION = '1';
const MAIL_USER_ACCOUNTS_VALIDATION = '2';
const ADMINISTRATOR_USER_ACCOUNTS_VALIDATION = '3';
public function get_member_accounts_validation_method()
{
return $this->get_property(self::MEMBER_ACCOUNTS_VALIDATION_METHOD_PROPERTY);
}
public function set_member_accounts_validation_method($method)
{
$this->set_property(self::MEMBER_ACCOUNTS_VALIDATION_METHOD_PROPERTY, $method);
}
public function get_welcome_message()
{
return $this->get_property(self::WELCOME_MESSAGE_PROPERTY);
}
public function set_welcome_message($message)
{
$this->set_property(self::WELCOME_MESSAGE_PROPERTY, $message);
}
public function is_registration_enabled()
{
return $this->get_property(self::REGISTRATION_ENABLED_PROPERTY);
}
public function set_registration_enabled($enabled)
{
$this->set_property(self::REGISTRATION_ENABLED_PROPERTY, $enabled);
}
public function enable_registration()
{
$this->set_registration_enabled(true);
}
public function disable_registration()
{
$this->set_registration_enabled(false);
}
public function get_registration_agreement()
{
return $this->get_property(self::REGISTRATION_AGREEMENT_PROPERTY);
}
public function set_registration_agreement($agreement)
{
$this->set_property(self::REGISTRATION_AGREEMENT_PROPERTY, $agreement);
}
public function is_avatar_upload_enabled()
{
return $this->get_property(self::ENABLE_AVATAR_UPLOAD_PROPERTY);
}
public function set_avatar_upload_enabled($enabled)
{
$this->set_property(self::ENABLE_AVATAR_UPLOAD_PROPERTY, $enabled);
}
public function is_avatar_auto_resizing_enabled()
{
return $this->get_property(self::ENABLE_AVATAR_AUTO_RESIZING);
}
public function set_avatar_auto_resizing_enabled($enabled)
{
$this->set_property(self::ENABLE_AVATAR_AUTO_RESIZING, $enabled);
}
public function enable_avatar_upload()
{
$this->set_avatar_upload_enabled(true);
}
public function disable_avatar_upload()
{
$this->set_avatar_upload_enabled(false);
}
public function get_unactivated_accounts_timeout()
{
return $this->get_property(self::UNACTIVATED_ACCOUNTS_TIMEOUT_PROPERTY);
}
public function set_unactivated_accounts_timeout($duration)
{
$this->set_property(self::UNACTIVATED_ACCOUNTS_TIMEOUT_PROPERTY, $duration);
}
public function is_default_avatar_enabled()
{
return $this->get_property(self::DEFAULT_AVATAR_ENABLED_PROPERTY);
}
public function set_default_avatar_name_enabled($enabled)
{
$this->set_property(self::DEFAULT_AVATAR_ENABLED_PROPERTY, $enabled);
}
public function enable_default_avatar()
{
$this->set_default_avatar_name_enabled(true);
}
public function disable_default_avatar()
{
$this->set_default_avatar_name_enabled(false);
}
public function get_default_avatar_name()
{
return $this->get_property(self::DEFAULT_AVATAR_URL_PROPERTY);
}
public function set_default_avatar_name($url)
{
if (empty($url))
{
$url = 'no_avatar.png';
}
$this->set_property(self::DEFAULT_AVATAR_URL_PROPERTY, $url);
}
public function get_max_avatar_width()
{
return $this->get_property(self::MAX_AVATAR_WIDTH_PROPERTY);
}
public function set_max_avatar_width($width)
{
$this->set_property(self::MAX_AVATAR_WIDTH_PROPERTY, $width);
}
public function get_max_avatar_height()
{
return $this->get_property(self::MAX_AVATAR_HEIGHT_PROPERTY);
}
public function set_max_avatar_height($height)
{
$this->set_property(self::MAX_AVATAR_HEIGHT_PROPERTY, $height);
}
public function get_max_avatar_weight()
{
return $this->get_property(self::MAX_AVATAR_WEIGHT_PROPERTY);
}
public function set_max_avatar_weight($weight)
{
$this->set_property(self::MAX_AVATAR_WEIGHT_PROPERTY, $weight);
}
public function get_auth_read_members()
{
return $this->get_property(self::AUTH_READ_MEMBERS);
}
public function set_auth_read_members($auth)
{
$this->set_property(self::AUTH_READ_MEMBERS, $auth);
}
public function get_default_lang()
{
return $this->get_property(self::DEFAULT_LANG);
}
public function set_default_lang($lang)
{
$this->set_property(self::DEFAULT_LANG, $lang);
}
public function get_default_theme()
{
return $this->get_property(self::DEFAULT_THEME);
}
public function set_default_theme($theme)
{
$this->set_property(self::DEFAULT_THEME, $theme);
}
public function get_max_private_messages_number()
{
return $this->get_property(self::MAX_PRIVATE_MESSAGES_NUMBER);
}
public function set_max_private_messages_number($number)
{
$this->set_property(self::MAX_PRIVATE_MESSAGES_NUMBER, $number);
}
public function are_users_allowed_to_change_display_name()
{
return $this->get_property(self::ALLOW_USERS_TO_CHANGE_DISPLAY_NAME);
}
public function set_allow_users_to_change_display_name($enabled)
{
$this->set_property(self::ALLOW_USERS_TO_CHANGE_DISPLAY_NAME, $enabled);
}
public function are_users_allowed_to_change_email()
{
return $this->get_property(self::ALLOW_USERS_TO_CHANGE_EMAIL);
}
public function set_allow_users_to_change_email($enabled)
{
$this->set_property(self::ALLOW_USERS_TO_CHANGE_EMAIL, $enabled);
}
public function get_default_values()
{
$server_configuration = new ServerConfiguration();
return array(
self::REGISTRATION_ENABLED_PROPERTY => FormFieldCheckbox::CHECKED,
self::MEMBER_ACCOUNTS_VALIDATION_METHOD_PROPERTY => self::AUTOMATIC_USER_ACCOUNTS_VALIDATION,
self::WELCOME_MESSAGE_PROPERTY => LangLoader::get_message('site_config_msg_mbr', 'main'),
self::REGISTRATION_AGREEMENT_PROPERTY => LangLoader::get_message('register_agreement', 'main'),
self::UNACTIVATED_ACCOUNTS_TIMEOUT_PROPERTY => 20,
self::ENABLE_AVATAR_UPLOAD_PROPERTY => FormFieldCheckbox::CHECKED,
self::ENABLE_AVATAR_AUTO_RESIZING => $server_configuration->has_gd_library() ? FormFieldCheckbox::CHECKED : FormFieldCheckbox::UNCHECKED,
self::DEFAULT_AVATAR_ENABLED_PROPERTY => FormFieldCheckbox::CHECKED,
self::DEFAULT_AVATAR_URL_PROPERTY => 'no_avatar.png',
self::MAX_AVATAR_WIDTH_PROPERTY => 120,
self::MAX_AVATAR_HEIGHT_PROPERTY => 120,
self::MAX_AVATAR_WEIGHT_PROPERTY => 20,
self::AUTH_READ_MEMBERS => array('r0' => 1, 'r1' => 1),
self::DEFAULT_LANG => 'english',
self::DEFAULT_THEME => 'base',
self::MAX_PRIVATE_MESSAGES_NUMBER => 50,
self::ALLOW_USERS_TO_CHANGE_DISPLAY_NAME => false,
self::ALLOW_USERS_TO_CHANGE_EMAIL => false
);
}
public static function load()
{
return ConfigManager::load(__CLASS__, 'kernel', 'user-accounts');
}
public static function save()
{
ConfigManager::save('kernel', self::load(), 'user-accounts');
}
}
?>