source: extensions/AMetaData/amd_ajax.php @ 6723

Last change on this file since 6723 was 6723, checked in by grum, 14 years ago

forgotten file on the previous commit...

  • ajax management entirely rewritted
File size: 44.4 KB
RevLine 
[6723]1<?php
2/*
3 * -----------------------------------------------------------------------------
4 * Plugin Name: Advanced MetaData
5 * -----------------------------------------------------------------------------
6 * Author     : Grum
7 *   email    : grum@piwigo.org
8 *   website  : http://photos.grum.fr
9 *   PWG user : http://forum.piwigo.org/profile.php?id=3706
10 *
11 *   << May the Little SpaceFrog be with you ! >>
12 *
13 * -----------------------------------------------------------------------------
14 *
15 * See main.inc.php for release information
16 *
17 * manage all the ajax requests
18 * -----------------------------------------------------------------------------
19 */
20
21  define('PHPWG_ROOT_PATH',dirname(dirname(dirname(__FILE__))).'/');
22
23  /*
24   * set ajax module in admin mode if request is used for admin interface
25   */
26  if(!isset($_REQUEST['ajaxfct'])) $_REQUEST['ajaxfct']='';
27  if(preg_match('/^admin\./i', $_REQUEST['ajaxfct']))
28  {
29    define('IN_ADMIN', true);
30  }
31
32  // the common.inc.php file loads all the main.inc.php plugins files
33  include_once(PHPWG_ROOT_PATH.'include/common.inc.php' );
34  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
35  include_once('amd_root.class.inc.php');
36
37  load_language('plugin.lang', AMD_PATH);
38
39
40  class AMD_ajax extends AMD_root
41  {
42    /**
43     * constructor
44     */
45    public function __construct($prefixeTable, $filelocation)
46    {
47      parent::__construct($prefixeTable, $filelocation);
48      $this->loadConfig();
49      $this->checkRequest();
50      $this->returnAjaxContent();
51    }
52
53    /**
54     * check the $_REQUEST values and set default values
55     *
56     */
57    protected function checkRequest()
58    {
59      global $user;
60
61      if(!isset($_REQUEST['ajaxfct'])) $_REQUEST['ajaxfct']='';
62
63      // check if asked function is valid
64      if(!(
65           $_REQUEST['ajaxfct']=='admin.makeStats.getList' or
66           $_REQUEST['ajaxfct']=='admin.makeStats.doAnalyze' or
67           $_REQUEST['ajaxfct']=='admin.makeStats.consolidate' or
68           $_REQUEST['ajaxfct']=='admin.makeStats.getStatus' or
69           $_REQUEST['ajaxfct']=='admin.showStats.getListTags' or
70           $_REQUEST['ajaxfct']=='admin.showStats.getListImages' or
71           $_REQUEST['ajaxfct']=='admin.updateTag.select' or
72           $_REQUEST['ajaxfct']=='admin.group.getList' or
73           $_REQUEST['ajaxfct']=='admin.group.delete' or
74           $_REQUEST['ajaxfct']=='admin.group.getNames' or
75           $_REQUEST['ajaxfct']=='admin.group.setNames' or
76           $_REQUEST['ajaxfct']=='admin.group.setOrder' or
77           $_REQUEST['ajaxfct']=='admin.group.getTagList' or
78           $_REQUEST['ajaxfct']=='admin.group.setTagList' or
79           $_REQUEST['ajaxfct']=='admin.group.getOrderedTagList' or
80           $_REQUEST['ajaxfct']=='admin.group.setOrderedTagList' or
81           $_REQUEST['ajaxfct']=='admin.userDefined.getList' or
82           $_REQUEST['ajaxfct']=='admin.userDefined.getTag' or
83           $_REQUEST['ajaxfct']=='admin.userDefined.setTag' or
84           $_REQUEST['ajaxfct']=='admin.userDefined.deleteTag' or
85
86           $_REQUEST['ajaxfct']=='public.makeStats.doPictureAnalyze')) $_REQUEST['ajaxfct']='';
87
88      if(preg_match('/^admin\./i', $_REQUEST['ajaxfct']) and !is_admin()) $_REQUEST['ajaxfct']='';
89
90      if($_REQUEST['ajaxfct']!='')
91      {
92        /*
93         * check admin.makeStats.getList values
94         */
95        if($_REQUEST['ajaxfct']=="admin.makeStats.getList")
96        {
97          if(!isset($_REQUEST['selectMode'])) $_REQUEST['selectMode']="caddieAdd";
98
99          if(!($_REQUEST['selectMode']=="notAnalyzed" or
100               $_REQUEST['selectMode']=="caddieAdd" or
101               $_REQUEST['selectMode']=="caddieReplace" or
102               $_REQUEST['selectMode']=="all")) $_REQUEST['selectMode']="caddieAdd";
103
104          if(!isset($_REQUEST['numOfItems'])) $_REQUEST['numOfItems']=25;
105        }
106
107        /*
108         * check admin.makeStats.doAnalyze values
109         */
110        if($_REQUEST['ajaxfct']=="admin.makeStats.doAnalyze")
111        {
112          if(!isset($_REQUEST['imagesList'])) $_REQUEST['imagesList']="";
113        }
114
115        /*
116         * check admin.makeStats.consolidate values
117         */
118        if($_REQUEST['ajaxfct']=="admin.makeStats.consolidate")
119        {
120          if(!isset($_REQUEST['step'])) $_REQUEST['step']="*";
121        }
122
123        /*
124         * check admin.showStats.getListTags values
125         */
126        if($_REQUEST['ajaxfct']=="admin.showStats.getListTags")
127        {
128          if(!isset($_REQUEST['orderType'])) $_REQUEST['orderType']="tag";
129
130          if(!($_REQUEST['orderType']=="tag" or
131               $_REQUEST['orderType']=="label" or
132               $_REQUEST['orderType']=="num")) $_REQUEST['orderType']="tag";
133
134          if(!isset($_REQUEST['filterType'])) $_REQUEST['filterType']="";
135
136          if(!($_REQUEST['filterType']=="" or
137               $_REQUEST['filterType']=="magic" or
138               $_REQUEST['filterType']=="userDefined" or
139               $_REQUEST['filterType']=="exif" or
140               $_REQUEST['filterType']=="exif.Canon" or
141               $_REQUEST['filterType']=="exif.Nikon" or
142               $_REQUEST['filterType']=="exif.Pentax" or
143               $_REQUEST['filterType']=="xmp" or
144               $_REQUEST['filterType']=="iptc")) $_REQUEST['filterType']="";
145
146          if(!isset($_REQUEST['excludeUnusedTag'])) $_REQUEST['excludeUnusedTag']="n";
147
148          if(!($_REQUEST['excludeUnusedTag']=="y" or
149               $_REQUEST['excludeUnusedTag']=="n" )) $_REQUEST['excludeUnusedTag']="n";
150
151          if(!isset($_REQUEST['selectedTagOnly'])) $_REQUEST['selectedTagOnly']="n";
152
153          if(!($_REQUEST['selectedTagOnly']=="y" or
154               $_REQUEST['selectedTagOnly']=="n" )) $_REQUEST['selectedTagOnly']="n";
155        }
156
157        /*
158         * check admin.showStats.getListImages values
159         */
160        if($_REQUEST['ajaxfct']=="admin.showStats.getListImages")
161        {
162          if(!isset($_REQUEST['orderType'])) $_REQUEST['orderType']="num";
163
164          if(!($_REQUEST['orderType']=="value" or
165               $_REQUEST['orderType']=="num")) $_REQUEST['orderType']="num";
166
167          if(!isset($_REQUEST['tagId'])) $_REQUEST['tagId']="*";
168        }
169
170        /*
171         * check admin.updateTag.select values
172         */
173        if($_REQUEST['ajaxfct']=="admin.updateTag.select")
174        {
175          if(!isset($_REQUEST['numId'])) $_REQUEST['numId']="";
176
177          if(!isset($_REQUEST['tagSelected'])) $_REQUEST['tagSelected']="";
178        }
179
180        /*
181         * check admin.group.delete values
182         */
183        if($_REQUEST['ajaxfct']=="admin.group.delete" and !isset($_REQUEST['id']))
184        {
185          $_REQUEST['id']="";
186        }
187
188        /*
189         * check admin.groupSetOrder values
190         */
191        if($_REQUEST['ajaxfct']=="admin.group.setOrder" and !isset($_REQUEST['listGroup']))
192        {
193          $_REQUEST['listGroup']="";
194        }
195
196        /*
197         * check admin.group.getNames values
198         */
199        if($_REQUEST['ajaxfct']=="admin.group.getNames" and !isset($_REQUEST['id']))
200        {
201          $_REQUEST['id']="";
202        }
203
204        /*
205         * check admin.group.setNames values
206         */
207        if($_REQUEST['ajaxfct']=="admin.group.setNames")
208        {
209          if(!isset($_REQUEST['listNames'])) $_REQUEST['listNames']="";
210
211          if(!isset($_REQUEST['id'])) $_REQUEST['id']="";
212        }
213
214        /*
215         * check admin.group.getTagList values
216         */
217        if($_REQUEST['ajaxfct']=="admin.group.getTagList" and !isset($_REQUEST['id']))
218        {
219          $_REQUEST['id']="";
220        }
221
222        /*
223         * check admin.group.setTagList values
224         */
225        if($_REQUEST['ajaxfct']=="admin.group.setTagList")
226        {
227          if(!isset($_REQUEST['id'])) $_REQUEST['id']="";
228
229          if(!isset($_REQUEST['listTag'])) $_REQUEST['listTag']="";
230        }
231
232        /*
233         * check admin.group.getOrderedTagList values
234         */
235        if($_REQUEST['ajaxfct']=="admin.group.getOrderedTagList" and !isset($_REQUEST['id']))
236        {
237          $_REQUEST['id']="";
238        }
239
240        /*
241         * check admin.group.setOrderedTagList values
242         */
243        if($_REQUEST['ajaxfct']=="admin.group.setOrderedTagList")
244        {
245          if(!isset($_REQUEST['id'])) $_REQUEST['id']="";
246
247          if(!isset($_REQUEST['listTag'])) $_REQUEST['listTag']="";
248        }
249
250        /*
251         * check admin.userDefined.getTag values
252         */
253        if($_REQUEST['ajaxfct']=="admin.userDefined.getTag" and !isset($_REQUEST['id']))
254        {
255          $_REQUEST['id']="";
256        }
257
258        /*
259         * check admin.userDefined.setTag values
260         */
261        if($_REQUEST['ajaxfct']=="admin.userDefined.setTag")
262        {
263          if(!isset($_REQUEST['id'])) $_REQUEST['id']="";
264          if($_REQUEST['id']!='' and !preg_match('/\d+/', $_REQUEST['id'])) $_REQUEST['id']="";
265
266          if(!isset($_REQUEST['properties']) or
267              (isset($_REQUEST['properties']) and
268               !(isset($_REQUEST['properties']['name']) and
269                 isset($_REQUEST['properties']['rules']) and
270                 isset($_REQUEST['properties']['tagId'])
271                )
272              )
273            ) $_REQUEST['ajaxfct']='';
274
275          if(isset($_REQUEST['properties']['rules']))
276          {
277            foreach($_REQUEST['properties']['rules'] as $val)
278            {
279              if(!(isset($val['order']) and
280                   isset($val['value']) and
281                   isset($val['parentId']) and
282                   isset($val['type']) and
283                   isset($val['defId']))) $_REQUEST['ajaxfct']='';
284            }
285          }
286        }
287
288        /*
289         * check admin.userDefined.deleteTag values
290         */
291        if($_REQUEST['ajaxfct']=="admin.userDefined.deleteTag" and !isset($_REQUEST['id']))
292        {
293          $_REQUEST['id']="";
294        }
295
296
297        /*
298         * check public.makeStats.doPictureAnalyze values
299         */
300        if($_REQUEST['ajaxfct']=="public.makeStats.doPictureAnalyze")
301        {
302          if(!isset($_REQUEST['id'])) $_REQUEST['id']="0";
303        }
304      }
305    }
306
307
308    /**
309     * return ajax content
310     */
311    protected function returnAjaxContent()
312    {
313      $result="<p class='errors'>An error has occured</p>";
314      switch($_REQUEST['ajaxfct'])
315      {
316        case 'admin.makeStats.getList':
317          $result=$this->ajax_amd_admin_makeStatsGetList($_REQUEST['selectMode'], $_REQUEST['numOfItems']);
318          break;
319        case 'admin.makeStats.doAnalyze':
320          $result=$this->ajax_amd_admin_makeStatsDoAnalyze($_REQUEST['imagesList']);
321          break;
322        case 'admin.makeStats.consolidate':
323          $result=$this->ajax_amd_admin_makeStatsConsolidate();
324          break;
325        case 'admin.makeStats.getStatus':
326          $result=$this->ajax_amd_admin_makeStatsGetStatus();
327          break;
328        case 'admin.showStats.getListTags':
329          $result=$this->ajax_amd_admin_showStatsGetListTags($_REQUEST['orderType'], $_REQUEST['filterType'], $_REQUEST['excludeUnusedTag'], $_REQUEST['selectedTagOnly']);
330          break;
331        case 'admin.showStats.getListImages':
332          $result=$this->ajax_amd_admin_showStatsGetListImages($_REQUEST['tagId'], $_REQUEST['orderType']);
333          break;
334        case 'admin.updateTag.select':
335          $result=$this->ajax_amd_admin_updateTagSelect($_REQUEST['numId'], $_REQUEST['tagSelected']);
336          break;
337        case 'admin.group.getList':
338          $result=$this->ajax_amd_admin_groupGetList();
339          break;
340        case 'admin.group.delete':
341          $result=$this->ajax_amd_admin_groupDelete($_REQUEST['id']);
342          break;
343        case 'admin.group.getNames':
344          $result=$this->ajax_amd_admin_groupGetNames($_REQUEST['id']);
345          break;
346        case 'admin.group.setNames':
347          $result=$this->ajax_amd_admin_groupSetNames($_REQUEST['id'], $_REQUEST['listNames']);
348          break;
349        case 'admin.group.setOrder':
350          $result=$this->ajax_amd_admin_groupSetOrder($_REQUEST['listGroup']);
351          break;
352        case 'admin.group.getTagList':
353          $result=$this->ajax_amd_admin_groupGetTagList($_REQUEST['id']);
354          break;
355        case 'admin.group.setTagList':
356          $result=$this->ajax_amd_admin_groupSetTagList($_REQUEST['id'], $_REQUEST['listTag']);
357          break;
358        case 'admin.group.getOrderedTagList':
359          $result=$this->ajax_amd_admin_groupGetOrderedTagList($_REQUEST['id']);
360          break;
361        case 'admin.group.setOrderedTagList':
362          $result=$this->ajax_amd_admin_groupSetOrderedTagList($_REQUEST['id'], $_REQUEST['listTag']);
363          break;
364        case 'admin.userDefined.getList':
365          $result=$this->ajax_amd_admin_userDefinedGetList();
366          break;
367        case 'admin.userDefined.getTag':
368          $result=$this->ajax_amd_admin_userDefinedGetTag($_REQUEST['id']);
369          break;
370        case 'admin.userDefined.setTag':
371          $result=$this->ajax_amd_admin_userDefinedSetTag($_REQUEST['id'], $_REQUEST['properties']);
372          break;
373        case 'admin.userDefined.deleteTag':
374          $result=$this->ajax_amd_admin_userDefinedDeleteTag($_REQUEST['id']);
375          break;
376
377
378        case 'public.makeStats.doPictureAnalyze':
379          $result=$this->ajax_amd_public_makeStatsDoPictureAnalyze($_REQUEST['id']);
380          break;
381      }
382      GPCAjax::returnResult($result);
383    }
384
385    /*------------------------------------------------------------------------*
386     *
387     * PUBLIC FUNCTIONS
388     *
389     *----------------------------------------------------------------------- */
390    private function ajax_amd_public_makeStatsDoPictureAnalyze($imageId)
391    {
392      if($imageId==0)
393      {
394        // get a randomly picture...
395        $sql="SELECT pai.imageId, pi.path
396              FROM ".$this->tables['images']." pai
397                LEFT JOIN ".IMAGES_TABLE." pi ON pai.imageId=pi.id
398              WHERE analyzed='n'
399              ORDER BY RAND() LIMIT 1;";
400      }
401      else
402      {
403        $sql="SELECT path, id AS imageId
404              FROM ".IMAGES_TABLE."
405              WHERE id='$imageId';";
406      }
407
408      $result=pwg_query($sql);
409      if($result)
410      {
411        $path=dirname(dirname(dirname(__FILE__)));
412        while($row=pwg_db_fetch_assoc($result))
413        {
414          $imageId=$row['imageId'];
415          $filename=$path."/".$row['path'];
416        }
417
418        $this->analyzeImageFile($filename, $imageId);
419        $this->makeStatsConsolidation();
420
421        return("Analyze of image #$imageId is a success !");
422      }
423
424      return("Try to analyze image #$imageId failed...");
425
426    }
427
428
429
430    /*------------------------------------------------------------------------*
431     *
432     * ADMIN FUNCTIONS
433     *
434     *----------------------------------------------------------------------- */
435
436    /**
437     * return a list of picture Id
438     *
439     * picture id are separated with a space " "
440     * picture id are grouped in blocks of 'amd_NumberOfItemsPerRequest' items and
441     * are separated with a semi-colon ";"
442     *
443     * client side just have to split blocks, and transmit it to the server
444     *
445     * There is two mode to determine the pictures being analyzed :
446     *  - "all"         : analyze all the images
447     *  - "notAnalyzed" : analyze only the images not yet analyzed
448     *
449     * @param String $mode
450     * @param Integer $nbOfItems : number of items per request
451     * @return String : list of image id to be analyzed, separated with a space
452     *                      "23 78 4523 5670"
453     */
454    private function ajax_amd_admin_makeStatsGetList($mode, $nbOfItems)
455    {
456      global $user;
457
458      $returned="";
459      $this->config['amd_NumberOfItemsPerRequest']=$nbOfItems;
460      $this->saveConfig();
461
462      $sql="SELECT ait.imageId FROM ".$this->tables['images']." ait";
463      if($mode=="notAnalyzed")
464      {
465        $sql.=" WHERE ait.analyzed='n'";
466      }
467      elseif($mode=="caddieAdd" or $mode=="caddieReplace")
468      {
469
470        $sql.=" LEFT JOIN ".CADDIE_TABLE." ct ON ait.imageId = ct.element_id
471              WHERE ct.user_id = ".$user['id']." ";
472
473        if($mode=="caddieAdd") $sql.=" AND ait.analyzed='n'";
474      }
475
476      if($mode=="all" or $mode=="caddieReplace")
477      {
478        pwg_query("UPDATE ".$this->tables['images']." SET analyzed='n', nbTags=0");
479        pwg_query("UPDATE ".$this->tables['used_tags']." SET numOfImg=0");
480        pwg_query("DELETE FROM ".$this->tables['images_tags']);
481      }
482
483      $result=pwg_query($sql);
484      if($result)
485      {
486        $i=0;
487        while($row=pwg_db_fetch_row($result))
488        {
489          $returned.=$row[0];
490          $i++;
491          if($i>=$nbOfItems)
492          {
493            $returned.=";";
494            $i=0;
495          }
496          else
497          {
498            $returned.=" ";
499          }
500        }
501      }
502      return(trim($returned).";");
503    }
504
505
506    /**
507     * extract metadata from images
508     *
509     * @param String $imageList : list of image id to be analyzed, separated with
510     *                            a space
511     *                                "23 78 4523 5670"
512     * @return String : list of the analyzed pictures, with number of tags found
513     *                  for each picture
514     *                    "23=0;78=66;4523=33;5670=91;"
515     */
516    private function ajax_amd_admin_makeStatsDoAnalyze($imagesList)
517    {
518      $list=explode(" ", trim($imagesList));
519
520      $returned="";
521
522      if(count($list)>0 and trim($imagesList)!='')
523      {
524        // $path = path of piwigo's on the server filesystem
525        $path=dirname(dirname(dirname(__FILE__)));
526
527        $sql="SELECT id, path FROM ".IMAGES_TABLE." WHERE id IN (".implode(", ", $list).")";
528        $result=pwg_query($sql);
529        if($result)
530        {
531          while($row=pwg_db_fetch_assoc($result))
532          {
533            /*
534             * in some case (in a combination of some pictures), when there is too
535             * much pictures to analyze in the same request, a fatal error occurs
536             * with the message : "Allowed memory size of XXXXX bytes exhausted"
537             *
538             *
539             * tracking memory leak is not easy... :-(
540             *
541             */
542            //echo "analyzing:".$row['id']."\n";
543            //$mem1=memory_get_usage();
544            //echo "memory before analyze:".$mem1."\n";
545            $returned.=$this->analyzeImageFile($path."/".$row['path'], $row['id']);
546            //echo $returned."\n";
547            //$mem2=memory_get_usage();
548            //echo "memory after analyze:".$mem2." (".($mem2-$mem1).")\n";
549          }
550        }
551      }
552      return($returned);
553    }
554
555    /**
556     * do some consolidation on database to optimize other requests
557     *
558     */
559    private function ajax_amd_admin_makeStatsConsolidate()
560    {
561      $this->makeStatsConsolidation();
562    }
563
564    /**
565     * returns a list of formated string, separated with a semi-colon :
566     *  - number of current analyzed pictures + number of current analyzed tags
567     *    for the analyzed pictures
568     *  - number of pictures not analyzed
569     *  - number of pictures without tag
570     *
571     * @return String
572     */
573    private function ajax_amd_admin_makeStatsGetStatus()
574    {
575      $numOfMetaData=0;
576      $numOfPictures=0;
577      $numOfPicturesNotAnalyzed=0;
578
579      $sql="SELECT COUNT(imageId), SUM(nbTags) FROM ".$this->tables['images']."
580              WHERE analyzed='y';";
581      $result=pwg_query($sql);
582      if($result)
583      {
584        while($row=pwg_db_fetch_row($result))
585        {
586          $numOfPictures=$row[0];
587          $numOfMetaData=$row[1];
588        }
589      }
590
591
592      $sql="SELECT COUNT(imageId) FROM ".$this->tables['images']."
593              WHERE analyzed='n';";
594      $result=pwg_query($sql);
595      if($result)
596      {
597        while($row=pwg_db_fetch_row($result))
598        {
599          $numOfPicturesNotAnalyzed=$row[0];
600        }
601      }
602
603      $sql="SELECT COUNT(imageId) FROM ".$this->tables['images']."
604              WHERE nbTags=0;";
605      $result=pwg_query($sql);
606      if($result)
607      {
608        while($row=pwg_db_fetch_row($result))
609        {
610          $numOfPicturesWithoutTags=$row[0];
611        }
612      }
613
614      return(sprintf(l10n("g003_numberOfAnalyzedPictures"), $numOfPictures, $numOfMetaData).";".
615                sprintf(l10n("g003_numberOfNotAnalyzedPictures"), $numOfPicturesNotAnalyzed).";".
616                sprintf(l10n("g003_numberOfPicturesWithoutTags"), $numOfPicturesWithoutTags));
617    }
618
619
620    /**
621     * return a formatted <table> (using the template "amd_stat_show_iListTags")
622     * of used tag with, for each tag, the number and the percentage of pictures
623     * where the tag was found
624     *
625     * @param String $orderType : order for the list (by tag 'tag' or by number of
626     *                            pictures 'num')
627     * @param String $filterType : filter for the list ('exif', 'xmp', 'iptc' or '')
628     * @return String
629     */
630    private function ajax_amd_admin_showStatsGetListTags($orderType, $filterType, $excludeUnusedTag, $selectedTagOnly)
631    {
632      global $template;
633
634      $this->config['amd_GetListTags_OrderType'] = $orderType;
635      $this->config['amd_GetListTags_FilterType'] = $filterType;
636      $this->config['amd_GetListTags_ExcludeUnusedTag'] = $excludeUnusedTag;
637      $this->config['amd_GetListTags_SelectedTagOnly'] = $selectedTagOnly;
638      $this->saveConfig();
639
640      $local_tpl = new Template(AMD_PATH."admin/", "");
641      $local_tpl->set_filename('body_page',
642                    dirname($this->getFileLocation()).'/admin/amd_metadata_select_iListTags.tpl');
643
644      $numOfPictures=$this->getNumOfPictures();
645
646      $datas=array();
647      $sql="SELECT ut.numId, ut.tagId, ut.translatable, ut.name, ut.numOfImg, if(st.tagId IS NULL, 'n', 'y') as checked, ut.translatedName
648              FROM ".$this->tables['used_tags']." ut
649                LEFT JOIN ".$this->tables['selected_tags']." st
650                  ON st.tagId = ut.tagId ";
651      $where="";
652
653      if($filterType!='')
654      {
655        if($filterType=='exif')
656        {
657          $where.=" WHERE ut.tagId LIKE 'exif.tiff.%'
658                      OR ut.tagId LIKE 'exif.exif.%'
659                      OR ut.tagId LIKE 'exif.gps.%'  ";
660        }
661        else
662        {
663          $where.=" WHERE ut.tagId LIKE '".$filterType.".%' ";
664        }
665      }
666
667      if($excludeUnusedTag=='y')
668      {
669        ($where=="")?$where=" WHERE ":$where.=" AND ";
670        $where.=" ut.numOfImg > 0 ";
671      }
672
673      if($selectedTagOnly=='y')
674      {
675        ($where=="")?$where=" WHERE ":$where.=" AND ";
676        $where.=" st.tagId IS NOT NULL ";
677      }
678
679      $sql.=$where;
680
681      switch($orderType)
682      {
683        case 'tag':
684          $sql.=" ORDER BY tagId ASC";
685          break;
686        case 'num':
687          $sql.=" ORDER BY numOfImg DESC, tagId ASC";
688          break;
689        case 'label':
690          $sql.=" ORDER BY translatedName ASC, tagId ASC";
691          break;
692      }
693
694      $result=pwg_query($sql);
695      if($result)
696      {
697        while($row=pwg_db_fetch_assoc($result))
698        {
699          $datas[]=array(
700            "numId" => $row['numId'],
701            "tagId" => $row['tagId'],
702            "label" => L10n::get($row['name']),
703            "nb"    => $row['numOfImg'],
704            "pct"   => ($numOfPictures!=0)?sprintf("%.2f", 100*$row['numOfImg']/$numOfPictures):"0",
705            "tagChecked" => ($row['checked']=='y')?"checked":""
706          );
707        }
708      }
709
710      $local_tpl->assign('themeconf', Array('name' => $template->get_themeconf('name')));
711      $local_tpl->assign('datas', $datas);
712
713      return($local_tpl->parse('body_page', true));
714    }
715
716
717    /*
718     *
719     *
720     */
721    private function ajax_amd_admin_showStatsGetListImages($tagId, $orderType)
722    {
723      global $template;
724
725      $this->config['amd_GetListImages_OrderType'] = $orderType;
726      $this->saveConfig();
727
728      $local_tpl = new Template(AMD_PATH."admin/", "");
729      $local_tpl->set_filename('body_page',
730                    dirname($this->getFileLocation()).'/admin/amd_metadata_select_iListImages.tpl');
731
732
733
734      $datas=array();
735      $sql="SELECT ut.translatable, ut.numOfImg, COUNT(it.imageId) AS Nb, it.value
736              FROM ".$this->tables['used_tags']." ut
737                LEFT JOIN ".$this->tables['images_tags']." it
738                ON ut.numId = it.numId
739              WHERE ut.tagId = '".$tagId."'
740                AND it.value IS NOT NULL
741              GROUP BY it.value
742              ORDER BY ";
743      switch($orderType)
744      {
745        case 'value':
746          $sql.="it.value ASC";
747          break;
748        case 'num':
749          $sql.="Nb DESC";
750          break;
751      }
752
753      $result=pwg_query($sql);
754      if($result)
755      {
756        while($row=pwg_db_fetch_assoc($result))
757        {
758          $datas[]=array(
759            "value" => $this->prepareValueForDisplay($row['value'], ($row['translatable']=='y'), ", "),
760            "nb"    => $row['Nb'],
761            "pct"   => ($row['numOfImg']!=0)?sprintf("%.2f", 100*$row['Nb']/$row['numOfImg']):"-"
762          );
763        }
764      }
765
766      if(count($datas)>0)
767      {
768        $local_tpl->assign('themeconf', Array('name' => $template->get_themeconf('name')));
769        $local_tpl->assign('datas', $datas);
770        return($local_tpl->parse('body_page', true));
771      }
772      else
773      {
774        return("<div style='width:100%;text-align:center;padding-top:20px;'>".l10n('g003_selected_tag_isnot_linked_with_any_picture')."</div>");
775      }
776    }
777
778
779    /*
780     *
781     *
782     */
783    private function ajax_amd_admin_updateTagSelect($numId, $selected)
784    {
785      if($selected=='y')
786      {
787        $sql="SELECT ut.tagId FROM ".$this->tables['selected_tags']." st
788                LEFT JOIN ".$this->tables['used_tags']." ut
789                  ON ut.tagID = st.tagId
790                WHERE ut.numId = $numId;";
791        $result=pwg_query($sql);
792        if($result)
793        {
794          if(pwg_db_num_rows($result)==0)
795          {
796            $sql="INSERT INTO ".$this->tables['selected_tags']."
797                    SELECT ut.tagId, 0, -1
798                    FROM ".$this->tables['used_tags']." ut
799                      LEFT JOIN ".$this->tables['selected_tags']." st
800                        ON ut.tagID = st.tagId
801                    WHERE ut.numId = $numId;";
802            pwg_query($sql);
803          }
804        }
805      }
806      elseif($selected=='n')
807      {
808        $sql="DELETE FROM ".$this->tables['selected_tags']." st
809                USING ".$this->tables['used_tags']." ut
810                  LEFT JOIN ".$this->tables['selected_tags']." st
811                    ON ut.tagID = st.tagId
812                WHERE ut.numId = $numId;";
813        pwg_query($sql);
814      }
815
816    }
817
818
819    /**
820     * this function return the list of tags :
821     *  - associated with the group
822     *  - not associated with a group
823     * the list is used to make tags selection
824     *
825     * @param String $id      : Id of the current group
826     * @return String : an HTML formatted list with checkbox
827     */
828    private function ajax_amd_admin_groupGetTagList($id)
829    {
830      global $template;
831
832      if($id!="")
833      {
834        $sql="SELECT st.tagId, st.groupId, ut.name, ut.numId
835              FROM ".$this->tables['selected_tags']." st
836                LEFT JOIN ".$this->tables['used_tags']." ut
837                  ON st.tagId = ut.tagId
838              ORDER BY tagId";
839        $result=pwg_query($sql);
840        if($result)
841        {
842          $datas=Array();
843          while($row=pwg_db_fetch_assoc($result))
844          {
845            if($row['groupId']==$id)
846            {
847              $state="checked";
848            }
849            elseif($row['groupId']==-1)
850            {
851              $state="";
852            }
853            else
854            {
855              $state="n/a";
856            }
857
858            if($state!="n/a")
859              $datas[]=Array(
860                'tagId' => $row['tagId'],
861                'name'  => L10n::get($row['name']),
862                'state' => $state,
863                'numId' => $row['numId']
864              );
865          }
866
867          if(count($datas)>0)
868          {
869            $local_tpl = new Template(AMD_PATH."admin/", "");
870            $local_tpl->set_filename('body_page',
871                          dirname($this->getFileLocation()).'/admin/amd_metadata_display_groupListTagSelect.tpl');
872            $local_tpl->assign('themeconf', Array('name' => $template->get_themeconf('name')));
873            $local_tpl->assign('datas', $datas);
874            return($local_tpl->parse('body_page', true));
875          }
876          else
877          {
878            return(l10n("g003_no_tag_can_be_selected"));
879          }
880        }
881      }
882      else
883      {
884        return(l10n("g003_invalid_group_id"));
885      }
886    }
887
888
889    /**
890     * this function associate tags to a group
891     *
892     * @param String $id      : Id of group
893     * @param String $listTag : list of selected tags, items are separated by a
894     *                          semi-colon ";" char
895     */
896    private function ajax_amd_admin_groupSetTagList($id, $listTag)
897    {
898      if($id!="")
899      {
900        $sql="UPDATE ".$this->tables['selected_tags']."
901              SET groupId = -1
902              WHERE groupId = $id;";
903        pwg_query($sql);
904
905        if($listTag!="")
906        {
907          $sql="UPDATE ".$this->tables['selected_tags']." st, ".$this->tables['used_tags']." ut
908                SET st.groupId = $id
909                WHERE st.tagId = ut.tagId
910                  AND ut.numId IN ($listTag);";
911          pwg_query($sql);
912        }
913      }
914      else
915      {
916        return("KO");
917      }
918    }
919
920
921    /**
922     * this function returns an ordered list of tags associated with a group
923     *
924     * @param String $id        : the group Id
925     * @return String : an HTML formatted list
926     */
927    private function ajax_amd_admin_groupGetOrderedTagList($id)
928    {
929      global $template;
930      if($id!="")
931      {
932        $numOfPictures=$this->getNumOfPictures();
933
934        $sql="SELECT st.tagId, ut.name, ut.numId, ut.numOfImg
935              FROM ".$this->tables['selected_tags']." st
936                LEFT JOIN ".$this->tables['used_tags']." ut
937                  ON st.tagId = ut.tagId
938              WHERE st.groupId = $id
939              ORDER BY st.order ASC, st.tagId ASC";
940        $result=pwg_query($sql);
941        if($result)
942        {
943          $datas=Array();
944          while($row=pwg_db_fetch_assoc($result))
945          {
946            $datas[]=Array(
947              'tagId' => $row['tagId'],
948              'name'  => L10n::get($row['name']),
949              'numId' => $row['numId'],
950              'nbItems' => $row['numOfImg'],
951              'pct'   => ($numOfPictures==0)?"0":sprintf("%.2f", 100*$row['numOfImg']/$numOfPictures)
952            );
953          }
954
955          if(count($datas)>0)
956          {
957            $template->set_filename('list_page',
958                          dirname($this->getFileLocation()).'/admin/amd_metadata_display_groupListTagOrder.tpl');
959            $template->assign('datas', $datas);
960            $template->assign('group', $id);
961            return($template->parse('list_page', true));
962          }
963          else
964          {
965            return(l10n("g003_no_tag_can_be_selected"));
966          }
967        }
968      }
969      else
970      {
971        return(l10n("g003_invalid_group_id"));
972      }
973    }
974
975
976    /**
977     * this function update the tags order inside a group
978     *
979     * @param String $id        : the group Id
980     * @param String $listGroup : the ordered list of tags, items are separated
981     *                            by a semi-colon ";" char
982     */
983    private function ajax_amd_admin_groupSetOrderedTagList($id, $listTag)
984    {
985      $tags=explode(';', $listTag);
986      if($id!="" and count($tags)>0)
987      {
988        /*
989         * by default, all items are set with order equals -1 (if list is not
990         * complete, forgotten items are sorted in head)
991         */
992        pwg_query("UPDATE ".$this->tables['selected_tags']." st
993                    SET st.order = -1
994                    WHERE st.groupId = $id;");
995
996        foreach($tags as $key=>$val)
997        {
998          $sql="UPDATE ".$this->tables['selected_tags']." st, ".$this->tables['used_tags']." ut
999                SET st.order = $key
1000                WHERE st.groupId = $id
1001                  AND st.tagId = ut.tagId
1002                  AND ut.numId = $val;";
1003          $result=pwg_query($sql);
1004        }
1005      }
1006    }
1007
1008
1009
1010    /**
1011     * this function update the groups order
1012     *
1013     * @param String $listGroup : the ordered list of groups, items are separated
1014     *                            by a semi-colon ";" char
1015     */
1016    private function ajax_amd_admin_groupSetOrder($listGroup)
1017    {
1018      $groups=explode(";",$listGroup);
1019      if(count($groups)>0)
1020      {
1021        /*
1022         * by default, all items are set with order equals -1 (if list is not
1023         * complete, forgotten items are sorted in head)
1024         */
1025        pwg_query("UPDATE ".$this->tables['groups']." g SET g.order = -1;");
1026
1027        foreach($groups as $key=>$val)
1028        {
1029          $sql="UPDATE ".$this->tables['groups']." g
1030                SET g.order = $key
1031                WHERE g.groupId = $val;";
1032          $result=pwg_query($sql);
1033        }
1034      }
1035    }
1036
1037    /**
1038     * this function is used to create a new group ($groupId = "") or update the
1039     * group name (names are given in all langs in a list)
1040     *
1041     * @param String $groupId : the groupId to update, or "" to create a new groupId
1042     * @param String $listNames : name of the group, in all language given as a
1043     *                            list ; each lang is separated by a carraige
1044     *                            return "\n" char, each items is defined as
1045     *                            lang=value
1046     *                              en_UK=the name group
1047     *                              fr_FR=le nom du groupe
1048     */
1049    private function ajax_amd_admin_groupSetNames($groupId, $listNames)
1050    {
1051      $names=explode("\n", $listNames);
1052      if($groupId=="" and count($names)>0)
1053      {
1054        $sql="INSERT INTO ".$this->tables['groups']." VALUES('', 9999)";
1055        $result=pwg_query($sql);
1056        $groupId=pwg_db_insert_id();
1057      }
1058
1059      if(is_numeric($groupId) and count($names)>0)
1060      {
1061        $sql="DELETE FROM ".$this->tables['groups_names']."
1062              WHERE groupId = $groupId;";
1063        pwg_query($sql);
1064
1065
1066        $sql="";
1067        foreach($names as $val)
1068        {
1069          $tmp=explode("=", $val);
1070          if($sql!="") $sql.=", ";
1071          $sql.=" ($groupId, '".$tmp[0]."', '".$tmp[1]."')";
1072        }
1073        $sql="INSERT INTO ".$this->tables['groups_names']." VALUES ".$sql;
1074        pwg_query($sql);
1075      }
1076    }
1077
1078    /**
1079     * this function returns an html form, allowing to manage the group
1080     *
1081     * @param String $groupId : the groupId to manage, or "" to return a creation
1082     *                          form
1083     * @return String : the form
1084     */
1085    private function ajax_amd_admin_groupGetNames($groupId)
1086    {
1087      global $user;
1088
1089      $local_tpl = new Template(AMD_PATH."admin/", "");
1090      $local_tpl->set_filename('body_page',
1091                    dirname($this->getFileLocation()).'/admin/amd_metadata_display_groupEdit.tpl');
1092
1093      $datasLang=array(
1094        'language_list' => Array(),
1095        'lang_selected' => $user['language'],
1096        'fromlang' => substr($user['language'],0,2),
1097        'default' => ''
1098      );
1099
1100      $langs=get_languages();
1101      foreach($langs as $key => $val)
1102      {
1103        $datasLang['language_list'][$key] = Array(
1104          'langName' => str_replace("\n", "", $val),
1105          'name' => ""
1106        );
1107      }
1108
1109      if($groupId!="")
1110      {
1111        $sql="SELECT lang, name FROM ".$this->tables['groups_names']."
1112              WHERE groupId = $groupId;";
1113        $result=pwg_query($sql);
1114        if($result)
1115        {
1116          while($row=pwg_db_fetch_assoc($result))
1117          {
1118            if(array_key_exists($row['lang'], $datasLang['language_list']))
1119            {
1120              $datasLang['language_list'][$row['lang']]['name']=htmlentities($row['name'], ENT_QUOTES, 'UTF-8');
1121              if($user['language']==$row['lang'])
1122              {
1123                $datasLang['default']=$datasLang['language_list'][$row['lang']]['name'];
1124              }
1125            }
1126          }
1127        }
1128      }
1129
1130      $local_tpl->assign('datasLang', $datasLang);
1131
1132      return($local_tpl->parse('body_page', true));
1133    }
1134
1135
1136    /**
1137     * this function returns an html form, allowing to manage the group
1138     *
1139     * @param String $groupId : the groupId to manage, or "" to return a creation
1140     *                          form
1141     * @return String : the form
1142     */
1143    private function ajax_amd_admin_groupGetList()
1144    {
1145      global $user, $template;
1146
1147      //$local_tpl = new Template(AMD_PATH."admin/", "");
1148      $template->set_filename('group_list',
1149                    dirname($this->getFileLocation()).'/admin/amd_metadata_display_groupList.tpl');
1150
1151
1152      $datas=array(
1153        'groups' => Array(),
1154      );
1155
1156      $sql="SELECT g.groupId, gn.name
1157            FROM ".$this->tables['groups']." g
1158              LEFT JOIN ".$this->tables['groups_names']." gn
1159                ON g.groupId = gn.groupId
1160            WHERE gn.lang = '".$user['language']."'
1161            ORDER BY g.order;";
1162      $result=pwg_query($sql);
1163      if($result)
1164      {
1165        while($row=pwg_db_fetch_assoc($result))
1166        {
1167          $datas['groups'][]=Array(
1168            'id' => $row['groupId'],
1169            'name' => htmlentities($row['name'], ENT_QUOTES, "UTF-8")
1170          );
1171        }
1172      }
1173
1174      $template->assign('datas', $datas);
1175      return($template->parse('group_list', true));
1176    }
1177
1178
1179    /**
1180     * delete the group
1181     * associated tag returns in the available tag list
1182     *
1183     * @param String $groupId : the groupId to delete
1184     */
1185    private function ajax_amd_admin_groupDelete($groupId)
1186    {
1187      if($groupId!="")
1188      {
1189        $sql="DELETE FROM ".$this->tables['groups']."
1190              WHERE groupId = $groupId;";
1191        pwg_query($sql);
1192
1193        $sql="DELETE FROM ".$this->tables['groups_names']."
1194              WHERE groupId = $groupId;";
1195        pwg_query($sql);
1196
1197        $sql="UPDATE ".$this->tables['selected_tags']."
1198              SET groupId = -1
1199              WHERE groupId = $groupId;";
1200        pwg_query($sql);
1201      }
1202    }
1203
1204
1205    /**
1206     * return the list of userDefined tag
1207     *
1208     * @return String : an HTML list ready to use
1209     */
1210    private function ajax_amd_admin_userDefinedGetList()
1211    {
1212      global $user, $template;
1213
1214      //$local_tpl = new Template(AMD_PATH."admin/", "");
1215      $template->set_filename('userDefList',
1216                    dirname($this->getFileLocation()).'/admin/amd_metadata_personnal_iListTags.tpl');
1217
1218      $datas=array();
1219
1220      $sql="SELECT aut.numId, aut.tagId, aut.translatedName, COUNT(autd.defId) AS numOfRules
1221            FROM ".$this->tables['used_tags']." aut
1222              LEFT JOIN ".$this->tables['user_tags_def']." autd ON aut.numId=autd.numId
1223            WHERE aut.tagId LIKE 'userDefined.%'
1224            GROUP BY aut.numId
1225            ORDER BY aut.tagId;";
1226      $result=pwg_query($sql);
1227      if($result)
1228      {
1229        while($row=pwg_db_fetch_assoc($result))
1230        {
1231          $datas[]=Array(
1232            'numId' => $row['numId'],
1233            'tagId' => $row['tagId'],
1234            'label' => htmlspecialchars($row['translatedName'], ENT_QUOTES, "UTF-8"),
1235            'numOfRules' => $row['numOfRules']
1236          );
1237        }
1238      }
1239
1240      $template->assign('datas', $datas);
1241      return($template->parse('userDefList', true));
1242    }
1243
1244    /**
1245     * returns a userDefined tag
1246     *
1247     * @param String $id :
1248     * @return String :
1249     */
1250    private function ajax_amd_admin_userDefinedGetTag($id)
1251    {
1252      $returned=array(
1253        'numId' => 0,
1254        'tagId' => '',
1255        'label' => '',
1256        'rules' => Array(),
1257        'lastDefId' => 1,
1258      );
1259
1260      $sql="SELECT aut.numId, aut.tagId, aut.name, MAX(autd.defId) AS lastDefId
1261            FROM ".$this->tables['used_tags']." aut
1262              LEFT JOIN ".$this->tables['user_tags_def']." autd ON autd.numId=aut.numId
1263            WHERE aut.numId='$id'
1264            GROUP BY aut.numId";
1265      $result=pwg_query($sql);
1266      if($result)
1267      {
1268        while($row=pwg_db_fetch_assoc($result))
1269        {
1270          $returned['numId']=$row['numId'];
1271          $returned['tagId']=$row['tagId'];
1272          $returned['label']=$row['name'];
1273          $returned['lastDefId']=$row['lastDefId'];
1274        }
1275
1276        $sql="SELECT numId, defId, parentId, `order`, type, value, conditionType, conditionValue
1277              FROM ".$this->tables['user_tags_def']."
1278              WHERE numId='$id'
1279              ORDER BY numId, `order`";
1280        $result=pwg_query($sql);
1281        if($result)
1282        {
1283          while($row=pwg_db_fetch_assoc($result))
1284          {
1285            $returned['rules'][]=$row;
1286          }
1287        }
1288      }
1289
1290      return(json_encode($returned));
1291    }
1292
1293
1294    /**
1295     * set a userDefined tag
1296     *
1297     * @param String $id :
1298     * @param Array $properties :
1299     * @return String : ok or ko
1300     */
1301    private function ajax_amd_admin_userDefinedSetTag($id, $properties)
1302    {
1303      global $user;
1304
1305      $currentTagId='';
1306
1307      if(!preg_match('/^userDefined\./', $properties['tagId']))
1308      {
1309        $properties['tagId']='userDefined.'.$properties['tagId'];
1310      }
1311
1312      $sql="SELECT numId, tagId FROM ".$this->tables['used_tags']."
1313            WHERE tagId='".$properties['tagId']."';";
1314      $result=pwg_query($sql);
1315      if($result)
1316      {
1317        while($row=pwg_db_fetch_assoc($result))
1318        {
1319          if($row['numId']!=$id)
1320          {
1321            return('iBDTagId!'.l10n('g003_tagIdAlreadyExist'));
1322          }
1323          $currentTagId=$row['tagId'];
1324        }
1325      }
1326
1327      /*
1328       * to set a user defined tag
1329       *  1/ if it's a new user tag, create the tag into the used_tags table to
1330       *     get a new numId for the tag
1331       *  2/ delete all properties into the user_tags_def
1332       *  3/ insert the properties
1333       */
1334      if($id=='')
1335      {
1336        // add a new metadata
1337        $sql="INSERT INTO ".$this->tables['used_tags']."
1338              VALUES ('', '".$properties['tagId']."', 'n', '".$properties['name']."', 0, '".$properties['name']."')";
1339        $result=pwg_query($sql);
1340        $id=pwg_db_insert_id();
1341
1342        /*
1343         * multilanguage management will be coded later....
1344        $sql="INSERT INTO ".$this->tables['user_tags_label']."
1345              VALUES ('$id', '".$user['language']."', '".$properties['name']."');";
1346        $result=pwg_query($sql);
1347        */
1348      }
1349      else
1350      {
1351        //update an existing metadata
1352        $sql="UPDATE ".$this->tables['used_tags']."
1353              SET tagId='".$properties['tagId']."',
1354                  name='".$properties['name']."',
1355                  translatedName='".$properties['name']."'
1356              WHERE numId='$id';";
1357        $result=pwg_query($sql);
1358
1359        $sql="DELETE FROM ".$this->tables['user_tags_def']."
1360              WHERE numId='$id';";
1361        $result=pwg_query($sql);
1362
1363        $sql="DELETE FROM ".$this->tables['images_tags']."
1364              WHERE numId='$id';";
1365        $result=pwg_query($sql);
1366
1367        if($currentTagId!='' and $currentTagId!=$properties['tagId'])
1368        {
1369          $sql="UPDATE ".$this->tables['selected_tags']."
1370                SET tagId='".$properties['tagId']."'
1371                WHERE tagId='$currentTagId'";
1372          $result=pwg_query($sql);
1373        }
1374      }
1375
1376      $inserts=array();
1377      foreach($properties['rules'] as $rule)
1378      {
1379        $inserts[]="('$id', '".$rule['defId']."', '".$rule['parentId']."', '".$rule['order']."', '".$rule['type']."', '".$rule['value']."', '".$rule['conditionType']."', '".$rule['conditionValue']."')";
1380      }
1381      $sql="INSERT INTO ".$this->tables['user_tags_def']."
1382            VALUES ".implode(',', $inserts);
1383      $result=pwg_query($sql);
1384
1385      $nbImg=$this->buildUserDefinedTags($id);
1386
1387      $sql="UPDATE ".$this->tables['used_tags']."
1388              SET numOfImg='$nbImg';";
1389      $result=pwg_query($sql);
1390
1391      return($id.','.$nbImg);
1392    }
1393
1394
1395    /**
1396     * delete a userDefined tag
1397     *
1398     * @param String $id :
1399     * @return String : ok or ko
1400     */
1401    private function ajax_amd_admin_userDefinedDeleteTag($id)
1402    {
1403      $tagId='';
1404      $sql="SELECT tagId
1405            FROM ".$this->tables['used_tags']."
1406            WHERE numId='$id';";
1407      $result=pwg_query($sql);
1408      if($result)
1409      {
1410        while($row=pwg_db_fetch_assoc($result))
1411        {
1412          $tagId=$row['tagId'];
1413        }
1414      }
1415
1416      if($tagId!='')
1417      {
1418        $sql="DELETE FROM ".$this->tables['selected_tags']."
1419              WHERE tagId='$tagId';";
1420        $result=pwg_query($sql);
1421      }
1422
1423      $sql="DELETE FROM ".$this->tables['used_tags']."
1424            WHERE numId='$id';";
1425      $result=pwg_query($sql);
1426
1427      $sql="DELETE FROM ".$this->tables['user_tags_label']."
1428            WHERE numId='$id';";
1429      $result=pwg_query($sql);
1430
1431      $sql="DELETE FROM ".$this->tables['user_tags_def']."
1432            WHERE numId='$id';";
1433      $result=pwg_query($sql);
1434
1435      $sql="DELETE FROM ".$this->tables['images_tags']."
1436            WHERE numId='$id';";
1437      $result=pwg_query($sql);
1438    }
1439
1440
1441  }
1442
1443
1444  $returned=new AMD_ajax($prefixeTable, __FILE__);
1445?>
Note: See TracBrowser for help on using the repository browser.