| [ PHPXref.com ] | [ Generated: Sun Jul 20 16:35:25 2008 ] | [ bBlog 0.7.6 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 // admin.links.php - administer links 4 // Copyright (C) 2003 Mario Delgado <mario@seraphworks.com> 5 // admin.links.php - a plug-in written for bBlog Weblog 6 /* 7 ** bBlog Weblog http://www.bblog.com/ 8 ** Copyright (C) 2003 Eaden McKee <email@eadz.co.nz> 9 ** 10 ** This program is free software; you can redistribute it and/or modify 11 ** it under the terms of the GNU General Public License as published by 12 ** the Free Software Foundation; either version 2 of the License, or 13 ** (at your option) any later version. 14 ** 15 ** This program is distributed in the hope that it will be useful, 16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ** GNU General Public License for more details. 19 ** 20 ** You should have received a copy of the GNU General Public License 21 ** along with this program; if not, write to the Free Software 22 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 */ 24 25 function identify_admin_links () { 26 27 $help = '<p>Links is just a way of managing links. This plugin allows you to add, edit and delete links.'; 28 29 return array ( 30 'name' =>'links', 31 'type' =>'admin', 32 'nicename' =>'Links', 33 'description' =>'Edit bBlog Links', 34 'template' =>'links.html', 35 'authors' =>'Mario Delgado <mario@seraphworks.com>, Eaden McKee <email@eadz.co.nz>', 36 'licence' =>'GPL', 37 'help' => $help 38 ); 39 } 40 41 function admin_plugin_links_run(&$bBlog) { 42 43 if(isset($_GET['linkdo'])) { $linkdo = $_GET['linkdo']; } 44 elseif(isset($_POST['linkdo'])) { $linkdo = $_POST['linkdo']; } 45 else { $linkdo = ''; } 46 47 switch($linkdo) { 48 49 case "New" : // add new link 50 $maxposition = $bBlog->get_var("select position from ".T_LINKS." order by position desc limit 0,1"); 51 $position = $maxposition + 10; 52 $bBlog->query("insert into ".T_LINKS." 53 set nicename='".my_addslashes($_POST['nicename'])."', 54 url='".my_addslashes($_POST['url'])."', 55 category='".my_addslashes($_POST['category'])."', 56 position='$position'"); 57 break; 58 59 case "Delete" : // delete link 60 $bBlog->query("delete from ".T_LINKS." where linkid=".$_POST['linkid']); 61 break; 62 63 case "Save" : // update an existing link 64 $bBlog->query("update ".T_LINKS." 65 set nicename='".my_addslashes($_POST['nicename'])."', 66 url='".my_addslashes($_POST['url'])."', 67 category='".my_addslashes($_POST['category'])."' 68 where linkid=".$_POST['linkid']); 69 break; 70 case "Up" : 71 $bBlog->query("update ".T_LINKS." set position=position-15 where linkid=".$_POST['linkid']); 72 reorder_links(); 73 74 break; 75 76 case "Down" : 77 $bBlog->query("update ".T_LINKS." set position=position+15 where linkid=".$_POST['linkid']); 78 reorder_links(); 79 break; 80 default : // show form 81 break; 82 } 83 84 if(isset($_GET['catdo'])) { $catdo = $_GET['catdo']; } 85 elseif (isset($_POST['catdo'])) { $catdo = $_POST['catdo']; } 86 else { $catdo = ''; } 87 88 switch($catdo) { 89 case "New" : // add new category 90 $bBlog->query("insert into ".T_CATEGORIES." 91 set name='".my_addslashes($_POST['name'])."'"); 92 break; 93 94 case "Delete" : // delete category 95 // have to remove all references to the category in the links 96 $bBlog->query("update ".T_LINKS." 97 set linkid=0 where linkid=".$_POST['categoryid']); 98 // delete the category 99 $bBlog->query("delete from ".T_CATEGORIES." where categoryid=".$_POST['categoryid']); 100 break; 101 102 case "Save" : // update an existing category 103 $bBlog->query("update ".T_CATEGORIES." 104 set name='".my_addslashes($_POST['name'])."' 105 where categoryid=".$_POST['categoryid']); 106 break; 107 108 default : // show form 109 break; 110 } 111 112 $bBlog->assign('ecategories',$bBlog->get_results("select * from ".T_CATEGORIES)); 113 $bBlog->assign('elinks',$bBlog->get_results("select * from ".T_LINKS." order by position")); 114 115 116 } 117 function reorder_links () { 118 global $bBlog; 119 $i = 20; 120 $links = $bBlog->get_results("select * from ".T_LINKS." order by position"); 121 foreach($links as $link) { 122 $bBlog->query("update ".T_LINKS." set position='$i' where linkid='{$link->linkid}'"); 123 $i += 10; 124 } 125 } 126 127 128 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |