コード例 #1
0
 /**
  * Get Image Id
  *
  * @param string $imagename
  * @param int|null
  */
 public function getImageId($imagename)
 {
     $tab = preg_split("/\\//", $imagename);
     isset($tab[0]) ? $dirname = $tab[0] : ($dirname = null);
     isset($tab[1]) ? $imagename = $tab[1] : ($imagename = null);
     if (!isset($imagename) || !isset($dirname)) {
         return null;
     }
     $query = "SELECT img.img_id " . "FROM view_img_dir dir, view_img_dir_relation rel, view_img img " . "WHERE dir.dir_id = rel.dir_dir_parent_id " . "AND rel.img_img_id = img.img_id " . "AND img.img_path = '" . $imagename . "' " . "AND dir.dir_name = '" . $dirname . "' " . "LIMIT 1";
     $db = Centreon_Db_Manager::factory('centreon');
     $res = $db->query($query);
     $img_id = null;
     $row = $res->fetch();
     if (isset($row['img_id']) && $row['img_id']) {
         $img_id = $row['img_id'];
     }
     return $img_id;
 }
コード例 #2
0
 /**
  * Constructor
  *
  * @return void
  */
 public function __construct()
 {
     $this->db = Centreon_Db_Manager::factory('centreon');
 }
コード例 #3
0
 /**
  * Insert audit log
  *
  * @param string $actionType
  * @param int $objId
  * @param string $objName
  * @param array $objValues
  */
 public function addAuditLog($actionType, $objId, $objName, $objValues = array())
 {
     $objType = strtoupper($this->action);
     $objectTypes = array('HTPL' => 'host', 'STPL' => 'service', 'CONTACT' => 'contact', 'SG' => 'servicegroup', 'TP' => 'timeperiod', 'SERVICE' => 'service', 'CG' => 'contactgroup', 'CMD' => 'command', 'HOST' => 'host', 'HC' => 'hostcategories', 'HG' => 'hostgroup', 'SC' => 'servicecategories');
     if (!isset($objectTypes[$objType])) {
         return null;
     }
     $objType = $objectTypes[$objType];
     $contactObj = new Centreon_Object_Contact();
     $contact = $contactObj->getIdByParameter('contact_alias', CentreonUtils::getUserName());
     $userId = $contact[0];
     $dbstorage = Centreon_Db_Manager::factory('storage');
     $query = 'INSERT INTO log_action
         (action_log_date, object_type, object_id, object_name, action_type, log_contact_id)
         VALUES (?, ?, ?, ?, ?, ?)';
     $time = time();
     $dbstorage->query($query, array($time, $objType, $objId, $objName, $actionType, $userId));
     $query = 'SELECT MAX(action_log_id) as action_log_id
         FROM log_action
         WHERE action_log_date = ?';
     $stmt = $dbstorage->query($query, array($time));
     $row = $stmt->fetch();
     if (false === $row) {
         throw new CentreonClapiException("Error while inserting log action");
     }
     $stmt->closeCursor();
     $actionId = $row['action_log_id'];
     $query = 'INSERT INTO log_action_modification
         (field_name, field_value, action_log_id)
         VALUES (?, ?, ?)';
     foreach ($objValues as $name => $value) {
         try {
             if (is_array($value)) {
                 $value = implode(',', $value);
             }
             if (is_null($value)) {
                 $value = '';
             }
             $dbstorage->query($query, array($name, $value, $actionId));
         } catch (Exception $e) {
             throw $e;
         }
     }
 }
コード例 #4
0
ファイル: Relation.php プロジェクト: euidzero/centreon-clapi
 /**
  * Constructor
  *
  * @return void
  */
 public function __construct()
 {
     $this->db = Centreon_Db_Manager::factory('centreon');
     $this->cache = Centreon_Cache_Manager::factory('centreonRelations');
     $this->useCache = false;
 }
コード例 #5
0
ファイル: Object.php プロジェクト: euidzero/centreon-clapi
 /**
  * Constructor
  *
  * @return void
  */
 public function __construct()
 {
     $this->db = Centreon_Db_Manager::factory('centreon');
     $this->cache = Centreon_Cache_Manager::factory('centreonObjects', 60, '/tmp/');
     $this->useCache = false;
 }