Changeset 26879


Ignore:
Timestamp:
01/19/14 09:58:14 (6 years ago)
Author:
ddtddt
Message:

[extensions] - user_delete_photo - redirection in the right section if the user isn't in album

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/user_delete_photo/initpicture.php

    r26561 r26879  
    11<?php 
     2//Add prefilter 
     3add_event_handler('loc_begin_picture', 'udp', 55 ); 
     4 function udp() 
     5  { 
     6  global $template; 
     7  $template->set_prefilter('picture', 'udpT'); 
     8  } 
    29 
    3  
    4  
    5 //Ajout du prefiltre 
    6 add_event_handler('loc_begin_picture', 'udp', 55 ); 
    7  
    8 function udp() 
    9  { 
    10         global $template; 
    11         $template->set_prefilter('picture', 'udpT'); 
    12  } 
    13  
    14 function udpT($content, &$smarty) 
    15  { 
    16           global $conf; 
    17   
     10 function udpT($content, &$smarty) 
     11  { 
     12  global $conf; 
    1813  $search = '#<div id="'.$conf['udp'].'" class="imageInfo">#'; 
    19    
    2014  $replacement = ' 
    21  
    2215{if $UDFA} 
    23   <div id="udp" class="imageInfo"> 
    24     <form method="post"> 
    25           <input class="submit" name="submitudpA" type="submit" value="{\'delete photo\'|@translate}"> 
    26           <label><input type="checkbox" name="confirm_deletionudp" value="1"> {\'Are you sure?\'|@translate}</label> 
    27     </form> 
    28   </div> 
     16 <div id="udp" class="imageInfo"> 
     17  <form method="post"> 
     18   <input class="submit" name="submitudpA" type="submit" value="{\'delete photo\'|@translate}"> 
     19   <label><input type="checkbox" name="confirm_deletionudp" value="1"> {\'Are you sure?\'|@translate}</label> 
     20  </form> 
     21 </div> 
    2922{/if} 
    30 <div id="'.$conf['udp'].'" class="imageInfo">'; 
    31  
     23 <div id="'.$conf['udp'].'" class="imageInfo">'; 
    3224  return preg_replace($search, $replacement, $content); 
    33  } 
     25  } 
    3426 
    3527add_event_handler('loc_begin_picture', 'udpA'); 
    3628 
    37 function udpA() 
     29 function udpA() 
    3830{ 
    39 global $conf, $page, $template  ; 
    40 load_language('plugin.lang', UDP_PATH); 
    41 load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) ); 
    42  
    43           global $conf, $user, $page; 
     31  global $conf, $page, $template  ; 
     32  load_language('plugin.lang', UDP_PATH); 
     33  load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) ); 
     34  global $conf, $user, $page; 
    4435 
    4536  $query = ' 
     
    5142$row = pwg_db_fetch_assoc($result); 
    5243$userudp=$row['added_by']; 
    53    
     44  
    5445  $query = ' 
    5546select '.$conf['user_fields']['username'].' AS username 
     
    6354if (($udp == $user['username'])) 
    6455 { 
    65                     $template->assign(          array   ( 
    66                 'UDFA' => 'udp', 
    67                                 )                       ); 
     56 $template->assign( 
     57 array  ( 
     58 'UDFA' => 'udp', 
     59 )); 
    6860 } 
    6961 
    7062if ((isset($_POST['submitudpA']) and ($udp == $user['username']))) 
     63 { 
     64  if (!(isset($_POST['confirm_deletionudp']) and 1 == $_POST['confirm_deletionudp'])) 
    7165  { 
    72          
    73         if (!(isset($_POST['confirm_deletionudp']) and 1 == $_POST['confirm_deletionudp'])) 
    74         { 
    75          array_push($page['errors'], l10n('You need to confirm deletion')); 
    76         } 
    77         else 
    78         { 
    79         include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
    80           global $page; 
    81         $deletephotoudp =array($page['image_id']); 
    82         delete_elements($deletephotoudp, true); 
    83         invalidate_user_cache(); 
    84         $redirect_url = get_root_url().'index.php?/category/'.($page['category']['id']); 
    85         $_SESSION['page_infos'] = array(l10n('Photo deleted')); 
    86     redirect($redirect_url); 
    87         } 
     66  array_push($page['errors'], l10n('You need to confirm deletion')); 
    8867  } 
     68  else 
     69  { 
     70  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
     71  global $page; 
     72  $deletephotoudp =array($page['image_id']); 
     73  delete_elements($deletephotoudp, true); 
     74  invalidate_user_cache(); 
     75   if (isset($page['category']['id'])) 
     76   { 
     77   $redirect_url = get_root_url().'index.php?/category/'.($page['category']['id']); 
     78   } 
     79   else 
     80   { 
     81   $redirect_url = get_root_url().'index.php?/'.($page['section']); 
     82   } 
     83   $_SESSION['page_infos'] = array(l10n('Photo deleted')); 
     84   redirect($redirect_url); 
     85  } 
     86 } 
    8987} 
    90                          
    91  
    9288?> 
Note: See TracChangeset for help on using the changeset viewer.