Changeset 1940:0fb7e85337bf for plugins/maintenance/_admin.php
- Timestamp:
- 09/18/13 10:51:42 (12 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/maintenance/_admin.php
r1925 r1940 24 24 $core->addBehavior('dcMaintenanceRegister', array('dcMaintenanceAdmin', 'register')); 25 25 $core->addBehavior('adminDashboardFavs', array('dcMaintenanceAdmin', 'favs')); 26 $core->addBehavior('adminDashboardFavsIcon', array('dcMaintenanceAdmin', 'favsicon')); 27 $core->addBehavior('adminPreferencesForm', array('dcMaintenanceAdmin', 'prefform')); 28 $core->addBehavior('adminBeforeUserOptionsUpdate', array('dcMaintenanceAdmin', 'userupd')); 26 29 27 30 /** … … 35 38 { 36 39 /** 37 * Register default tasks 40 * Register default tasks. 38 41 * 39 42 * @param $core <b>dcCore</b> dcCore instance … … 57 60 58 61 /** 59 * Dashboard favs 62 * Dashboard favs. 60 63 * 61 64 * @param $core <b>dcCore</b> dcCore instance … … 74 77 } 75 78 76 /** @todo Rminder*/ 79 /** 80 * Dashboard favs icon. 81 * 82 * This updates maintenance fav icon text 83 * if there are tasks required maintenance. 84 * 85 * @param $core <b>dcCore</b> dcCore instance 86 * @param $name <b>string</b> Current fav name 87 * @param $icon <b>arrayObject</b> Current fav attributes 88 */ 89 public static function favsicon($core, $name, $icon) 90 { 91 // Check icon 92 if ($name !== 'maintenance') { 93 return null; 94 } 95 96 // Check user option 97 $user_options = $core->auth->getOptions(); 98 if (empty($user_options['user_maintenance_expired'])) { 99 return null; 100 } 101 102 // Check expired tasks 103 $maintenance = new dcMaintenance($core); 104 $expired = $maintenance->getExpired(); 105 $expired = count($expired); 106 if (!$expired) { 107 return null; 108 } 109 110 $icon[0] .= '<br />'.sprintf(__('One task to update', '%s tasks to update', $expired), $expired); 111 } 112 113 /** 114 * User preferences form. 115 * 116 * This add options for superadmin user 117 * to show or not expired taks. 118 * 119 * @param $args <b>object</b> dcCore instance or record 120 */ 121 public static function prefform($args) 122 { 123 $opts = array(); 124 if ($args instanceof dcCore) { 125 $opts = $args->auth->getOptions(); 126 $core = $args; 127 } 128 elseif ($args instanceof record) { 129 $opts = $args->options(); 130 $core = $args->core; 131 } 132 133 echo 134 '<p><label for="user_maintenance_expired" class="classic">'. 135 form::checkbox('user_maintenance_expired', 1, !empty($opts['user_maintenance_expired'])).' '. 136 __('Show maintenance tasks to update.').'</label></p>'; 137 } 138 139 /** 140 * User preferences update. 141 * 142 * @param $cur <b>cursor</b> Cursor of user options 143 * @param $user_id <b>string</b> User ID 144 */ 145 public static function userupd($cur, $user_id=null) 146 { 147 if (!is_null($user_id)) { 148 $cur->user_options['user_maintenance_expired'] = !empty($_POST['user_maintenance_expired']); 149 } 150 } 77 151 }
Note: See TracChangeset
for help on using the changeset viewer.