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

