source: trunk/admin/site_update.php @ 22979

Last change on this file since 22979 was 22979, checked in by plg, 11 years ago

merge r22978 from branch 2.5 to trunk

bug 2915 fixed: really disable synchronization on synchronization and site (directories) manager screens.

  • Property svn:eol-style set to LF
File size: 23.6 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2013 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die('Hacking attempt!');
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
30
31// +-----------------------------------------------------------------------+
32// | Check Access and exit when user status is not ok                      |
33// +-----------------------------------------------------------------------+
34
35if (!$conf['enable_synchronization'])
36{
37  die('synchronization is disabled');
38}
39
40check_status(ACCESS_ADMINISTRATOR);
41
42if (!is_numeric($_GET['site']))
43{
44  die ('site param missing or invalid');
45}
46$site_id = $_GET['site'];
47
48$query='
49SELECT galleries_url
50  FROM '.SITES_TABLE.'
51  WHERE id = '.$site_id;
52list($site_url) = pwg_db_fetch_row(pwg_query($query));
53if (!isset($site_url))
54{
55  die('site '.$site_id.' does not exist');
56}
57$site_is_remote = url_is_remote($site_url);
58
59list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
60define('CURRENT_DATE', $dbnow);
61
62$error_labels = array(
63  'PWG-UPDATE-1' => array(
64    l10n('wrong filename'),
65    l10n('The name of directories and files must be composed of letters, numbers, "-", "_" or "."')
66    ),
67  'PWG-ERROR-NO-FS' => array(
68    l10n('File/directory read error'),
69    l10n('The file or directory cannot be accessed (either it does not exist or the access is denied)')
70    ),
71  );
72$errors = array();
73$infos = array();
74
75if ($site_is_remote)
76{
77  fatal_error('remote sites not supported');
78}
79else
80{
81  include_once( PHPWG_ROOT_PATH.'admin/site_reader_local.php');
82  $site_reader = new LocalSiteReader($site_url);
83}
84
85$general_failure = true;
86if (isset($_POST['submit']))
87{
88  if ($site_reader->open())
89  {
90    $general_failure = false;
91  }
92
93  // shall we simulate only
94  if (isset($_POST['simulate']) and $_POST['simulate'] == 1)
95  {
96    $simulate = true;
97  }
98  else
99  {
100    $simulate = false;
101  }
102}
103
104// +-----------------------------------------------------------------------+
105// |                      directories / categories                         |
106// +-----------------------------------------------------------------------+
107if (isset($_POST['submit'])
108    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files'))
109{
110  $counts['new_categories'] = 0;
111  $counts['del_categories'] = 0;
112  $counts['del_elements'] = 0;
113  $counts['new_elements'] = 0;
114  $counts['upd_elements'] = 0;
115}
116
117
118if (isset($_POST['submit'])
119    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')
120    and !$general_failure)
121{
122  $start = get_moment();
123  // which categories to update ?
124  $query = '
125SELECT id, uppercats, global_rank, status, visible
126  FROM '.CATEGORIES_TABLE.'
127  WHERE dir IS NOT NULL
128    AND site_id = '.$site_id;
129  if (isset($_POST['cat']) and is_numeric($_POST['cat']))
130  {
131    if (isset($_POST['subcats-included']) and $_POST['subcats-included'] == 1)
132    {
133      $query.= '
134    AND uppercats '.DB_REGEX_OPERATOR.' \'(^|,)'.$_POST['cat'].'(,|$)\'
135';
136    }
137    else
138    {
139      $query.= '
140    AND id = '.$_POST['cat'].'
141';
142    }
143  }
144  $db_categories = hash_from_query($query, 'id');
145
146  // get categort full directories in an array for comparison with file
147  // system directory tree
148  $db_fulldirs = get_fulldirs(array_keys($db_categories));
149
150  // what is the base directory to search file system sub-directories ?
151  if (isset($_POST['cat']) and is_numeric($_POST['cat']))
152  {
153    $basedir = $db_fulldirs[$_POST['cat']];
154  }
155  else
156  {
157    $basedir = preg_replace('#/*$#', '', $site_url);
158  }
159
160  // we need to have fulldirs as keys to make efficient comparison
161  $db_fulldirs = array_flip($db_fulldirs);
162
163  // finding next rank for each id_uppercat. By default, each category id
164  // has 1 for next rank on its sub-categories to create
165  $next_rank['NULL'] = 1;
166
167  $query = '
168SELECT id
169  FROM '.CATEGORIES_TABLE;
170  $result = pwg_query($query);
171  while ($row = pwg_db_fetch_assoc($result))
172  {
173    $next_rank[$row['id']] = 1;
174  }
175
176  // let's see if some categories already have some sub-categories...
177  $query = '
178SELECT id_uppercat, MAX(rank)+1 AS next_rank
179  FROM '.CATEGORIES_TABLE.'
180  GROUP BY id_uppercat';
181  $result = pwg_query($query);
182  while ($row = pwg_db_fetch_assoc($result))
183  {
184    // for the id_uppercat NULL, we write 'NULL' and not the empty string
185    if (!isset($row['id_uppercat']) or $row['id_uppercat'] == '')
186    {
187      $row['id_uppercat'] = 'NULL';
188    }
189    $next_rank[$row['id_uppercat']] = $row['next_rank'];
190  }
191
192  // next category id available
193  $next_id = pwg_db_nextval('id', CATEGORIES_TABLE);
194
195  // retrieve sub-directories fulldirs from the site reader
196  $fs_fulldirs = $site_reader->get_full_directories($basedir);
197
198  // get_full_directories doesn't include the base directory, so if it's a
199  // category directory, we need to include it in our array
200  if (isset($_POST['cat']))
201  {
202    array_push($fs_fulldirs, $basedir);
203  }
204  // If $_POST['subcats-included'] != 1 ("Search in sub-albums" is unchecked)
205  // $db_fulldirs doesn't include any subdirectories and $fs_fulldirs does
206  // So $fs_fulldirs will be limited to the selected basedir
207  // (if that one is in $fs_fulldirs)
208  if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
209  {
210    $fs_fulldirs = array_intersect($fs_fulldirs, array_keys($db_fulldirs));
211  }
212  $inserts = array();
213  // new categories are the directories not present yet in the database
214  foreach (array_diff($fs_fulldirs, array_keys($db_fulldirs)) as $fulldir)
215  {
216    $dir = basename($fulldir);
217    if (preg_match($conf['sync_chars_regex'], $dir))
218    {
219      $insert = array(
220        'id'          => $next_id++,
221        'dir'         => $dir,
222        'name'        => str_replace('_', ' ', $dir),
223        'site_id'     => $site_id,
224        'commentable' =>
225          boolean_to_string($conf['newcat_default_commentable']),
226        'status'      => $conf['newcat_default_status'],
227        'visible'     => boolean_to_string($conf['newcat_default_visible']),
228        );
229
230      if (isset($db_fulldirs[dirname($fulldir)]))
231      {
232        $parent = $db_fulldirs[dirname($fulldir)];
233
234        $insert['id_uppercat'] = $parent;
235        $insert['uppercats'] =
236          $db_categories[$parent]['uppercats'].','.$insert['id'];
237        $insert['rank'] = $next_rank[$parent]++;
238        $insert['global_rank'] =
239          $db_categories[$parent]['global_rank'].'.'.$insert['rank'];
240        if ('private' == $db_categories[$parent]['status'])
241        {
242          $insert['status'] = 'private';
243        }
244        if ('false' == $db_categories[$parent]['visible'])
245        {
246          $insert['visible'] = 'false';
247        }
248      }
249      else
250      {
251        $insert['uppercats'] = $insert['id'];
252        $insert{'rank'} = $next_rank['NULL']++;
253        $insert['global_rank'] = $insert['rank'];
254      }
255
256      array_push($inserts, $insert);
257      array_push(
258        $infos,
259        array(
260          'path' => $fulldir,
261          'info' => l10n('added')
262          )
263        );
264
265      // add the new category to $db_categories and $db_fulldirs array
266      $db_categories[$insert{'id'}] =
267        array(
268          'id' => $insert['id'],
269          'status' => $insert['status'],
270          'visible' => $insert['visible'],
271          'uppercats' => $insert['uppercats'],
272          'global_rank' => $insert['global_rank']
273          );
274      $db_fulldirs[$fulldir] = $insert['id'];
275      $next_rank[$insert{'id'}] = 1;
276    }
277    else
278    {
279      array_push(
280        $errors,
281        array(
282          'path' => $fulldir,
283          'type' => 'PWG-UPDATE-1'
284          )
285        );
286    }
287  }
288
289  if (count($inserts) > 0)
290  {
291    if (!$simulate)
292    {
293      $dbfields = array(
294        'id','dir','name','site_id','id_uppercat','uppercats','commentable',
295        'visible','status','rank','global_rank'
296        );
297      mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
298
299      // add default permissions to categories
300      $category_ids = array();
301      foreach ($inserts as $category)
302      {
303        $category_ids[] = $category['id'];
304      }
305      add_permission_on_category($category_ids, get_admins());
306    }
307
308    $counts['new_categories'] = count($inserts);
309  }
310
311  // to delete categories
312  $to_delete = array(); $to_delete_derivative_dirs = array();
313  foreach (array_diff(array_keys($db_fulldirs), $fs_fulldirs) as $fulldir)
314  {
315    array_push($to_delete, $db_fulldirs[$fulldir]);
316    unset($db_fulldirs[$fulldir]);
317    array_push($infos, array('path' => $fulldir,
318                             'info' => l10n('deleted')));
319    if (substr_compare($fulldir, '../', 0, 3)==0)
320    {
321      $fulldir = substr($fulldir, 3);
322    }
323    $to_delete_derivative_dirs[] = PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$fulldir;
324  }
325  if (count($to_delete) > 0)
326  {
327    if (!$simulate)
328    {
329      delete_categories($to_delete);
330      foreach($to_delete_derivative_dirs as $to_delete_dir)
331      {
332        if (is_dir($to_delete_dir))
333        {
334          clear_derivative_cache_rec($to_delete_dir, '#.+#');
335        }
336      }
337    }
338    $counts['del_categories'] = count($to_delete);
339  }
340
341  $template->append('footer_elements', '<!-- scanning dirs : '
342    . get_elapsed_time($start, get_moment())
343    . ' -->' );
344}
345// +-----------------------------------------------------------------------+
346// |                           files / elements                            |
347// +-----------------------------------------------------------------------+
348if (isset($_POST['submit']) and $_POST['sync'] == 'files'
349      and !$general_failure)
350{
351  $start_files = get_moment();
352  $start= $start_files;
353
354  $fs = $site_reader->get_elements($basedir);
355  $template->append('footer_elements', '<!-- get_elements: '
356    . get_elapsed_time($start, get_moment())
357    . ' -->' );
358
359  $cat_ids = array_diff(array_keys($db_categories), $to_delete);
360
361  $db_elements = array();
362
363  if (count($cat_ids) > 0)
364  {
365    $query = '
366SELECT id, path
367  FROM '.IMAGES_TABLE.'
368  WHERE storage_category_id IN ('
369      .wordwrap(
370        implode(', ', $cat_ids),
371        160,
372        "\n"
373        ).')';
374    $db_elements = simple_hash_from_query($query, 'id', 'path');
375  }
376
377  // next element id available
378  $next_element_id = pwg_db_nextval('id', IMAGES_TABLE);
379
380  $start = get_moment();
381
382  $inserts = array();
383  $insert_links = array();
384
385  foreach (array_diff(array_keys($fs), $db_elements) as $path)
386  {
387    $insert = array();
388    // storage category must exist
389    $dirname = dirname($path);
390    if (!isset($db_fulldirs[$dirname]))
391    {
392      continue;
393    }
394    $filename = basename($path);
395    if (!preg_match($conf['sync_chars_regex'], $filename))
396    {
397      array_push(
398        $errors,
399        array(
400          'path' => $path,
401          'type' => 'PWG-UPDATE-1'
402          )
403        );
404
405      continue;
406    }
407
408    $insert = array(
409      'id'             => $next_element_id++,
410      'file'           => $filename,
411      'name'           => get_name_from_file($filename),
412      'date_available' => CURRENT_DATE,
413      'path'           => $path,
414      'representative_ext'  => $fs[$path]['representative_ext'],
415      'storage_category_id' => $db_fulldirs[$dirname],
416      'added_by'       => $user['id'],
417      );
418
419    if ( $_POST['privacy_level']!=0 )
420    {
421      $insert['level'] = $_POST['privacy_level'];
422    }
423
424    array_push(
425      $inserts,
426      $insert
427      );
428
429    array_push(
430      $insert_links,
431      array(
432        'image_id'    => $insert['id'],
433        'category_id' => $insert['storage_category_id'],
434        )
435      );
436
437    array_push(
438      $infos,
439      array(
440        'path' => $insert['path'],
441        'info' => l10n('added')
442        )
443      );
444
445    $caddiables[] = $insert['id'];
446  }
447
448  if (count($inserts) > 0)
449  {
450    if (!$simulate)
451    {
452      // inserts all new elements
453      mass_inserts(
454        IMAGES_TABLE,
455        array_keys($inserts[0]),
456        $inserts
457        );
458
459      // inserts all links between new elements and their storage category
460      mass_inserts(
461        IMAGE_CATEGORY_TABLE,
462        array_keys($insert_links[0]),
463        $insert_links
464        );
465
466      // add new photos to caddie
467      if (isset($_POST['add_to_caddie']) and $_POST['add_to_caddie'] == 1)
468      {
469        fill_caddie($caddiables);
470      }
471    }
472    $counts['new_elements'] = count($inserts);
473  }
474
475  // delete elements that are in database but not in the filesystem
476  $to_delete_elements = array();
477  foreach (array_diff($db_elements, array_keys($fs)) as $path)
478  {
479    array_push($to_delete_elements, array_search($path, $db_elements));
480    array_push($infos, array('path' => $path,
481                             'info' => l10n('deleted')));
482  }
483  if (count($to_delete_elements) > 0)
484  {
485    if (!$simulate)
486    {
487      delete_elements($to_delete_elements);
488    }
489    $counts['del_elements'] = count($to_delete_elements);
490  }
491
492  $template->append('footer_elements', '<!-- scanning files : '
493    . get_elapsed_time($start_files, get_moment())
494    . ' -->' );
495}
496
497// +-----------------------------------------------------------------------+
498// |                          synchronize files                            |
499// +-----------------------------------------------------------------------+
500if (isset($_POST['submit'])
501    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')
502    and !$general_failure )
503{
504  if (!$simulate)
505  {
506    $start = get_moment();
507    update_category('all');
508    $template->append('footer_elements', '<!-- update_category(all) : '
509      . get_elapsed_time($start,get_moment())
510      . ' -->' );
511    $start = get_moment();
512    update_global_rank();
513    $template->append('footer_elements', '<!-- ordering categories : '
514      . get_elapsed_time($start, get_moment())
515      . ' -->');
516  }
517
518  if ($_POST['sync'] == 'files')
519  {
520    $start = get_moment();
521    $opts['category_id'] = '';
522    $opts['recursive'] = true;
523    if (isset($_POST['cat']))
524    {
525      $opts['category_id'] = $_POST['cat'];
526      if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
527      {
528        $opts['recursive'] = false;
529      }
530    }
531    $files = get_filelist($opts['category_id'], $site_id,
532                          $opts['recursive'],
533                          false);
534    $template->append('footer_elements', '<!-- get_filelist : '
535      . get_elapsed_time($start, get_moment())
536      . ' -->');
537    $start = get_moment();
538
539    $datas = array();
540    foreach ( $files as $id=>$file )
541    {
542      $file = $file['path'];
543      $data = $site_reader->get_element_update_attributes($file);
544      if ( !is_array($data) )
545      {
546        continue;
547      }
548
549      $data['id']=$id;
550      array_push($datas, $data);
551    } // end foreach file
552
553    $counts['upd_elements'] = count($datas);
554    if (!$simulate and count($datas)>0 )
555    {
556      mass_updates(
557        IMAGES_TABLE,
558        // fields
559        array(
560          'primary' => array('id'),
561          'update'  => $site_reader->get_update_attributes(),
562          ),
563        $datas
564        );
565    }
566    $template->append('footer_elements', '<!-- update files : '
567      . get_elapsed_time($start,get_moment())
568      . ' -->');
569  }// end if sync files
570}
571
572// +-----------------------------------------------------------------------+
573// |                          synchronize files                            |
574// +-----------------------------------------------------------------------+
575if (isset($_POST['submit'])
576    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files'))
577{
578  $template->assign(
579    'update_result',
580    array(
581      'NB_NEW_CATEGORIES'=>$counts['new_categories'],
582      'NB_DEL_CATEGORIES'=>$counts['del_categories'],
583      'NB_NEW_ELEMENTS'=>$counts['new_elements'],
584      'NB_DEL_ELEMENTS'=>$counts['del_elements'],
585      'NB_UPD_ELEMENTS'=>$counts['upd_elements'],
586      'NB_ERRORS'=>count($errors),
587      ));
588}
589
590// +-----------------------------------------------------------------------+
591// |                          synchronize metadata                         |
592// +-----------------------------------------------------------------------+
593if (isset($_POST['submit']) and isset($_POST['sync_meta'])
594         and !$general_failure)
595{
596  // sync only never synchronized files ?
597  $opts['only_new'] = isset($_POST['meta_all']) ? false : true;
598  $opts['category_id'] = '';
599  $opts['recursive'] = true;
600
601  if (isset($_POST['cat']))
602  {
603    $opts['category_id'] = $_POST['cat'];
604    // recursive ?
605    if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
606    {
607      $opts['recursive'] = false;
608    }
609  }
610  $start = get_moment();
611  $files = get_filelist($opts['category_id'], $site_id,
612                        $opts['recursive'],
613                        $opts['only_new']);
614
615  $template->append('footer_elements', '<!-- get_filelist : '
616    . get_elapsed_time($start, get_moment())
617    . ' -->');
618
619  $start = get_moment();
620  $datas = array();
621  $tags_of = array();
622
623  foreach ( $files as $id => $element_infos )
624  {
625    $data = $site_reader->get_element_metadata($element_infos);
626
627    if ( is_array($data) )
628    {
629      $data['date_metadata_update'] = CURRENT_DATE;
630      $data['id']=$id;
631      array_push($datas, $data);
632
633      foreach (array('keywords', 'tags') as $key)
634      {
635        if (isset($data[$key]))
636        {
637          if (!isset($tags_of[$id]))
638          {
639            $tags_of[$id] = array();
640          }
641
642          foreach (explode(',', $data[$key]) as $tag_name)
643          {
644            array_push(
645              $tags_of[$id],
646              tag_id_from_tag_name($tag_name)
647              );
648          }
649        }
650      }
651    }
652    else
653    {
654      array_push($errors, array('path' => $element_infos['path'], 'type' => 'PWG-ERROR-NO-FS'));
655    }
656  }
657
658  if (!$simulate)
659  {
660    if (count($datas) > 0)
661    {
662      mass_updates(
663        IMAGES_TABLE,
664        // fields
665        array(
666          'primary' => array('id'),
667          'update'  => array_unique(
668            array_merge(
669              array_diff(
670                $site_reader->get_metadata_attributes(),
671                // keywords and tags fields are managed separately
672                array('keywords', 'tags')
673                ),
674              array('date_metadata_update'))
675            )
676          ),
677        $datas,
678        isset($_POST['meta_empty_overrides']) ? 0 : MASS_UPDATES_SKIP_EMPTY
679        );
680    }
681    set_tags_of($tags_of);
682  }
683
684  $template->append('footer_elements', '<!-- metadata update : '
685    . get_elapsed_time($start, get_moment())
686    . ' -->');
687
688  $template->assign(
689    'metadata_result',
690    array(
691      'NB_ELEMENTS_DONE' => count($datas),
692      'NB_ELEMENTS_CANDIDATES' => count($files),
693      'NB_ERRORS' => count($errors),
694      ));
695}
696
697// +-----------------------------------------------------------------------+
698// |                        template initialization                        |
699// +-----------------------------------------------------------------------+
700$template->set_filenames(array('update'=>'site_update.tpl'));
701$result_title = '';
702if (isset($simulate) and $simulate)
703{
704  $result_title.= '['.l10n('Simulation').'] ';
705}
706
707// used_metadata string is displayed to inform admin which metadata will be
708// used from files for synchronization
709$used_metadata = implode( ', ', $site_reader->get_metadata_attributes());
710if ($site_is_remote and !isset($_POST['submit']) )
711{
712  $used_metadata.= ' + ...';
713}
714
715$template->assign(
716  array(
717    'SITE_URL'=>$site_url,
718    'U_SITE_MANAGER'=> get_root_url().'admin.php?page=site_manager',
719    'L_RESULT_UPDATE'=>$result_title.l10n('Search for new images in the directories'),
720    'L_RESULT_METADATA'=>$result_title.l10n('Metadata synchronization results'),
721    'METADATA_LIST' => $used_metadata,
722    'U_HELP' => get_root_url().'admin/popuphelp.php?page=synchronize',
723    ));
724
725// +-----------------------------------------------------------------------+
726// |                        introduction : choices                         |
727// +-----------------------------------------------------------------------+
728if (isset($_POST['submit']))
729{
730  $tpl_introduction = array(
731      'sync'  => $_POST['sync'],
732      'sync_meta'  => isset($_POST['sync_meta']) ? true : false,
733      'display_info' => isset($_POST['display_info']) and $_POST['display_info']==1,
734      'add_to_caddie' => isset($_POST['add_to_caddie']) and $_POST['add_to_caddie']==1,
735      'subcats_included' => isset($_POST['subcats-included']) and $_POST['subcats-included']==1,
736      'privacy_level_selected' => (int)@$_POST['privacy_level'],
737      'meta_all'  => isset($_POST['meta_all']) ? true : false,
738      'meta_empty_overrides'  => isset($_POST['meta_empty_overrides']) ? true : false,
739    );
740
741  if (isset($_POST['cat']) and is_numeric($_POST['cat']))
742  {
743    $cat_selected = array($_POST['cat']);
744  }
745  else
746  {
747    $cat_selected = array();
748  }
749}
750else
751{
752  $tpl_introduction = array(
753      'sync'  => 'dirs',
754      'sync_meta'  => true,
755      'display_info' => false,
756      'add_to_caddie' => false,
757      'subcats_included' => true,
758      'privacy_level_selected' => 0,
759      'meta_all'  => false,
760      'meta_empty_overrides'  => false,
761    );
762
763  $cat_selected = array();
764
765  if (isset($_GET['cat_id']))
766  {
767    check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
768
769    $cat_selected = array($_GET['cat_id']);
770    $tpl_introduction['sync'] = 'files';
771  }
772}
773
774$tpl_introduction['privacy_level_options'] = get_privacy_level_options();
775
776$template->assign('introduction', $tpl_introduction);
777
778$query = '
779SELECT id,name,uppercats,global_rank
780  FROM '.CATEGORIES_TABLE.'
781  WHERE site_id = '.$site_id;
782display_select_cat_wrapper($query,
783                           $cat_selected,
784                           'category_options',
785                           false);
786
787
788if (count($errors) > 0)
789{
790  foreach ($errors as $error)
791  {
792    $template->append(
793      'sync_errors',
794      array(
795        'ELEMENT' => $error['path'],
796        'LABEL' => $error['type'].' ('.$error_labels[$error['type']][0].')'
797        ));
798  }
799
800  foreach ($error_labels as $error_type=>$error_description)
801  {
802    $template->append(
803      'sync_error_captions',
804      array(
805        'TYPE' => $error_type,
806        'LABEL' => $error_description[1]
807        ));
808  }
809}
810
811if (count($infos) > 0
812    and isset($_POST['display_info'])
813    and $_POST['display_info'] == 1)
814{
815  foreach ($infos as $info)
816  {
817    $template->append(
818      'sync_infos',
819      array(
820        'ELEMENT' => $info['path'],
821        'LABEL' => $info['info']
822        ));
823  }
824}
825
826// +-----------------------------------------------------------------------+
827// |                          sending html code                            |
828// +-----------------------------------------------------------------------+
829$template->assign_var_from_handle('ADMIN_CONTENT', 'update');
830?>
Note: See TracBrowser for help on using the repository browser.