Annotation of /mambo/branches/4.6/includes/getids.php
Parent Directory
|
Revision Log
Revision 1 -
(view)
(download)
Original Path: mambo/trunk/includes/getids.php
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: getids.php,v 1.1 2005/07/22 01:57:13 eddieajau Exp $ | ||
| 4 : | * @package Mambo | ||
| 5 : | * @copyright (C) 2000 - 2005 Miro International Pty Ltd | ||
| 6 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL | ||
| 7 : | * Mambo is Free Software | ||
| 8 : | */ | ||
| 9 : | |||
| 10 : | /** ensure this file is being included by a parent file */ | ||
| 11 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 12 : | |||
| 13 : | function getcatids($field, $table, $gid, $db, $_dbprefix){ | ||
| 14 : | |||
| 15 : | //Get all Story Topics | ||
| 16 : | $resultC = mysql_db_query ($db, "SELECT $field FROM ".$_dbprefix."$table WHERE published=1") or $mysql_eval_err = mysql_error(); | ||
| 17 : | if ($mysql_eval_err<>'') { | ||
| 18 : | return ''; | ||
| 19 : | } | ||
| 20 : | $c = 0; | ||
| 21 : | while ($rowC = mysql_fetch_object($resultC)){ | ||
| 22 : | $topic[$c] = $rowC->$field; | ||
| 23 : | $c++; | ||
| 24 : | } | ||
| 25 : | |||
| 26 : | //Build CatID query | ||
| 27 : | $accquery="("; | ||
| 28 : | for ($a=0; $a<count($topic); $a++){ | ||
| 29 : | $pos = strrpos($accquery, $topic[$a]); | ||
| 30 : | if ($pos === false) { | ||
| 31 : | $accquery = $accquery."id=".$topic[$a]." OR "; | ||
| 32 : | } | ||
| 33 : | } | ||
| 34 : | |||
| 35 : | //Strip off the final OR | ||
| 36 : | if (strlen($accquery)>4) { | ||
| 37 : | $accquery = substr($accquery,0,(strlen($accquery)-4)); | ||
| 38 : | } | ||
| 39 : | $accquery=$accquery.")"; | ||
| 40 : | |||
| 41 : | //Get all CatIDs | ||
| 42 : | $resultD = mysql_db_query ($db, "SELECT id FROM ".$_dbprefix."categories WHERE (access<='$gid' AND published=1 AND ".$accquery.")") or $mysql_eval_err = mysql_error(); | ||
| 43 : | if ($mysql_eval_err<>'') { | ||
| 44 : | return ''; | ||
| 45 : | } | ||
| 46 : | $d = 0; | ||
| 47 : | while ($rowD = mysql_fetch_object($resultD)){ | ||
| 48 : | $cid[$d] = $rowD->id; | ||
| 49 : | $d++; | ||
| 50 : | } | ||
| 51 : | |||
| 52 : | //Build TopicID query | ||
| 53 : | $topquery="("; | ||
| 54 : | for ($a=0; $a<count($cid); $a++){ | ||
| 55 : | $pos = strrpos($topquery, $cid[$a]); | ||
| 56 : | if ($pos === false) { | ||
| 57 : | $topquery = $topquery.$field."=".$cid[$a]." OR "; | ||
| 58 : | } | ||
| 59 : | } | ||
| 60 : | |||
| 61 : | //Strip off the final OR | ||
| 62 : | if (strlen($topquery)>4) { | ||
| 63 : | $topquery = substr($topquery,0,(strlen($topquery)-4)); | ||
| 64 : | $topquery = "AND ".$topquery.")"; | ||
| 65 : | } else { | ||
| 66 : | $topquery = ""; | ||
| 67 : | } | ||
| 68 : | |||
| 69 : | |||
| 70 : | return $topquery; | ||
| 71 : | } | ||
| 72 : | |||
| 73 : | |||
| 74 : | function getmenuids($field, $table, $gid, $db, $_dbprefix){ | ||
| 75 : | |||
| 76 : | //Get all Story Topics | ||
| 77 : | $resultC = mysql_db_query ($db, "SELECT $field FROM ".$_dbprefix."$table WHERE published=1") or $mysql_eval_err = mysql_error(); | ||
| 78 : | if ($mysql_eval_err<>'') { | ||
| 79 : | return ''; | ||
| 80 : | } | ||
| 81 : | $c = 0; | ||
| 82 : | while ($rowC = mysql_fetch_object($resultC)){ | ||
| 83 : | $topic[$c] = $rowC->$field; | ||
| 84 : | $c++; | ||
| 85 : | } | ||
| 86 : | |||
| 87 : | //Build MenuID query | ||
| 88 : | $accquery="("; | ||
| 89 : | for ($a=0; $a<count($topic); $a++){ | ||
| 90 : | $pos = strpos($accquery, $topic[$a]); | ||
| 91 : | if ($pos === false) { | ||
| 92 : | $accquery = $accquery."id=".$topic[$a]." OR "; | ||
| 93 : | } | ||
| 94 : | } | ||
| 95 : | //Strip off the final OR | ||
| 96 : | if (strlen($accquery)>4) { | ||
| 97 : | $accquery = substr($accquery,0,(strlen($accquery)-4)); | ||
| 98 : | } | ||
| 99 : | $accquery=$accquery.")"; | ||
| 100 : | |||
| 101 : | //Get all MenuIDs | ||
| 102 : | $resultD = mysql_db_query ($db, "SELECT id FROM ".$_dbprefix."menu WHERE (access<='$gid' AND published=1 AND ".$accquery.")") or $mysql_eval_err = mysql_error(); | ||
| 103 : | if ($mysql_eval_err<>'') { | ||
| 104 : | return ''; | ||
| 105 : | } | ||
| 106 : | $d = 0; | ||
| 107 : | while ($rowD = mysql_fetch_object($resultD)){ | ||
| 108 : | $cid[$d] = $rowD->id; | ||
| 109 : | $d++; | ||
| 110 : | } | ||
| 111 : | |||
| 112 : | //Build MenuContentID query | ||
| 113 : | $topquery="("; | ||
| 114 : | for ($a=0; $a<count($cid); $a++){ | ||
| 115 : | $pos = strpos($topquery, $cid[$a]); | ||
| 116 : | if ($pos === false) { | ||
| 117 : | $topquery = $topquery."menuid"."=".$cid[$a]." OR "; | ||
| 118 : | } | ||
| 119 : | } | ||
| 120 : | |||
| 121 : | //Strip off the final OR | ||
| 122 : | if (strlen($topquery)>4) { | ||
| 123 : | $topquery = substr($topquery,0,(strlen($topquery)-4)); | ||
| 124 : | $topquery = "AND ".$topquery.")"; | ||
| 125 : | } else { | ||
| 126 : | $topquery = ""; | ||
| 127 : | } | ||
| 128 : | |||
| 129 : | return $topquery; | ||
| 130 : | } | ||
| 131 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

