| 1 | <?php |
| 2 | function listbookforum($parid){ |
| 3 | global $user_id; |
| 4 | global $bookcat_name; |
| 5 | global $f_id; |
| 6 | global $f_name; |
| 7 | global $f_sub; |
| 8 | global $f_subc; |
| 9 | global $f_parent; |
| 10 | global $f_owner; |
| 11 | for($j=0;$j<count($f_id);$j++){ |
| 12 | if ($f_parent[$j]==$parid){ |
| 13 | echo "\n<br><input size='0' style='border : 0;width : 10;height : 10;' type='checkbox' name='move[]' value='".$f_id[$j]."'> <a href='?action=forum&node_id=",$f_id[$j],"'>",$f_name[$j],"</a>"; |
| 14 | if ($f_subc[$j]) echo "- <font color='red'>".$f_subc[$j]." NEW</font>"; |
| 15 | echo " (".$bookcat_name[prevod($parid)].")"; |
| 16 | if ($f_owner[$j]!=$user_id) {echo "<a href='?action=b00kmarkz&book=1&node_id=",$f_id[$j],"' onClick=\"return confirm('Chces si unbooknut tento klub?')\"> :: unbook</a>";} |
| 17 | } |
| 18 | } |
| 19 | if ($j>0){echo "<br>";} |
| 20 | } |
| 21 | function listbookforum1($parid){ |
| 22 | global $user_id; |
| 23 | global $bookcat_name; |
| 24 | global $bookcat_open; |
| 25 | global $bookcat_parent; |
| 26 | global $bookcat_id; |
| 27 | global $f_id; |
| 28 | global $f_name; |
| 29 | global $f_login; |
| 30 | global $f_sub; |
| 31 | global $f_subc; |
| 32 | global $f_parent; |
| 33 | global $f_owner; |
| 34 | for($j=0;$j<count($f_id);$j++){ |
| 35 | if ($f_parent[$j]==$parid){ |
| 36 | echo "\n<br> <a href='?action=forum&node_id=",$f_id[$j],"'>",$f_name[$j],"</a>"; |
| 37 | if ($f_subc[$j]) echo "- <font color='red'>".$f_subc[$j]." NEW</font>"; |
| 38 | echo " (".$bookcat_name[prevod($parid)].")"; |
| 39 | if ($f_owner[$j]!=$user_id) {echo "<a href='?action=b00kmarkz&book=1&node_id=",$f_id[$j],"' onClick=\"return confirm('Chces si unbooknut tento klub?')\"> :: unbook</a>";} |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | |
| 45 | //old for edit |
| 46 | function listbookcat($catid){ |
| 47 | global $bookcat_name; |
| 48 | global $bookcat_open; |
| 49 | global $bookcat_parent; |
| 50 | global $bookcat_id; |
| 51 | for($i=0;$i<=count($bookcat_id);$i++){ |
| 52 | if ($bookcat_parent[$i]==$catid){ |
| 53 | echo "\n<a href='?action=b00kedit&editcat=".$bookcat_id[$i]."'>- ".$bookcat_name[$i]."</a>"; |
| 54 | if (isSet($lasti)){ |
| 55 | echo " <a href='?action=b00kedit&editcat=". $bookcat_parent[prevod($i)] ."&movecat=". $bookcat_id[$i] ."&upcat=". $bookcat_id[$lasti] ."'>^UP^</a>"; |
| 56 | } |
| 57 | echo "<br>"; |
| 58 | $lasti=$i; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | //new for edit |
| 63 | function listbookcat3($catid,$edc){ |
| 64 | global $bookcat_name; |
| 65 | global $bookcat_open; |
| 66 | global $bookcat_parent; |
| 67 | global $bookcat_id; |
| 68 | global $bookcat_subc; |
| 69 | for($i=0;$i<=count($bookcat_id);$i++){ |
| 70 | if (($bookcat_parent[$i]==$catid)){ |
| 71 | echo "<table border='0'><tr><td width='15'> </td><td>"; |
| 72 | if ($edc==$bookcat_id[$i]){ |
| 73 | echo "\n<b>- ".$bookcat_name[$i]."</b>"; |
| 74 | }else{ |
| 75 | echo "\n<a href='?action=b00kedit&editcat=".$bookcat_id[$i]."'><b>- ".$bookcat_name[$i]."</b></a>"; |
| 76 | } |
| 77 | if (isSet($lasti)){ |
| 78 | echo " <a href='?action=b00kedit&editcat=". $edc ."&movecat=". $bookcat_id[$i] ."&upcat=". $bookcat_id[$lasti] ."'>^UP^</a>"; |
| 79 | } |
| 80 | echo " :: <a href='?action=b00kedit&delete=".$bookcat_id[$i]."'>delete</a>"; |
| 81 | // echo "<br>"; |
| 82 | if(($edc!='0')&&($bookcat_id[$i]==$edc)){ |
| 83 | echo " :: <input class='bigtextinput' type='text' name='bookcatname'>"; |
| 84 | echo "<input type='submit' value='pridaj.b00kcat' name='action' class='bigtextinput'>"; |
| 85 | } |
| 86 | listbookcat3($bookcat_id[$i],$edc); |
| 87 | echo "</td></tr></table>"; |
| 88 | $lasti=$i; |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | |
| 94 | function listbookforum2($parid){ |
| 95 | global $user_id; |
| 96 | global $f_id; |
| 97 | global $f_name; |
| 98 | global $f_login; |
| 99 | global $f_sub; |
| 100 | global $f_subc; |
| 101 | global $f_parent; |
| 102 | global $f_owner; |
| 103 | for($j=0;$j<count($f_id);$j++){ |
| 104 | if ($f_parent[$j]==$parid){ |
| 105 | echo "\n<br> <a href='?action=forum&node_id=",$f_id[$j],"'>",$f_name[$j],"</a> (".$f_sub[$j]." subz "; |
| 106 | if ($f_subc[$j]) echo "- <font color='red'>".$f_subc[$j]." NEW</font>"; |
| 107 | echo ")"; |
| 108 | if ($f_owner[$j]!=$user_id) {echo "<a href='?action=b00kmarkz&book=1&node_id=",$f_id[$j],"' onClick=\"return confirm('Chces si unbooknut tento klub?')\"> :: unbook</a>";} |
| 109 | // echo "<a href='?action=b00kmarkz&book=1&node_id=",$f_id[$j],"' onClick=\"return confirm('Chces si unbooknut tento klub?')\"> :: unbook</a>"; |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | |
| 115 | function listbookcat2($catid){ |
| 116 | global $bookcat_name; |
| 117 | global $bookcat_open; |
| 118 | global $bookcat_parent; |
| 119 | global $bookcat_id; |
| 120 | global $bookcat_subc; |
| 121 | for($i=0;$i<=count($bookcat_id);$i++){ |
| 122 | if (($bookcat_parent[$i]==$catid)){ |
| 123 | echo "<blockquote>"; |
| 124 | if ($bookcat_open[$i]=="no") {echo "\n<a href='?action=b00kmarkz&openswich=".$bookcat_id[$i]."&swichto=yes'><b>- ".$bookcat_name[$i]."@";} |
| 125 | if ($bookcat_open[$i]=="yes") {echo "\n<a href='?action=b00kmarkz&openswich=".$bookcat_id[$i]."&swichto=no'><b>- ".$bookcat_name[$i]."^";} |
| 126 | if (($bookcat_subc[$i]>'0') and ($bookcat_open[$i]=="no")){echo "(<font color='red'>".$bookcat_subc[$i]." NEW</font>)";} |
| 127 | echo "</b></a>"; |
| 128 | if (($bookcat_open[$i]=="yes")){ |
| 129 | listbookforum2($bookcat_id[$i]); |
| 130 | listbookcat2($bookcat_id[$i]); |
| 131 | } |
| 132 | echo "</blockquote>"; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | } |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | function bookfmove($del_id){ |
| 142 | global $user_id; |
| 143 | global $f_id; |
| 144 | global $f_parent; |
| 145 | global $qf; |
| 146 | global $if; |
| 147 | for($j=0;$j<count($f_id);$j++){ |
| 148 | if ($f_parent[$j]==$del_id){ |
| 149 | if ($if=='0') {$qf.=" (user_id='$user_id' and forum_id='".$f_id[$j]."')";} |
| 150 | else{$qf.=" or (user_id='$user_id' and forum_id='".$f_id[$j]."')";} |
| 151 | $if++; |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | function bookcatdel2($del_id){ |
| 160 | global $user_id; |
| 161 | global $bookcat_parent; |
| 162 | global $bookcat_id; |
| 163 | global $qf; |
| 164 | global $if; |
| 165 | global $qc; |
| 166 | for($i=0;$i<=count($bookcat_id);$i++){ |
| 167 | if (($bookcat_parent[$i]==$del_id)){ |
| 168 | $qc.=" or (user_id='$user_id' and bookcat_id='$bookcat_id[$i]')"; |
| 169 | bookfmove($bookcat_id[$i]); |
| 170 | bookcatdel2($bookcat_id[$i]); |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | function bookcatdel($del_id){ |
| 179 | global $user_id; |
| 180 | global $bookcat_id; |
| 181 | global $qf; |
| 182 | global $if; |
| 183 | global $qc; |
| 184 | global $kyberia; |
| 185 | $qf="update user_forum set parent_id='0' where"; |
| 186 | $if='0'; |
| 187 | $qc="delete from user_bookcat where (user_id='$user_id' and bookcat_id='$del_id')"; |
| 188 | bookfmove($del_id); |
| 189 | bookcatdel2($del_id); |
| 190 | $kyberia->query($qc); |
| 191 | if ($if>'0') {$kyberia->query($qf);} |
| 192 | } |
| 193 | |
| 194 | |
| 195 | |
| 196 | function prevod($id){ |
| 197 | global $bookcat_id; |
| 198 | if ($id=='0'){$id='-1';} |
| 199 | for($i=0;$i<count($bookcat_id);$i++){ |
| 200 | if (($bookcat_id[$i])==$id){$id=$i; break;} |
| 201 | } |
| 202 | return $id; |
| 203 | } |
| 204 | |
| 205 | |
| 206 | |
| 207 | function readbookdb(){ |
| 208 | global $user_id; |
| 209 | global $bookcat_name; |
| 210 | global $bookcat_open; |
| 211 | global $bookcat_parent; |
| 212 | global $bookcat_id; |
| 213 | global $f_id; |
| 214 | global $f_name; |
| 215 | global $f_login; |
| 216 | global $f_sub; |
| 217 | global $f_subc; |
| 218 | global $f_parent; |
| 219 | global $f_owner; |
| 220 | global $kyberia; |
| 221 | global $bookcat_subc; |
| 222 | |
| 223 | $q="select * from user_bookcat where user_id='".$user_id."' order by bookcat_id"; |
| 224 | $bset=$kyberia->query($q); |
| 225 | $label='0'; |
| 226 | while ($bset->next()){ |
| 227 | $bookcat_name[$label]=$bset->getString('bookcat_name'); |
| 228 | $bookcat_open[$label]=$bset->getString('is_open'); |
| 229 | $bookcat_parent[$label]=$bset->getString('parent_id'); |
| 230 | $bookcat_id[$label]=$bset->getString('bookcat_id'); |
| 231 | $label++; |
| 232 | } |
| 233 | $q="SELECT user_forum.submission_count,user_forum.parent_id as fparent_id,user.login,forum.* from forum left join user on forum.forum_owner=user.id left join user_forum on (forum.forum_id=user_forum.forum_id and user_forum.user_id='$user_id')"; |
| 234 | $q.=" WHERE forum.forum_owner='$user_id'"; |
| 235 | $q.=" order by forum_name "; |
| 236 | $forumset=$kyberia->query($q); |
| 237 | $i=0; |
| 238 | while ($forumset->next()){ |
| 239 | $f_id[$i]=$forumset->getString('forum_id'); |
| 240 | $f_name[$i]=$forumset->getString('forum_name'); |
| 241 | $f_login[$i]=$forumset->getString('login'); |
| 242 | $f_sub[$i]=$forumset->getString('forum_submissions'); |
| 243 | $f_subc[$i]=$forumset->getString('submission_count'); |
| 244 | $f_parent[$i]=$forumset->getString('fparent_id'); |
| 245 | $f_owner[$i]=$forumset->getString('forum_owner'); |
| 246 | $i++; |
| 247 | } |
| 248 | |
| 249 | $q="SELECT user_forum.submission_count,user_forum.parent_id as fparent_id,user.login,forum.*"; |
| 250 | $q.=" from forum left join user on forum.forum_owner=user.id"; |
| 251 | $q.=" left join user_forum on (forum.forum_id=user_forum.forum_id and user_forum.user_id='$user_id')"; |
| 252 | $q.=" WHERE user_forum.user_bookmark='yes' and forum.forum_owner != '$user_id'"; |
| 253 | $q.=" order by forum_name "; |
| 254 | $forumset=$kyberia->query($q); |
| 255 | while ($forumset->next()){ |
| 256 | $f_id[$i]=$forumset->getString('forum_id'); |
| 257 | $f_name[$i]=$forumset->getString('forum_name'); |
| 258 | $f_login[$i]=$forumset->getString('login'); |
| 259 | $f_sub[$i]=$forumset->getString('forum_submissions'); |
| 260 | $f_subc[$i]=$forumset->getString('submission_count'); |
| 261 | $f_parent[$i]=$forumset->getString('fparent_id'); |
| 262 | $f_owner[$i]=$forumset->getString('forum_owner'); |
| 263 | $i++; |
| 264 | } |
| 265 | |
| 266 | $bookcat_subc['-1']=countnew('0'); |
| 267 | } |
| 268 | |
| 269 | function countnew($catid){ |
| 270 | global $bookcat_parent; |
| 271 | global $bookcat_id; |
| 272 | global $bookcat_subc; |
| 273 | global $bookcat_name; |
| 274 | |
| 275 | for($i=0;$i<=count($bookcat_id);$i++){ |
| 276 | if (($bookcat_parent[$i]==$catid)){ |
| 277 | $bookcat_subc[prevod($catid)] += countnew($bookcat_id[$i]); |
| 278 | } |
| 279 | } |
| 280 | countnewforum($catid); |
| 281 | return $bookcat_subc[prevod($catid)]; |
| 282 | } |
| 283 | function countnewforum($catid){ |
| 284 | global $user_id; |
| 285 | global $f_id; |
| 286 | global $f_subc; |
| 287 | global $f_parent; |
| 288 | global $bookcat_subc; |
| 289 | global $bookcat_name; |
| 290 | for($j=0;$j<count($f_id);$j++){ |
| 291 | if ($f_parent[$j]==$catid){ |
| 292 | if ($f_subc[$j]) {$bookcat_subc[prevod($catid)]+=$f_subc[$j];} |
| 293 | } |
| 294 | } |
| 295 | return $bookcat_subc[prevod($catid)]; |
| 296 | } |
| 297 | ?> |