Skip to content

Commit a30be97

Browse files
committed
2.0.8; closes #23, #22
1 parent 1a26b7b commit a30be97

File tree

6 files changed

+26
-15
lines changed

6 files changed

+26
-15
lines changed

code/FormGenerator.class.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,9 @@ public static function maybeTakeScheduledFormOffline($config)
604604
$db = Core::$db;
605605
$just_taken_offline = false;
606606

607-
// first, check the form shouldn't be taken offline right now
608-
if ($config["is_online"] == "yes" && $config["offline_date"] != "0000-00-00 00:00:00") {
607+
608+
// take the form offline if it passed the offline date
609+
if ($config["is_online"] == "yes" && !is_null($config["offline_date"])) {
609610
$default_timezone_offset = Settings::get("default_timezone_offset");
610611

611612
$now = date("U");
@@ -619,7 +620,7 @@ public static function maybeTakeScheduledFormOffline($config)
619620
$db->query("
620621
UPDATE {PREFIX}module_form_builder_forms
621622
SET is_online = 'no',
622-
offline_date = '0000-00-00 00:00:00'
623+
offline_date = NULL
623624
WHERE published_form_id = :published_form_id
624625
");
625626
$db->bind("published_form_id", $published_form_id);

code/Forms.class.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -714,16 +714,18 @@ public static function saveBuilderSettings($info)
714714
}
715715

716716
try {
717+
717718
if (empty($published_form_id)) {
718719
$list_order = self::getNextPublishedFormOrder($info["form_id"]);
719720

720721
$db->query("
721722
INSERT INTO {PREFIX}module_form_builder_forms (is_online, is_published, form_id, view_id,
722723
set_id, filename, folder_path, folder_url, include_review_page, include_thanks_page_in_nav,
723-
thankyou_page_content, form_offline_page_content, review_page_title, thankyou_page_title, list_order)
724+
thankyou_page_content, form_offline_page_content, review_page_title, thankyou_page_title, list_order,
725+
offline_date)
724726
VALUES (:is_online, :is_published, :form_id, :view_id, :set_id, :filename, :folder_path, :folder_url,
725727
:include_review_page, :include_thanks_page_in_nav, :thankyou_page_content, :form_offline_page_content,
726-
:review_page_title, :thankyou_page_title, :list_order)
728+
:review_page_title, :thankyou_page_title, :list_order, :offline_date)
727729
");
728730
$db->bindAll(array(
729731
"is_online" => $is_online,
@@ -740,7 +742,8 @@ public static function saveBuilderSettings($info)
740742
"form_offline_page_content" => $info["form_offline_page_content"],
741743
"review_page_title" => $info["review_page_title"],
742744
"thankyou_page_title" => $info["thankyou_page_title"],
743-
"list_order" => $list_order
745+
"list_order" => $list_order,
746+
"offline_date" => $offline_date
744747
));
745748
$db->execute();
746749
$published_form_id = $db->getInsertId();

code/Module.class.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class Module extends CoreModule
1818
protected $author = "Ben Keen";
1919
protected $authorEmail = "[email protected]";
2020
protected $authorLink = "https://formtools.org";
21-
protected $version = "2.0.7";
22-
protected $date = "2018-05-13";
21+
protected $version = "2.0.8";
22+
protected $date = "2018-05-18";
2323
protected $originLanguage = "en_us";
2424

2525
// important! This needs to be updated any time the default template set filename changes
@@ -215,7 +215,7 @@ public function upgrade($module_id, $old_module_version)
215215
{
216216
$this->resetHooks();
217217

218-
if ($this->version === "3.0.6") {
218+
if ($this->version === "2.0.8") {
219219
$this->updateOfflineDateFieldAllowNulls();
220220
}
221221
}
@@ -410,7 +410,7 @@ public function displayPublishTab($location, $vars)
410410
// loop through each published form and take any offline that need it
411411
$at_least_one_form_just_taken_offline = false; // yes, this variable name ROCKS!!!!!
412412
foreach ($published_forms["results"] as $config) {
413-
if ($config["is_online"] == "yes" && $config["offline_date"] != "0000-00-00 00:00:00") {
413+
if ($config["is_online"] == "yes" && !is_null($config["offline_date"])) {
414414
$taken_offline = FormGenerator::maybeTakeScheduledFormOffline($config);
415415
if ($taken_offline) {
416416
$at_least_one_form_just_taken_offline = true;
@@ -576,5 +576,12 @@ private function updateOfflineDateFieldAllowNulls()
576576
$db = Core::$db;
577577
$db->query("ALTER TABLE {PREFIX}module_form_builder_forms CHANGE offline_date offline_date DATETIME NULL");
578578
$db->execute();
579+
580+
$db->query("
581+
UPDATE {PREFIX}module_form_builder_forms
582+
SET offline_date = NULL
583+
WHERE offline_date = '0000-00-00 00:00:00'
584+
");
585+
$db->execute();
579586
}
580587
}

css/edit_form.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828
.form_builder_form_list .header_row .col6 {
2929
width: 182px;
30-
padding-left: 0px;
30+
padding-left: 0;
3131
}
3232
.form_builder_form_list .col6 {
3333
width: 180px;
@@ -43,11 +43,11 @@ div.published_form_url {
4343
white-space:nowrap;
4444
}
4545
.publish_tab_offline_date {
46-
background: transparent url(../../../../global/images/clock.png) center center no-repeat;
46+
background: transparent url(../../../global/images/clock.png) center center no-repeat;
4747
width: 16px;
4848
height: 20px;
4949
margin-left: 3px;
5050
display:inline-block;
5151
text-indent: -9999px;
5252
cursor: pointer;
53-
}
53+
}

preview.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
$published_folder_url = $config_info["folder_url"];
5858
$published_folder_path = $config_info["folder_path"];
5959

60-
if ($config_info["offline_date"] != "0000-00-00 00:00:00") {
60+
if (!is_null($config_info["offline_date"])) {
6161
// convert the datetime to a friendlier format
6262
list($date, $time) = explode(" ", $config_info["offline_date"]);
6363
list($year, $month, $day) = explode("-", $date);

templates/admin/tab_publish.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<span class="light_grey">&#8212;</span>
7979
{elseif $info.is_online == "yes"}
8080
<span class="green">{$LANG.word_yes}</span>
81-
{if $info.offline_date != "0000-00-00 00:00:00"}
81+
{if !is_null($info.offline_date)}
8282
{assign var=d value=$info.offline_date|replace:':':''}
8383
{assign var=d value=$d|replace:' ':''}
8484
{assign var=d value=$d|replace:'-':''}

0 commit comments

Comments
 (0)