Ignore:
Timestamp:
Aug 28, 2010, 4:26:07 PM (14 years ago)
Author:
nikrou
Message:

Update tags with an ajax request

File:
1 copied

Legend:

Unmodified
Added
Removed
  • extensions/user_tags/include/t4u_admin_action.inc.php

    r6812 r6813  
    2424}
    2525
    26 define('T4U_PLUGIN_ROOT', dirname(__FILE__));
     26if (!empty($_GET['action']) && ($_GET['action']=='add')
     27    && !empty($_POST['tags']) && $me->getPermission('add')) {
     28  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     29 
     30  $tag_ids = get_fckb_tag_ids($_POST['tags']);
     31  set_tags($tag_ids, $_POST['image_id']);
    2732
    28 include_once T4U_PLUGIN_ROOT . "/include/constants.inc.php";
    29 include_once T4U_PLUGIN_ROOT . "/include/t4u_config.class.php";
     33  if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
     34    header("Content-Type: application/json");
    3035
    31 load_language('plugin.lang', T4U_PLUGIN_LANG);
    32 
    33 $plugin_config = new t4u_Config(T4U_PLUGIN_ROOT, T4U_PLUGIN_NAME);
    34 $plugin_config->load_config();
    35 
    36 if (defined('IN_ADMIN')) {
    37   add_event_handler('get_admin_plugin_menu_links', array($plugin_config, 'plugin_admin_menu'));
    38   add_event_handler('get_popup_help_content',
    39                     array($plugin_config, 'get_admin_help'),
    40                     EVENT_HANDLER_PRIORITY_NEUTRAL,
    41                     2
    42                     );
    43 } else {
    44   include_once T4U_PLUGIN_ROOT . '/public.php';
     36    $message['info'] = l10n('Tags updated');
     37    echo json_encode($message);
     38    exit();
     39  } else {
     40    redirect(get_absolute_root_url().$_POST['referer']);
     41  }
     42} elseif (!empty($_GET['action']) && $_GET['action']=='get' && $me->getPermission('add')) {
     43  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     44     
     45  $query = '
     46SELECT
     47    id AS tag_id,
     48    name AS tag_name
     49  FROM '.TAGS_TABLE.'
     50;';
     51  header("Content-Type: application/json");
     52  echo json_encode(get_fckb_taglist($query));
     53  exit();
    4554}
    46 
    47 set_plugin_data($plugin['id'], $plugin_config);
    4855?>
Note: See TracChangeset for help on using the changeset viewer.