/**
  * Edit a delivery template instance
  *
  * @access public
  * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
  * @return void
  */
 public function editTemplate()
 {
     $clazz = $this->getCurrentClass();
     $delivery = $this->getCurrentInstance();
     $formContainer = new DeliveryForm($clazz, $delivery);
     $myForm = $formContainer->getForm();
     $myForm->evaluate();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $propertyValues = $myForm->getValues();
             // then save the property values as usual
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($delivery);
             $delivery = $binder->bind($propertyValues);
             // edit process label:
             $this->service->onChangeLabel($delivery);
             $this->setData("selectNode", tao_helpers_Uri::encode($delivery->getUri()));
             $this->setData('message', __('Delivery saved'));
             $this->setData('reload', true);
         }
     }
     $this->setData('contentForm', $this->getContentForm());
     $this->setData('uri', tao_helpers_Uri::encode($delivery->getUri()));
     $this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri()));
     $this->setData('hasContent', !is_null($this->service->getContent($delivery)));
     $this->setData('formTitle', __('Delivery properties'));
     $this->setData('myForm', $myForm->render());
     if (\common_ext_ExtensionsManager::singleton()->isEnabled('taoCampaign')) {
         $this->setData('campaign', \taoCampaign_helpers_Campaign::renderCampaignTree($delivery));
     }
     $this->setView('DeliveryTemplate/editDelivery.tpl');
 }
 /**
  * Edit a delivery instance
  *
  * @access public
  * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
  * @return void
  */
 public function editDelivery()
 {
     $clazz = $this->getCurrentClass();
     $delivery = $this->getCurrentInstance();
     $formContainer = new DeliveryForm($clazz, $delivery);
     $myForm = $formContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $propertyValues = $myForm->getValues();
             // then save the property values as usual
             $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($delivery);
             $delivery = $binder->bind($propertyValues);
             $this->getEventManager()->trigger(new DeliveryUpdatedEvent($delivery->getUri(), $propertyValues));
             $this->setData("selectNode", \tao_helpers_Uri::encode($delivery->getUri()));
             $this->setData('message', __('Delivery saved'));
             $this->setData('reload', true);
         }
     }
     $this->setData('label', $delivery->getLabel());
     // history
     $this->setData('date', $this->getClassService()->getCompilationDate($delivery));
     if (\taoDelivery_models_classes_execution_ServiceProxy::singleton()->implementsMonitoring()) {
         $execs = \taoDelivery_models_classes_execution_ServiceProxy::singleton()->getExecutionsByDelivery($delivery);
         $this->setData('exec', count($execs));
     }
     // define the groups related to the current delivery
     $property = new core_kernel_classes_Property(PROPERTY_GROUP_DELVIERY);
     $tree = \tao_helpers_form_GenerisTreeForm::buildReverseTree($delivery, $property);
     $tree->setTitle(__('Assigned to'));
     $tree->setTemplate(Template::getTemplate('widgets/assignGroup.tpl'));
     $this->setData('groupTree', $tree->render());
     // testtaker brick
     $this->setData('assemblyUri', $delivery->getUri());
     // define the subjects excluded from the current delivery
     $property = new core_kernel_classes_Property(TAO_DELIVERY_EXCLUDEDSUBJECTS_PROP);
     $excluded = $delivery->getPropertyValues($property);
     $this->setData('ttexcluded', count($excluded));
     $users = $this->getServiceManager()->get('taoDelivery/assignment')->getAssignedUsers($delivery->getUri());
     $assigned = array_diff(array_unique($users), $excluded);
     $this->setData('ttassigned', count($assigned));
     $this->setData('formTitle', __('Properties'));
     $this->setData('myForm', $myForm->render());
     if (\common_ext_ExtensionsManager::singleton()->isEnabled('taoCampaign')) {
         $this->setData('campaign', taoCampaign_helpers_Campaign::renderCampaignTree($delivery));
     }
     $this->setView('DeliveryMgmt/editDelivery.tpl');
 }