| @@ 152-183 (lines=32) @@ | ||
| 149 | * |
|
| 150 | * @return bool true on success, otherwise false |
|
| 151 | **/ |
|
| 152 | public function insert(XoopsObject $imgsetimg) |
|
| 153 | { |
|
| 154 | $className = 'XoopsImageSetImg'; |
|
| 155 | if (!($imgsetimg instanceof $className)) { |
|
| 156 | return false; |
|
| 157 | } |
|
| 158 | ||
| 159 | if (!$imgsetimg->isDirty()) { |
|
| 160 | return true; |
|
| 161 | } |
|
| 162 | if (!$imgsetimg->cleanVars()) { |
|
| 163 | return false; |
|
| 164 | } |
|
| 165 | foreach ($imgsetimg->cleanVars as $k => $v) { |
|
| 166 | ${$k} = $v; |
|
| 167 | } |
|
| 168 | if ($imgsetimg->isNew()) { |
|
| 169 | $imgsetimg_id = $this->db->genId('imgsetimg_imgsetimg_id_seq'); |
|
| 170 | $sql = sprintf('INSERT INTO %s (imgsetimg_id, imgsetimg_file, imgsetimg_body, imgsetimg_imgset) VALUES (%u, %s, %s, %s)', $this->db->prefix('imgsetimg'), $imgsetimg_id, $this->db->quoteString($imgsetimg_file), $this->db->quoteString($imgsetimg_body), $this->db->quoteString($imgsetimg_imgset)); |
|
| 171 | } else { |
|
| 172 | $sql = sprintf('UPDATE %s SET imgsetimg_file = %s, imgsetimg_body = %s, imgsetimg_imgset = %s WHERE imgsetimg_id = %u', $this->db->prefix('imgsetimg'), $this->db->quoteString($imgsetimg_file), $this->db->quoteString($imgsetimg_body), $this->db->quoteString($imgsetimg_imgset), $imgsetimg_id); |
|
| 173 | } |
|
| 174 | if (!$result = $this->db->query($sql)) { |
|
| 175 | return false; |
|
| 176 | } |
|
| 177 | if (empty($imgsetimg_id)) { |
|
| 178 | $imgsetimg_id = $this->db->getInsertId(); |
|
| 179 | } |
|
| 180 | $imgsetimg->assignVar('imgsetimg_id', $imgsetimg_id); |
|
| 181 | ||
| 182 | return true; |
|
| 183 | } |
|
| 184 | ||
| 185 | /** |
|
| 186 | * Delete an image from the database |
|
| @@ 195-225 (lines=31) @@ | ||
| 192 | * |
|
| 193 | * @return bool true on success, otherwise false |
|
| 194 | */ |
|
| 195 | public function insert(XoopsObject $tplset) |
|
| 196 | { |
|
| 197 | $className = 'XoopsTplset'; |
|
| 198 | if (!($tplset instanceof $className)) { |
|
| 199 | return false; |
|
| 200 | } |
|
| 201 | if (!$tplset->isDirty()) { |
|
| 202 | return true; |
|
| 203 | } |
|
| 204 | if (!$tplset->cleanVars()) { |
|
| 205 | return false; |
|
| 206 | } |
|
| 207 | foreach ($tplset->cleanVars as $k => $v) { |
|
| 208 | ${$k} = $v; |
|
| 209 | } |
|
| 210 | if ($tplset->isNew()) { |
|
| 211 | $tplset_id = $this->db->genId('tplset_tplset_id_seq'); |
|
| 212 | $sql = sprintf('INSERT INTO %s (tplset_id, tplset_name, tplset_desc, tplset_credits, tplset_created) VALUES (%u, %s, %s, %s, %u)', $this->db->prefix('tplset'), $tplset_id, $this->db->quoteString($tplset_name), $this->db->quoteString($tplset_desc), $this->db->quoteString($tplset_credits), $tplset_created); |
|
| 213 | } else { |
|
| 214 | $sql = sprintf('UPDATE %s SET tplset_name = %s, tplset_desc = %s, tplset_credits = %s, tplset_created = %u WHERE tplset_id = %u', $this->db->prefix('tplset'), $this->db->quoteString($tplset_name), $this->db->quoteString($tplset_desc), $this->db->quoteString($tplset_credits), $tplset_created, $tplset_id); |
|
| 215 | } |
|
| 216 | if (!$result = $this->db->query($sql)) { |
|
| 217 | return false; |
|
| 218 | } |
|
| 219 | if (empty($tplset_id)) { |
|
| 220 | $tplset_id = $this->db->getInsertId(); |
|
| 221 | } |
|
| 222 | $tplset->assignVar('tplset_id', $tplset_id); |
|
| 223 | ||
| 224 | return true; |
|
| 225 | } |
|
| 226 | ||
| 227 | /** |
|
| 228 | * delete a tplset from the database |
|
| @@ 167-197 (lines=31) @@ | ||
| 164 | * |
|
| 165 | * @return bool true on success, otherwise false |
|
| 166 | */ |
|
| 167 | public function insert(XoopsObject $group) |
|
| 168 | { |
|
| 169 | $className = 'XoopsGroup'; |
|
| 170 | if (!($group instanceof $className)) { |
|
| 171 | return false; |
|
| 172 | } |
|
| 173 | if (!$group->isDirty()) { |
|
| 174 | return true; |
|
| 175 | } |
|
| 176 | if (!$group->cleanVars()) { |
|
| 177 | return false; |
|
| 178 | } |
|
| 179 | foreach ($group->cleanVars as $k => $v) { |
|
| 180 | ${$k} = $v; |
|
| 181 | } |
|
| 182 | if ($group->isNew()) { |
|
| 183 | $groupid = $this->db->genId('group_groupid_seq'); |
|
| 184 | $sql = sprintf('INSERT INTO %s (groupid, name, description, group_type) VALUES (%u, %s, %s, %s)', $this->db->prefix('groups'), $groupid, $this->db->quoteString($name), $this->db->quoteString($description), $this->db->quoteString($group_type)); |
|
| 185 | } else { |
|
| 186 | $sql = sprintf('UPDATE %s SET name = %s, description = %s, group_type = %s WHERE groupid = %u', $this->db->prefix('groups'), $this->db->quoteString($name), $this->db->quoteString($description), $this->db->quoteString($group_type), $groupid); |
|
| 187 | } |
|
| 188 | if (!$result = $this->db->query($sql)) { |
|
| 189 | return false; |
|
| 190 | } |
|
| 191 | if (empty($groupid)) { |
|
| 192 | $groupid = $this->db->getInsertId(); |
|
| 193 | } |
|
| 194 | $group->assignVar('groupid', $groupid); |
|
| 195 | ||
| 196 | return true; |
|
| 197 | } |
|
| 198 | ||
| 199 | /** |
|
| 200 | * remove a group from the database |
|