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

Last change on this file since 9095 was 7560, checked in by grum, 13 years ago

fix bug:1487 - LMT image not displayed with IE8
implement feature:1689 - Add possibility to search picture by licence

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