forked from Aspen-Discovery/aspen-discovery
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
code/web/cron/updateCommunityEngagementMilestonesProgress.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
require_once __DIR__ . '/../bootstrap.php'; | ||
|
||
#DO CODE HERE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
$hook_actions = array(); | ||
|
||
/** | ||
* Attach (or remove) multiple callbacks to an action and trigger those callbacks when that action is called. | ||
* | ||
* @param string $hook name | ||
* @param string $action name | ||
* @param mixed $callback the method or function to call - FALSE to remove all callbacks for action | ||
*/ | ||
|
||
function add_action($hook_name, $action_name, $callback = NULL){ | ||
global $hook_actions; | ||
|
||
if($callback) | ||
{ | ||
$hook_actions[$hook_name][$action_name] = $callback; | ||
} | ||
else | ||
{ | ||
unset($hook_actions[$hook_name][$action_name]); | ||
} | ||
} | ||
|
||
/** | ||
* Executes all callback functions attached to a given action. | ||
* | ||
* @param string $action The name of the action to execute. | ||
* @param mixed $value (optional) The value to pass to each callback function. Defaults to NULL. | ||
* @return void | ||
*/ | ||
|
||
function do_action($hook_name, $value = NULL){ | ||
global $hook_actions; | ||
|
||
if(isset($hook_actions[$hook_name])) // Fire a callback | ||
{ | ||
foreach($hook_actions[$hook_name] as $function) | ||
{ | ||
call_user_func($function, $value); | ||
} | ||
} | ||
} | ||
|
||
add_action('before_object_insert', 'before_checkout_insert', function($value){ | ||
|
||
$tableName = 'user_checkout'; | ||
|
||
# Bail if not the table we want | ||
if($value['__table'] != $tableName) return; | ||
|
||
# Bail if the newly created checkout already exists | ||
$checkOuts = new CheckOut(); | ||
$checkOuts->query("SELECT sourceId from {$tableName} WHERE sourceId = {$value['sourceId']}"); | ||
if ($checkOuts->getNumResults() > 0) { | ||
return; | ||
} | ||
|
||
# Add entry to ce_milestone_goal_actions | ||
|
||
}); | ||
|
||
// Example of action hook | ||
// add_action('after_object_insert', 'after_checkout_insert', function($value){ | ||
|
||
// $tableName = 'user_checkout'; | ||
|
||
// # Bail if not the table we want | ||
// if($value->__table != $tableName) return; | ||
|
||
// # Bail if the newly created checkout already exists | ||
// $checkOuts = new CheckOut(); | ||
// $checkOuts->query("SELECT sourceId from {$tableName} WHERE sourceId = {$value->sourceId}"); | ||
// if ($checkOuts->getNumResults() > 0) { | ||
// return; | ||
// } | ||
|
||
|
||
// }); |