/**
  * Save contact notification ways
  *
  * @param int $id The contact id
  * @param string $action The action
  * @param array $params The parameters to save
  */
 public static function saveNotificationWays($id, $action = 'add', $listWays = array())
 {
     $dbconn = Di::getDefault()->get('db_centreon');
     if ($action == 'update') {
         $contactInfos = ContactInfo::getIdByParameter('contact_id', $id);
         foreach ($contactInfos as $contactInfo) {
             ContactInfo::delete($contactInfo);
         }
     }
     if (count($listWays) > 0) {
         foreach ($listWays as $name => $params) {
             ContactInfo::insert(array('contact_id' => $id, 'info_key' => $name, 'info_value' => $params['value']));
         }
     }
 }
示例#2
0
 /**
  * 
  * @param type $contactId
  * @param type $grouped
  * @return type
  */
 public static function getContactInfo($contactId, $grouped = false)
 {
     $finalInfos = array();
     $contactInfos = ContactInfo::getList('*', -1, 0, null, 'ASC', array('contact_id' => $contactId));
     if ($grouped) {
         foreach ($contactInfos as $info) {
             if (!isset($finalInfos[$info['info_key']])) {
                 $finalInfos[$info['info_key']] = array();
             }
             $finalInfos[$info['info_key']][] = array('value' => $info['info_value'], 'id' => $info['contact_info_id']);
         }
     } else {
         $finalInfos = $contactInfos;
     }
     return $finalInfos;
 }
 /**
  *
  * @param string $userId
  * @return string
  */
 public static function getEmail($userId)
 {
     $contactEmail = array();
     $contactId = Contact::getParameters($userId, array('contact_id'));
     if (isset($contactId['contact_id'])) {
         $contactInfosId = ContactInfo::getIdByParameter('contact_id', $contactId['contact_id']);
         foreach ($contactInfosId as $id) {
             $contactInfos = ContactInfo::getParameters($id, array('info_key', 'info_value'));
             if ($contactInfos['info_key'] === 'email') {
                 $contactEmail[] = $contactInfos['info_value'];
             }
         }
     }
     return $contactEmail;
 }