syntaxe POO (visibilite) et maj indentation
[mw_sourceml] / app / data / modules / xml / sml_data_authors.php
index 953ccfe..410227d 100644 (file)
@@ -1,46 +1,45 @@
 <?php
 
-  class sml_data_authors extends mw_data
-  {
+  class sml_data_authors extends mw_data{
 
-    var $groupes;
+    public $groupes;
 
     # ----------------------------------------------------------------------------------------
     #                                                                                  groupes
     #
 
-    function groupes($id_user = null, $start = null, $alpha = null)
-    { $sgbd = $this->sgbd();
+    public function groupes($id_user = null, $start = null, $alpha = null){
+      $sgbd = $this->sgbd();
       $env = $this->env();
       $groupes = array("list" => array(), "total" => 0);
-      if(true || isset($id_user))
-      { if($rst = $sgbd->open_data("sml_authors"))
-        { while($v_rst = $sgbd->fetch_data($rst))
-          { if(isset($v_rst))
-            { if(!isset($alpha) || (isset($v_rst["nom"]) && substr($v_rst["nom"], 0, 1) == $alpha))
-              { if(!isset($id_user) || (isset($v_rst["id_user"]) && $v_rst["id_user"] == $id_user))
-                { $groupes["total"]++;
+      if(true || isset($id_user)){
+        if($rst = $sgbd->open_data("sml_authors")){
+          while($v_rst = $sgbd->fetch_data($rst)){
+            if(isset($v_rst)){
+              if(!isset($alpha) || (isset($v_rst["nom"]) && substr($v_rst["nom"], 0, 1) == $alpha)){
+                if(!isset($id_user) || (isset($v_rst["id_user"]) && $v_rst["id_user"] == $id_user)){
+                  $groupes["total"]++;
                   $groupes["list"][$v_rst["id"]] = $v_rst;
                 }
               }
             }
-            else
-            { $groupes = false;
+            else{
+              $groupes = false;
               break;
             }
           }
           $sgbd->close_data($rst);
-          if($groupes !== false)
-          { $n = -1;
-            foreach($groupes["list"] as $id_groupe => $groupe)
-            { $n++;
-              if(isset($start) && $env->config("max_list") && ($n < $start || $n >= ($start + $env->config("max_list"))))
-              { unset($groupes["list"][$id_groupe]);
+          if($groupes !== false){
+            $n = -1;
+            foreach($groupes["list"] as $id_groupe => $groupe){
+              $n++;
+              if(isset($start) && $env->config("max_list") && ($n < $start || $n >= ($start + $env->config("max_list")))){
+                unset($groupes["list"][$id_groupe]);
               }
               else{
                 if(!isset($groupes["list"][$id_groupe]["image"])) $groupes["list"][$id_groupe]["image"] = "";
-                $groupes["list"][$id_groupe]["image_uri"] =
-                ( $groupes["list"][$id_groupe]["image"] ?
+                $groupes["list"][$id_groupe]["image_uri"] = (
+                  $groupes["list"][$id_groupe]["image"] ?
                     $env->path("content")."uploads/".$groupes["list"][$id_groupe]["image"]
                   : ""
                 );
       return $groupes;
     }
 
-    function groupe($id){
+    public function groupe($id){
       if(!isset($this->groupes)) $this->groupes = array();
       if(isset($this->groupes[$id])) return $this->groupes[$id];
       $sgbd = $this->sgbd();
       $env = $this->env();
       if(($groupe = $sgbd->get_data("sml_authors", $id)) !== null){
         if(!isset($groupe["image"])) $groupe["image"] = "";
-        $groupe["image_uri"] =
-        ( $groupe["image"] ?
+        $groupe["image_uri"] = (
+          $groupe["image"] ?
             $env->path("content")."uploads/".$groupe["image"]
           : ""
         );
       return $groupe;
     }
 
-    function groupe_exists($nom, $other_than_id = null)
-    { $sgbd = $this->sgbd();
+    public function groupe_exists($nom, $other_than_id = null){
+      $sgbd = $this->sgbd();
       $EXISTS = 0;
-      if($rst = $sgbd->open_data("sml_authors"))
-      { while($v_rst = $sgbd->fetch_data($rst))
-        { if(isset($v_rst))
-          { if(isset($v_rst["nom"]) && $v_rst["nom"] == $nom)
-            { if(isset($other_than_id))
-              { if($v_rst["id"] != $other_than_id) $EXISTS++;
+      if($rst = $sgbd->open_data("sml_authors")){
+        while($v_rst = $sgbd->fetch_data($rst)){
+          if(isset($v_rst)){
+            if(isset($v_rst["nom"]) && $v_rst["nom"] == $nom){
+              if(isset($other_than_id)){
+                if($v_rst["id"] != $other_than_id) $EXISTS++;
               }
               else $EXISTS++;
             }
           }
-          else
-          { $EXISTS = false;
+          else{
+            $EXISTS = false;
             break;
           }
         }
       return $EXISTS;
     }
 
-    function add_groupe($id_user, $nom, $image, $description, $email, $contact_form, $captcha)
-    { $sgbd = $this->sgbd();
-      return $sgbd->add_data
-      ( "sml_authors",
-        array
-        ( "id_user" => $id_user,
+    public function add_groupe($id_user, $nom, $image, $description, $email, $contact_form, $captcha){
+      $sgbd = $this->sgbd();
+      return $sgbd->add_data(
+        "sml_authors",
+        array(
+          "id_user" => $id_user,
           "nom" => $nom,
           "image" => $image,
           "description" => $description,
       );
     }
 
-    function set_groupe($id, $nom, $image, $description, $email, $contact_form, $captcha)
-    { if(($groupe = $this->groupe($id)) !== false)
-      { $sgbd = $this->sgbd();
-        if($nom != $groupe["nom"])
-        { $groupe["nom"] = $nom;
+    public function set_groupe($id, $nom, $image, $description, $email, $contact_form, $captcha){
+      if(($groupe = $this->groupe($id)) !== false){
+        $sgbd = $this->sgbd();
+        if($nom != $groupe["nom"]){
+          $groupe["nom"] = $nom;
           if(!$this->maj_source_xml_groupe($groupe)) return false;
         }
-        return $sgbd->set_data
-        ( "sml_authors",
+        return $sgbd->set_data(
+          "sml_authors",
           $id,
-          array
-          ( "id_user" => $groupe["id_user"],
+          array(
+            "id_user" => $groupe["id_user"],
             "nom" => $nom,
             "image" => $image,
             "description" => $description,
       return false;
     }
 
-    function del_groupe($id)
-    { $OK = true;
+    public function del_groupe($id){
+      $OK = true;
       $USED = false;
       $sgbd = $this->sgbd();
       $env = $this->env();
-      if($rst = $sgbd->open_data("sml_sources_authors"))
-      { while($source_author = $sgbd->fetch_data($rst))
-        { if(isset($source_author))
-          { if($source_author["id_author"] == $id)
-            { $USED = true;
+      if($rst = $sgbd->open_data("sml_sources_authors")){
+        while($source_author = $sgbd->fetch_data($rst)){
+          if(isset($source_author)){
+            if($source_author["id_author"] == $id){
+              $USED = true;
               break;
             }
           }
-          else
-          { $OK = false;
+          else{
+            $OK = false;
             break;
           }
         }
         $sgbd->close_data($rst);
       }
       else $OK = false;
-      if($OK)
-      { if($USED) return 1;
+      if($OK){
+        if($USED) return 1;
         return $sgbd->del_data("sml_authors", $id) ? true : false;
       }
       return false;
     }
 
   }
-
-?>
\ No newline at end of file