Ignore:
Timestamp:
Nov 23, 2013, 4:16:27 PM (10 years ago)
Author:
mistic100
Message:
  • add quick edit form for picture (todo: album)
  • add "Delete photo" button
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/AdminTools/include/events.inc.php

    r25629 r25654  
    2121    'USER' => $MultiView->get_user(),
    2222    'CURRENT_USERNAME' => $user['id']==$conf['guest_id'] ? l10n('guest') : $user['username'],
     23    'PWG_TOKEN' => get_pwg_token(),
    2324    );
    2425
     
    2728  {
    2829    global $picture;
     30
     31    include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php');
    2932
    3033    $url_self = duplicate_picture_url();
     
    3841      ));
    3942
     43    $template->set_prefilter('picture', 'admintools_remove_privacy');
     44
    4045    $query = 'SELECT element_id FROM ' . CADDIE_TABLE . '
    4146      WHERE element_id = ' . $page['image_id'] .';';
     
    6368      $url_self,
    6469      array('action'=>'add_to_caddie')
     70      );
     71
     72    // gets tags
     73    $query = '
     74SELECT id, name
     75  FROM '.IMAGE_TAG_TABLE.' AS it
     76    JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id
     77  WHERE image_id = '.$page['image_id'].'
     78;';
     79    $tag_selection = get_taglist($query);
     80
     81    $query = '
     82SELECT id, name
     83  FROM '.TAGS_TABLE.'
     84;';
     85    $tags = get_taglist($query, false);
     86
     87    $tpl_vars['QUICK_EDIT'] = array(
     88      'file' => $picture['current']['file'],
     89      'name' => $picture['current']['name'],
     90      'comment' => $picture['current']['comment'],
     91      'author' => $picture['current']['author'],
     92      'level' => $picture['current']['level'],
     93      'date_creation' => substr($picture['current']['date_creation'], 0, 10),
     94      'date_creation_time' => substr($picture['current']['date_creation'], 11, 5),
     95      'tag_selection' => $tag_selection,
     96      'tags' => $tags,
    6597      );
    6698  }
     
    122154  $template->parse('ato');
    123155}
     156
     157function admintools_remove_privacy($content)
     158{
     159  $search = '{if $display_info.privacy_level and isset($available_permission_levels)}';
     160  $replace = '{if false}';
     161  return str_replace($search, $replace, $content);
     162}
     163
     164function admintools_save_picture()
     165{
     166  global $page, $conf;
     167
     168  if (isset($_GET['delete']) and get_pwg_token()==@$_GET['pwg_token'])
     169  {
     170    include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php');
     171
     172    delete_elements(array($page['image_id']), true);
     173    invalidate_user_cache();
     174
     175    if (isset($page['category']))
     176    {
     177      redirect(
     178        make_index_url(
     179          array(
     180            'category' => $page['category']
     181            )
     182          )
     183        );
     184    }
     185
     186    redirect(make_index_url());
     187  }
     188
     189  if (@$_POST['action'] == 'quick_edit')
     190  {
     191    include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php');
     192
     193    $data = array(
     194      'name' => $_POST['name'],
     195      'author' => $_POST['author'],
     196      'level' => $_POST['level'],
     197      );
     198
     199    if ($conf['allow_html_descriptions'])
     200    {
     201      $data['comment'] = @$_POST['comment'];
     202    }
     203    else
     204    {
     205      $data['comment'] = strip_tags(@$_POST['comment']);
     206    }
     207
     208    if (!empty($_POST['date_creation']) and strtotime($_POST['date_creation']) !== false)
     209    {
     210      $data['date_creation'] = $_POST['date_creation'] .' '. $_POST['date_creation_time'];
     211    }
     212
     213    single_update(
     214      IMAGES_TABLE,
     215      $data,
     216      array('id' => $page['image_id'])
     217      );
     218
     219    $tag_ids = array();
     220    if (!empty($_POST['tags']))
     221    {
     222      $tag_ids = get_tag_ids($_POST['tags']);
     223    }
     224    set_tags($tag_ids, $page['image_id']);
     225  }
     226}
Note: See TracChangeset for help on using the changeset viewer.