Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ deployment/**/*
!deployment/overrides/course-creator/
!deployment/overrides/course-creator/config/
!deployment/overrides/course-creator/config/config.ini
!deployment/**/README.md
!deployment/config/
!deployment/config/README.md
!deployment/mail_overrides/
!deployment/mail_overrides/README.md
!deployment/templates_overrides/
!deployment/templates_overrides/README.md

.phpunit.result.cache

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Admin Features:
- Automatic updating of LDAP to reflect current state of users, groups, organizations, PI groups
- Cluster notices
- Added to front page, mailed, and exposed via REST API
- WYSIWYG HTML editor ([ckeditor5](https://github.com/ckeditor/ckeditor5)) for webpage contents, cluster notices
- Created with a WYSIWYG HTML editor ([ckeditor5](https://github.com/ckeditor/ckeditor5))
- Responsive Tables ([datatables.net](https://datatables.net)) for filtering, sorting, pagination, etc.
- Branding customization for multiple domains simultaneously
- Custom UIDNumber / GIDNumber mappings for specific users
Expand Down Expand Up @@ -131,6 +131,9 @@ rm "$prod" && ln -s "$old" "$prod"

- the `update-qualified-users-group.php` worker should be executed
- this may remove a large number of users from your qualified users group
- the `pages` SQL table should be droppped
- the `home` page can be copied over to `deployment/templates_overrides/home.php`
- the `support` page should be moved over to wherever you host your documentation

### 1.5 -> 1.6

Expand Down
2 changes: 1 addition & 1 deletion deployment/mail_overrides/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Mail Overrides

In this location, you can copy any file in the resources/mail folder into here and modify it. **The filename must remain the same**
In this location, you can copy any file in the `resources/mail` folder into here and modify it. **The filename must remain the same**
3 changes: 3 additions & 0 deletions deployment/templates_overrides/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Template Overrides

In this location, you can copy any file in the `resources/templates` folder into here and modify it. **The filename must remain the same**
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ parameters:
- messages:
- '#Variable \$(LDAP|SQL|MAILER|WEBHOOK|GITHUB|SSO|OPERATOR|USER|LOC_HEADER|LOC_FOOTER) might not be defined.#'
paths:
- webroot/*
- *
3 changes: 0 additions & 3 deletions resources/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,3 @@

$USER->updateIsQualified(); // in case manual changes have been made to PI groups
}

$LOC_HEADER = __DIR__ . "/templates/header.php";
$LOC_FOOTER = __DIR__ . "/templates/footer.php";
16 changes: 8 additions & 8 deletions resources/lib/UnityMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/
class UnityMailer extends PHPMailer
{
private string $template_dir = __DIR__ . "/../mail"; // location of all email templates
private string $override_template_dir = __DIR__ . "/../../deployment/mail_overrides";
private string $content_dir = __DIR__ . "/../mail"; // location of all email templates
private string $override_dir = __DIR__ . "/../../deployment/mail";

private string $MSG_SENDER_EMAIL;
private string $MSG_SENDER_NAME;
Expand Down Expand Up @@ -83,16 +83,16 @@ public function sendMail(string|array $recipients, ?string $template = null, mix
$this->addReplyTo($this->MSG_SUPPORT_EMAIL, $this->MSG_SUPPORT_NAME);

$template_filename = $template . ".php";
if (file_exists($this->override_template_dir . "/" . $template_filename)) {
$template_path = $this->override_template_dir . "/" . $template_filename;
if (file_exists($this->override_dir . "/" . $template_filename)) {
$template_path = $this->override_dir . "/" . $template_filename;
} else {
$template_path = $this->template_dir . "/" . $template_filename;
$template_path = $this->content_dir . "/" . $template_filename;
}

if (file_exists($this->override_template_dir . "/footer.php")) {
$footer_template_path = $this->override_template_dir . "/footer.php";
if (file_exists($this->override_dir . "/footer.php")) {
$footer_template_path = $this->override_dir . "/footer.php";
} else {
$footer_template_path = $this->template_dir . "/footer.php";
$footer_template_path = $this->content_dir . "/footer.php";
}

ob_start();
Expand Down
27 changes: 0 additions & 27 deletions resources/lib/UnitySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class UnitySQL
{
private const string TABLE_REQS = "requests";
private const string TABLE_NOTICES = "notices";
private const string TABLE_PAGES = "pages";
private const string TABLE_AUDIT_LOG = "audit_log";
private const string TABLE_ACCOUNT_DELETION_REQUESTS = "account_deletion_requests";
// FIXME this string should be changed to something more intuitive, requires production change
Expand Down Expand Up @@ -182,32 +181,6 @@ public function getNotices(): array
return $stmt->fetchAll();
}

public function getPages(): array
{
$stmt = $this->conn->prepare("SELECT * FROM " . self::TABLE_PAGES);
$stmt->execute();
return $stmt->fetchAll();
}

public function getPage(string $id): array
{
$stmt = $this->conn->prepare("SELECT * FROM " . self::TABLE_PAGES . " WHERE page=:id");
$stmt->bindParam(":id", $id);
$stmt->execute();
return $stmt->fetchAll()[0];
}

public function editPage(string $id, string $content): void
{
$stmt = $this->conn->prepare(
"UPDATE " . self::TABLE_PAGES . " SET content=:content WHERE page=:id",
);
$stmt->bindParam(":id", $id);
$stmt->bindParam(":content", $content);
$stmt->execute();
$this->addLog("edited_page", "");
}

public function addLog(string $action_type, string $recipient): void
{
$table = self::TABLE_AUDIT_LOG;
Expand Down
10 changes: 10 additions & 0 deletions resources/lib/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,13 @@ function shortenString(
$ellipsis .
substr($x, -1 * $trailing_chars, $trailing_chars);
}

function getTemplatePath(string $basename)
{
$template_path = __DIR__ . "/../templates/$basename";
$override_path = __DIR__ . "/../../deployment/templates_overrides/$basename";
if (file_exists($override_path)) {
return $override_path;
}
return $template_path;
}
2 changes: 0 additions & 2 deletions resources/templates/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@

if (isset($_SESSION["user_exists"]) && $_SESSION["user_exists"]) {
// Menu Items for Present Users
echo getHyperlink("Support", "panel/support.php") . "\n";
echo getHyperlink("Account Settings", "panel/account.php") . "\n";
echo getHyperlink("My PIs", "panel/groups.php") . "\n";

Expand All @@ -127,7 +126,6 @@
echo getHyperlink("User Management", "admin/user-mgmt.php") . "\n";
echo getHyperlink("PI Management", "admin/pi-mgmt.php") . "\n";
echo getHyperlink("Cluster Notices", "admin/notices.php") . "\n";
echo getHyperlink("Content Management", "admin/content.php") . "\n";
}
} else {
echo getHyperlink("Login / Request Account", "panel/account.php") . "\n";
Expand Down
28 changes: 28 additions & 0 deletions resources/templates/home.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<h1>Welcome</h1>
<p>
Welcome to the UnityHPC Platform Account Portal.
Here you can manage your SSH keys, join and leave PI groups, manage your own PI group, and more.
<?php
if (!($_SESSION["user_exists"] ?? false)) {
$hyperlink = getHyperlink("Log In", "panel/account.php");
echo "Please $hyperlink for more information.";
}
?>
</p>

<br>

<h2>Cluster Notices</h2>

<?php

$notices = $SQL->getNotices();
foreach ($notices as $notice) {
echo "<div class='notice'>";
echo "<span class='noticeTitle'>" . $notice["title"] . "</span>";
echo "<span class='noticeDate'>" . date('m-d-Y', strtotime($notice["date"])) . "</span>";
echo $notice["message"];
echo "</div>";
}

?>
2 changes: 0 additions & 2 deletions test/functional/PageLoadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ public static function providerMisc()
// normal page load
["Admin", "admin/pi-mgmt.php", "/PI Management/"],
["Admin", "admin/user-mgmt.php", "/User Management/"],
["Admin", "admin/content.php", "/Page Content Management/"],
["Admin", "admin/notices.php", "/Cluster Notice Management/"],
["NonExistent", "panel/new_account.php", "/Register New Account/"],
["Blank", "panel/account.php", "/Account Settings/"],
["Blank", "panel/groups.php", "/My Principal Investigators/"],
["Blank", "panel/support.php", "/Support/"],
["EmptyPIGroupOwner", "panel/pi.php", "/My Users/"],
// new_account.php should redirect to account.php if account already exists
["Blank", "panel/new_account.php", "/panel\/account\.php/", true],
Expand Down
32 changes: 0 additions & 32 deletions tools/docker-dev/sql/bootstrap.sql
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,6 @@ INSERT INTO `notices` (`id`, `date`, `title`, `message`) VALUES

-- --------------------------------------------------------

--
-- Table structure for table `pages`
--

CREATE TABLE `pages` (
`id` int(11) NOT NULL,
`page` varchar(300) NOT NULL,
`content` longtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `pages`
--

INSERT INTO `pages` (`id`, `page`, `content`) VALUES
(0,'home','<h1>Docmentation and FAQ</h1><p>You can find our documentation <a href=\"https://docs.unity.rc.umass.edu/\">here</a>. We also have an <a href=\"https://docs.unity.rc.umass.edu/documentation/help/faq/\">FAQ</a> page which could help answer quick questions.</p><h3>Office Hours</h3><p>We offer office hours every week on <strong>Tuesdays 2-4 PM</strong> in-person at <strong>W.E.B. DuBois Library 786</strong> or remote on <a href=\"https://github.com/\"><strong>Zoom</strong></a>. Be sure to check the <a href=\"/\">cluster notes</a> page for up-to-date information on any canceled/delayed office hours.</p><h3>Support Email</h3><p>You can create a support ticket by emailing <a href=\"mailto:hpc@umass.edu\">hpc@umass.edu</a>. We will do our best to reply as fast as possible!</p><p>&nbsp;</p>'),
(1,'support','<h1>Docmentation and FAQ</h1><p>You can find our documentation <a href=\"https://esdconfluence.it.umass.edu/confluence/display/UNITY/Unity+Cluster+Documentation+Home\">here</a>. We also have an <a href=\"https://esdconfluence.it.umass.edu/confluence/display/UNITY/Frequently+Asked+Questions\">FAQ</a> page which could help answer quick questions.</p><h3>Office Hours</h3><p>We offer office hours every week on <strong>Tuesdays 2-4 PM</strong> in-person at <strong>W.E.B. DuBois Library 786</strong> or remote on <a href=\"https://umass-amherst.zoom.us/j/95663998309\"><strong>Zoom</strong></a>. Be sure to check the <a href=\"&lt;?php echo $CONFIG[\">/index.php\"&gt;cluster notes</a> page for up-to-date information on any canceled/delayed office hours.</p><h3>Support Email</h3><p>You can create a support ticket by emailing <a href=\"mailto:hpc@umass.edu\">hpc@umass.edu</a>. We will do our best to reply as fast as possible!</p>');

-- --------------------------------------------------------

--
-- Table structure for table `requests`
--
Expand Down Expand Up @@ -151,12 +131,6 @@ ALTER TABLE `audit_log`
ALTER TABLE `notices`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `pages`
--
ALTER TABLE `pages`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `requests`
--
Expand Down Expand Up @@ -185,12 +159,6 @@ ALTER TABLE `audit_log`
ALTER TABLE `notices`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;

--
-- AUTO_INCREMENT for table `pages`
--
ALTER TABLE `pages`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `requests`
--
Expand Down
15 changes: 0 additions & 15 deletions webroot/admin/ajax/get_page_contents.php

This file was deleted.

73 changes: 0 additions & 73 deletions webroot/admin/content.php

This file was deleted.

4 changes: 2 additions & 2 deletions webroot/admin/notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
}

require $LOC_HEADER;
require getTemplatePath("header.php");
$CSRFTokenHiddenFormInput = UnityHTTPD::getCSRFTokenHiddenFormInput();
?>

Expand Down Expand Up @@ -146,4 +146,4 @@
});
</script>

<?php require $LOC_FOOTER; ?>
<?php require getTemplatePath("footer.php"); ?>
4 changes: 2 additions & 2 deletions webroot/admin/pi-mgmt.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
}

require $LOC_HEADER;
require getTemplatePath("header.php");
$CSRFTokenHiddenFormInput = UnityHTTPD::getCSRFTokenHiddenFormInput();
?>

Expand Down Expand Up @@ -194,4 +194,4 @@
content: "";
}
</style>
<?php require $LOC_FOOTER; ?>
<?php require getTemplatePath("footer.php"); ?>
4 changes: 2 additions & 2 deletions webroot/admin/user-mgmt.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
}

require $LOC_HEADER;
require getTemplatePath("header.php");
$CSRFTokenHiddenFormInput = UnityHTTPD::getCSRFTokenHiddenFormInput();
?>

Expand Down Expand Up @@ -104,4 +104,4 @@ class="stripe compact hover"
});
});
</script>
<?php require $LOC_FOOTER; ?>
<?php require getTemplatePath("footer.php"); ?>
Loading