Commit c1eb3c9b authored by Ayolo's avatar Ayolo

revert

parent 81085b16
......@@ -277,9 +277,8 @@ class forum extends basedb
{
$grps = $user->get_groups_csv();
$query .= "AND ((droits_acces_forum & 0x1) OR " .
"((droits_acces_forum & 0x10) AND frm_forum.id_groupe IN ($grps)) OR " .
"(id_groupe_admin IN ($grps))) ".
"AND (frm_sujet.id_groupe IN ($grps) OR frm_sujet.id_groupe IS NULL) ";
"((droits_acces_forum & 0x10) AND id_groupe IN ($grps)) OR " .
"(id_groupe_admin IN ($grps))) ";
}
$query .= "ORDER BY frm_forum.ordre_forum";
......@@ -295,7 +294,6 @@ class forum extends basedb
function get_sujets ( &$user, $st, $npp )
{
$grps = $user->get_groups_csv();
$query = "SELECT frm_sujet.*, ".
"frm_message.date_message, " .
"frm_message.id_message, " .
......@@ -309,6 +307,7 @@ class forum extends basedb
CONCAT(premier_auteur.prenom_utl,' ',premier_auteur.nom_utl)
) AS `nom_utilisateur_premier_auteur`, " .
"premier_auteur.id_utilisateur AS `id_utilisateur_premier`, ";
if ( !$user->is_valid() )
$query .= "0 AS `nonlu`, 0 AS `etoile` ";
elseif( is_null($user->tout_lu_avant))
......@@ -335,8 +334,6 @@ class forum extends basedb
$query .= "WHERE " .
"id_forum='".$this->id."' ";
if ( !$this->is_admin( $user ) )
$query .= "AND (id_groupe IN ($grps) OR id_groupe IS NULL)";
$query .= "ORDER BY frm_sujet.type_sujet=2 DESC, frm_message.date_message DESC ";
$query .= "LIMIT $st, $npp";
......
......@@ -36,7 +36,7 @@ define("SUJET_ANNONCESITE",4);
/**
* Sujet dans un forum
*/
class sujet extends basedb
class sujet extends stdentity
{
var $id_utilisateur;
......@@ -62,18 +62,18 @@ class sujet extends basedb
function load_by_id ( $id )
{
$req = new requete($this->db, "SELECT * FROM `frm_sujet`
WHERE `id_sujet` = '" .
mysql_real_escape_string($id) . "'
LIMIT 1");
WHERE `id_sujet` = '" .
mysql_real_escape_string($id) . "'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
function _load($row)
......@@ -93,12 +93,11 @@ class sujet extends basedb
$this->id_nouvelle = $row["id_nouvelle"];
$this->id_catph = $row["id_catph"];
$this->id_sondage = $row["id_sondage"];
$this->id_groupe = $row['id_groupe'];
}
function create ( &$forum, $id_utilisateur, $titre, $soustitre=null,
$type=SUJET_NORMAL,$icon=null,$date_fin_annonce=null,
$id_nouvelle=null,$id_catph=null,$id_sondage=null, $id_groupe=null)
$id_nouvelle=null,$id_catph=null,$id_sondage=null )
{
/**@TODO: tester droit d'écriture*/
......@@ -122,7 +121,7 @@ class sujet extends basedb
$this->id_nouvelle=$id_nouvelle;
$this->id_catph=$id_catph;
$this->id_sondage=$id_sondage;
$this->id_groupe=$id_groupe;
$req = new insert ($this->dbrw,
"frm_sujet", array(
......@@ -139,25 +138,24 @@ class sujet extends basedb
"id_utilisateur_moderateur"=>$this->id_utilisateur_moderateur,
"id_nouvelle"=>$this->id_nouvelle,
"id_catph"=>$this->id_catph,
"id_sondage"=>$this->id_sondage,
"id_groupe"=>$this->id_groupe
"id_sondage"=>$this->id_sondage
));
if ( $req )
{
$this->id = $req->get_id();
$this->auto_user_star($forum,true);
return true;
}
$this->id = null;
if ( $req )
{
$this->id = $req->get_id();
$this->auto_user_star($forum,true);
return true;
}
$this->id = null;
return false;
}
// $forum->update_last_sujet();
function update ( $titre, $soustitre=null,
$type=SUJET_NORMAL,$icon=null,$date_fin_annonce=null,
$id_nouvelle=null,$id_catph=null,$id_sondage=null, $id_groupe=null )
$id_nouvelle=null,$id_catph=null,$id_sondage=null )
{
$this->titre=$titre;
......@@ -172,7 +170,7 @@ class sujet extends basedb
$this->id_nouvelle=$id_nouvelle;
$this->id_catph=$id_catph;
$this->id_sondage=$id_sondage;
$this->id_groupe=$id_groupe;
$req = new update ($this->dbrw,
"frm_sujet", array(
"id_forum"=>$this->id_forum,
......@@ -184,8 +182,7 @@ class sujet extends basedb
"id_utilisateur_moderateur"=>$this->id_utilisateur_moderateur,
"id_nouvelle"=>$this->id_nouvelle,
"id_catph"=>$this->id_catph,
"id_sondage"=>$this->id_sondage,
"id_groupe"=>$this->id_groupe
"id_sondage"=>$this->id_sondage
),
array("id_sujet"=>$this->id) );
......@@ -235,8 +232,8 @@ class sujet extends basedb
return;
$req = new requete($this->db,
"SELECT `id_utilisateur` FROM `asso_membre` " .
"WHERE `asso_membre`.`date_fin` IS NULL AND `asso_membre`.`id_asso`='".$forum->id_asso."' ");
"SELECT `id_utilisateur` FROM `asso_membre` " .
"WHERE `asso_membre`.`date_fin` IS NULL AND `asso_membre`.`id_asso`='".$forum->id_asso."' ");
while ( list($id_utilisateur) = $req->get_row() )
{
......@@ -251,14 +248,14 @@ class sujet extends basedb
/**
* Met à jour le dernier message posté et le nombre de messages
*/
function update_last_message ( &$forum )
function update_last_message ( &$forum )
{
$req = new requete($this->db,
"SELECT id_message ".
"FROM `frm_message` ".
"WHERE `id_sujet` = '". mysql_real_escape_string($this->id) . "' ".
"ORDER BY `date_message` DESC ".
"LIMIT 1");
"WHERE `id_sujet` = '". mysql_real_escape_string($this->id) . "' ".
"ORDER BY `date_message` DESC ".
"LIMIT 1");
if ( $req->lines == 0 )
{
......@@ -271,8 +268,8 @@ class sujet extends basedb
$req = new requete($this->db,
"SELECT COUNT(*) ".
"FROM `frm_message` ".
"WHERE `id_sujet` = '". mysql_real_escape_string($this->id) . "' ");
"WHERE `id_sujet` = '". mysql_real_escape_string($this->id) . "' ");
list($this->nb_messages) = $req->get_row();
$req = new update ($this->dbrw, "frm_sujet",
......@@ -284,14 +281,14 @@ class sujet extends basedb
function get_user_infos ( $id_utilisateur )
{
$req = new requete($this->db, "SELECT id_message_dernier_lu, etoile_sujet FROM `frm_sujet_utilisateur`
WHERE `id_sujet` = '".mysql_real_escape_string($this->id) . "'
AND `id_utilisateur` = '".mysql_real_escape_string($id_utilisateur) . "'
LIMIT 1");
if ( $req->lines == 0 )
return null;
return $req->get_row();
WHERE `id_sujet` = '".mysql_real_escape_string($this->id) . "'
AND `id_utilisateur` = '".mysql_real_escape_string($id_utilisateur) . "'
LIMIT 1");
if ( $req->lines == 0 )
return null;
return $req->get_row();
}
/**
......@@ -307,7 +304,7 @@ class sujet extends basedb
if ( is_null($row) )
return null;
return $row['id_message_dernier_lu'];
return $row['id_message_dernier_lu'];
}
/**
......@@ -379,12 +376,12 @@ class sujet extends basedb
$req = new requete($this->db,$query);
$rows = array();
while ( $row = $req->get_row() )
$rows[] = $row;
return $rows;
$rows = array();
while ( $row = $req->get_row() )
$rows[] = $row;
return $rows;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment