예제 #1
0
 /**
  * 
  * @param array $element
  * @return array
  */
 public static function renderHtmlInput(array $element)
 {
     $notificationWays = NotificationWayRepository::getNotificationWays();
     $contactId = $element['label_extra']['id'];
     $currentNotificationWays = ContactRepository::getContactInfo($contactId, false);
     $tpl = Di::getDefault()->get('template');
     $tpl->addCss('select2.css')->addCss('select2-bootstrap.css');
     $tpl->addJs('jquery.select2/select2.min.js')->addJs('centreon-clone.js')->addJs('component/notificationWay.js');
     $tpl->assign('notificationWays', $notificationWays);
     $tpl->assign('currentNotificationWays', $currentNotificationWays);
     return array('html' => $tpl->fetch('file:[Core]/form/component/notificationway.tpl'));
 }
예제 #2
0
 /**
  * Create a new host
  *
  * @method post
  * @route /contact/add
  */
 public function createAction()
 {
     $aTags = array();
     $givenParameters = $this->getParams('post');
     $id = parent::createAction(false);
     $listWays = array();
     if (isset($givenParameters['way_name']) && isset($givenParameters['way_value'])) {
         $wayName = $givenParameters['way_name'];
         $wayValue = $givenParameters['way_value'];
         foreach ($wayName as $key => $name) {
             if (!empty($name) && !empty($wayValue[$key])) {
                 $listWays[$name] = array('value' => $wayValue[$key]);
             }
         }
     }
     try {
         NotificationWayRepository::saveNotificationWays($id, 'create', $listWays);
     } catch (\Exception $ex) {
         $errorMessage = $ex->getMessage();
         $this->router->response()->json(array('success' => false, 'error' => $errorMessage));
     }
     if (isset($givenParameters['contact_tags'])) {
         $aTagList = explode(",", $givenParameters['contact_tags']);
         foreach ($aTagList as $var) {
             $var = trim($var);
             if (!empty($var)) {
                 array_push($aTags, $var);
             }
         }
         if (count($aTags) > 0) {
             TagsRepository::saveTagsForResource(self::$objectName, $id, $aTags, '', false, 1);
         }
     }
     $this->router->response()->json(array('success' => true));
 }