function get_default_area($id_site = -1) { if (Settings::get("module_multisite") == "Oui") { $use_multisite = true; } else { $use_multisite = false; } if (OPTION_IP_ADR == 1) { $sql = "SELECT ip_adr, id FROM " . TABLE_PREFIX . "_area WHERE ip_adr!='' ORDER BY access, order_display, area_name"; $res = grr_sql_query($sql); if ($res) { for ($i = 0; $row = grr_sql_row($res, $i); $i++) { if (compare_ip_adr($_SERVER['REMOTE_ADDR'], $row[0])) { return $row[1]; } } } } if (authGetUserLevel(getUserName(), -1) >= 6) { if ($id_site != -1 and $use_multisite) { $res = grr_sql_query("SELECT a.id\n\t\t\t\tFROM " . TABLE_PREFIX . "_area a, " . TABLE_PREFIX . "_j_site_area j\n\t\t\t\tWHERE a.id=j.id_area and j.id_site={$id_site}\n\t\t\t\tORDER BY a.order_display, a.area_name"); } else { $res = grr_sql_query("SELECT id FROM " . TABLE_PREFIX . "_area ORDER BY access, order_display, area_name"); } } else { if ($id_site != -1 and $use_multisite) { $res = grr_sql_query("SELECT a.id\n\t\t\t\tFROM " . TABLE_PREFIX . "_area a, " . TABLE_PREFIX . "_j_site_area j\n\t\t\t\tWHERE a.id=j.id_area and j.id_site={$id_site} and a.access!='r'\n\t\t\t\tORDER BY a.order_display, a.area_name"); } else { $res = grr_sql_query("SELECT id FROM " . TABLE_PREFIX . "_area WHERE access!='r' ORDER BY access, order_display, area_name"); } } if ($res && grr_sql_count($res) > 0) { $row = grr_sql_row($res, 0); grr_sql_free($res); return $row[0]; } else { if ($id_site != -1 and $use_multisite) { $res = grr_sql_query("SELECT a.id\n\t\t\t\tFROM " . TABLE_PREFIX . "_area a, " . TABLE_PREFIX . "_j_site_area j, " . TABLE_PREFIX . "_j_user_area u\n\t\t\t\tWHERE a.id=j.id_area and j.id_site={$id_site} and a.id=u.id_area and u.login='******'\n\t\t\t\tORDER BY a.order_display, a.area_name"); } else { $res = grr_sql_query("select id from " . TABLE_PREFIX . "_area, " . TABLE_PREFIX . "_j_user_area WHERE\n\t\t\t\t" . TABLE_PREFIX . "_area.id=" . TABLE_PREFIX . "_j_user_area.id_area and\n\t\t\t\tlogin='******'\n\t\t\t\tORDER BY order_display, area_name"); } if ($res && grr_sql_count($res) > 0) { $row = grr_sql_row($res, 0); grr_sql_free($res); return $row[0]; } else { return -1; } } }
function get_default_area($id_site=-1) { if (getSettingValue("module_multisite") == "Oui") $use_multisite = TRUE; else $use_multisite = FALSE; if (OPTION_IP_ADR==1) { // Affichage d'un domaine par defaut en fonction de l'adresse IP de la machine cliente /*if (($id_site != -1) and ($use_multisite)) $sql= "SELECT a.ip_adr, a.id FROM ".TABLE_PREFIX."_area a, ".TABLE_PREFIX."_j_site_area j WHERE a.id=j.id_area and j.id_site=$id_site and a.ip_adr!='' ORDER BY a.access, a.order_display, a.area_name"; else */ $sql = "SELECT ip_adr, id FROM ".TABLE_PREFIX."_area WHERE ip_adr!='' ORDER BY access, order_display, area_name"; $res = grr_sql_query($sql); if ($res) { for ($i = 0; ($row = grr_sql_row($res, $i)); $i++) { if (compare_ip_adr($_SERVER['REMOTE_ADDR'],$row[0])) { return $row[1];} } } } if(authGetUserLevel(getUserName(),-1) >= 6) // si l'admin est connecté, on cherche le premier domaine venu if (($id_site != -1) and ($use_multisite)) $res = grr_sql_query("SELECT a.id FROM ".TABLE_PREFIX."_area a, ".TABLE_PREFIX."_j_site_area j WHERE a.id=j.id_area and j.id_site=$id_site ORDER BY a.order_display, a.area_name"); else $res = grr_sql_query("SELECT id FROM ".TABLE_PREFIX."_area ORDER BY access, order_display, area_name"); else // s'il ne s'agit pas de l'admin, on cherche le premier domaine à accès non restreint if (($id_site != -1) and ($use_multisite)) $res = grr_sql_query("SELECT a.id FROM ".TABLE_PREFIX."_area a, ".TABLE_PREFIX."_j_site_area j WHERE a.id=j.id_area and j.id_site=$id_site and a.access!='r' ORDER BY a.order_display, a.area_name"); else $res = grr_sql_query("SELECT id FROM ".TABLE_PREFIX."_area where access!='r' ORDER BY access, order_display, area_name"); if ($res && grr_sql_count($res)>0 ) { $row = grr_sql_row($res, 0); grr_sql_free($res); return $row[0]; } else { // On cherche le premier domaine à accès restreint if (($id_site != -1) and ($use_multisite)) $res = grr_sql_query("SELECT a.id FROM ".TABLE_PREFIX."_area a, ".TABLE_PREFIX."_j_site_area j, ".TABLE_PREFIX."_j_user_area u WHERE a.id=j.id_area and j.id_site=$id_site and a.id=u.id_area and u.login='******' ORDER BY a.order_display, a.area_name"); else $res = grr_sql_query("select id from ".TABLE_PREFIX."_area, ".TABLE_PREFIX."_j_user_area where ".TABLE_PREFIX."_area.id=".TABLE_PREFIX."_j_user_area.id_area and login='******' ORDER BY order_display, area_name"); if ($res && grr_sql_count($res)>0 ) { $row = grr_sql_row($res, 0); grr_sql_free($res); return $row[0]; } else return -1; } }