source: extensions/lmt/lmt_aip.class.inc.php

Last change on this file was 17604, checked in by grum, 12 years ago

bug:2726

  • Property svn:executable set to *
File size: 24.2 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : LMT
4  Author     : Grum
5    email    : grum@piwigo.org
6    website  : http://photos.grum.fr
7
8    << May the Little SpaceFrog be with you ! >>
9  ------------------------------------------------------------------------------
10  See main.inc.php for release information
11
12  LMT_AIP : classe to manage plugin admin pages
13
14  --------------------------------------------------------------------------- */
15
16include_once('lmt_root.class.inc.php');
17include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
18include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php');
19include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/genericjs.class.inc.php');
20include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPagesNavigation.class.inc.php');
21include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
22
23class LMT_AIP extends LMT_root
24{
25  protected $tabsheet;
26
27  public function __construct($prefixeTable, $filelocation)
28  {
29    parent::__construct($prefixeTable, $filelocation);
30    $this->loadConfig();
31    $this->initEvents();
32
33    $this->tabsheet = new tabsheet();
34    $this->tabsheet->add('list',
35                          l10n('lmt_list'),
36                          $this->getAdminLink()."-list");
37    $this->tabsheet->add('manage',
38                          l10n('lmt_manage'),
39                          $this->getAdminLink()."-manage");
40    $this->tabsheet->add('manageaut',
41                          l10n('lmt_manageaut'),
42                          $this->getAdminLink()."-manageaut");
43    $this->tabsheet->add('search',
44                          l10n('lmt_search'),
45                          $this->getAdminLink()."-search");
46    $this->tabsheet->add('config',
47                          l10n('lmt_config'),
48                          $this->getAdminLink()."-config");
49    $this->tabsheet->add('help',
50                          l10n('lmt_help'),
51                          $this->getAdminLink()."-help");
52  }
53
54  public function __destruct()
55  {
56    unset($this->tabsheet);
57    parent::__destruct();
58  }
59
60  /*
61    initialize events call for the plugin
62  */
63  public function initEvents()
64  {
65    parent::initEvents();
66
67    if(isset($_GET['tab']) and $_GET['tab']=='search')
68    {
69      // load request builder JS only on the search page
70      GPCRequestBuilder::loadJSandCSS();
71    }
72  }
73
74
75  /*
76    display administration page
77  */
78  public function manage()
79  {
80    global $template;
81
82    $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/lmt_admin.tpl");
83    GPCCore::setTemplateToken();
84
85    if(!isset($_GET['tab'])) $_GET['tab']='list';
86
87    switch($_GET['tab'])
88    {
89      case 'list':
90        $this->display_list_page();
91        break;
92      case 'manage':
93        $this->display_manage_page();
94        break;
95      case 'manageaut':
96        $this->display_manageaut_page();
97        break;
98      case 'managedoc':
99        $this->display_managedoc_page();
100        break;
101      case 'search':
102        $this->displaySearch();
103        break;
104      case 'help':
105        $this->display_help_page();
106        break;
107      case 'config':
108        $this->display_config_page();
109        break;
110    }
111
112    $this->tabsheet->select($_GET['tab']);
113    $this->tabsheet->assign();
114    $selected_tab=$this->tabsheet->get_selected();
115    $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]");
116
117    $template_plugin["LMT_VERSION"] = "<i>".$this->getPluginName()."</i> ".l10n('lmt_release').LMT_VERSION;
118    $template_plugin["LMT_PAGE"] = $_GET['tab'];
119    $template_plugin["LMT_TITLE"] = "";
120
121    $template->assign('plugin', $template_plugin);
122    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
123  }
124
125
126  /*
127    manage display of config page & save config
128  */
129  protected function display_config_page()
130  {
131    $languages=get_languages();
132
133    GPCCore::addHeaderJS('lmt.config', './plugins/lmt/js/lmtConfig.js', array('jquery'));
134    GPCCore::addUI('inputNum,simpleTip');
135    if(!$this->adviser_abort())
136    {
137
138      if(isset($_POST['submit_save_config']))
139      {
140        foreach($this->config as $key => $val)
141        {
142          if(is_array($val))
143          {
144            foreach($languages as $key2 => $val2)
145            {
146              if(isset($_REQUEST[str2url('f_'.$key.'_'.$key2)]))
147              {
148                $this->config[$key][$key2] = htmlspecialchars(stripslashes($_REQUEST[str2url('f_'.$key.'_'.$key2)]), ENT_QUOTES);
149              }
150            }
151          }
152          else
153          {
154            if(isset($_REQUEST['f_'.$key]))
155            {
156              $this->config[$key] = $_REQUEST['f_'.$key];
157            }
158          }
159
160        }
161        $this->displayResult(l10n('lmt_save_config'), $this->saveConfig());
162      }
163    }
164    $this->display_config();
165  }
166
167
168  /*
169
170  */
171  protected function display_help_page()
172  {
173    global $template;
174
175    $template->set_filename('body_page',
176                dirname($this->getFileLocation()).'/admin/plugin_admin_help.tpl');
177
178    $template->assign('imgdir', LMT_PATH."img/");
179
180    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
181  }
182
183  /*
184  */
185  protected function display_list_page()
186  {
187    global $template, $conf, $user;
188
189    $template->set_filename('body_page',
190                dirname($this->getFileLocation()).'/admin/plugin_admin_list.tpl');
191
192    if(!isset($_REQUEST['filter']) ||
193       !($_REQUEST['filter']=="BY" ||
194         $_REQUEST['filter']=="BY-SA" ||
195         $_REQUEST['filter']=="BY-ND" ||
196         $_REQUEST['filter']=="BY-NC-ND" ||
197         $_REQUEST['filter']=="BY-NC-SA" ||
198         $_REQUEST['filter']=="BY-NC" ||
199         $_REQUEST['filter']=="CRIGHT" ||
200         $_REQUEST['filter']=="CLEFT" ||
201         $_REQUEST['filter']=="CC0" ||
202         $_REQUEST['filter']=="PD"
203      ))
204    {
205      $_REQUEST['filter']='';
206    }
207
208    $datas=array(
209      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink('ajax')
210    );
211
212    $filter_list_selected = '';
213    $filter_list_values = array_slice(LMT_root::$licences,0,count(LMT_root::$licences)-1);
214    $filter_list_labels = array();
215    foreach($filter_list_values as $key=>$val)
216    {
217      $filter_list_labels[] = "[".$this->translateCopyright("lmt_lbl_cc_s-".strtolower($val))."] ".$this->translateCopyright("lmt_lbl_cc-".strtolower($val));
218      if($val==$_REQUEST['filter'])
219      {
220        $filter_list_selected = $val;
221      }
222    }
223
224    $filter_list_values = array_merge(array(''), $filter_list_values);
225    $filter_list_labels = array_merge(array(l10n('lmt_nofilter')), $filter_list_labels);
226    $default_licence = $this->translateCopyright("lmt_lbl_cc-".strtolower($this->config['lmt_licence_default']));
227    $default_licence_img =LMT_PATH."img/".strtolower($this->config['lmt_licence_default'])."_80x15.png";
228
229    $results=true;
230    if(isset($_POST["submit_replace_caddie"]))
231    {
232      $sql="DELETE FROM ".CADDIE_TABLE." WHERE user_id='".$user['id']."'";
233      $result=pwg_query($sql);
234      ($result)?$results=true:$results=false;
235    }
236
237    if(isset($_POST["submit_add_to_caddie"]) || isset($_POST["submit_replace_caddie"]))
238    {
239
240      $sql="REPLACE INTO ".CADDIE_TABLE."
241        SELECT '".$user['id']."', it.id FROM ".IMAGES_TABLE." it, ".$this->tables["images"]." lmti
242        WHERE it.id = lmti.image_id";
243      if($_REQUEST['filter']!="")
244      {
245        $sql.=" AND lmti.licence_type='".$_REQUEST['filter']."'";
246      }
247
248      $result=pwg_query($sql);
249      if((!$results)||(!$result))
250      {
251        $this->displayResult(l10n("lmt_caddie_not_updated"), false);
252      }
253      else
254      {
255        $this->displayResult(l10n("lmt_caddie_updated"), true);
256      }
257    }
258
259    $template->assign('datas', $datas);
260    $template->assign('default_licence', $default_licence);
261    $template->assign('default_licence_img', $default_licence_img);
262    $template->assign('filter_list_values', $filter_list_values);
263    $template->assign('filter_list_labels', $filter_list_labels);
264    $template->assign('filter_list_selected', $filter_list_selected);
265    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
266  }
267
268
269  /*
270  */
271  protected function display_manage_page()
272  {
273    global $template, $conf, $user;
274
275    /*
276      apply licence
277    */
278    if(isset($_POST['submit_apply_licence']))
279    {
280      $results=array("", "");
281      $lst=array();
282      foreach($_POST as $key => $val)
283      {
284        if((substr($key,0,2)=="fn")&&($val=="1")) $lst[]=substr($key,2);
285      }
286
287      if(count($lst)>0)
288      {
289        if($_POST['manage_caddie']!="napp_clear_selected")
290        {
291          if($_POST['licence']=='DEFAULT')
292          {
293            $sql="DELETE FROM ".$this->tables['images']."
294                    WHERE image_id IN (".implode(",", $lst).")";
295          }
296          else
297          {
298            $sql="REPLACE INTO ".$this->tables['images']."
299                    SELECT id, '".$_POST['licence']."', '".$_POST['author']."'
300                    FROM ".IMAGES_TABLE."
301                    WHERE id IN (".implode(",", $lst).")";
302          }
303          $result=pwg_query($sql);
304          ($result)?$results[0].=l10n("lmt_add_licence_ok")."<br/>":$results[1].=l10n("lmt_add_licence_ko")."<br/>";
305        }
306
307        switch($_POST['manage_caddie'])
308        {
309          case 'app_clear':
310            $sql="DELETE FROM ".CADDIE_TABLE." WHERE user_id = '".$user['id']."'";
311            $result=pwg_query($sql);
312            ($result)?$results[0].=l10n("lmt_clear_caddie_ok")."<br/>":$results[1].=l10n("lmt_clear_caddie_ko")."<br/>";
313            break;
314          case 'app_clear_selected':
315          case 'napp_clear_selected':
316            $sql="DELETE FROM ".CADDIE_TABLE."
317                  WHERE user_id = '".$user['id']."'
318                  AND element_id IN (".implode(",", $lst).")";
319            $result=pwg_query($sql);
320            ($result)?$results[0].=l10n("lmt_clear_si_caddie_ok")."<br/>":$results[1].=l10n("lmt_clear_si_caddie_ko")."<br/>";
321            break;
322        }
323
324        if($results[0]!="")
325        {
326          $this->displayResult($results[0], true);
327        }
328
329        if($results[1]!="")
330        {
331          $this->displayResult($results[1], false);
332        }
333      }
334      else
335      {
336        $this->displayResult(l10n("lmt_no_element_selected"), false);
337      }
338    }
339
340
341    $template->set_filename('body_page',
342                dirname($this->getFileLocation()).'/admin/plugin_admin_manage.tpl');
343
344    $datas=array(
345      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink('ajax')
346    );
347
348    if(!isset($_REQUEST['select']))
349    {
350      $_REQUEST['select']="caddie";
351    }
352
353    $sql="SELECT count(element_id) FROM ".CADDIE_TABLE." WHERE user_id = '".$user['id']."'";
354    $result=pwg_query($sql);
355    $nbphotos=pwg_db_fetch_row($result);
356
357    $author_list_values = array(0);
358    $author_list_labels = array(l10n("lmt_no_author"));
359    $sql="SELECT * FROM ".$this->tables["licence_author"]." ORDER BY id";
360    $result=pwg_query($sql);
361    if($result)
362    {
363      while($row=pwg_db_fetch_assoc($result))
364      {
365        $author_list_values[]=$row['id'];
366        $author_list_labels[]=$row['text1']."&nbsp;".$row['text2'];
367      }
368    }
369
370    $licences_list_values = array();
371    $licences_list_values = self::$licences;
372    $licences_list_labels = array();
373    foreach($licences_list_values as $key=>$val)
374    {
375      $licences_list_labels[] = "[".$this->translateCopyright("lmt_lbl_cc_s-".strtolower($val))."] ".$this->translateCopyright("lmt_lbl_cc-".strtolower($val));
376    }
377
378/*    $licences_list_values = array_merge(array('DEFAULT'), $licences_list_values);
379    $licences_list_labels = array_merge(array(l10n('lmt_bydefault')), $licences_list_labels);*/
380
381    $selectlist_list_values=array("-", "all", "none", "invert");
382    $selectlist_list_values=array_merge($selectlist_list_values, $licences_list_values);
383
384    $selectlist_list_labels=array(
385        l10n("lmt_choose_select"),
386        l10n("lmt_select_all"),
387        l10n("lmt_select_none"),
388        l10n("lmt_select_invert")
389    );
390    $selectlist_list_labels=array_merge($selectlist_list_labels, $licences_list_labels);
391
392    $template->assign('datas', $datas);
393    $template->assign('nbphotos', $nbphotos[0]);
394    $template->assign('selectlist_list_values', $selectlist_list_values);
395    $template->assign('selectlist_list_labels', $selectlist_list_labels);
396    $template->assign('filter_list_selected', "");
397    $template->assign('licences_list_values', $licences_list_values);
398    $template->assign('licences_list_labels', $licences_list_labels);
399    $template->assign('licences_list_selected', "");
400    $template->assign('author_list_values', $author_list_values);
401    $template->assign('author_list_labels', $author_list_labels);
402    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
403  }
404
405
406  /*
407    display config page
408  */
409  protected function display_config()
410  {
411    global $template, $lang;
412
413    $template->set_filename('body_page',
414                dirname($this->getFileLocation()).'/admin/plugin_admin_config.tpl');
415
416
417    $datas=array(
418      "img_directory" => LMT_PATH."img/"
419    );
420    foreach($this->config as $key => $val)
421    {
422      if(!is_array($val))
423      {
424        $datas[$key]=$val;
425      }
426    }
427
428    $lmt_yesno_values=array("y", "n");
429    $lmt_yesno_labels=array(l10n("lmt_yesno_y"), l10n("lmt_yesno_n"));
430
431    $lmt_licence_logo_values=array("80x15", "88x31", "text");
432    $lmt_licence_logo_labels=array(l10n("lmt_icon_80x15"), l10n("lmt_icon_88x31"), l10n("lmt_icon_text"));
433
434    $datas['lmt_redirect_urls']=array();
435    $lmt_licence_default_values = array_slice(self::$licences,0,count(self::$licences)-1);
436    $lmt_licence_default_labels = array();
437
438    $tmp=array();
439    foreach($lmt_licence_default_values as $key=>$val)
440    {
441      $lmt_licence_default_labels[] = "[".$this->translateCopyright("lmt_lbl_cc_s-".strtolower($val))."] ".$this->translateCopyright("lmt_lbl_cc-".strtolower($val));
442
443      $tmp[]="'".str2url("ilmt_redirect_url-".strToLower($val))."'";
444      $datas['lmt_redirect_urls'][str2url('lmt_redirect_url-'.strToLower($val))]=array(
445        'text' => $this->translateCopyright("lmt_lbl_cc_s-".strToLower($val)),
446        'langs' => array()
447      );
448    }
449    $datas['objnames2'] = implode(",", $tmp);
450
451
452    //langs list & texts
453    $datas['lmt_warning_texts']=array();
454
455    $lmt_language_list=array();
456    $lmt_language_list_values=array();
457    $lmt_language_list_labels=array();
458    $lmt_language_selected=str2url(get_default_language());
459    $languages=get_languages();
460
461    foreach($languages as $key => $val)
462    {
463      $lmt_language_list_values[]=str2url($key);
464      $lmt_language_list_labels[]=$val;
465
466      $datas['lmt_warning_texts'][]=array(
467        'lang' => str2url($key),
468        'text' => $this->config['lmt_warning_texts'][$key]
469      );
470
471      foreach($lmt_licence_default_values as $key2 => $val2)
472      {
473        $datas['lmt_redirect_urls'][str2url('lmt_redirect_url-'.strToLower($val2))]['langs'][str2url($key)]=
474            $this->config['lmt_redirect_url-'.strToLower($val2)][$key];
475      }
476    }
477
478    $lmt_licence_default_author_values=array(0);
479    $lmt_licence_default_author_labels=array(l10n("lmt_no_author"));
480    $sql="SELECT * FROM ".$this->tables['licence_author']." ORDER BY id";
481    $result=pwg_query($sql);
482    if($result)
483    {
484      while($row=pwg_db_fetch_assoc($result))
485      {
486        $lmt_licence_default_author_values[]=$row['id'];
487        $lmt_licence_default_author_labels[]=$row['text1']." ".$row['text2'];
488      }
489    }
490
491    $template->assign('datas', $datas);
492    $template->assign('extended_code', $this->generate_js_licence_author());
493    $template->assign('lmt_yesno_values', $lmt_yesno_values);
494    $template->assign('lmt_yesno_labels', $lmt_yesno_labels);
495    $template->assign('lmt_licence_logo_values', $lmt_licence_logo_values);
496    $template->assign('lmt_licence_logo_labels', $lmt_licence_logo_labels);
497    $template->assign('lmt_licence_default_values', $lmt_licence_default_values);
498    $template->assign('lmt_licence_default_labels', $lmt_licence_default_labels);
499    $template->assign('lmt_licence_default_author_values', $lmt_licence_default_author_values);
500    $template->assign('lmt_licence_default_author_labels', $lmt_licence_default_author_labels);
501    $template->assign('lmt_language_list_values', $lmt_language_list_values);
502    $template->assign('lmt_language_list_labels', $lmt_language_list_labels);
503    $template->assign('lmt_language_selected', $lmt_language_selected);
504    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
505
506  } //display_config
507
508
509
510  /**
511   * display the search page
512   *
513   */
514  protected function displaySearch()
515  {
516    global $template;
517
518    $template->set_filename('body_page',
519                dirname($this->getFileLocation()).'/admin/lmt_search.tpl');
520
521    $template->assign('lmt_search_page', GPCRequestBuilder::displaySearchPage($this->getPluginName()));
522
523    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
524  }
525
526
527
528  /*
529  */
530  protected function display_manageaut_page()
531  {
532    global $template, $conf, $user;
533
534    if(!isset($_REQUEST['action']))
535    {
536      $_REQUEST['action']="list";
537    }
538    if(!isset($_REQUEST['id']))
539    {
540      $_REQUEST['id']="";
541    }
542
543
544    /* ------------------------------------------------------------------------
545     * Add an author
546     * ---------------------------------------------------------------------- */
547    if(isset($_POST['submit_add_author']))
548    {
549      if($_POST["text1"]!="")
550      {
551        $sql="INSERT INTO ".$this->tables["licence_author"]." VALUES('', '". htmlspecialchars($_POST["text1"], ENT_QUOTES)."', '".htmlspecialchars($_POST["text2"], ENT_QUOTES)."')";
552        $result=pwg_query($sql);
553        if($result)
554        {
555          $this->displayResult(l10n("lmt_author_added"), true);
556          $_REQUEST['action']="list";
557        }
558        else
559        {
560          $this->displayResult(l10n("lmt_cannot_add_author"), false);
561        }
562      }
563      else
564      {
565        $this->displayResult(l10n("lmt_no_text"), false);
566      }
567    }
568
569    /* ------------------------------------------------------------------------
570     * Modify an author
571     * ---------------------------------------------------------------------- */
572    if(isset($_POST['submit_modify_author']))
573    {
574      if($_POST["text1"]!="")
575      {
576        $sql="UPDATE ".$this->tables["licence_author"]."
577              SET text1 = '". htmlspecialchars($_POST["text1"], ENT_QUOTES)."',
578                  text2 = '".htmlspecialchars($_POST["text2"], ENT_QUOTES)."'
579              WHERE id = '".$_POST["id"]."'";
580        $result=pwg_query($sql);
581        if($result)
582        {
583          $this->displayResult(l10n("lmt_author_modified"), true);
584          $_REQUEST['action']="list";
585        }
586        else
587        {
588          $this->displayResult(l10n("lmt_cannot_modify_author"), false);
589        }
590      }
591      else
592      {
593        $this->displayResult(l10n("lmt_no_text"), false);
594      }
595    }
596
597    /* ------------------------------------------------------------------------
598     * delete an author
599     * ---------------------------------------------------------------------- */
600    if($_REQUEST['action']=="delete")
601    {
602      $sql="DELETE FROM ".$this->tables['licence_author']." WHERE id = '".$_REQUEST['id']."'";
603      $result=pwg_query($sql);
604      if($result)
605      {
606        if(pwg_db_changes($result)==1)
607        {
608          $this->displayResult(l10n("lmt_author_deleted"), true);
609
610          $sql="UPDATE ".$this->tables["images"]." SET author_id = NULL
611                WHERE author_id = '".$_REQUEST['id']."'";
612          $result=pwg_query($sql);
613          if($result)
614          {
615            $nbimages=pwg_db_changes($result);
616            if($nbimages>0)
617            {
618              $this->displayResult($nbimages."&nbsp;".l10n("lmt_author_nb_images_updated"), true);
619            }
620          }
621          else
622          {
623            $this->displayResult(l10n("lmt_cannot_delete_author"), false);
624          }
625        }
626        else
627        {
628          $this->displayResult(l10n("lmt_cannot_delete_author"), false);
629        }
630      }
631      else
632      {
633        $this->displayResult(l10n("lmt_cannot_delete_author"), false);
634      }
635      $this->display_manageaut_page_list();
636    }
637    elseif($_REQUEST['action']=="add")
638    {
639      $this->display_manageaut_page_add_modify("add");
640    }
641    elseif($_REQUEST['action']=="edit")
642    {
643      $this->display_manageaut_page_add_modify("edit");
644    }
645    else
646    {
647      // list
648      $this->display_manageaut_page_list();
649    }
650  } //display_manageaut
651
652  protected function display_manageaut_page_list()
653  {
654    global $template;
655
656    $template->set_filename('body_page',
657                dirname($this->getFileLocation()).'/admin/plugin_admin_manageaut.tpl');
658
659    $datas=array(
660      "author_list" => array(),
661      "img_directory" => LMT_PATH."img/",
662      "default_licencepublished" => $this->translateCopyright("lmt_lbl_under-".strToLower($this->config['lmt_licence_default'])),
663      "default_licenceL" => strToLower($this->config['lmt_licence_default']),
664      "default_licenceU" => $this->translateCopyright("lmt_lbl_cc_s-".strToLower($this->config['lmt_licence_default'])),
665      "lmt_licence_logo" => $this->config['lmt_licence_logo'],
666      "nbauthor" => 0,
667      "add_link" => $this->getAdminLink().'-manageaut&amp;action=add'
668    );
669
670    $sql="SELECT * FROM ".$this->tables['licence_author']." ORDER BY id";
671    $result=pwg_query($sql);
672    if($result)
673    {
674      while($row=pwg_db_fetch_assoc($result))
675      {
676        $datas["author_list"][]=array(
677          "id" => $row['id'],
678          "text1" => $row['text1'],
679          "text2" => $row['text2'],
680          "lnk_delete" => $this->getAdminLink().'-manageaut&amp;action=delete&amp;id='.$row['id'],
681          "lnk_edit" => $this->getAdminLink().'-manageaut&amp;action=edit&amp;id='.$row['id']
682        );
683      }
684      $datas["nbauthor"] = count($datas["author_list"]);
685    }
686
687    $template->assign('datas', $datas);
688    //$template->assign('extended_code', $this->generate_js_licence_author());
689    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
690  }
691
692  protected function display_manageaut_page_add_modify()
693  {
694    global $template;
695
696    $template->set_filename('body_page',
697                dirname($this->getFileLocation()).'/admin/plugin_admin_manageaut_edit.tpl');
698
699    if($_REQUEST["action"]=="edit")
700    {
701      $sql="SELECT * FROM ".$this->tables['licence_author']." WHERE id = '".$_REQUEST['id']."'";
702      $result = pwg_query($sql);
703      if($result)
704      {
705        while($row=pwg_db_fetch_assoc($result))
706        {
707          $datas=array(
708            "action" => "modify",
709            "id" => $_REQUEST['id'],
710            "text1" => $row["text1"],
711            "text2" => $row["text2"]
712          );
713        }
714      }
715      else
716      {
717        $datas=array(
718          "action" => "add",
719          "id" => "",
720          "text1" => "",
721          "text2" => "",
722        );
723      }
724    }
725    else
726    {
727      $datas=array(
728        "action" => "add",
729        "id" => "",
730        "text1" => "",
731        "text2" => "",
732      );
733    }
734
735    $datas["urllist"] = $this->getAdminLink().'-manageaut';
736
737    $template->assign('datas', $datas);
738    //$template->assign('extended_code', $this->generate_js_licence_author());
739    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
740  }
741
742
743  /*
744    manage adviser profile
745      return true if user is adviser
746  */
747  protected function adviser_abort()
748  {
749    if(is_adviser())
750    {
751      $this->displayResult(l10n("lmt_adviser_not_allowed"), false);
752      return(true);
753    }
754    return(false);
755  }
756
757
758  /*
759    this function return a js to manage licence text
760  */
761  protected function generate_js_licence_author()
762  {
763    $local_tpl = new Template(LMT_PATH."admin/", "");
764    $local_tpl->set_filename('body_page',
765                  dirname($this->getFileLocation()).'/admin/lmt_js.tpl');
766
767    $lmt_licence_default_values=array_slice(self::$licences,0,count(self::$licences)-1);
768    $datas['shortlicencetext']=array();
769    foreach($lmt_licence_default_values as $key=>$val)
770    {
771      $datas['shortlicencetext'][$val] = array(
772        "txt" => $this->translateCopyright("lmt_lbl_cc_s-".strtolower($val)),
773        "published" => $this->translateCopyright("lmt_lbl_under-".strtolower($val))
774      );
775    }
776
777    $local_tpl->assign("datas",$datas);
778
779    return($local_tpl->parse('body_page', true));
780  }
781
782
783  /* ---------------------------------------------------------------------------
784    function to manage database manipulation
785  --------------------------------------------------------------------------- */
786
787} //class
788
789
790?>
Note: See TracBrowser for help on using the repository browser.