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.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /************************************************************************ |
||
| 3 | * OVIDENTIA http://www.ovidentia.org * |
||
| 4 | ************************************************************************ |
||
| 5 | * Copyright (c) 2003 by CANTICO ( http://www.cantico.fr ) * |
||
| 6 | * * |
||
| 7 | * This file is part of Ovidentia. * |
||
| 8 | * * |
||
| 9 | * Ovidentia is free software; you can redistribute it and/or modify * |
||
| 10 | * it under the terms of the GNU General Public License as published by * |
||
| 11 | * the Free Software Foundation; either version 2, or (at your option) * |
||
| 12 | * any later version. * |
||
| 13 | * * |
||
| 14 | * This program is distributed in the hope that it will be useful, but * |
||
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
||
| 17 | * See the GNU General Public License for more details. * |
||
| 18 | * * |
||
| 19 | * You should have received a copy of the GNU General Public License * |
||
| 20 | * along with this program; if not, write to the Free Software * |
||
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,* |
||
| 22 | * USA. * |
||
| 23 | ************************************************************************/ |
||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | |||
| 29 | require_once dirname(__FILE__).'/increment.class.php'; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @property int $id_right |
||
| 33 | * |
||
| 34 | */ |
||
| 35 | View Code Duplication | class absences_IncrementRight extends absences_IncrementRecord |
|
|
0 ignored issues
–
show
|
|||
| 36 | { |
||
| 37 | private $right; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @return absences_DynamicRight |
||
| 41 | */ |
||
| 42 | 12 | public static function getById($id) |
|
| 43 | { |
||
| 44 | 12 | $dright = new absences_IncrementRight; |
|
| 45 | 12 | $dright->id = $id; |
|
| 46 | |||
| 47 | 12 | return $dright; |
|
| 48 | } |
||
| 49 | |||
| 50 | |||
| 51 | /** |
||
| 52 | * (non-PHPdoc) |
||
| 53 | * @see absences_Record::getRow() |
||
| 54 | */ |
||
| 55 | 15 | public function getRow() |
|
| 56 | { |
||
| 57 | 15 | if (null === $this->row) |
|
| 58 | 15 | { |
|
| 59 | if (!isset($this->id)) |
||
| 60 | { |
||
| 61 | throw new Exception('Failed to load increment right, missing id'); |
||
| 62 | } |
||
| 63 | |||
| 64 | global $babDB; |
||
| 65 | $res = $babDB->db_query('SELECT * FROM absences_increment_right WHERE id='.$babDB->quote($this->id)); |
||
| 66 | $this->setRow($babDB->db_fetch_assoc($res)); |
||
| 67 | } |
||
| 68 | |||
| 69 | 15 | return $this->row; |
|
| 70 | } |
||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | /** |
||
| 75 | * |
||
| 76 | * @param absences_Right $right |
||
| 77 | * @return absences_IncrementRight |
||
| 78 | */ |
||
| 79 | 12 | public function setRight(absences_Right $right) |
|
| 80 | { |
||
| 81 | 12 | $this->right = $right; |
|
| 82 | 12 | return $this; |
|
| 83 | } |
||
| 84 | |||
| 85 | |||
| 86 | /** |
||
| 87 | * @return absences_Right |
||
| 88 | */ |
||
| 89 | public function getRight() |
||
| 90 | { |
||
| 91 | if (!isset($this->right)) |
||
| 92 | { |
||
| 93 | require_once dirname(__FILE__).'/right.class.php'; |
||
| 94 | |||
| 95 | $row = $this->getRow(); |
||
| 96 | $this->right = new absences_Right($row['id_user_right']); |
||
| 97 | } |
||
| 98 | |||
| 99 | return $this->right; |
||
| 100 | } |
||
| 101 | |||
| 102 | |||
| 103 | |||
| 104 | |||
| 105 | /** |
||
| 106 | * Save element (insert or update or delete) |
||
| 107 | */ |
||
| 108 | 12 | public function save() |
|
| 109 | { |
||
| 110 | 12 | global $babDB; |
|
| 111 | |||
| 112 | 12 | if (isset($this->id)) |
|
| 113 | 12 | { |
|
| 114 | $quantity = (int) round(100 * $this->quantity); |
||
| 115 | |||
| 116 | if (0 === $quantity) |
||
| 117 | { |
||
| 118 | // if quantity has been set to 0, the element must be deleted |
||
| 119 | |||
| 120 | $babDB->db_query("DELETE FROM absences_increment_right WHERE id=".$babDB->quote($this->id)); |
||
| 121 | |||
| 122 | } else { |
||
| 123 | |||
| 124 | |||
| 125 | $babDB->db_query(" |
||
| 126 | UPDATE absences_increment_right |
||
| 127 | SET |
||
| 128 | quantity=".$babDB->quote($this->quantity)." |
||
| 129 | WHERE |
||
| 130 | id=".$babDB->quote($this->id) |
||
| 131 | ); |
||
| 132 | |||
| 133 | } |
||
| 134 | |||
| 135 | |||
| 136 | } else { |
||
| 137 | |||
| 138 | |||
| 139 | 12 | $babDB->db_query(" |
|
| 140 | INSERT INTO absences_increment_right |
||
| 141 | (id_right, quantity, monthkey, createdOn) |
||
| 142 | VALUES |
||
| 143 | ( |
||
| 144 | 12 | " .$babDB->quote($this->id_right). ", |
|
| 145 | 12 | " .$babDB->quote($this->quantity). ", |
|
| 146 | 12 | " .$babDB->quote($this->monthkey). ", |
|
| 147 | 12 | " .$babDB->quote($this->createdOn). " |
|
| 148 | ) |
||
| 149 | 12 | "); |
|
| 150 | |||
| 151 | 12 | $this->id = $babDB->db_insert_id(); |
|
| 152 | } |
||
| 153 | |||
| 154 | |||
| 155 | 12 | } |
|
| 156 | |||
| 157 | |||
| 158 | 12 | public function saveOrUpdate() |
|
| 159 | { |
||
| 160 | 12 | global $babDB; |
|
| 161 | |||
| 162 | 12 | $res = $babDB->db_query('SELECT id FROM absences_increment_right |
|
| 163 | 12 | WHERE monthkey='.$babDB->quote($this->monthkey).' |
|
| 164 | 12 | AND id_right='.$babDB->quote($this->id_right)); |
|
| 165 | |||
| 166 | 12 | if ($arr = $babDB->db_fetch_assoc($res)) { |
|
| 167 | $this->id = (int) $arr['id']; |
||
| 168 | } |
||
| 169 | |||
| 170 | 12 | $this->save(); |
|
| 171 | 12 | } |
|
| 172 | } |
||
| 173 | |||
| 174 | |||
| 175 | |||
| 176 | |||
| 177 | View Code Duplication | class absences_IncrementRightIterator extends absences_Iterator |
|
|
0 ignored issues
–
show
This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 178 | { |
||
| 179 | protected $right; |
||
| 180 | |||
| 181 | /** |
||
| 182 | * @var string YYYY-MM-DD |
||
| 183 | */ |
||
| 184 | public $upto; |
||
| 185 | |||
| 186 | |||
| 187 | 42 | public function setRight(absences_Right $right) |
|
| 188 | { |
||
| 189 | 42 | $this->right = $right; |
|
| 190 | 42 | } |
|
| 191 | |||
| 192 | |||
| 193 | 42 | public function executeQuery() |
|
| 194 | { |
||
| 195 | 42 | if(is_null($this->_oResult)) |
|
| 196 | 42 | { |
|
| 197 | 42 | global $babDB; |
|
| 198 | $req = "SELECT |
||
| 199 | ir.* |
||
| 200 | FROM |
||
| 201 | absences_increment_right ir |
||
| 202 | WHERE |
||
| 203 | 42 | ir.id_right=".$babDB->quote($this->right->id); |
|
| 204 | |||
| 205 | 42 | if (isset($this->upto) && '0000-00-00' !== $this->upto) { |
|
| 206 | 14 | $req .= ' AND ir.createdOn<='.$babDB->quote($this->upto.' 23:59:59'); |
|
| 207 | 14 | } |
|
| 208 | |||
| 209 | 42 | $req .= " ORDER BY ir.createdOn, ir.id"; |
|
| 210 | |||
| 211 | 42 | $this->setMySqlResult($this->getDataBaseAdapter()->db_query($req)); |
|
| 212 | 42 | } |
|
| 213 | 42 | } |
|
| 214 | |||
| 215 | |||
| 216 | 12 | public function getObject($data) |
|
| 217 | { |
||
| 218 | 12 | $dynRight = absences_IncrementRight::getById($data['id']); |
|
| 219 | 12 | $dynRight->setRow($data); |
|
| 220 | 12 | $dynRight->setRight($this->right); |
|
| 221 | |||
| 222 | 12 | return $dynRight; |
|
| 223 | } |
||
| 224 | |||
| 225 | |||
| 226 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.