php js css php js css

Changes

Changes to Script: Keep prepared examples ready for live feature screenshots

246132
Today 4:33am
McNaught, Scott
Modified script
246133
Today 4:33am
McNaught, Scott
Modified script
Can't Undo: This is the current version
Last Run:
Id:
h0v2dFt30K8R51A2
h0v2dFt30K8R51A2
Title:
Keep prepared examples ready for live feature screenshots
Keep prepared examples ready for live feature screenshots
Code:
<?php
$disabledBefore = \Components\Marketing\Automation\Progress::getDisabledIds();
\Components\Marketing\Automation\Progress::setDisabledIds(array_column(\Components\Marketing\Automation::getAll(), 'automation_id'));
try {
foreach ([3 => '2026-11-10 23:00:00', 4 => '2026-11-10 23:00:00', 5 => '2026-11-18 23:00:00'] as $examId => $registrationEnd) {
\Components\AF\Exams::save(['exam_id' => $examId, 'exam_registration_start_datetime' => date('Y-m-d H:i:s', strtotime('2026-10-01 00:00:00')), 'exam_registration_end_datetime' => date('Y-m-d H:i:s', strtotime($registrationEnd))]);
}
$categoryId = \Components\AF\Memberships\Products::getProductCategoryId();
if (!$categoryId) throw new \RuntimeException('Membership product category is not configured.');
\Components\Commerce\Products\Categories::addProductToCategory(519, $categoryId);
\Components\AF\Memberships\Products::save(['product_id' => 519, 'membership_products_type' => 'Individual', 'membership_products_duration' => '1 year', 'membership_products_hidden_in_course_selector' => 0]);
\Components\AF\Courses\Assignments::save(['assignment_id' => 12, 'assignment_deadline' => date('Y-m-d H:i:s', strtotime('2026-10-16 23:00:00'))]);
$borrowingItems = \Components\AF\Libraries\Documents\Borrowings\Items::getAll(['filter' => ['borrowing_id', 'IN', [17, 18]]]);
foreach ($borrowingItems as $item) {
\Components\AF\Libraries\Documents\Borrowings\Items::save(['borrowing_item_id' => $item['borrowing_item_id'], 'borrowing_item_expected_return_datetime' => date('Y-m-d H:i:s', strtotime('2026-10-27 00:00:00'))]);
}
$out = [];
foreach ([3, 4, 5] as $id) {
$out['exam_' . $id . '_registration_end'] = \Components\AF\Exams::getColumn($id, 'exam_registration_end_datetime');
}
$out['membership_categories'] = \Components\Commerce\Products\Categories::getAllIdsForProduct(519);
$out['assignment_deadline'] = \Components\AF\Courses\Assignments::getColumn(12, 'assignment_deadline');
$out['borrowing_items'] = \Components\AF\Libraries\Documents\Borrowings\Items::getAll(['filter' => ['borrowing_id', 'IN', [17, 18]]]);
$out['membership_card_html_ready'] = (bool) \Components\AF\Memberships::generateMembershipCardHTML(1394);
echo json_encode($out, JSON_PRETTY_PRINT);
} finally {
\Components\Marketing\Automation\Progress::setDisabledIds($disabledBefore);
}
<?php
$disabledBefore = \Components\Marketing\Automation\Progress::getDisabledIds();
\Components\Marketing\Automation\Progress::setDisabledIds(array_column(\Components\Marketing\Automation::getAll(), 'automation_id'));
try {
foreach ([3 => '2026-11-10 23:00:00', 4 => '2026-11-10 23:00:00', 5 => '2026-11-18 23:00:00'] as $examId => $registrationEnd) {
\Components\AF\Exams::save(['exam_id' => $examId, 'exam_registration_start_datetime' => date('Y-m-d H:i:s', strtotime('2026-10-01 00:00:00')), 'exam_registration_end_datetime' => date('Y-m-d H:i:s', strtotime($registrationEnd))]);
}
$categoryId = \Components\AF\Memberships\Products::getProductCategoryId();
if (!$categoryId) throw new \RuntimeException('Membership product category is not configured.');
\Components\Commerce\Products\Categories::addProductToCategory(519, $categoryId);
\Components\AF\Memberships\Products::save(['product_id' => 519, 'membership_products_type' => 'Individual', 'membership_products_duration' => '1 year', 'membership_products_hidden_in_course_selector' => 0]);
\Components\AF\Courses\Assignments::save(['assignment_id' => 12, 'assignment_deadline' => date('Y-m-d H:i:s', strtotime('2026-10-16 23:00:00'))]);
$borrowingItems = \Components\AF\Libraries\Documents\Borrowings\Items::getAll(['filter' => ['borrowing_id', 'IN', [17, 18]]]);
foreach ($borrowingItems as $item) {
\Components\AF\Libraries\Documents\Borrowings\Items::save(['borrowing_item_id' => $item['borrowing_item_id'], 'borrowing_item_expected_return_datetime' => date('Y-m-d H:i:s', strtotime('2026-10-27 00:00:00'))]);
}
$out = [];
foreach ([3, 4, 5] as $id) {
$out['exam_' . $id . '_registration_end'] = \Components\AF\Exams::getColumn($id, 'exam_registration_end_datetime');
}
$out['membership_categories'] = \Components\Commerce\Products\Categories::getAllIdsForProduct(519);
$out['assignment_deadline'] = \Components\AF\Courses\Assignments::getColumn(12, 'assignment_deadline');
$out['borrowing_items'] = \Components\AF\Libraries\Documents\Borrowings\Items::getAll(['filter' => ['borrowing_id', 'IN', [17, 18]]]);
$out['membership_card_html_ready'] = (bool) \Components\AF\Memberships::generateMembershipCardHTML(1394);
echo json_encode($out, JSON_PRETTY_PRINT);
} finally {
\Components\Marketing\Automation\Progress::setDisabledIds($disabledBefore);
}
Created:
2026-10-08 01:30:34
2026-10-08 01:30:34
Is Ai Generated:
Is Readonly:
0
0
Summary:
Here's what this will do, in everyday terms:

**1. Pause all automated marketing messages**
It temporarily switches off every automated marketing message in the system (all of them), so nothing gets sent out while the changes below are being made. Once everything is done, it switches them back on again exactly as they were.

**2. Change the sign-up dates for three exams**
- Exam 3: sign-up opens 1 October 2026 and closes 10 November 2026 at 11pm
- Exam 4: sign-up opens 1 October 2026 and closes 10 November 2026 at 11pm
- Exam 5: sign-up opens 1 October 2026 and closes 18 November 2026 at 11pm

**3. Add a membership product to the shop's membership section**
Product number 519 gets added to the group of products used for memberships. It's then set up as an individual membership lasting one year, and it will be shown in the course selector (the "hide it" option is turned off).

**4. Move a course deadline**
Assignment number 12 gets a new deadline: 16 October 2026 at 11pm.

**5. Push back the return dates for borrowed items**
Every item listed under borrowing records 17 and 18 gets a new expected return date: 27 October 2026. This affects all items in those two borrowing records.

**6. Check that everything worked**
After making the changes, it looks up the new exam dates, the membership's category, the assignment deadline, and the borrowed items to confirm they were saved. It also creates the membership card for member number 1394 to make sure that can be generated.

Finally, it prints a summary of all these checks on screen so you can see the results.
Here's what this will do, in everyday terms:

**1. Pause all automated marketing messages**
It temporarily switches off every automated marketing message in the system (all of them), so nothing gets sent out while the changes below are being made. Once everything is done, it switches them back on again exactly as they were.

**2. Change the sign-up dates for three exams**
- Exam 3: sign-up opens 1 October 2026 and closes 10 November 2026 at 11pm
- Exam 4: sign-up opens 1 October 2026 and closes 10 November 2026 at 11pm
- Exam 5: sign-up opens 1 October 2026 and closes 18 November 2026 at 11pm

**3. Add a membership product to the shop's membership section**
Product number 519 gets added to the group of products used for memberships. It's then set up as an individual membership lasting one year, and it will be shown in the course selector (the "hide it" option is turned off).

**4. Move a course deadline**
Assignment number 12 gets a new deadline: 16 October 2026 at 11pm.

**5. Push back the return dates for borrowed items**
Every item listed under borrowing records 17 and 18 gets a new expected return date: 27 October 2026. This affects all items in those two borrowing records.

**6. Check that everything worked**
After making the changes, it looks up the new exam dates, the membership's category, the assignment deadline, and the borrowed items to confirm they were saved. It also creates the membership card for member number 1394 to make sure that can be generated.

Finally, it prints a summary of all these checks on screen so you can see the results.
Modified:
2026-10-08 01:30:37
2026-10-08 01:30:37
Contact Id:
-2
-2