Browse Source

Core : fix install on user

idleman 3 years ago
parent
commit
3b56a6541c
4 changed files with 269 additions and 378 deletions
  1. 73 0
      class/Entity.class.php
  2. 1 0
      install.php
  3. 174 378
      plugin/dashboard/action.php
  4. 21 0
      plugin/dashboard/page.list.dashboard.php

+ 73 - 0
class/Entity.class.php

@@ -495,6 +495,67 @@ class Entity {
         return $instance->customQuery($sql, $values, true, $joins);
     }
 
+    public static function get($options=array()) {
+        $class = get_called_class();
+        $instance = new $class();
+        $connector = $instance->connector;
+
+        $values = array();
+        $i=0;
+        $filters = array();
+
+
+        if(!empty($options['where'])){
+            foreach($options['where'] as $key=>$value){
+                $filter = array(
+                    'operator' => '=',
+                    'field' => $key,
+                    'postoperator' => ''
+                );
+                if(strpos($key,':')!==false){
+                    $infos = explode(':',$key);
+                    $filter['operator'] = $infos[1];
+                    $filter['field'] = $infos[0];
+                }
+
+                $fieldInfos = $instance->fieldMapping[$filter['field']];
+                $filter['type'] = $fieldInfos['type'];
+                $filter['column'] = $fieldInfos['column'];
+
+                $connector::processField($filter,$value,$values,$i);
+                $filters[] = $filter;
+             }
+         }
+
+         if(!empty($order)){
+             foreach ($order as $key=>$clause) {
+                foreach ($instance->fieldMapping as $attribute => $infos) {
+                    $order[$key] = str_replace( $attribute,$infos['column'],$order[$key]);
+                }
+             }
+         }
+         $tableName = $class::tableName(false,$instance);
+         $data = array(
+            'table' => $tableName,
+            'selected' => $selColumn,
+            'limit' =>  !isset($limit) || count($limit) == 0 ? null: $limit,
+            'orderby'  => !isset($order) || count($order) == 0 ? null: $order,
+            'filter' => !isset($filters) ||  count($filters) == 0 ? null: $filters,
+            'fieldMapping' => $instance->fieldMapping
+        );
+        $data['joins']  = array();
+        if($joins!=0){
+            foreach ($data['selected'] as $k=>$column)
+               $data['selected'][$k] = $tableName.'.'.$column;
+
+            $data = self::recursiveJoining($instance,$data,$joins);
+        }
+        $sql = $connector::select();
+        $sql = Entity::render($sql,$data);
+
+        return $instance->customQuery($sql, $values, true, $joins,$alterator);
+    }
+
     /**
      * Méthode privée de gestion du join récursif sur les objets liés
      * @category manipulation SQL
@@ -622,9 +683,21 @@ class Entity {
      * @param <Array>  $colonnes      (WHERE)
      * @param <Array>  $valeurs       (WHERE)
      * @param <String> $operation="=" definis le type d'operateur pour la requete select
+     * @deprecated use byId
      * @return <Entity> $Entity ou false si aucun objet n'est trouvé en base
      */
     public static function getById($id,$joins =0 ) {
+        return self::byId($id,$joins =0);
+    }
+
+    /**
+     * Méthode de selection unique d'élements de l'entité.
+     * @param <Array>  $colonnes      (WHERE)
+     * @param <Array>  $valeurs       (WHERE)
+     * @param <String> $operation="=" definis le type d'operateur pour la requete select