XoopsModules25x /
soapbox
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 |
||
| 2 | |||
| 3 | namespace XoopsModules\Soapbox; |
||
| 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 http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||
| 18 | * @package |
||
| 19 | * @since |
||
| 20 | * @author XOOPS Development Team |
||
| 21 | */ |
||
| 22 | |||
| 23 | use XoopsModules\Soapbox; |
||
| 24 | |||
| 25 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||
| 26 | //require_once XOOPS_ROOT_PATH . '/modules/soapbox/include/cleantags.php'; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Class ColumnsHandler |
||
| 30 | */ |
||
| 31 | class ColumnsHandler extends \XoopsPersistableObjectHandler |
||
| 32 | { |
||
| 33 | public $totalarts_AllPermcheck; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * create a new category |
||
| 37 | * |
||
| 38 | * @param bool $isNew flag the new objects as "new"? |
||
| 39 | * @return object Columns |
||
| 40 | */ |
||
| 41 | public function create($isNew = true) |
||
| 42 | { |
||
| 43 | $sbcolumn = new Columns(); |
||
| 44 | if ($isNew) { |
||
| 45 | $sbcolumn->setNew(); |
||
| 46 | } |
||
| 47 | |||
| 48 | return $sbcolumn; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * retrieve a category |
||
| 53 | * |
||
| 54 | * @param mixed|null $id |
||
| 55 | * @param null $fields |
||
| 56 | * @return mixed reference to the <a href='psi_element://Columns'>Columns</a> object, FALSE if failed |
||
| 57 | * object, FALSE if failed |
||
| 58 | * object, FALSE if failed |
||
| 59 | * @internal param int $columnID columnID of the category |
||
| 60 | */ |
||
| 61 | public function get($id = null, $fields = null) //&get($id) |
||
| 62 | { |
||
| 63 | $ret = false; |
||
| 64 | if ((int)$id > 0) { |
||
| 65 | $sql = 'SELECT * FROM ' . $this->db->prefix('sbcolumns') . " WHERE columnID = '$id'"; |
||
| 66 | if (!$result = $this->db->query($sql)) { |
||
| 67 | return $ret; |
||
| 68 | } |
||
| 69 | $numrows = $this->db->getRowsNum($result); |
||
| 70 | if (1 === $numrows) { |
||
| 71 | $sbcolumn = new Columns(); |
||
| 72 | $sbcolumn->assignVars($this->db->fetchArray($result)); |
||
| 73 | |||
| 74 | return $sbcolumn; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | |||
| 78 | return $ret; |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * retrieve categorys from the database |
||
| 83 | * |
||
| 84 | * @param \CriteriaElement $criteria {@link CriteriaElement} conditions to be match |
||
| 85 | * @param bool $id_as_key use the columnID as key for the array? |
||
| 86 | * @param bool $as_object |
||
| 87 | * @return array array of <a href='psi_element://Columns'>Columns</a> objects |
||
| 88 | * objects |
||
| 89 | */ |
||
| 90 | public function &getObjects(\CriteriaElement $criteria = null, $id_as_key = false, $as_object = true) //&getObjects($criteria = null, $id_as_key = false) |
||
| 91 | { |
||
| 92 | $ret = []; |
||
| 93 | $limit = $start = 0; |
||
| 94 | $sql = 'SELECT * FROM ' . $this->db->prefix('sbcolumns'); |
||
| 95 | if (isset($criteria) && $criteria instanceof \CriteriaElement) { |
||
| 96 | $sql .= ' ' . $criteria->renderWhere(); |
||
| 97 | if ('' !== $criteria->getSort()) { |
||
| 98 | $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); |
||
| 99 | } |
||
| 100 | $limit = $criteria->getLimit(); |
||
| 101 | $start = $criteria->getStart(); |
||
| 102 | } |
||
| 103 | $result = $this->db->query($sql, $limit, $start); |
||
| 104 | if (!$result) { |
||
| 105 | return $ret; |
||
| 106 | } |
||
| 107 | while (false !== ($myrow = $this->db->fetchArray($result))) { |
||
| 108 | $sbcolumn = new Columns(); |
||
| 109 | $sbcolumn->assignVars($myrow); |
||
| 110 | if (!$id_as_key) { |
||
| 111 | $ret[] = $sbcolumn; |
||
| 112 | } else { |
||
| 113 | $ret[$myrow['columnID']] = $sbcolumn; |
||
| 114 | } |
||
| 115 | unset($sbcolumn); |
||
| 116 | } |
||
| 117 | $this->db->freeRecordSet($result); |
||
| 118 | |||
| 119 | return $ret; |
||
| 120 | } |
||
| 121 | |||
| 122 | /** |
||
| 123 | * insert a new category in the database |
||
| 124 | * |
||
| 125 | * @param \XoopsObject $sbcolumn reference to the {@link Columns} |
||
| 126 | * object |
||
| 127 | * @param bool $force |
||
| 128 | * @return bool FALSE if failed, TRUE if already present and unchanged or successful |
||
| 129 | */ |
||
| 130 | public function insert(\XoopsObject $sbcolumn, $force = false)//insert($sbcolumn, $force = false) |
||
| 131 | { |
||
| 132 | if (mb_strtolower(get_class($sbcolumn)) !== mb_strtolower(Columns::class)) { |
||
| 133 | return false; |
||
| 134 | } |
||
| 135 | if (!$sbcolumn->isDirty()) { |
||
| 136 | return true; |
||
| 137 | } |
||
| 138 | if (!$sbcolumn->cleanVars()) { |
||
| 139 | return false; |
||
| 140 | } |
||
| 141 | foreach ($sbcolumn->cleanVars as $k => $v) { |
||
| 142 | ${$k} = $v; |
||
| 143 | } |
||
| 144 | // RMV-NOTIFY |
||
| 145 | if ($sbcolumn->isNew()) { |
||
| 146 | $columnID = $this->db->genId($this->db->prefix('sbcolumns') . '_columnID_seq'); |
||
| 147 | $sql = sprintf('INSERT INTO `%s` (columnID, author, NAME, description, total, weight, colimage, created) VALUES (%u, %u, %s, %s, %u, %u, %s, %u)', $this->db->prefix('sbcolumns'), $columnID, $author, $this->db->quoteString($name), $this->db->quoteString($description), $total, |
||
|
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
|
|||
| 148 | $weight, $this->db->quoteString($colimage), $created); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
|
|||
| 149 | } else { |
||
| 150 | $sql = sprintf('UPDATE `%s` SET author = %s, NAME = %s, description = %s, total = %u, weight = %u, colimage = %s, created = %u WHERE columnID = %u', $this->db->prefix('sbcolumns'), $author, $this->db->quoteString($name), $this->db->quoteString($description), $total, $weight, |
||
| 151 | $this->db->quoteString($colimage), $created, $columnID); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 152 | } |
||
| 153 | if ($force) { |
||
| 154 | $result = $this->db->queryF($sql); |
||
| 155 | } else { |
||
| 156 | $result = $this->db->query($sql); |
||
| 157 | } |
||
| 158 | if (!$result) { |
||
| 159 | return false; |
||
| 160 | } |
||
| 161 | if (empty($columnID)) { |
||
| 162 | $columnID = $this->db->getInsertId(); |
||
| 163 | } |
||
| 164 | $sbcolumn->assignVar('columnID', $columnID); |
||
| 165 | |||
| 166 | return true; |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * delete a category from the database |
||
| 171 | * |
||
| 172 | * @param \XoopsObject $sbcolumn reference to the category to delete |
||
| 173 | * @param bool $force |
||
| 174 | * @return bool FALSE if failed. |
||
| 175 | */ |
||
| 176 | public function delete(\XoopsObject $sbcolumn, $force = false)//delete($sbcolumn, $force = false) |
||
| 177 | { |
||
| 178 | if (mb_strtolower(get_class($sbcolumn)) !== mb_strtolower(Columns::class)) { |
||
| 179 | return false; |
||
| 180 | } |
||
| 181 | $sql = sprintf('DELETE FROM `%s` WHERE columnID = %u', $this->db->prefix('sbcolumns'), $sbcolumn->getVar('columnID')); |
||
| 182 | if ($force) { |
||
| 183 | $result = $this->db->queryF($sql); |
||
| 184 | } else { |
||
| 185 | $result = $this->db->query($sql); |
||
| 186 | } |
||
| 187 | if (!$result) { |
||
| 188 | return false; |
||
| 189 | } |
||
| 190 | |||
| 191 | return true; |
||
| 192 | } |
||
| 193 | |||
| 194 | /** |
||
| 195 | * count categorys matching a condition |
||
| 196 | * |
||
| 197 | * @param \CriteriaElement $criteria {@link CriteriaElement} to match |
||
| 198 | * @return int count of categorys |
||
| 199 | */ |
||
| 200 | public function getCount(\CriteriaElement $criteria = null)//getCount($criteria = null) |
||
| 201 | { |
||
| 202 | $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('sbcolumns'); |
||
| 203 | if (isset($criteria) && $criteria instanceof \CriteriaElement) { |
||
| 204 | $sql .= ' ' . $criteria->renderWhere(); |
||
| 205 | } |
||
| 206 | $result = $this->db->query($sql); |
||
| 207 | if (!$result) { |
||
| 208 | return 0; |
||
| 209 | } |
||
| 210 | list($count) = $this->db->fetchRow($result); |
||
| 211 | |||
| 212 | return $count; |
||
| 213 | } |
||
| 214 | |||
| 215 | /** |
||
| 216 | * updates a single field in a Column record |
||
| 217 | * |
||
| 218 | * @param object $entry reference to the {@link Columns} object |
||
| 219 | * @param string $fieldName name of the field to update |
||
| 220 | * @param string $fieldValue updated value for the field |
||
| 221 | * @param bool $force |
||
| 222 | * @return bool TRUE if success or unchanged, FALSE on failure |
||
| 223 | */ |
||
| 224 | public function updateByField($entry, $fieldName, $fieldValue, $force = false) |
||
| 225 | { |
||
| 226 | if (mb_strtolower(get_class($entry)) !== mb_strtolower(Columns::class)) { |
||
| 227 | return false; |
||
| 228 | } |
||
| 229 | $entry->setVar($fieldName, $fieldValue); |
||
| 230 | |||
| 231 | return $this->insert($entry, $force); |
||
| 232 | } |
||
| 233 | } |
||
| 234 |