[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorDashboardMovePanelController 4 extends PhabricatorDashboardController { 5 6 private $id; 7 8 public function willProcessRequest(array $data) { 9 $this->id = $data['id']; 10 } 11 12 public function processRequest() { 13 $request = $this->getRequest(); 14 $viewer = $request->getUser(); 15 16 $column_id = $request->getStr('columnID'); 17 $panel_phid = $request->getStr('objectPHID'); 18 $after_phid = $request->getStr('afterPHID'); 19 $before_phid = $request->getStr('beforePHID'); 20 21 $dashboard = id(new PhabricatorDashboardQuery()) 22 ->setViewer($viewer) 23 ->withIDs(array($this->id)) 24 ->needPanels(true) 25 ->requireCapabilities( 26 array( 27 PhabricatorPolicyCapability::CAN_VIEW, 28 PhabricatorPolicyCapability::CAN_EDIT, 29 )) 30 ->executeOne(); 31 if (!$dashboard) { 32 return new Aphront404Response(); 33 } 34 $panels = mpull($dashboard->getPanels(), null, 'getPHID'); 35 $panel = idx($panels, $panel_phid); 36 if (!$panel) { 37 return new Aphront404Response(); 38 } 39 40 $layout_config = $dashboard->getLayoutConfigObject(); 41 $layout_config->removePanel($panel_phid); 42 $panel_location_grid = $layout_config->getPanelLocations(); 43 44 $column_phids = idx($panel_location_grid, $column_id, array()); 45 $column_phids = array_values($column_phids); 46 if ($column_phids) { 47 $insert_at = 0; 48 foreach ($column_phids as $index => $phid) { 49 if ($phid === $before_phid) { 50 $insert_at = $index; 51 break; 52 } 53 if ($phid === $after_phid) { 54 $insert_at = $index + 1; 55 break; 56 } 57 } 58 59 $new_column_phids = $column_phids; 60 array_splice( 61 $new_column_phids, 62 $insert_at, 63 0, 64 array($panel_phid)); 65 } else { 66 $new_column_phids = array(0 => $panel_phid); 67 } 68 69 $panel_location_grid[$column_id] = $new_column_phids; 70 $layout_config->setPanelLocations($panel_location_grid); 71 $dashboard->setLayoutConfigFromObject($layout_config); 72 $dashboard->save(); 73 74 return id(new AphrontAjaxResponse())->setContent(''); 75 } 76 77 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |