Merge branch 'master' into es_17_01
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
<div class="col-md-2 col-md-offset-9">
|
||||
<form action="{$site_url/}gcse" class="search-form" id="gcse_search_form">
|
||||
<div class="form-group has-feedback">
|
||||
<input type="search" class="form-control" name="q" id="gcse_search" placeholder="search" value="{$google_search/}" >
|
||||
<input type="search" class="form-control" name="q" id="gcse_search" placeholder="search" value="{$cms_search_query/}" >
|
||||
<span class="glyphicon glyphicon-search form-control-feedback"></span>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -271,6 +271,9 @@ feature -- Handler
|
||||
then
|
||||
f.append_to_html (r.wsf_theme, b)
|
||||
end
|
||||
if attached new_change_profile_name_form (r) as f then
|
||||
f.append_to_html (r.wsf_theme, b)
|
||||
end
|
||||
if attached new_change_password_form (r) as f then
|
||||
f.append_to_html (r.wsf_theme, b)
|
||||
end
|
||||
@@ -729,6 +732,24 @@ feature -- Handler
|
||||
f := new_change_email_form (r)
|
||||
r.set_main_content (f.to_html (r.wsf_theme))
|
||||
end
|
||||
elseif l_fieldname.is_case_insensitive_equal ("profile_name") then
|
||||
f := new_change_profile_name_form (r)
|
||||
f.process (r)
|
||||
if
|
||||
attached f.last_data as fd and then
|
||||
not fd.has_error and then
|
||||
attached fd.string_item ("new_profile_name") as l_new_profile_name
|
||||
then
|
||||
check api.user_api.is_valid_profile_name (l_new_profile_name) end
|
||||
l_user.set_profile_name (l_new_profile_name)
|
||||
l_user_api.update_user (l_user)
|
||||
r.add_success_message ("Profile name updated.")
|
||||
r.set_redirection ("account/")
|
||||
r.set_redirection_delay (3)
|
||||
else
|
||||
r.add_error_message ("Invalid form data!")
|
||||
r.set_main_content (f.to_html (r.wsf_theme))
|
||||
end
|
||||
elseif l_fieldname.is_case_insensitive_equal ("username") then
|
||||
if api.has_permission ("change own username") then
|
||||
f := new_change_username_form (r)
|
||||
@@ -919,6 +940,35 @@ feature -- Handler
|
||||
fs.extend_html_text ("<button type=%"submit%">Confirm</button>")
|
||||
end
|
||||
|
||||
new_change_profile_name_form (a_response: CMS_RESPONSE): CMS_FORM
|
||||
local
|
||||
fs: WSF_FORM_FIELD_SET
|
||||
txt: WSF_FORM_TEXT_INPUT
|
||||
do
|
||||
create Result.make (a_response.url ("account/change/profile_name", Void), "change-profile-name-form")
|
||||
create fs.make
|
||||
fs.set_legend ("Change profile name (i.e the name displayed on pages)")
|
||||
Result.extend (fs)
|
||||
|
||||
create txt.make ("new_profile_name")
|
||||
txt.set_label ("Profile name")
|
||||
txt.set_validation_action (agent (fd: WSF_FORM_DATA; api: CMS_API)
|
||||
do
|
||||
if
|
||||
attached fd.string_item ("new_profile_name") as l_new and then
|
||||
api.user_api.is_valid_profile_name (l_new)
|
||||
then
|
||||
-- Ok
|
||||
else
|
||||
fd.report_invalid_field ("new_profile_name", "Invalid profile name!")
|
||||
end
|
||||
end (?, a_response.api)
|
||||
)
|
||||
txt.enable_required
|
||||
fs.extend (txt)
|
||||
fs.extend_html_text ("<button type=%"submit%">Confirm</button>")
|
||||
end
|
||||
|
||||
new_change_password_form (a_response: CMS_RESPONSE): CMS_FORM
|
||||
local
|
||||
fs: WSF_FORM_FIELD_SET
|
||||
|
||||
@@ -11,14 +11,9 @@ class
|
||||
inherit
|
||||
|
||||
CMS_MODULE
|
||||
redefine
|
||||
setup_hooks
|
||||
end
|
||||
|
||||
CMS_HOOK_BLOCK_HELPER
|
||||
|
||||
CMS_HOOK_VALUE_TABLE_ALTER
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
export
|
||||
{NONE} all
|
||||
@@ -57,30 +52,6 @@ feature -- Router
|
||||
a_router.map (m, a_router.methods_head_get)
|
||||
end
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
do
|
||||
a_hooks.subscribe_to_value_table_alter_hook (Current)
|
||||
end
|
||||
|
||||
value_table_alter (a_value: CMS_VALUE_TABLE; a_response: CMS_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_url: STRING
|
||||
l_url_name: READABLE_STRING_GENERAL
|
||||
do
|
||||
if
|
||||
attached {WSF_STRING} a_response.request.query_parameter ("q") as l_query and then
|
||||
not l_query.value.is_empty
|
||||
then
|
||||
a_value.force (l_query.value, "google_search")
|
||||
else
|
||||
a_value.force (Void, "google_search")
|
||||
end
|
||||
end
|
||||
|
||||
feature -- GCSE Keys
|
||||
|
||||
gcse_secret_key (api: CMS_API): detachable READABLE_STRING_8
|
||||
@@ -132,6 +103,7 @@ feature -- Handler
|
||||
attached gcse_cx_key (api) as l_cx and then
|
||||
attached gcse_secret_key (api) as l_key
|
||||
then
|
||||
r.set_value (l_query.value, "cms_search_query")
|
||||
create l_parameters.make (l_key, l_cx, l_query.url_encoded_value )
|
||||
if
|
||||
attached {WSF_STRING} req.query_parameter ("start") as l_index and then
|
||||
|
||||
@@ -42,6 +42,32 @@ feature -- Validation
|
||||
end
|
||||
end
|
||||
|
||||
is_valid_profile_name (a_name: READABLE_STRING_32): BOOLEAN
|
||||
local
|
||||
c: CHARACTER_32
|
||||
do
|
||||
if a_name.is_empty or a_name.is_whitespace then
|
||||
Result := False
|
||||
elseif a_name[1].is_space then
|
||||
Result := False
|
||||
elseif a_name[a_name.count].is_space then
|
||||
Result := False
|
||||
else
|
||||
Result := True
|
||||
across
|
||||
a_name as ic
|
||||
until
|
||||
not Result
|
||||
loop
|
||||
c := ic.item
|
||||
if c.is_alpha_numeric or c = '-' or c = '_' or c.is_space or c = '%'' then
|
||||
else
|
||||
Result := False
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access: user
|
||||
|
||||
user_by_id (a_id: like {CMS_USER}.id): detachable CMS_USER
|
||||
|
||||
Reference in New Issue
Block a user