@@ 363-379 (lines=17) @@ | ||
360 | * @param string $typeid |
|
361 | * @return int|string |
|
362 | */ |
|
363 | function getTypeFromId($typeid = '0') |
|
364 | { |
|
365 | global $xoopsDB; |
|
366 | $myts = MyTextSanitizer::getInstance(); |
|
367 | $result = $xoopsDB->query('SELECT typename FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_itemtypes') . " WHERE typeid = '" . $typeid . '\''); |
|
368 | $num_results = $xoopsDB->getRowsNum($result); |
|
369 | $typename = ''; |
|
370 | if (!$result) { |
|
371 | return 0; |
|
372 | } |
|
373 | for ($i = 0; $i < $num_results; ++$i) { |
|
374 | $row = $GLOBALS['xoopsDB']->fetchBoth($result); |
|
375 | $typename = $row['typename']; |
|
376 | } |
|
377 | ||
378 | return $typename; |
|
379 | } |
|
380 | ||
381 | /** |
|
382 | * @param string $catid |
|
@@ 385-401 (lines=17) @@ | ||
382 | * @param string $catid |
|
383 | * @return int |
|
384 | */ |
|
385 | function getDirId($catid = '0') |
|
386 | { |
|
387 | global $xoopsDB; |
|
388 | $myts = MyTextSanitizer::getInstance(); |
|
389 | $result = $xoopsDB->query('SELECT dirid FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_cat') . " WHERE cid = '" . $catid . '\''); |
|
390 | $num_results = $xoopsDB->getRowsNum($result); |
|
391 | $dirid = 0; |
|
392 | if (!$result) { |
|
393 | return 0; |
|
394 | } |
|
395 | for ($i = 0; $i < $num_results; ++$i) { |
|
396 | $row = $GLOBALS['xoopsDB']->fetchBoth($result); |
|
397 | $dirid = $row['dirid']; |
|
398 | } |
|
399 | ||
400 | return $dirid; |
|
401 | } |
|
402 | ||
403 | /** |
|
404 | * @param string $catid |
|
@@ 548-565 (lines=18) @@ | ||
545 | * @param int $item |
|
546 | * @return int |
|
547 | */ |
|
548 | function getDirIdFromItem($item = 0) |
|
549 | { |
|
550 | global $xoopsDB; |
|
551 | $block = array(); |
|
552 | $myts = MyTextSanitizer::getInstance(); |
|
553 | $dirid = 0; |
|
554 | $result = $xoopsDB->query('SELECT dirid FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . ' WHERE itemid = ' . $item . ''); |
|
555 | $num_results = $xoopsDB->getRowsNum($result); |
|
556 | if (!$result) { |
|
557 | return 0; |
|
558 | } |
|
559 | for ($i = 0; $i < $num_results; ++$i) { |
|
560 | $row = $GLOBALS['xoopsDB']->fetchBoth($result); |
|
561 | $dirid = $row['dirid']; |
|
562 | } |
|
563 | ||
564 | return $dirid; |
|
565 | } |
|
566 | ||
567 | /** |
|
568 | * @param int $item |
|
@@ 571-588 (lines=18) @@ | ||
568 | * @param int $item |
|
569 | * @return int |
|
570 | */ |
|
571 | function getUserIdFromItem($item = 0) |
|
572 | { |
|
573 | global $xoopsDB; |
|
574 | $block = array(); |
|
575 | $myts = MyTextSanitizer::getInstance(); |
|
576 | $userid = 0; |
|
577 | $result = $xoopsDB->query('SELECT uid FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . ' WHERE itemid = ' . $item . ''); |
|
578 | $num_results = $xoopsDB->getRowsNum($result); |
|
579 | if (!$result) { |
|
580 | return 0; |
|
581 | } |
|
582 | for ($i = 0; $i < $num_results; ++$i) { |
|
583 | $row = $GLOBALS['xoopsDB']->fetchBoth($result); |
|
584 | $userid = $row['uid']; |
|
585 | } |
|
586 | ||
587 | return $userid; |
|
588 | } |
|
589 | ||
590 | //updates rating data in itemtable for a given item |
|
591 | /** |