fix_lp_calendar.php 973 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require __DIR__ . '/../../main/inc/global.inc.php';
  4. $extraField = new ExtraField('lp_item');
  5. $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable('calendar');
  6. if (empty($extraFieldInfo)) {
  7. echo 'No calendar extra field';
  8. exit;
  9. }
  10. $extraFieldId = $extraFieldInfo['id'];
  11. $sql = 'select iid from c_lp_item where title like "%(+)%"';
  12. $result = Database::query($sql);
  13. while ($row = Database::fetch_array($result)) {
  14. $lpItemId = $row['iid'];
  15. $extraField = new ExtraFieldValue('lp_item');
  16. $values = $extraField->get_values_by_handler_and_field_variable($lpItemId, 'calendar');
  17. if (empty($values)) {
  18. $value = 1;
  19. $params = [
  20. 'field_id' => $extraFieldId,
  21. 'value' => $value,
  22. 'item_id' => $lpItemId,
  23. ];
  24. //var_dump($params);
  25. echo 'LP item id added: '.$lpItemId.PHP_EOL;
  26. $extraField->save($params);
  27. }
  28. }
  29. exit;