mambax7 /
adslight
| 1 | <?php |
||
| 2 | |||
| 3 | namespace XoopsModules\Adslight; |
||
| 4 | |||
| 5 | /* |
||
| 6 | ------------------------------------------------------------------------- |
||
| 7 | ADSLIGHT 2 : Module for Xoops |
||
| 8 | |||
| 9 | Redesigned and ameliorate By Luc Bizet user at www.frxoops.org |
||
| 10 | Started with the Classifieds module and made MANY changes |
||
| 11 | Website : http://www.luc-bizet.fr |
||
| 12 | Contact : [email protected] |
||
| 13 | ------------------------------------------------------------------------- |
||
| 14 | Original credits below Version History |
||
| 15 | ########################################################################## |
||
| 16 | # Classified Module for Xoops # |
||
| 17 | # By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com # |
||
| 18 | # Started with the MyAds module and made MANY changes # |
||
| 19 | ########################################################################## |
||
| 20 | Original Author: Pascal Le Boustouller |
||
| 21 | Author Website : [email protected] |
||
| 22 | Licence Type : GPL |
||
| 23 | ------------------------------------------------------------------------- |
||
| 24 | */ |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Protection against inclusion outside the site |
||
| 28 | */ |
||
| 29 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Includes of form objects and uploader |
||
| 33 | */ |
||
| 34 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||
| 35 | require_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
||
| 36 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
| 37 | require_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * light_pictures class. |
||
| 41 | * $this class is responsible for providing data access mechanisms to the data source |
||
| 42 | * of XOOPS user class objects. |
||
| 43 | */ |
||
| 44 | class Pictures extends \XoopsObject |
||
| 45 | { |
||
| 46 | /** @var \XoopsMySQLDatabase $db */ |
||
| 47 | public $db; |
||
| 48 | // constructor |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param null $id |
||
| 52 | * @param null|array $lid |
||
| 53 | */ |
||
| 54 | public function __construct($id = null, $lid = null) |
||
| 55 | { |
||
| 56 | $this->db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 57 | $this->initVar('cod_img', XOBJ_DTYPE_INT, null, false, 10); |
||
| 58 | $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false); |
||
| 59 | $this->initVar('date_added', XOBJ_DTYPE_TXTBOX, null, false); |
||
| 60 | $this->initVar('date_modified', XOBJ_DTYPE_TXTBOX, null, false); |
||
| 61 | $this->initVar('lid', XOBJ_DTYPE_INT, null, false, 10); |
||
| 62 | $this->initVar('uid_owner', XOBJ_DTYPE_TXTBOX, null, false); |
||
| 63 | $this->initVar('url', XOBJ_DTYPE_TXTBOX, null, false); |
||
| 64 | if (!empty($lid)) { |
||
| 65 | if (is_array($lid)) { |
||
| 66 | $this->assignVars($lid); |
||
| 67 | } else { |
||
| 68 | $this->load((int)$lid); |
||
| 69 | } |
||
| 70 | } else { |
||
| 71 | $this->setNew(); |
||
| 72 | } |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @param $id |
||
| 77 | */ |
||
| 78 | public function load($id) |
||
| 79 | { |
||
| 80 | $sql = 'SELECT * FROM ' . $this->db->prefix('adslight_pictures') . ' WHERE cod_img=' . $id . ' '; |
||
| 81 | $myrow = $this->db->fetchArray($this->db->query($sql)); |
||
| 82 | $this->assignVars($myrow); |
||
| 83 | if (!$myrow) { |
||
| 84 | $this->setNew(); |
||
| 85 | } |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @param array $criteria |
||
| 90 | * @param bool $asobject |
||
| 91 | * @param string $sort |
||
| 92 | * @param string $cat_order |
||
| 93 | * @param int $limit |
||
| 94 | * @param int $start |
||
| 95 | * @return array |
||
| 96 | * @internal param string $order |
||
| 97 | * @deprecated this should be handled through {@see PicturesHandler} |
||
| 98 | */ |
||
| 99 | public function getAllPictures($criteria = [], $asobject = false, $sort = 'cod_img', $cat_order = 'ASC', $limit = 0, $start = 0) |
||
| 100 | { |
||
| 101 | /** @var \XoopsMySQLDatabase $xoopsDB */ |
||
| 102 | $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 103 | $ret = []; |
||
| 104 | $where_query = ''; |
||
| 105 | if (is_array($criteria) && count($criteria) > 0) { |
||
| 106 | $where_query = ' WHERE'; |
||
| 107 | foreach ($criteria as $c) { |
||
| 108 | $where_query .= " {$c} AND"; |
||
| 109 | } |
||
| 110 | $where_query = mb_substr($where_query, 0, -4); |
||
| 111 | } elseif (!is_array($criteria) && $criteria) { |
||
| 112 | $where_query = " WHERE {$criteria}"; |
||
| 113 | } |
||
| 114 | if (!$asobject) { |
||
| 115 | $sql = 'SELECT cod_img FROM ' . $xoopsDB->prefix('adslight_pictures') . "$where_query ORDER BY $sort $cat_order"; |
||
| 116 | $result = $xoopsDB->query($sql, $limit, $start); |
||
|
0 ignored issues
–
show
|
|||
| 117 | while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
||
| 118 | $ret[] = $myrow['cog_img']; |
||
| 119 | } |
||
| 120 | } else { |
||
| 121 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('adslight_pictures') . "$where_query ORDER BY $sort $cat_order"; |
||
| 122 | $result = $xoopsDB->query($sql, $limit, $start); |
||
|
0 ignored issues
–
show
Are you sure the assignment to
$result is correct as $xoopsDB->query($sql, $limit, $start) targeting XoopsMySQLDatabase::query() seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||
| 123 | while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
||
| 124 | $ret[] = new self($myrow); |
||
| 125 | } |
||
| 126 | } |
||
| 127 | |||
| 128 | return $ret; |
||
| 129 | } |
||
| 130 | } |
||
| 131 | |||
| 132 | // ------------------------------------------------------------------------- |
||
| 133 | // ------------------light_pictures user handler class ------------------- |
||
| 134 | // ------------------------------------------------------------------------- |
||
| 135 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.