osclass/Osclass — pull request #953 by gpoole (2013-08-27 07:03:00+00:00)
Title: Some additional item hooks and enhancements to existing hooks

During development of a custom theme for my team's implementation of Osclass, I was required to make several changes to the core to use some of the hooks. The biggest change that I believe is quite useful is that the 'init' hook called by each controller (subclasses of BaseModel) is now passed an instance of the controller. This allows for the hook to use some extra getters I added to determine things about the controller it's being called by:
```php
function example_hook($model) {
// If the model we've been given is an admin module we don't want to run the hook
if($model->isAdmin()) {
return;
}
}
osc_add_hook('init', 'example_hook');
```

Our implementation also required using the Moreedit plugin to force all ads to be approved by the administrator before being visible to other users. Unfortunately this prevents the user from being able to see their listings that have been blocked, so I found it useful to extend the user's listing panel to allow blocked entries to be turned on or off. It's now also possible to call findItemTypesByUserID and countItemTypesByUserID with multiple item types:
```php
// Retrieve all the blocked, active and expired items for the current user
Item::newInstance()->findItemTypesByUserID(osc_logged_user_id(), $page * $itemsPerPage, $itemsPerPage, array('blocked', 'active', 'expired'));
```

It was also useful to add some pre- and post-save hooks for item edits. We're using this to redirect our users using a custom plugin but I could imagine this being useful to other plugins too.