includes/pageutils.php
changeset 696 bd5069e1f19a
parent 690 aeac05b5b7ca
child 729 ebac7eeb89eb
equal deleted inserted replaced
695:6bd7215c718b 696:bd5069e1f19a
  1160    
  1160    
  1161   public static function delvote($page_id, $namespace)
  1161   public static function delvote($page_id, $namespace)
  1162   {
  1162   {
  1163     global $db, $session, $paths, $template, $plugins; // Common objects
  1163     global $db, $session, $paths, $template, $plugins; // Common objects
  1164     global $lang;
  1164     global $lang;
       
  1165     global $cache;
       
  1166     
  1165     if ( !$session->get_permissions('vote_delete') )
  1167     if ( !$session->get_permissions('vote_delete') )
  1166     {
  1168     {
  1167       return $lang->get('etc_access_denied');
  1169       return $lang->get('etc_access_denied');
  1168     }
  1170     }
  1169     
  1171     
  1212     
  1214     
  1213     $cv++;
  1215     $cv++;
  1214     
  1216     
  1215     $q = 'UPDATE ' . table_prefix.'pages SET delvotes=' . $cv . ',delvote_ips=\'' . $ips . '\' WHERE urlname=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\'';
  1217     $q = 'UPDATE ' . table_prefix.'pages SET delvotes=' . $cv . ',delvote_ips=\'' . $ips . '\' WHERE urlname=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\'';
  1216     $w = $db->sql_query($q);
  1218     $w = $db->sql_query($q);
       
  1219     if ( !$w )
       
  1220       $db->_die();
       
  1221     
       
  1222     // all done, flush page cache to mark it up
       
  1223     $cache->purge('page_meta');
  1217     
  1224     
  1218     return $lang->get('ajax_delvote_success');
  1225     return $lang->get('ajax_delvote_success');
  1219   }
  1226   }
  1220   
  1227   
  1221   /**
  1228   /**
  1227   
  1234   
  1228   public static function resetdelvotes($page_id, $namespace)
  1235   public static function resetdelvotes($page_id, $namespace)
  1229   {
  1236   {
  1230     global $db, $session, $paths, $template, $plugins; // Common objects
  1237     global $db, $session, $paths, $template, $plugins; // Common objects
  1231     global $lang;
  1238     global $lang;
       
  1239     global $cache;
       
  1240     
  1232     if(!$session->get_permissions('vote_reset'))
  1241     if(!$session->get_permissions('vote_reset'))
  1233     {
  1242     {
  1234       return $lang->get('etc_access_denied');
  1243       return $lang->get('etc_access_denied');
  1235     }
  1244     }
  1236     $q = 'UPDATE ' . table_prefix.'pages SET delvotes=0,delvote_ips=\'' . $db->escape(serialize(array('ip'=>array(),'u'=>array()))) . '\' WHERE urlname=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\'';
  1245     $q = 'UPDATE ' . table_prefix.'pages SET delvotes=0,delvote_ips=\'' . $db->escape(serialize(array('ip'=>array(),'u'=>array()))) . '\' WHERE urlname=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\'';
  1237     $e = $db->sql_query($q);
  1246     $e = $db->sql_query($q);
  1238     if(!$e) $db->_die('The number of delete votes was not reset.');
  1247     if ( !$e )
       
  1248     {
       
  1249       $db->_die('The number of delete votes was not reset.');
       
  1250     }
  1239     else
  1251     else
  1240     {
  1252     {
       
  1253       $cache->purge('page_meta');
  1241       return $lang->get('ajax_delvote_reset_success');
  1254       return $lang->get('ajax_delvote_reset_success');
  1242     }
  1255     }
  1243   }
  1256   }
  1244   
  1257   
  1245   /**
  1258   /**