Skip to main content
Topic: What file did you edit? (Read 21764 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: What file did you edit?

Reply #30

Wanting to add a scheduled task have the database query ready.
But was looking to see if there was a hook or way to add to "class Scheduled_Task" I want add another function in there and load the language strings hopefully without editing the file.

Re: What file did you edit?

Reply #31

This could be useful:
Quote from: Spuds  -  Remember Elk also has several "generic" hooks which allow you to act on almost every action and subaction ...  a few that I use are:

Code: [Select]
call_integration_hook('integrate_action_' . $hook . '_before', array($this->_function_name));
call_integration_hook('integrate_action_' . $hook . '_after', array($this->_function_name));
call_integration_hook('integrate_sa_' . $this->_name, array(&$subactions));
call_integration_hook('integrate_list_' . $listOptions['id'], array(&$listOptions));

The first two are in the Site Dispatcher, allowing you to act both before and after an action is initiated.  One minor thing to note and something that is being worked on, is the _after hook is not always guaranteed to fire ... for example an action with an exit / die / fatal etc inside of it.  So pretty much anywhere a ?action=xyz is called, these hooks are called.

The third is in the Action.class allowing you integrate before a sub-action is called from a controller.  This allows you to easily add your own subActions to a controller, or simply act / trigger at the start of any subAction.  So wherever you see $action->initialize() in a controller, that hook is being called (~55 times)

The last is called wherever you see a createList(); call, it allows you to add / modify to any list / form that gets displayed, this is super useful as we really implemented createList (~170 times)


I did found these (but now sure what it is for) in ManageScheduledTasks.controller.php::
Code: [Select]

Code: [Select]
		// We need to find what's the action. call integrate_sa_manage_scheduled_tasks
$subAction = $action->initialize($subActions, 'tasks');

Otherwise, looking at the code, we could add a hook somewhere in the end of this line:
Code: [Select]
	public function action_index()
global $context, $txt;


$subActions = array(
'taskedit' => array($this, 'action_edit', 'permission' => 'admin_forum'),
'tasklog' => array($this, 'action_log', 'permission' => 'admin_forum'),
'tasks' => array($this, 'action_tasks', 'permission' => 'admin_forum'),

// Control those actions
$action = new Action('manage_scheduled_tasks');

// Now for the lovely tabs. That we all love.
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['scheduled_tasks_title'],
'help' => '',
'description' => $txt['maintain_info'],
'tabs' => array(
'tasks' => array(
'description' => $txt['maintain_tasks_desc'],
'tasklog' => array(
'description' => $txt['scheduled_log_desc'],

// We need to find what's the action. call integrate_sa_manage_scheduled_tasks
$subAction = $action->initialize($subActions, 'tasks');

// Page details
$context['page_title'] = $txt['maintain_info'];
$context['sub_action'] = $subAction;

// Call the right function for this sub-action.

As in my last comparison, SMF 2.1 Beta did put this hook there:
Code: [Select]
	call_integration_hook('integrate_manage_scheduled_tasks', array(&$subActions));

// Call it.

Whether that hook add is necessary or otherwise, I don't know.

Re: What file did you edit?

Reply #32

To add a new scheduled task there is no need to edit files.
In 1.0: include your file using "integrate_autotask_include", then the task (i.e. the "task" column in the database) can be in the form of a simple function ("my_custom_task") or a static method ("MyScheduled::method") and it will be used.
In 1.1: you'll have a class in sources/subs/ScheduledTask/ implementing the ScheduledTaskInterface.php and in the database you store the name of the class. Elk will take care of the rest.

Re: What file did you edit?

Reply #33

@ahrasis any time you see
Code: [Select]
$action = new Action('something');
$subAction = $action->initialize($subActions, 'an_action');
you already have an hook available in the form:
Code: [Select]
that will pass you the $subActions array.
Let's say the equivalent of:
Code: [Select]
call_integration_hook('integrate_sa_something', array(&$subActions));
for reference, see the comment in the code you posted:
Code: [Select]
// We need to find what's the action. call integrate_sa_manage_scheduled_tasks

Re: What file did you edit?

Reply #34

Thanks will give it try

Re: What file did you edit?

Reply #35

I'm looking at trying to change/add information in the recent and unread posts pages, and there does not seem to be any way to add custom selects or joins to the sql and no hooks to work on the data before/in the context array.

Re: What file did you edit?

Reply #36

@Cody right you remembered me about this, I worked on this code for 1.1, and set it up to make it easier to add an hook to the queries, but for some reason I didn't add it.
I'll try to find out the reason. lol

Re: What file did you edit?

Reply #37

Something else I've noticed when trying to add to forms in various places. If the start and end of the form, essentially the form tag and the closing tag, were moved into their own layer it would be easier to add another layer when adding options to the form.

 It was possible with the post form because its in multiple parts, but to add settings to, for instance, the modify board form, you have to edit the template.


Re: What file did you edit?

Reply #38

The boards list class has no way of altering the database query to add or alter information in $context['categories'] for the main board index.  I can use a module to run another query and add information but its information that could have easily been gathered in the original query.