Ejemplo n.º 1
0
 /**
  * Links an feature to a particular feature
  */
 public function linkfeatureAction()
 {
     $thisFeature = $this->byId();
     $feature = $this->byId($this->_getParam('featureid'), 'Feature');
     $linkType = $this->_getParam('linktype');
     if ($thisFeature == null) {
         $this->flash('Invalid feature specified');
         $this->redirect('feature', 'edit', array('id' => $this->_getParam('id'), '#features'));
         return;
     }
     if ($thisFeature == null || $feature == null) {
         $this->flash('Invalid Feature specified');
         $this->redirect('feature', 'edit', array('id' => $this->_getParam('id'), '#features'));
         return;
     }
     try {
         // okay, link the feature TO the feature
         if ($linkType == 'to') {
             $this->itemLinkService->parentChildLink($thisFeature, $feature);
             $this->flash("Linked feature '{$thisFeature->title}' to feature '{$feature->title}'");
         } else {
             $this->itemLinkService->parentChildLink($feature, $thisFeature);
             $this->flash("Linked feature '{$feature->title}' to feature '{$thisFeature->title}'");
         }
     } catch (Exception $e) {
         $this->flash("Failed linking items: " . $e->getMessage());
     }
     $params = array('id' => $this->_getParam('id'), '#features');
     if ($this->_getParam('_ajax')) {
         $params['_ajax'] = 1;
     }
     $this->redirect('feature', 'edit', $params);
 }
Ejemplo n.º 2
0
 /**
  * Create a link from another object to this task
  */
 public function linkfromAction()
 {
     $to = $this->byId();
     $from = $this->byId($this->_getParam('fromid'), $this->_getParam('fromtype'));
     if ($to && $from) {
         try {
             $this->itemLinkService->parentChildLink($from, $to);
             $this->flash("Successfully linked " . $from->title . " to " . $to->title);
         } catch (Exception $e) {
             $this->flash($e->getMessage());
         }
         if ($this->_getParam('_ajax')) {
             $this->redirect('task', 'edit', array('_ajax' => 1, 'id' => $to->id));
         } else {
             $this->_redirect($this->getCallingUrl());
         }
     }
 }