Пример #1
0
 /**
  * Vyhledavani v záznamech objektu
  *
  * @param string $what hledaný výraz
  * @return array pole výsledků
  */
 public function searchString($what)
 {
     $results = array();
     $conds = array();
     $columns[] = $this->myKeyColumn;
     foreach ($this->useKeywords as $keyword => $keywordInfo) {
         if (strstr($keywordInfo, 'VARCHAR')) {
             $conds[] = " `{$keyword}` LIKE '%" . $what . "%'";
             $columns[] = "`{$keyword}`";
         }
     }
     $res = EaseShared::db()->queryToArray("SELECT " . implode(',', $columns) . "," . $this->nameColumn . " FROM " . $this->myTable . " WHERE " . implode(' OR ', $conds) . ' ORDER BY ' . $this->nameColumn, $this->myKeyColumn);
     foreach ($res as $result) {
         $occurences = '';
         foreach ($result as $key => $value) {
             if (strstr($value, $what)) {
                 $occurences .= '(' . $key . ': ' . $value . ') ';
             }
         }
         $results[$result[$this->myKeyColumn]] = array($this->nameColumn => $result[$this->nameColumn], 'what' => $occurences);
     }
     return $results;
 }
Пример #2
0
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
require_once 'classes/IESearcher.php';
$oPage->onlyForLogged();
$query = $oPage->getRequestValue('search', 'string');
$found = array();
$searcher = new IESearcher($oPage->getRequestValue('table', 'string'), $oPage->getRequestValue('column', 'string'));
if (strlen($query) < 2) {
    $oPage->addStatusMessage(_('Vyheldávaný řetězec je příliš krátký'), 'warning');
} else {
    $results = $searcher->searchAll(EaseShared::db()->EaseAddslashes($query));
    foreach ($results as $rectype => $records) {
        foreach ($records as $recid => $record) {
            $found[] = array('url' => $rectype . '.php?' . $rectype . '_id=' . $recid, 'name' => current($record), 'type' => $rectype, 'what' => $record['what']);
        }
    }
    if (count($found) == 1) {
        $oPage->addStatusMessage(_('Nalezen pouze jeden výsledek', 'success'));
        header('Location: ' . $found[0]['url'] . '&search=' . $query);
        exit;
    }
}
$oPage->addItem(new IEPageTop(_('Výsledky hledání')));
$listing = new EaseHtmlUlTag(null, array('class' => 'list-group'));
foreach ($found as $foundItem) {
    $listing->addItem(new EaseHtmlLiTag(new EaseHtmlATag($foundItem['url'], $foundItem['type'] . '&nbsp;<h4>' . $foundItem['name'] . '</h4>&nbsp;' . str_replace($query, '<strong>' . $query . '</strong>', $foundItem['what'])), array('class' => 'list-group-item')));
Пример #3
0
        $oPage->addStatusMessage(_('Kontakty odstraněni'), 'success');
    }
    if ($oPage->getRequestValue('contactgroup')) {
        EaseShared::db()->exeQuery('TRUNCATE TABLE `contactgroup`');
        $oPage->addStatusMessage(_('Skupiny kontaktů  byly odstraněny'), 'success');
    }
    if ($oPage->getRequestValue('service')) {
        EaseShared::db()->exeQuery('DELETE FROM `service` WHERE register=1');
        $oPage->addStatusMessage(_('Služby odstraněny'), 'success');
    }
    if ($oPage->getRequestValue('servicegroup')) {
        EaseShared::db()->exeQuery('TRUNCATE TABLE `servicegroup`');
        $oPage->addStatusMessage(_('Skupiny služeb byly odstraněny'), 'success');
    }
    if ($oPage->getRequestValue('desync')) {
        EaseShared::db()->exeQuery('UPDATE `host` SET config_hash = 0');
        $oPage->addStatusMessage(_('Stavy senzorů byly rozhasheny'), 'success');
    }
    if ($oPage->getRequestValue('sync')) {
        $host = new IEHost();
        $allHosts = $host->getListing();
        foreach ($allHosts as $hostId => $hostInfo) {
            $host->dataReset();
            $host->loadFromMySQL((int) $hostId);
            $host->setDataValue('config_hash', $host->getConfigHash());
            $host->saveToMySQL();
        }
        $oPage->addStatusMessage(sprintf(_('Stavy %s senzorů byly nastaveny'), count($allHosts)), 'success');
    }
}
$oPage->addItem(new IEPageTop(_('Reset objekt')));