@@ 287-344 (lines=58) @@ | ||
284 | xoops_confirm(['ok' => true, 'op' => 'del_oldprotocol'], $currentFile, _AM_XNEWSLETTER_MAINTENANCE_DELETEPROTOCOL); |
|
285 | } |
|
286 | break; |
|
287 | case 'del_invalid_catsubscr': |
|
288 | //delete data in table catsubscr, if catsubscr_subscrid is no more existing in table subscr |
|
289 | if (true === Request::getBool('ok', false, 'POST')) { |
|
290 | $number_ids = 0; |
|
291 | $deleted = 0; |
|
292 | $errors = []; |
|
293 | $sql = 'SELECT Count(`catsubscr_id`) AS `nb_ids`'; |
|
294 | $sql .= " FROM `{$xoopsDB->prefix('xnewsletter_catsubscr')}` LEFT JOIN `{$xoopsDB->prefix('xnewsletter_subscr')}` ON `catsubscr_subscrid` = `subscr_id`"; |
|
295 | $sql .= ' WHERE (`subscr_id` Is Null)'; |
|
296 | $result = $xoopsDB->query($sql); |
|
297 | if ($result) { |
|
298 | $row_result = $xoopsDB->fetchRow($result); |
|
299 | $number_ids = $row_result[0]; |
|
300 | } |
|
301 | if ($number_ids > 0) { |
|
302 | $sql = "DELETE `{$xoopsDB->prefix('xnewsletter_catsubscr')}`"; |
|
303 | $sql .= " FROM `{$xoopsDB->prefix('xnewsletter_catsubscr')}` LEFT JOIN `{$xoopsDB->prefix('xnewsletter_subscr')}` ON `catsubscr_subscrid` = `subscr_id`"; |
|
304 | $sql .= ' WHERE (`subscr_id` Is Null)'; |
|
305 | $result = $xoopsDB->query($sql); |
|
306 | if ($result) { |
|
307 | ++$deleted; |
|
308 | } else { |
|
309 | $errors[] = 'Error delete catsubscr: ' . $result->getHtmlErrors(); |
|
310 | } |
|
311 | } |
|
312 | ||
313 | if (count($errors) > 0) { |
|
314 | foreach ($errors as $error) { |
|
315 | $protocolObj = $helper->getHandler('Protocol')->create(); |
|
316 | $protocolObj->setVar('protocol_letter_id', 0); |
|
317 | $protocolObj->setVar('protocol_subscriber_id', 0); |
|
318 | $protocolObj->setVar('protocol_status', '[' . _MI_XNEWSLETTER_ADMENU11 . ' catsubscr] ' . $error); |
|
319 | $protocolObj->setVar('protocol_success', false); |
|
320 | $protocolObj->setVar('protocol_submitter', $GLOBALS['xoopsUser']->uid()); |
|
321 | $protocolObj->setVar('protocol_created', time()); |
|
322 | if (!$helper->getHandler('Protocol')->insert($protocolObj)) { |
|
323 | $GLOBALS['xoopsTpl']->assign('error', _AM_XNEWSLETTER_MAINTENANCE_ERROR); |
|
324 | } |
|
325 | } |
|
326 | } else { |
|
327 | $protocolObj = $helper->getHandler('Protocol')->create(); |
|
328 | $protocolObj->setVar('protocol_letter_id', 0); |
|
329 | $protocolObj->setVar('protocol_subscriber_id', 0); |
|
330 | $status = 0 == $number_ids ? _AM_XNEWSLETTER_MAINTENANCE_DELETE_INVALID_SUBCR_NODATA : sprintf(_AM_XNEWSLETTER_MAINTENANCE_DELETE_INVALID_SUBCR_OK, $number_ids); |
|
331 | $protocolObj->setVar('protocol_status', '[' . _MI_XNEWSLETTER_ADMENU11 . ' catsubscr] ' . $status); |
|
332 | $protocolObj->setVar('protocol_success', true); |
|
333 | $protocolObj->setVar('protocol_submitter', $GLOBALS['xoopsUser']->uid()); |
|
334 | $protocolObj->setVar('protocol_created', time()); |
|
335 | ||
336 | if (!$helper->getHandler('Protocol')->insert($protocolObj)) { |
|
337 | $GLOBALS['xoopsTpl']->assign('error', _AM_XNEWSLETTER_MAINTENANCE_ERROR); |
|
338 | } |
|
339 | redirect_header($currentFile, 3, sprintf(_AM_XNEWSLETTER_MAINTENANCE_DELETE_INVALID_SUBCR_OK, $number_ids)); |
|
340 | } |
|
341 | } else { |
|
342 | xoops_confirm(['ok' => true, 'op' => 'del_invalid_catsubscr'], $currentFile, _AM_XNEWSLETTER_MAINTENANCE_DELETE_INVALID_SUBCR); |
|
343 | } |
|
344 | break; |
|
345 | case 'del_invalid_subscr_catdel': |
|
346 | //delete data in table catsubscr, if cat is no more existing in table cat |
|
347 | if (true === Request::getBool('ok', false, 'POST')) { |
|
@@ 345-402 (lines=58) @@ | ||
342 | xoops_confirm(['ok' => true, 'op' => 'del_invalid_catsubscr'], $currentFile, _AM_XNEWSLETTER_MAINTENANCE_DELETE_INVALID_SUBCR); |
|
343 | } |
|
344 | break; |
|
345 | case 'del_invalid_subscr_catdel': |
|
346 | //delete data in table catsubscr, if cat is no more existing in table cat |
|
347 | if (true === Request::getBool('ok', false, 'POST')) { |
|
348 | $number_ids = 0; |
|
349 | $deleted = 0; |
|
350 | $errors = []; |
|
351 | $sql = 'SELECT Count(`catsubscr_id`) AS `nb_ids`'; |
|
352 | $sql .= " FROM `{$xoopsDB->prefix('xnewsletter_catsubscr')}` LEFT JOIN `{$xoopsDB->prefix('xnewsletter_cat')}` ON `catsubscr_catid` = `cat_id`"; |
|
353 | $sql .= ' WHERE (`cat_id` Is Null)'; |
|
354 | $result = $xoopsDB->query($sql); |
|
355 | if ($result) { |
|
356 | $row_result = $xoopsDB->fetchRow($result); |
|
357 | $number_ids = $row_result[0]; |
|
358 | } |
|
359 | if ($number_ids > 0) { |
|
360 | $sql = "DELETE `{$xoopsDB->prefix('xnewsletter_catsubscr')}`"; |
|
361 | $sql .= " FROM `{$xoopsDB->prefix('xnewsletter_catsubscr')}` LEFT JOIN `{$xoopsDB->prefix('xnewsletter_cat')}` ON `catsubscr_catid` = `cat_id`"; |
|
362 | $sql .= ' WHERE (`cat_id` Is Null)'; |
|
363 | $result = $xoopsDB->query($sql); |
|
364 | if ($result) { |
|
365 | ++$deleted; |
|
366 | } else { |
|
367 | $errors[] = 'Error delete catsubscr: ' . $result->getHtmlErrors(); |
|
368 | } |
|
369 | } |
|
370 | ||
371 | if (count($errors) > 0) { |
|
372 | foreach ($errors as $error) { |
|
373 | $protocolObj = $helper->getHandler('Protocol')->create(); |
|
374 | $protocolObj->setVar('protocol_letter_id', 0); |
|
375 | $protocolObj->setVar('protocol_subscriber_id', 0); |
|
376 | $protocolObj->setVar('protocol_status', '[' . _MI_XNEWSLETTER_ADMENU11 . ' catsubscr] ' . $error); |
|
377 | $protocolObj->setVar('protocol_success', false); |
|
378 | $protocolObj->setVar('protocol_submitter', $GLOBALS['xoopsUser']->uid()); |
|
379 | $protocolObj->setVar('protocol_created', time()); |
|
380 | if (!$helper->getHandler('Protocol')->insert($protocolObj)) { |
|
381 | $GLOBALS['xoopsTpl']->assign('error', _AM_XNEWSLETTER_MAINTENANCE_ERROR); |
|
382 | } |
|
383 | } |
|
384 | } else { |
|
385 | $protocolObj = $helper->getHandler('Protocol')->create(); |
|
386 | $protocolObj->setVar('protocol_letter_id', 0); |
|
387 | $protocolObj->setVar('protocol_subscriber_id', 0); |
|
388 | $status = 0 == $number_ids ? _AM_XNEWSLETTER_MAINTENANCE_DELETE_INVALID_SUBCR_NODATA : sprintf(_AM_XNEWSLETTER_MAINTENANCE_DELETE_INVALID_SUBCR_OK, $number_ids); |
|
389 | $protocolObj->setVar('protocol_status', '[' . _MI_XNEWSLETTER_ADMENU11 . ' catsubscr] ' . $status); |
|
390 | $protocolObj->setVar('protocol_success', true); |
|
391 | $protocolObj->setVar('protocol_submitter', $GLOBALS['xoopsUser']->uid()); |
|
392 | $protocolObj->setVar('protocol_created', time()); |
|
393 | ||
394 | if (!$helper->getHandler('Protocol')->insert($protocolObj)) { |
|
395 | $GLOBALS['xoopsTpl']->assign('error', _AM_XNEWSLETTER_MAINTENANCE_ERROR); |
|
396 | } |
|
397 | redirect_header($currentFile, 3, sprintf(_AM_XNEWSLETTER_MAINTENANCE_DELETE_INVALID_SUBCR_OK, $number_ids)); |
|
398 | } |
|
399 | } else { |
|
400 | xoops_confirm(['ok' => true, 'op' => 'del_invalid_subscr_catdel'], $currentFile, _AM_XNEWSLETTER_MAINTENANCE_DELETE_INVALID_SUBCR_CATDEL); |
|
401 | } |
|
402 | break; |
|
403 | case 'del_invalid_ml': |
|
404 | if (true === Request::getBool('ok', false, 'POST')) { |
|
405 | $use_mailinglist = $GLOBALS['xoopsModuleConfig']['xn_use_mailinglist']; |