public function execute(HTTPRequestCustom $request) { $id = $request->get_int('id', null); $code = -1; if ($id !== null) { $extended_field = new ExtendedField(); $extended_field->set_id($id); $exist_field = ExtendedFieldsDatabaseService::check_field_exist_by_id($extended_field); if ($exist_field) { ExtendedFieldsService::delete_by_id($id); $code = $id; } } return new JSONResponse(array('code' => $code)); }
private function save($id) { $extended_field = new ExtendedField(); $extended_field->set_id($id); $extended_field = ExtendedFieldsService::data_field($extended_field); $freeze = $extended_field->get_is_freeze(); if (!$freeze) { $extended_field->set_field_name(ExtendedField::rewrite_field_name($this->form->get_value('name', $extended_field->get_field_name()))); $extended_field->set_field_type($this->form->get_value('field_type', $extended_field->get_field_type())->get_raw_value()); } else { $extended_field->set_field_name(TextHelper::htmlspecialchars($extended_field->get_field_name())); $extended_field->set_field_type($extended_field->get_field_type()); } $extended_field->set_name(TextHelper::htmlspecialchars($this->form->get_value('name'))); $extended_field->set_position(PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER_EXTENDED_FIELDS_LIST, 'MAX(position) + 1', '')); $extended_field->set_description(TextHelper::htmlspecialchars($this->form->get_value('description', $extended_field->get_description()))); if (!$this->form->field_is_disabled('possible_values')) { $extended_field->set_possible_values($this->form->get_value('possible_values')); } if (!$this->form->field_is_disabled('default_value')) { $extended_field->set_default_value($this->form->get_value('default_value')); } $extended_field->set_is_required((bool) $this->form->get_value('field_required')); $extended_field->set_display((bool) $this->form->get_value('display')); $regex = 0; if (!$this->form->field_is_disabled('regex_type')) { $regex = is_numeric($this->form->get_value('regex_type', '')->get_raw_value()) ? $this->form->get_value('regex_type', '')->get_raw_value() : $this->form->get_value('regex', ''); } $extended_field->set_regex($regex); $extended_field->set_authorization($this->form->get_value('authorizations', $extended_field->get_authorization())->build_auth_array()); ExtendedFieldsService::update($extended_field); return $extended_field; }
private function add_extended_fields() { $lang = LangLoader::get('user-common'); //Sex $extended_field = new ExtendedField(); $extended_field->set_name($lang['extended-field.field.sex']); $extended_field->set_field_name('user_sex'); $extended_field->set_description($lang['extended-field.field.sex-explain']); $extended_field->set_field_type('MemberUserSexExtendedField'); $extended_field->set_is_required(false); $extended_field->set_display(false); $extended_field->set_is_freeze(true); ExtendedFieldsService::add($extended_field); //Mail notofication when receiving PM $extended_field = new ExtendedField(); $extended_field->set_name($lang['extended-field.field.pmtomail']); $extended_field->set_field_name('user_pmtomail'); $extended_field->set_description($lang['extended-field.field.pmtomail-explain']); $extended_field->set_field_type('MemberUserPMToMailExtendedField'); $extended_field->set_is_required(false); $extended_field->set_display(false); $extended_field->set_is_freeze(true); ExtendedFieldsService::add($extended_field); //Date Birth $extended_field = new ExtendedField(); $extended_field->set_name($lang['extended-field.field.date-birth']); $extended_field->set_field_name('user_born'); $extended_field->set_description($lang['extended-field.field.date-birth-explain']); $extended_field->set_field_type('MemberUserBornExtendedField'); $extended_field->set_is_required(false); $extended_field->set_display(false); $extended_field->set_is_freeze(true); ExtendedFieldsService::add($extended_field); //Avatar $extended_field = new ExtendedField(); $extended_field->set_name($lang['extended-field.field.avatar']); $extended_field->set_field_name('user_avatar'); $extended_field->set_description($lang['extended-field.field.avatar-explain']); $extended_field->set_field_type('MemberUserAvatarExtendedField'); $extended_field->set_is_required(false); $extended_field->set_display(true); $extended_field->set_is_freeze(true); ExtendedFieldsService::add($extended_field); }
private static function set_error($error) { self::$error = $error; }
private function create_member_extended_field() { $lang = LangLoader::get('common', 'forum'); $extended_field = new ExtendedField(); $extended_field->set_name(self::$member_extended_field_last_view_forum_column); $extended_field->set_field_name(self::$member_extended_field_last_view_forum_column); $extended_field->set_field_type('MemberHiddenExtendedField'); $extended_field->set_is_freeze(true); ExtendedFieldsService::add($extended_field); //Website $extended_field = new ExtendedField(); $extended_field->set_name($lang['extended-field.field.website']); $extended_field->set_field_name('user_website'); $extended_field->set_description($lang['extended-field.field.website-explain']); $extended_field->set_field_type('MemberShortTextExtendedField'); $extended_field->set_is_required(false); $extended_field->set_display(false); $extended_field->set_is_freeze(true); $extended_field->set_regex(5); ExtendedFieldsService::add($extended_field); //Skype $extended_field = new ExtendedField(); $extended_field->set_name($lang['extended-field.field.skype']); $extended_field->set_field_name('user_skype'); $extended_field->set_description($lang['extended-field.field.skype-explain']); $extended_field->set_field_type('MemberShortTextExtendedField'); $extended_field->set_is_required(false); $extended_field->set_display(false); $extended_field->set_is_freeze(true); $extended_field->set_regex(4); ExtendedFieldsService::add($extended_field); //Sign $extended_field = new ExtendedField(); $extended_field->set_name($lang['extended-field.field.signing']); $extended_field->set_field_name('user_sign'); $extended_field->set_description($lang['extended-field.field.signing-explain']); $extended_field->set_field_type('MemberLongTextExtendedField'); $extended_field->set_is_required(false); $extended_field->set_display(false); $extended_field->set_is_freeze(true); ExtendedFieldsService::add($extended_field); }
private function delete_field_member() { ExtendedFieldsService::delete_by_field_name('register_newsletter'); }