Changeset 7200


Ignore:
Timestamp:
Oct 15, 2010, 5:59:23 PM (10 years ago)
Author:
grum
Message:

Add new possibilities for RBuilder modules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php

    r7181 r7200  
    22/* -----------------------------------------------------------------------------
    33  class name: GCPRequestBuilder
    4   class version  : 1.1.0
    5   plugin version : 3.2.0
     4  class version  : 1.1.1
     5  plugin version : 3.3.2
    66  date           : 2010-09-08
    77
     
    6868| 1.1.0   | 2010/09/08 | * add functionnalities to manage complex requests
    6969|         |            |
    70 |         |            |
    71 |         |            |
     70| 1.1.1   | 2010/10/14 | * fix bug on the buildGroupRequest function
     71|         |            |   . adding 'DISTINCT' keyword to the SQL requests
    7272|         |            |
    7373|         |            |
     
    365365  `connected_plugin` char(255) NOT NULL,
    366366  `filter` text NOT NULL,
     367  `parameters` text NOT NULL,
    367368  PRIMARY KEY  (`id`)
    368369)
     
    396397  static public function updateTables($pluginPreviousRelease)
    397398  {
    398     $tablesCreate=array();
    399     $tablesUpdate=array();
    400 
    401399    switch($pluginPreviousRelease)
    402400    {
    403401      case '03.01.00':
     402        $tablesCreate=array();
     403        $tablesUpdate=array();
     404
    404405        $tablesCreate[]=
    405406"CREATE TABLE `".self::$tables['temp']."` (
     
    412413        $tablesUpdate[self::$tables['request']]['filter']=
    413414"ADD COLUMN  `filter` text NOT NULL default '' ";
    414         break;
    415     }
    416 
    417     $tablef=new GPCTables(array(self::$tables['temp']));
    418 
    419     if(count($tablesCreate)>0) $tablef->create($tablesCreate);
    420     if(count($tablesUpdate)>0) $tablef->updateTablesFields($tablesUpdate);
     415
     416
     417        $tablef=new GPCTables(array(self::$tables['temp']));
     418
     419        $tablef->create($tablesCreate);
     420        $tablef->updateTablesFields($tablesUpdate);
     421        // no break ! need to be updated like the next release
     422        // break;
     423      case '03.01.01':
     424      case '03.02.00':
     425      case '03.02.01':
     426      case '03.03.00':
     427      case '03.03.01':
     428        $tablesUpdate=array();
     429
     430        $tablesUpdate[self::$tables['request']]['parameters']=
     431"ADD COLUMN `parameters` TEXT NOT NULL AFTER `filter`";
     432
     433        $tablef->updateTablesFields($tablesUpdate);
     434        // no break ! need to be updated like the next release
     435        // break;
     436    }
    421437
    422438    return(true);
     
    728744    {
    729745      $numberItems=pwg_db_changes($result);
    730       self::updateRequest($requestNumber, $numberItems, 0, implode(',', $pluginList), $build['FILTER']);
     746      self::updateRequest($requestNumber, $numberItems, 0, implode(',', $pluginList), $build['FILTER'], $_REQUEST['extraData']);
    731747
    732748      $returned="$requestNumber;".$numberItems;
     
    796812    );
    797813
     814
     815    $extraData=array();
     816    foreach($request['parameters'] as $data)
     817    {
     818      $extraData[$data['owner']]=$data['param'];
     819    }
     820
    798821    /* for each needed plugin :
    799822     *  - include the file
     
    808831          include_once($registeredPlugin[$val]['fileName']);
    809832
    810           $tmp=explode(',', call_user_func(Array('RBCallBack'.$val, 'getSelect')));
     833          $tmp=explode(',', call_user_func(Array('RBCallBack'.$val, 'getSelect'), $extraData[$val]));
    811834          foreach($tmp as $key2=>$val2)
    812835          {
     
    814837          }
    815838          $tmpBuild['SELECT'][$val]=implode(',', $tmp);
    816           $tmpBuild['FROM'][$val]=call_user_func(Array('RBCallBack'.$val, 'getFrom'));
    817           $tmpBuild['JOIN'][$val]=call_user_func(Array('RBCallBack'.$val, 'getJoin'));
     839          $tmpBuild['FROM'][$val]=call_user_func(Array('RBCallBack'.$val, 'getFrom'), $extraData[$val]);
     840          $tmpBuild['JOIN'][$val]=call_user_func(Array('RBCallBack'.$val, 'getJoin'), $extraData[$val]);
    818841        }
    819842      }
     
    10441067  static private function getNewRequest($userId)
    10451068  {
    1046     $sql="INSERT INTO ".self::$tables['request']." VALUES('', '$userId', '".date('Y-m-d H:i:s')."', 0, 0, '', '')";
     1069    $sql="INSERT INTO ".self::$tables['request']." VALUES('', '$userId', '".date('Y-m-d H:i:s')."', 0, 0, '', '', '')";
    10471070    $result=pwg_query($sql);
    10481071    if($result)
     
    10601083   * @param Float $executionTime : time in second to execute the request
    10611084   * @param String $pluginList : list of used plugins
     1085   * @param String $parameters : parameters given for the request
    10621086   * @return Boolean : true if request was updated, otherwise false
    10631087   */
    1064   static private function updateRequest($requestId, $numItems, $executionTime, $pluginList, $additionalFilter)
     1088  static private function updateRequest($requestId, $numItems, $executionTime, $pluginList, $additionalFilter, $parameters)
    10651089  {
    10661090    $sql="UPDATE ".self::$tables['request']."
     
    10681092                execution_time = $executionTime,
    10691093                connected_plugin = '$pluginList',
    1070                 filter = '".mysql_escape_string($additionalFilter)."'
     1094                filter = '".mysql_escape_string($additionalFilter)."',
     1095                parameters = '".serialize($parameters)."'
    10711096            WHERE id = $requestId";
    10721097    $result=pwg_query($sql);
     
    10871112  {
    10881113    $returned=false;
    1089     $sql="SELECT user_id, date, num_items, execution_time, connected_plugin, filter
     1114    $sql="SELECT user_id, date, num_items, execution_time, connected_plugin, filter, parameters
    10901115          FROM ".self::$tables['request']."
    10911116          WHERE id = $requestId";
     
    10951120      while($row=pwg_db_fetch_assoc($result))
    10961121      {
     1122        if($row['parameters']!='') $row['parameters']=unserialize($row['parameters']);
    10971123        $returned=$row;
    10981124      }
Note: See TracChangeset for help on using the changeset viewer.