Пример #1
0
/**
 * Menu gauche affichage des sites via select
 *
 * @param string $link
 * @param string $current_site
 * @param string $year
 * @param string $month
 * @param string $day
 * @param string $user
 * @return string
 */
function make_site_select_html($link, $current_site, $year, $month, $day, $user)
{
    global $vocab;
    $nb_sites_a_afficher = 0;
    $out_html = '<b><i>' . get_vocab('sites') . get_vocab('deux_points') . '</i></b><form id="site_001" action="' . $_SERVER['PHP_SELF'] . '"><div>';
    $out_html .= '<select class="form-control" name="site" onchange="site_go()">';
    if (strncmp("4.1", grr_sql_version(), 3) < 0) {
        $sql = "SELECT id,sitename\n\t\tFROM " . TABLE_PREFIX . "_site\n\t\tWHERE " . TABLE_PREFIX . "_site.id IN (SELECT id_site FROM " . TABLE_PREFIX . "_j_site_area GROUP BY id_site)\n\t\tORDER BY id ASC";
    } else {
        $sql = "SELECT id, sitename\n\t\tFROM " . TABLE_PREFIX . "_site\n\t\tleft join " . TABLE_PREFIX . "_j_site_area on " . TABLE_PREFIX . "_site.id = " . TABLE_PREFIX . "_j_site_area.id_site\n\t\tWHERE " . TABLE_PREFIX . "_j_site_area.id_site is not null\n\t\tGROUP BY id_site\n\t\tORDER BY id ASC\n\t\t";
    }
    $res = grr_sql_query($sql);
    if ($res) {
        for ($i = 0; $row = grr_sql_row($res, $i); $i++) {
            // Pour chaque site, on détermine le premier domaine disponible
            $sql = "SELECT id_area\n\t\t\tFROM " . TABLE_PREFIX . "_j_site_area\n\t\t\tWHERE " . TABLE_PREFIX . "_j_site_area.id_site='" . $row[0] . "'";
            $res2 = grr_sql_query($sql);
            // A on un résultat ?
            $default_area = -1;
            if ($res2 && grr_sql_count($res2) > 0) {
                for ($j = 0; $row2 = grr_sql_row($res2, $j); $j++) {
                    if (authUserAccesArea($user, $row2[0]) == 1) {
                        // on a trouvé un domaine autorisé
                        $default_area = $row2[0];
                        $j = grr_sql_count($res2) + 1;
                        // On arrête la boucle
                    }
                }
            }
            // On libère la ressource2
            grr_sql_free($res2);
            if ($default_area != -1) {
                // on affiche le site uniquement si au moins un domaine est visible par l'utilisateur
                $nb_sites_a_afficher++;
                $selected = $row[0] == $current_site ? 'selected="selected"' : '';
                $link2 = $link . '?year=' . $year . '&amp;month=' . $month . '&amp;day=' . $day . '&amp;area=' . $default_area;
                $out_html .= '<option ' . $selected . ' value="' . $link2 . '">' . htmlspecialchars($row[1]) . '</option>' . PHP_EOL;
            }
        }
    }
    if ($nb_sites_a_afficher > 1) {
        $out_html .= "</select>" . PHP_EOL;
        $out_html .= "</div>" . PHP_EOL;
        $out_html .= "<script type=\"text/javascript\">" . PHP_EOL;
        $out_html .= "function site_go()" . PHP_EOL;
        $out_html .= "{" . PHP_EOL;
        $out_html .= "box = document.getElementById(\"site_001\").site;" . PHP_EOL;
        $out_html .= "destination = box.options[box.selectedIndex].value;" . PHP_EOL;
        $out_html .= "if (destination) location.href = destination;" . PHP_EOL;
        $out_html .= "}" . PHP_EOL;
        $out_html .= "</script>" . PHP_EOL;
        $out_html .= "<noscript>" . PHP_EOL;
        $out_html .= "<div>" . PHP_EOL;
        $out_html .= "<input type=\"submit\" value=\"Change\" />" . PHP_EOL;
        $out_html .= "</div>" . PHP_EOL;
        $out_html .= "</noscript>" . PHP_EOL;
        $out_html .= "</form>" . PHP_EOL;
        return $out_html;
    }
}
Пример #2
0
// Calcul de la chaine à afficher
if ($version_grr_RC == "") {
    $display_version_grr = $version_grr.$sous_version_grr;
} else {
    $display_version_grr = $version_grr."_RC".$version_grr_RC;
}

echo "<h2>".get_vocab('admin_maj.php').grr_help("aide_grr_maj")."</h2>";

echo "<hr />";
// Numéro de version
echo "<h3>".get_vocab("num_version_title")."</h3>\n";
echo "<p>".get_vocab("num_version").$display_version_grr;
echo "</p>\n";

echo get_vocab('database') . grr_sql_version() . "\n";
echo "<br />" . get_vocab('system') . php_uname() . "\n";
echo "<br />Version PHP : " . phpversion() . "\n";


echo "<p>".get_vocab("maj_go_www")."<a href=\"".$grr_devel_url."\">".get_vocab("mrbs")."</a></p>\n";
echo "<hr />\n";
// Mise à jour de la base de donnée
echo "<h3>".get_vocab("maj_bdd")."</h3>";
// Vérification du numéro de version
if (verif_version()) {
    echo "<form action=\"admin_maj.php\" method=\"post\">";
    echo "<p><span style=\"color:red;\"><b>".get_vocab("maj_bdd_not_update");
    echo " ".get_vocab("maj_version_bdd").$display_version_old;
    echo "</b></span><br />";
    echo get_vocab("maj_do_update")."<b>".$display_version_grr."</b></p>";
Пример #3
0
/**
 * Fonction qui fait un render du template de champs de formulaire $fieldType,
 * pour selectionner le site à afficher.
 * @param $link
 * @param $current_site
 * @param $year
 * @param $month
 * @param $day
 * @param $user
 * @param $fieldType
 * @return string
 */
function make_site_selection_fields($link, $current_site, $year, $month, $day, $user, $fieldType)
{
    /**
     * init twig et le tableau
     */
    global $twig;
    $tplArray['fieldType'] = $fieldType;
    $nb_sites_a_afficher = 0;
    $tplArray['vocab']['sites'] = get_vocab('sites');
    $tplArray['vocab']['deux_points'] = get_vocab('deux_points');
    $tplArray['formAction'] = urlencode(strip_tags($_SERVER['PHP_SELF']));
    /*$out_html = '<b><i>'.get_vocab('sites').get_vocab('deux_points').'</i></b><form id="site_001" action="'.$_SERVER['PHP_SELF'].'"><div>';
      $out_html .= '<select class="form-control" name="site" onchange="site_go()">';*/
    if (strncmp('4.1', grr_sql_version(), 3) < 0) {
        $sql = 'SELECT id,sitename
		FROM ' . TABLE_PREFIX . '_site
		WHERE ' . TABLE_PREFIX . '_site.id IN (SELECT id_site FROM ' . TABLE_PREFIX . '_j_site_area GROUP BY id_site)
		ORDER BY id ASC';
    } else {
        $sql = 'SELECT id, sitename
		FROM ' . TABLE_PREFIX . '_site
		left join ' . TABLE_PREFIX . '_j_site_area on ' . TABLE_PREFIX . '_site.id = ' . TABLE_PREFIX . '_j_site_area.id_site
		WHERE ' . TABLE_PREFIX . '_j_site_area.id_site is not null
		GROUP BY id_site
		ORDER BY id ASC
		';
    }
    $res = grr_sql_query($sql);
    if ($res) {
        for ($i = 0; $row = grr_sql_row($res, $i); ++$i) {
            // Pour chaque site, on détermine le premier domaine disponible
            $sql = 'SELECT id_area
			FROM ' . TABLE_PREFIX . '_j_site_area
			WHERE ' . TABLE_PREFIX . "_j_site_area.id_site='" . $row[0] . "'";
            $res2 = grr_sql_query($sql);
            // A on un résultat ?
            $default_area = -1;
            if ($res2 && grr_sql_count($res2) > 0) {
                for ($j = 0; $row2 = grr_sql_row($res2, $j); ++$j) {
                    if (authUserAccesArea($user, $row2[0]) == 1) {
                        // on a trouvé un domaine autorisé
                        $default_area = $row2[0];
                        $j = grr_sql_count($res2) + 1;
                        // On arrête la boucle
                    }
                }
            }
            // On libère la ressource2
            grr_sql_free($res2);
            if ($default_area != -1) {
                // on affiche le site uniquement si au moins un domaine est visible par l'utilisateur
                ++$nb_sites_a_afficher;
                /**
                 * dans mon tableau pour chaque site j'ai si oui ou non c'est le site courant, le lien vers le site et le nom du site
                 * dans le template je construirai le form en fonction
                 */
                //$selected = ($row[0] == $current_site) ? 'selected="selected"' : '';
                $tplArray['sites'][$nb_sites_a_afficher]['current'] = $row[0] == $current_site ? true : false;
                //$link2 = $link.'?year='.$year.'&month='.$month.'&day='.$day.'&area='.$default_area;
                $tplArray['sites'][$nb_sites_a_afficher]['linkToDomaine'] = $link . '?year=' . $year . '&month=' . $month . '&day=' . $day . '&area=' . $default_area;
                /* j'a'joute un striptag, car j'ai pu entrer des tag html en bdd */
                $tplArray['sites'][$nb_sites_a_afficher]['txtOption'] = htmlspecialchars(strip_tags($row[1]));
                //$out_html .= '<option '.$selected.' value="'.$link2.'">'.htmlspecialchars($row[1]).'</option>'.PHP_EOL;
            }
        }
    }
    /* une fois les vérifications, si j'ai des sites à affichier je renvoi le render du template */
    if ($nb_sites_a_afficher > 1) {
        /*        $out_html .= '</select>'.PHP_EOL;
                  $out_html .= '</div>'.PHP_EOL;
                  $out_html .= '<script type="text/javascript">'.PHP_EOL;
                  $out_html .= 'function site_go()'.PHP_EOL;
                  $out_html .= '{'.PHP_EOL;
                  $out_html .= 'box = document.getElementById("site_001").site;'.PHP_EOL;
                  $out_html .= 'destination = box.options[box.selectedIndex].value;'.PHP_EOL;
                  $out_html .= 'if (destination) location.href = destination;'.PHP_EOL;
                  $out_html .= '}'.PHP_EOL;
                  $out_html .= '</script>'.PHP_EOL;
                  $out_html .= '<noscript>'.PHP_EOL;
                  $out_html .= '<div>'.PHP_EOL;
                  $out_html .= '<input type="submit" value="Change" />'.PHP_EOL;
                  $out_html .= '</div>'.PHP_EOL;
                  $out_html .= '</noscript>'.PHP_EOL;
                  $out_html .= '</form>'.PHP_EOL;*/
        return $tplArray;
        //return $twig->render('forms/siteFields.html.twig', $tplArray);
    }
    /* si je n'ai rien a afficher */
    return false;
}