Skip to content
Snippets Groups Projects
Commit b1a360f7 authored by Patrick Schmalstig's avatar Patrick Schmalstig
Browse files

override api changes

parent 2ed5d3ea
No related branches found
No related tags found
No related merge requests found
Showing
with 161 additions and 75 deletions
......@@ -44,7 +44,9 @@ function init__site__pages__modules_custom__galleries($code)
"if (\$type == 'workflow') {
require_code('workflows'); // Load workflow-related code
return workflow_update_handler();
}"
}",
1,
true
);
// Add workflow warnings to carousel mode galleries. This has to be done for images...
......@@ -63,7 +65,9 @@ function init__site__pages__modules_custom__galleries($code)
\$warning_details->attach(get_workflow_form(\$workflow_content_id));
}
}
}"
}",
1,
true
);
// ...and videos separately.
......@@ -82,7 +86,9 @@ function init__site__pages__modules_custom__galleries($code)
\$warning_details->attach(get_workflow_form(\$workflow_content_id));
}
}
}"
}",
1,
true
);
// Add workflow warnings to images
......@@ -97,7 +103,9 @@ function init__site__pages__modules_custom__galleries($code)
if (\$workflow_content_id !== null) {
\$warning_details->attach(get_workflow_form(\$workflow_content_id));
}
}"
}",
1,
true
);
// ...and videos separately.
......@@ -112,7 +120,9 @@ function init__site__pages__modules_custom__galleries($code)
if (\$workflow_content_id !== null) {
\$warning_details->attach(get_workflow_form(\$workflow_content_id));
}
}"
}",
1,
true
);
return $code;
......
......@@ -25,16 +25,19 @@ function init__site__pages__modules_custom__points($in)
return $in;
}
$in = override_str_replace_exactly(
require_code('override_api');
// Make sure we reason our transactions for Idolisr properly
insert_code_after__by_command(
$in,
'do_transact',
"\$reason = post_param_string('reason');",
"
<ditto>
\$give_reason_pre = post_param_string('give_reason_pre', '');
if (\$give_reason_pre != '') {
\$reason = \$give_reason_pre . \": \" . \$reason;
}
",
$in
);
return $in;
......
......@@ -25,10 +25,14 @@ function init__site__pages__modules_custom__quiz($in)
return $in;
}
$in = override_str_replace_exactly(
require_code('override_api');
// Charge for entering the competition
insert_code_after__by_command(
$in,
'_do_quiz',
"// We have not already got points",
"
<ditto>
\$cost = intval(ceil(floatval(\$quiz['q_points_for_passing']) / 2.0));
if (\$cost > 0) {
require_code('points2');
......@@ -38,20 +42,20 @@ function init__site__pages__modules_custom__quiz($in)
\$points_difference -= \$cost;
}
",
$in
);
$in = override_str_replace_exactly(
// Remove cost from awarded points
insert_code_after__by_command(
$in,
'_do_quiz',
"// Give them their result if it is a test.",
"
<ditto>
if ((addon_installed('points')) && (\$quiz['q_points_for_passing'] != 0)) {
require_code('points2');
\$cost = intval(floor(\$quiz['q_points_for_passing'] / 2));
\$points_difference -= \$cost;
}
",
$in
);
return $in;
......
......@@ -37,24 +37,45 @@ function init__cns_join($in)
} else {
$extra_code = "\$hidden->attach(get_referrer_field(false));";
}
$in = override_str_replace_exactly(
// Inject code, but do not cause full-on critical error if it is broken so members can still register.
require_code('override_api');
insert_code_after__by_command(
$in,
'cns_join_form',
"/*PSEUDO-HOOK: cns_join_form special fields*/",
$extra_code,
$in
"
" . $extra_code . "
",
1,
true
);
// Better referral detection, and proper qualification management
$in = override_str_replace_exactly(
insert_code_after__by_command(
$in,
'cns_join_form',
"/*PSEUDO-HOOK: cns_join_actual referrals*/",
"set_from_referrer_field();",
$in
"
set_from_referrer_field();
",
1,
true
);
// Handle signup referrals
$in = override_str_replace_exactly(
insert_code_after__by_command(
$in,
'cns_join_actual',
"/*PSEUDO-HOOK: cns_join_actual ends*/",
"require_code('referrals'); assign_referral_awards(\$member_id, 'join');",
$in
"
require_code('referrals');
assign_referral_awards(\$member_id, 'join');
",
1,
true
);
return $in;
......
......@@ -23,7 +23,9 @@ if (!function_exists('init__forum__cns')) {
$in = override_str_replace_exactly(
"return \$this->get_member_row_field(\$member_id, 'm_username');",
"return jestr_name_filter(\$this->get_member_row_field(\$member_id, 'm_username'));",
$in
$in,
1,
true
);
$in = override_str_replace_exactly(
......@@ -42,7 +44,9 @@ if (!function_exists('init__forum__cns')) {
<ditto>
}
",
$in
$in,
1,
true
);
return $in;
......
......@@ -25,116 +25,120 @@ function init__galleries2($code)
return $code;
}
require_code('override_api');
// We want to inject our workflow handling code into add_image...
$code = override_str_replace_exactly(
insert_code_before__by_command(
$code,
'add_image',
"log_it('ADD_IMAGE', strval(\$id), \$title);",
"
require_code('workflows');
handle_position_in_workflow_auto(\$validated, 'image', strval(\$id), 'gallery', \$cat, \$title);
<ditto>
",
$code
);
// ...and add_video...
$code = override_str_replace_exactly(
insert_code_before__by_command(
$code,
'add_video',
"log_it('ADD_VIDEO', strval(\$id), \$title);",
"
require_code('workflows');
handle_position_in_workflow_auto(\$validated, 'video', strval(\$id), 'gallery', \$cat, \$title);
<ditto>
",
$code
);
// ...and add gallery...
$code = override_str_replace_exactly(
insert_code_before__by_command(
$code,
'add_gallery',
"log_it('ADD_GALLERY', \$name, \$fullname);",
"
require_code('workflows');
handle_position_in_workflow_auto(1, 'gallery', \$name, 'gallery', \$parent_id, \$fullname);
<ditto>
",
$code
);
// Editing is a bit different; we switch the workflow if needed.
// Do this for images...
$code = override_str_replace_exactly(
insert_code_before__by_command(
$code,
'edit_image',
"log_it('EDIT_IMAGE', strval(\$id), \$title);",
"
require_code('workflows');
handle_position_in_workflow_edit(\$validated, 'image', strval(\$id), 'gallery', \$cat, \$title);
<ditto>
",
$code
);
// ...videos...
$code = override_str_replace_exactly(
insert_code_before__by_command(
$code,
'edit_video',
"log_it('EDIT_VIDEO', strval(\$id), \$title);",
"
require_code('workflows');
handle_position_in_workflow_edit(\$validated, 'video', strval(\$id), 'gallery', \$cat, \$title);
<ditto>
",
$code
);
// ...and galleries
$code = override_str_replace_exactly(
insert_code_before__by_command(
$code,
'edit_gallery',
"log_it('EDIT_GALLERY', \$name, \$fullname);",
"
require_code('workflows');
handle_position_in_workflow_edit(1, 'gallery', \$name, 'gallery', \$parent_id, \$fullname);
",
$code
);
// Now we add removal code for the delete functions.
// We do this for images...
$code = override_str_replace_exactly(
insert_code_after__by_command(
$code,
'delete_image',
"log_it('DELETE_IMAGE', strval(\$id), get_translated_text(\$title));",
"
<ditto>
require_code('workflows');
if (get_workflow_of_content('image', strval(\$id)) !== null) {
remove_content_from_workflows('image', strval(\$id));
}
",
$code
);
// ...videos...
$code = override_str_replace_exactly(
insert_code_after__by_command(
$code,
'delete_video',
"log_it('DELETE_VIDEO', strval(\$id), get_translated_text(\$title));",
"
<ditto>
require_code('workflows');
if (get_workflow_of_content('video', strval(\$id)) !== null) {
remove_content_from_workflows('video', strval(\$id));
}
",
$code
);
// ...and galleries.
$code = override_str_replace_exactly(
insert_code_after__by_command(
$code,
'delete_gallery',
"log_it('DELETE_GALLERY', \$name, get_translated_text(\$rows[0]['fullname']));",
"
<ditto>
require_code('workflows');
if (get_workflow_of_content('gallery', \$name) !== null) {
remove_content_from_workflows('gallery', \$name);
}
",
$code
);
return $code;
......
......@@ -32,7 +32,9 @@ class Hook_contentious_overrides_community_billboard
'{$,extra_footer_right_goes_here}',
"<ditto>
{+START,INCLUDE,COMMUNITY_BILLBOARD_FOOTER}{+END}",
$data
$data,
1,
true
);
}
}
......@@ -35,7 +35,9 @@ class Hook_contentious_overrides_facebook_support
'{$,extra_footer_right_goes_here}',
"<ditto>
{+START,INCLUDE,FACEBOOK_FOOTER}{+END}",
$data
$data,
1,
true
);
}
......@@ -44,7 +46,9 @@ class Hook_contentious_overrides_facebook_support
'{$,extra_footer_standalone_goes_here}',
"<ditto>
{+START,INCLUDE,FACEBOOK_FOOTER}{+END}",
$data
$data,
1,
true
);
}
}
......
......@@ -37,7 +37,9 @@ class Hook_contentious_overrides_karma
$data = override_str_replace_exactly(
"\t\t" . '{+START,IF_NON_EMPTY,{AVATAR_URL}}' . "\n\t\t\t" . '<div class="cns-member-profile-avatar">' . "\n\t\t\t\t" . '<img src="{$ENSURE_PROTOCOL_SUITABILITY*,{AVATAR_URL}}" alt="{!AVATAR}" />' . "\n\t\t\t" . '</div>' . "\n\t\t" . '{+END}',
"<ditto>{\$BLOCK,block=main_karma_graph,param={MEMBER_ID}}",
$data
$data,
1,
true
);
break;
......@@ -45,7 +47,9 @@ class Hook_contentious_overrides_karma
$data = override_str_replace_exactly(
'{POST_AVATAR}',
"<ditto>{\$BLOCK,block=main_karma_graph,param={POSTER_ID}}",
$data
$data,
1,
true
);
break;
}
......@@ -73,7 +77,9 @@ class Hook_contentious_overrides_karma
require_code('karma2');
add_karma('good', null, \$member_id, intval(get_option('karma_awards')), 'award', strval(\$award_id), \$content_id);
}
"
",
1,
true
);
}
......@@ -113,7 +119,9 @@ class Hook_contentious_overrides_karma
}
}
}
"
",
1,
true
);
}
......@@ -133,7 +141,9 @@ class Hook_contentious_overrides_karma
require_code('karma2');
reverse_karma(null, null, null, 'topic_poll', strval(\$poll_id));
}
"
",
1,
true
);
// Reverse karma when a poll is deleted.
......@@ -146,7 +156,9 @@ class Hook_contentious_overrides_karma
require_code('karma2');
reverse_karma(null, null, null, 'topic_poll', strval(\$poll_id));
}
"
",
1,
true
);
// Add karma when voting
......@@ -162,7 +174,9 @@ class Hook_contentious_overrides_karma
add_karma('good', null, \$member_id, \$karma_to_award, 'Voted on topic poll', 'topic_poll', strval(\$poll_id));
}
}
"
",
1,
true
);
// Reverse karma when a member revokes their vote
......@@ -175,7 +189,9 @@ class Hook_contentious_overrides_karma
require_code('karma2');
reverse_karma(null, null, \$member_id, 'topic_poll', strval(\$poll['id']));
}
"
",
1,
true
);
}
......@@ -198,7 +214,9 @@ class Hook_contentious_overrides_karma
add_karma('good', null, \$member_id, \$karma_to_award, 'Voted on website poll', 'poll', strval(\$poll_id));
}
}
"
",
1,
true
);
}
......@@ -223,7 +241,9 @@ class Hook_contentious_overrides_karma
add_karma('good', null, \$to_member_id, intval(\$karma_multiplier * \$influence), 'Received a gift', 'giftr', strval(\$gift_id));
}
}
"
",
1,
true
);
}
......@@ -257,7 +277,9 @@ class Hook_contentious_overrides_karma
add_karma('good', null, \$member_id, \$karma_to_award, 'Purchased ' . \$item_name, 'ecommerce', strval(\$txn_id));
}
}
"
",
1,
true
);
}
}
......
......@@ -38,6 +38,8 @@ function init__hooks__systems__ecommerce__cart_orders($in)
}
}
",
$in
$in,
1,
true
); // TODO: Needs updating
}
......@@ -30,6 +30,8 @@ function init__hooks__systems__ecommerce__usergroup($in)
assign_referral_awards(\$member_id, 'usergroup_subscribe_' . strval(\$usergroup_subscription_id));
}
",
$in
$in,
1,
true
);
}
......@@ -20,8 +20,12 @@ if (!function_exists('init__notifications')) {
return $in;
}
$in = override_str_replace_exactly(
"\$dispatcher = ",
require_code('override_api');
insert_code_before__by_command(
$in,
'dispatch_notification',
"\$dispatcher = new Notification_dispatcher",
"
if (
// Existing private topic?
......@@ -43,9 +47,7 @@ if (!function_exists('init__notifications')) {
require_code('password_censor');
\$message = _password_censor(\$message, PASSWORD_CENSOR__INTERACTIVE_SCAN);
}
<ditto>
",
$in
);
return $in;
......
......@@ -17,15 +17,21 @@
{
i_solemnly_declare(I_UNDERSTAND_SQL_INJECTION | I_UNDERSTAND_XSS | I_UNDERSTAND_PATH_INJECTION);
$code = override_str_replace_exactly(
require_code('override_api');
insert_code_after__by_command(
$code,
'points_dispatch_notification',
"// Leave this comment: Any code overrides attaching additional information to the sender notification should go here.",
"<ditto>
"
\$roles = array_map('trim', explode(',', get_option('idolisr_roles')));
if (preg_match('#^(' . implode('|', array_map('preg_quote', \$roles)) . '):#', \$reason) != 0) {
require_lang('idolisr');
\$message_raw->attach(do_notification_lang('IDOLISR_POINTS_SENT_L', \$their_displayname));
}",
$code
}
",
1,
true
);
return $code;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment