XoopsModules25x /
xhelp
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php declare(strict_types=1); |
||||||
| 2 | |||||||
| 3 | namespace XoopsModules\Xhelp; |
||||||
| 4 | |||||||
| 5 | /* |
||||||
| 6 | * You may not change or alter any portion of this comment or credits |
||||||
| 7 | * of supporting developers from this source code or any supporting source code |
||||||
| 8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
| 9 | * |
||||||
| 10 | * This program is distributed in the hope that it will be useful, |
||||||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
| 13 | */ |
||||||
| 14 | |||||||
| 15 | /** |
||||||
| 16 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||||
| 17 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||||||
| 18 | * @author Eric Juden <[email protected]> |
||||||
| 19 | * @author XOOPS Development Team |
||||||
| 20 | */ |
||||||
| 21 | |||||||
| 22 | // require_once XHELP_CLASS_PATH . '/BaseObjectHandler.php'; |
||||||
| 23 | |||||||
| 24 | /** |
||||||
| 25 | * TicketEmailsHandler class |
||||||
| 26 | * |
||||||
| 27 | * Department Handler for Department class |
||||||
| 28 | * |
||||||
| 29 | * @author Eric Juden <[email protected]> & |
||||||
| 30 | */ |
||||||
| 31 | class TicketEmailsHandler extends BaseObjectHandler |
||||||
| 32 | { |
||||||
| 33 | /** |
||||||
| 34 | * Name of child class |
||||||
| 35 | * |
||||||
| 36 | * @var string |
||||||
| 37 | */ |
||||||
| 38 | public $classname = TicketEmails::class; |
||||||
| 39 | /** |
||||||
| 40 | * DB table name |
||||||
| 41 | * |
||||||
| 42 | * @var string |
||||||
| 43 | */ |
||||||
| 44 | public $dbtable = 'xhelp_ticket_submit_emails'; |
||||||
| 45 | |||||||
| 46 | private const TABLE = 'xhelp_ticket_submit_emails'; |
||||||
| 47 | private const ENTITY = TicketEmails::class; |
||||||
| 48 | private const ENTITYNAME = 'TicketEmails'; |
||||||
| 49 | private const KEYNAME = 'ticketid'; |
||||||
| 50 | private const IDENTIFIER = 'uid'; |
||||||
| 51 | |||||||
| 52 | /** |
||||||
| 53 | * Constructor |
||||||
| 54 | * |
||||||
| 55 | * @param \XoopsMySQLDatabase|null $db reference to a xoopsDB object |
||||||
| 56 | */ |
||||||
| 57 | public function __construct(\XoopsMySQLDatabase $db = null) |
||||||
| 58 | { |
||||||
| 59 | $this->init($db); |
||||||
| 60 | $this->helper = Helper::getInstance(); |
||||||
| 61 | parent::__construct($db, static::TABLE, static::ENTITY, static::KEYNAME, static::IDENTIFIER); |
||||||
| 62 | } |
||||||
| 63 | |||||||
| 64 | /** |
||||||
| 65 | * @param \XoopsObject $object |
||||||
| 66 | * @return string |
||||||
| 67 | */ |
||||||
| 68 | public function insertQuery(\XoopsObject $object): string |
||||||
| 69 | { |
||||||
| 70 | //TODO mb replace with individual variables |
||||||
| 71 | // Copy all object vars into local variables |
||||||
| 72 | foreach ($object->cleanVars as $k => $v) { |
||||||
| 73 | ${$k} = $v; |
||||||
| 74 | } |
||||||
| 75 | |||||||
| 76 | $sql = \sprintf('INSERT INTO `%s` (ticketid, uid, email, suppress) VALUES (%u, %u, %s, %u)', $this->db->prefix($this->dbtable), $ticketid, $uid, $this->db->quoteString($email), $suppress); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 77 | |||||||
| 78 | return $sql; |
||||||
| 79 | } |
||||||
| 80 | |||||||
| 81 | /** |
||||||
| 82 | * @param \XoopsObject|null $object |
||||||
| 83 | * @return string |
||||||
| 84 | */ |
||||||
| 85 | public function deleteQuery(\XoopsObject $object = null): string |
||||||
| 86 | { |
||||||
| 87 | $sql = \sprintf('DELETE FROM `%s` WHERE ticketid = %u', $this->db->prefix($this->dbtable), $object->getVar('ticketid')); |
||||||
|
0 ignored issues
–
show
It seems like
$object->getVar('ticketid') can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
The method
getVar() does not exist on null.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 88 | |||||||
| 89 | return $sql; |
||||||
| 90 | } |
||||||
| 91 | |||||||
| 92 | /** |
||||||
| 93 | * @param \XoopsObject $object |
||||||
| 94 | * @return string |
||||||
| 95 | */ |
||||||
| 96 | public function updateQuery(\XoopsObject $object): string |
||||||
| 97 | { |
||||||
| 98 | //TODO mb replace with individual variables |
||||||
| 99 | // Copy all object vars into local variables |
||||||
| 100 | foreach ($object->cleanVars as $k => $v) { |
||||||
| 101 | ${$k} = $v; |
||||||
| 102 | } |
||||||
| 103 | |||||||
| 104 | $sql = \sprintf('UPDATE `%s` SET suppress = %u WHERE ticketid = %u AND uid = %u AND email = %s', $this->db->prefix($this->dbtable), $suppress, $ticketid, $uid, $this->db->quoteString($email)); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 105 | |||||||
| 106 | return $sql; |
||||||
| 107 | } |
||||||
| 108 | |||||||
| 109 | /** |
||||||
| 110 | * retrieve objects from the database |
||||||
| 111 | * |
||||||
| 112 | * @param \CriteriaElement|\CriteriaCompo|null $criteria {@link CriteriaElement} conditions to be met |
||||||
| 113 | * @param bool $id_as_key Should the department ID be used as array key |
||||||
| 114 | * @return array array of {@link Department} objects |
||||||
| 115 | */ |
||||||
| 116 | public function &getObjects(\CriteriaElement $criteria = null, $id_as_key = false, $as_object = true): array |
||||||
| 117 | { |
||||||
| 118 | $ret = []; |
||||||
| 119 | $limit = $start = 0; |
||||||
| 120 | $sql = $this->selectQuery($criteria); |
||||||
| 121 | if (null !== $criteria) { |
||||||
| 122 | $limit = $criteria->getLimit(); |
||||||
| 123 | $start = $criteria->getStart(); |
||||||
| 124 | } |
||||||
| 125 | |||||||
| 126 | $result = $this->db->query($sql, $limit, $start); |
||||||
| 127 | // If no records from db, return empty array |
||||||
| 128 | if (!$result) { |
||||||
| 129 | return $ret; |
||||||
| 130 | } |
||||||
| 131 | |||||||
| 132 | // Add each returned record to the result array |
||||||
| 133 | while (false !== ($myrow = $this->db->fetchArray($result))) { |
||||||
| 134 | $object = new $this->classname($myrow); |
||||||
| 135 | $ret[$object->getVar('email')] = $object; |
||||||
| 136 | unset($object); |
||||||
| 137 | } |
||||||
| 138 | |||||||
| 139 | return $ret; |
||||||
| 140 | } |
||||||
| 141 | |||||||
| 142 | /** |
||||||
| 143 | * retrieve objects from the database |
||||||
| 144 | * |
||||||
| 145 | * @param \CriteriaElement|\CriteriaCompo|null $criteria {@link CriteriaElement} conditions to be met |
||||||
| 146 | * @return array array of <a href='psi_element://Department'>Department</a> objects |
||||||
| 147 | * objects |
||||||
| 148 | * @internal param bool $id_as_key Should the department ID be used as array key |
||||||
| 149 | */ |
||||||
| 150 | public function &getObjectsSortedByTicket($criteria = null): array |
||||||
| 151 | { |
||||||
| 152 | $ret = []; |
||||||
| 153 | $limit = $start = 0; |
||||||
| 154 | $sql = $this->selectQuery($criteria); |
||||||
| 155 | if (null !== $criteria) { |
||||||
| 156 | $limit = $criteria->getLimit(); |
||||||
| 157 | $start = $criteria->getStart(); |
||||||
| 158 | } |
||||||
| 159 | |||||||
| 160 | $result = $this->db->query($sql, $limit, $start); |
||||||
| 161 | // If no records from db, return empty array |
||||||
| 162 | if (!$result) { |
||||||
| 163 | return $ret; |
||||||
| 164 | } |
||||||
| 165 | |||||||
| 166 | // Add each returned record to the result array |
||||||
| 167 | while (false !== ($myrow = $this->db->fetchArray($result))) { |
||||||
| 168 | $object = new $this->classname($myrow); |
||||||
| 169 | $ret[$object->getVar('ticketid')] = $object; |
||||||
| 170 | unset($object); |
||||||
| 171 | } |
||||||
| 172 | |||||||
| 173 | return $ret; |
||||||
| 174 | } |
||||||
| 175 | } |
||||||
| 176 |