use anonymous function
This commit is contained in:
parent
fe7cf97bc5
commit
796119e0d2
1 changed files with 68 additions and 93 deletions
37
_admin.php
37
_admin.php
|
@ -16,29 +16,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
|
||||
require __DIR__ . '/_widgets.php';
|
||||
|
||||
# Dashboard item and user preference
|
||||
dcCore::app()->addBehavior(
|
||||
'adminDashboardItemsV2',
|
||||
['dcLatestVersionsAdmin', 'adminDashboardItems']
|
||||
);
|
||||
dcCore::app()->addBehavior(
|
||||
'adminDashboardOptionsFormV2',
|
||||
['dcLatestVersionsAdmin', 'adminDashboardOptionsForm']
|
||||
);
|
||||
dcCore::app()->addBehavior(
|
||||
'adminAfterDashboardOptionsUpdate',
|
||||
['dcLatestVersionsAdmin', 'adminAfterDashboardOptionsUpdate']
|
||||
);
|
||||
|
||||
/**
|
||||
* @ingroup DC_PLUGIN_DCLATESTVERSIONS
|
||||
* @brief Display latest versions of Dotclear - admin methods.
|
||||
* @since 2.6
|
||||
*/
|
||||
class dcLatestVersionsAdmin
|
||||
{
|
||||
public static function adminDashboardItems($__dashboard_items)
|
||||
{
|
||||
dcCore::app()->addBehavior('adminDashboardItemsV2', function($__dashboard_items) {
|
||||
if (!dcCore::app()->auth->user_prefs->dashboard->get('dcLatestVersionsItems')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -92,10 +70,9 @@ class dcLatestVersionsAdmin
|
|||
'<h3>' . html::escapeHTML(__("Dotclear's latest versions")) . '</h3>' .
|
||||
'<ul>' . implode('', $li) . '</ul>' .
|
||||
'</div>';
|
||||
}
|
||||
});
|
||||
|
||||
public static function adminDashboardOptionsForm()
|
||||
{
|
||||
dcCore::app()->addBehavior('adminDashboardOptionsFormV2', function() {
|
||||
if (!dcCore::app()->auth->user_prefs->dashboard->prefExists('dcLatestVersionsItems')) {
|
||||
dcCore::app()->auth->user_prefs->dashboard->put(
|
||||
'dcLatestVersionsItems',
|
||||
|
@ -113,14 +90,12 @@ class dcLatestVersionsAdmin
|
|||
__("Show Dotclear's latest versions on dashboards.") .
|
||||
'</label></p>' .
|
||||
'</div>';
|
||||
}
|
||||
});
|
||||
|
||||
public static function adminAfterDashboardOptionsUpdate($user_id)
|
||||
{
|
||||
dcCore::app()->addBehavior('adminAfterDashboardOptionsUpdate', function($user_id) {
|
||||
dcCore::app()->auth->user_prefs->dashboard->put(
|
||||
'dcLatestVersionsItems',
|
||||
!empty($_POST['dcLatestVersionsItems']),
|
||||
'boolean'
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue