PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | admin/helpers/src/model/payschedules.php +55 -2 1.7.2 → 1.8.16 View file →
@@ -155,8 +155,56 @@
155 155 return array_map([$this, 'normalizeObject'], $records);
156 156 }
157 157
158 158 /**
159 + * Method to delete one or more records.
160 + *
161 + * @param mixed $pks An array of record primary keys, or a single one.
162 + *
163 + * @return bool True if successful, false if an error occurs.
164 + *
165 + * @since 1.8.19 (J) - 1.8.9 (WP)
166 + */
167 + public function delete($pks)
168 + {
169 + $dbo = JFactory::getDbo();
170 +
171 + if (!$pks) {
172 + // nothing to delete
173 + return false;
174 + }
175 +
176 + if (!is_array($pks)) {
177 + // wrap into an array
178 + $pks = [$pks];
179 + }
180 +
181 + $deleted = 0;
182 +
183 + foreach ($pks as $pk) {
184 + // ensure the item exists
185 + $item = $this->getItem($pk);
186 +
187 + if (!$item) {
188 + continue;
189 + }
190 +
191 + $dbo->setQuery(
192 + $dbo->getQuery(true)
193 + ->delete($dbo->qn('#__vikbooking_payschedules'))
194 + ->where($dbo->qn('id') . ' = ' . (int) $item->id)
195 + );
196 + $dbo->execute();
197 +
198 + if ((bool) $dbo->getAffectedRows()) {
199 + $deleted++;
200 + }
201 + }
202 +
203 + return (bool) $deleted;
204 + }
205 +
206 + /**
159 207 * Watches and eventually processes the automatic payment collections scheduled.
160 208 *
161 209 * @param int $lim the limit of payments to process, defaults to 5 per execution.
162 210 *
@@ -201,12 +249,17 @@
201 249 $processed++;
202 250 }
203 251 } catch (Exception $e) {
204 252 // append failure execution log and update status (2 = error)
205 - $dbo->setQuery(
253 + $maxBytes = 65000;
254 + $recordLog = ltrim($payschedule->logs . "\n" . $e->getMessage(), "\n");
255 + if (strlen($recordLog) > $maxBytes) {
256 + $recordLog = function_exists('mb_strcut') ? mb_strcut($recordLog, -$maxBytes, $maxBytes, 'UTF-8') : substr($recordLog, -$maxBytes, $maxBytes);
257 + }
258 + $dbo->setQuery(
206 259 $dbo->getQuery(true)
207 260 ->update($dbo->qn('#__vikbooking_payschedules'))
208 - ->set($dbo->qn('logs') . ' = ' . $dbo->q(ltrim($payschedule->logs . "\n" . $e->getMessage(), "\n")))
261 + ->set($dbo->qn('logs') . ' = ' . $dbo->q($recordLog))
209 262 ->set($dbo->qn('status') . ' = 2')
210 263 ->where($dbo->qn('id') . ' = ' . (int) $payschedule->id)
211 264 );
212 265 $dbo->execute();