Changeset 590:5f604a9e3c25 for admin/preferences.php
- Timestamp:
- 07/13/11 15:21:44 (13 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/preferences.php
r536 r590 44 44 $default_tab = !empty($_GET['tab']) ? html::escapeHTML($_GET['tab']) : 'user-profile'; 45 45 46 if (!empty($_GET['append']) || !empty($_GET['removed']) || !empty($_GET['neworder']) || !empty($_GET['replaced'])) { 46 if (!empty($_GET['append']) || !empty($_GET['removed']) || !empty($_GET['neworder']) || 47 !empty($_GET['replaced']) || !empty($_POST['appendaction']) || !empty($_POST['removeaction'])) { 47 48 $default_tab = 'user-favorites'; 48 49 } elseif (!empty($_GET['updated'])) { … … 122 123 123 124 # Update user options 124 if (isset($_POST['user_post_format'])) { 125 if (isset($_POST['user_post_format'])) 126 { 125 127 try 126 128 { … … 175 177 176 178 # Add selected favorites 177 if (!empty($_POST['appendaction']) && !empty($_POST['append'])) { 178 $ws = $core->auth->user_prefs->addWorkspace('favorites'); 179 $user_favs = $ws->DumpLocalPrefs(); 180 $count = count($user_favs); 181 foreach ($_POST['append'] as $k => $v) 182 { 179 if (!empty($_POST['appendaction'])) 180 { 181 try { 182 if (empty($_POST['append'])) { 183 throw new Exception(__('No favorite selected')); 184 } 185 186 $ws = $core->auth->user_prefs->addWorkspace('favorites'); 187 $user_favs = $ws->DumpLocalPrefs(); 188 $count = count($user_favs); 189 foreach ($_POST['append'] as $k => $v) 190 { 191 try { 192 $found = false; 193 foreach ($user_favs as $f) { 194 $f = unserialize($f['value']); 195 if ($f['name'] == $v) { 196 $found = true; 197 break; 198 } 199 } 200 if (!$found) { 201 $uid = sprintf("u%03s",$count); 202 $fav = array('name' => $_fav[$v][0],'title' => $_fav[$v][1],'url' => $_fav[$v][2],'small-icon' => $_fav[$v][3], 203 'large-icon' => $_fav[$v][4],'permissions' => $_fav[$v][5],'id' => $_fav[$v][6],'class' => $_fav[$v][7]); 204 $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string'); 205 $count++; 206 } 207 } catch (Exception $e) { 208 $core->error->add($e->getMessage()); 209 break; 210 } 211 } 212 213 if (!$core->error->flag()) { 214 http::redirect('preferences.php?append=1'); 215 } 216 } catch (Exception $e) { 217 $core->error->add($e->getMessage()); 218 } 219 } 220 221 # Delete selected favorites 222 if (!empty($_POST['removeaction'])) 223 { 224 try { 225 if (empty($_POST['remove'])) { 226 throw new Exception(__('No favorite selected')); 227 } 228 229 $ws = $core->auth->user_prefs->addWorkspace('favorites'); 230 foreach ($_POST['remove'] as $k => $v) 231 { 232 try { 233 $core->auth->user_prefs->favorites->drop($v); 234 } catch (Exception $e) { 235 $core->error->add($e->getMessage()); 236 break; 237 } 238 } 239 // Update pref_id values 183 240 try { 184 $found = false; 185 foreach ($user_favs as $f) { 186 $f = unserialize($f['value']); 187 if ($f['name'] == $v) { 188 $found = true; 189 break; 190 } 191 } 192 if (!$found) { 241 $user_favs = $ws->DumpLocalPrefs(); 242 $core->auth->user_prefs->favorites->dropAll(); 243 $count = 0; 244 foreach ($user_favs as $k => $v) 245 { 193 246 $uid = sprintf("u%03s",$count); 194 $fav = array('name' => $_fav[$v][0],'title' => $_fav[$v][1],'url' => $_fav[$v][2],'small-icon' => $_fav[$v][3], 195 'large-icon' => $_fav[$v][4],'permissions' => $_fav[$v][5],'id' => $_fav[$v][6],'class' => $_fav[$v][7]); 247 $f = unserialize($v['value']); 248 $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'], 249 'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']); 196 250 $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string'); 197 251 $count++; … … 199 253 } catch (Exception $e) { 200 254 $core->error->add($e->getMessage()); 201 break; 202 } 203 } 255 } 204 256 205 if (!$core->error->flag()) { 206 http::redirect('preferences.php?append=1'); 207 } 208 } 209 210 # Delete selected favorites 211 if (!empty($_POST['removeaction']) && !empty($_POST['remove'])) { 212 $ws = $core->auth->user_prefs->addWorkspace('favorites'); 213 foreach ($_POST['remove'] as $k => $v) 214 { 215 try { 216 $core->auth->user_prefs->favorites->drop($v); 217 } catch (Exception $e) { 218 $core->error->add($e->getMessage()); 219 break; 220 } 221 } 222 // Update pref_id values 223 try { 224 $user_favs = $ws->DumpLocalPrefs(); 225 $core->auth->user_prefs->favorites->dropAll(); 226 $count = 0; 227 foreach ($user_favs as $k => $v) 228 { 229 $uid = sprintf("u%03s",$count); 230 $f = unserialize($v['value']); 231 $fav = array('name' => $f['name'],'title' => $f['title'],'url' => $f['url'],'small-icon' => $f['small-icon'], 232 'large-icon' => $f['large-icon'],'permissions' => $f['permissions'],'id' => $f['id'],'class' => $f['class']); 233 $core->auth->user_prefs->favorites->put($uid,serialize($fav),'string'); 234 $count++; 257 if (!$core->error->flag()) { 258 http::redirect('preferences.php?removed=1'); 235 259 } 236 260 } catch (Exception $e) { 237 261 $core->error->add($e->getMessage()); 238 }239 240 if (!$core->error->flag()) {241 http::redirect('preferences.php?removed=1');242 262 } 243 263 }
Note: See TracChangeset
for help on using the changeset viewer.