Source of file MemberDashboard.php
Size: 2,332 Bytes - Last Modified: 2021-12-23T10:31:31+00:00
/var/www/docs.ssmods.com/process/src/code/dataobjects/MemberDashboard.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 | <?php /** * @author Marcus Nyeholt <marcus@silverstripe.com.au> * @license BSD http://silverstripe.org/BSD-license */ class MemberDashboard extends WidgetArea { public $template = __CLASS__; public $parent; private static $has_one = array( 'Dashboard' => 'DashboardPage', ); private static $extensions = array( 'Restrictable' ); private static $summary_fields = array( 'ID', 'ClassName' ); public function addDashlet(Dashlet $dashlet) { $dashlet->ParentID = $this->ID; // get all dashlets and figure out a posX and posY $all = $this->Widgets(); $maxY = 0; foreach ($all as $d) { if ($d->PosY > $maxY) { $maxY = $d->PosY + 1; } } $dashlet->PosY = $maxY > 1 ? $maxY : 1; $dashlet->write(); } public function WidgetControllers() { $set = new ArrayList(); $items = $this->ItemsToRender(); foreach ($items as $dashlet) { $class = ''; foreach (array_reverse(ClassInfo::ancestry($dashlet->class)) as $class) { if (class_exists($class = "{$class}_Controller")) { break; } } $controller = Injector::inst()->create($class, $dashlet, $this->parent->getController()); $controller->init(); $set->push($controller); } return $set; } public function permissionSource() { return $this->Dashboard(); } public function getCMSFields() { $fields = parent::getCMSFields(); $grid = $fields->dataFieldByName('Widgets'); if ($grid) { $grid->setModelClass('Dashlet'); } return $fields; } public function onBeforeDelete() { if (Widget::has_extension('Versioned')) { $currentStage = Versioned::current_stage(); Versioned::reading_stage('Stage'); parent::onBeforeDelete(); Versioned::reading_stage('Live'); parent::onBeforeDelete(); Versioned::reading_stage($currentStage); } else { parent::onBeforeDelete(); } } } |