Esempio n. 1
0
 public function __construct(array $path)
 {
     // Actions
     if ($path['id']) {
         if (DataCenterPage::userCan('remove')) {
             $this->actions['remove'] = array('page' => 'plans', 'type' => $path['type'], 'action' => 'remove', 'id' => $path['id']);
         }
         if (DataCenterPage::userCan('change')) {
             $this->actions['configure'] = array('page' => 'plans', 'type' => $path['type'], 'action' => 'configure', 'id' => $path['id']);
         }
         $this->actions['view'] = array('page' => 'plans', 'type' => $path['type'], 'action' => 'view', 'id' => $path['id']);
     }
     // Trail
     if ($path['id']) {
         $type = $path['type'];
         $id = $path['id'];
     } elseif (is_array($path['parameter']) && count($path['parameter']) >= 2) {
         $type = $path['parameter'][0];
         $id = $path['parameter'][1];
     }
     if (isset($id, $type)) {
         $include = false;
         foreach (array_reverse(self::$steps) as $step) {
             if ($step == $type) {
                 $include = true;
             }
             if (!$include) {
                 continue;
             }
             if ($step == 'plan') {
                 $plan = DataCenterDB::getPlan($id);
                 $this->trail[$plan->get('name')] = array('page' => 'plans', 'type' => 'plan', 'action' => 'view', 'id' => $plan->getId());
             } else {
                 $link = DataCenterDB::getLink('asset', $id);
                 $this->trail[$link->get('name')] = array('page' => 'plans', 'type' => $step, 'action' => 'view', 'id' => $link->getId());
                 $id = $link->get('parent_link');
                 if ($id == null) {
                     $id = $link->get('plan');
                 }
             }
         }
         $this->trail = array_reverse($this->trail);
     }
 }