Infra 1869 - minor tweaks to webmaster view Change-Id: I7f99c701b3224152bc5ed19360f26c62cf9cb7f0 Signed-off-by: Eric Poirier <eric@eclipse.org>
diff --git a/eclipse.org-common/classes/webmaster/firewall.class.php b/eclipse.org-common/classes/webmaster/firewall.class.php index 47eaecd..6b80c9d 100644 --- a/eclipse.org-common/classes/webmaster/firewall.class.php +++ b/eclipse.org-common/classes/webmaster/firewall.class.php
@@ -244,9 +244,6 @@ $search_results[] = $row; } } - if (empty($search_results)) { - $search_results[0]['no_results'] = "No results were found."; - } $this->search_results = $search_results; return $search_results;
diff --git a/eclipse.org-common/classes/webmaster/mailinglists.class.php b/eclipse.org-common/classes/webmaster/mailinglists.class.php index b794bcb..812e163 100644 --- a/eclipse.org-common/classes/webmaster/mailinglists.class.php +++ b/eclipse.org-common/classes/webmaster/mailinglists.class.php
@@ -24,6 +24,8 @@ private $search_results = NULL; + private $date_range = "5"; + public function __construct(App $App){ parent::__construct($App); if ($this->getFormName() === 'webmaster-mailinglists') { @@ -37,10 +39,20 @@ case 'search': $this->getSearchResults(); break; + case 'date-range': + $this->_setDateRange(); + break; } } } + private function _setDateRange() { + $range = filter_var($this->App->getHTTPParameter('date-range', 'POST'), FILTER_SANITIZE_STRING); + if (!empty($range)) { + $this->date_range = $range; + } + } + /** * This function returns the word selected wheter or not * an option is selected. @@ -62,7 +74,7 @@ */ public function getNewsgroups() { if (is_null($this->newsgroups)) { - $this->_fetchMailingListsOrNewsgroups('newsgroups'); + $this->_fetchMailingListsOrNewsgroups('newsgroups', $this->date_range); } return $this->newsgroups; } @@ -88,7 +100,7 @@ */ public function getMailingLists(){ if (is_null($this->mailing_lists)) { - $this->_fetchMailingListsOrNewsgroups('mailing_lists'); + $this->_fetchMailingListsOrNewsgroups('mailing_lists', $this->date_range); } return $this->mailing_lists; } @@ -238,19 +250,19 @@ * This function fetches mailing lists of newsgroups * * @param $table - This is the table name - * @param $provision_status - NULL, pending or completed - * @param $limit - Number of item to fetch + * @param $date - Number of days to limit the query * * @return array * */ - private function _fetchMailingListsOrNewsgroups($table) { + private function _fetchMailingListsOrNewsgroups($table, $range) { $lists = array(); if ($this->_isValidTable($table)) { $name = $this->getTableTitleName($table); $sql = "SELECT ". $this->App->sqlSanitize($name) ." as name, create_date, project_id, provision_status FROM " . $this->App->sqlSanitize($table) . " - WHERE is_deleted = 0"; - $sql .= " ORDER BY create_date DESC LIMIT 2000"; + WHERE is_deleted = 0 + AND create_date BETWEEN NOW() - INTERVAL ". $this->App->sqlSanitize($range) ." DAY AND NOW() + ORDER BY create_date DESC LIMIT 2000"; $result = $this->App->eclipse_sql($sql); while ($row = mysql_fetch_array($result)) {
diff --git a/eclipse.org-common/classes/webmaster/mirrors.class.php b/eclipse.org-common/classes/webmaster/mirrors.class.php index 63beb50..5afe06f 100644 --- a/eclipse.org-common/classes/webmaster/mirrors.class.php +++ b/eclipse.org-common/classes/webmaster/mirrors.class.php
@@ -51,10 +51,8 @@ public function getMirrorStatuses() { return array( 'approve', - 'wait', 'active', 'dropped', - 'NULL', ); } @@ -76,7 +74,8 @@ FROM mirrors as m LEFT JOIN mirror_protocols as mp ON m.mirror_id = mp.mirror_id"; - $sql .= ' ORDER BY FIELD(m.create_status, NULL, "", "approve", "wait", "active", "dropped") ASC'; + $sql .= ' WHERE m.create_status IN ("approve", "active", "dropped") + ORDER BY FIELD(m.create_status, "approve", "active", "dropped") ASC'; $result = $this->App->eclipse_sql($sql); $mirrors = array(); @@ -85,9 +84,6 @@ if ($row['is_internal'] === "1") { $row['is_internal'] = 'yes'; } - if ($row['create_status'] === NULL) { - $create_status = 'NULL'; - } $row['row_context'] = "default"; switch ($row['create_status']) { case 'active': @@ -96,15 +92,9 @@ case 'approve': $row['row_context'] = "warning"; break; - case 'wait': - $row['row_context'] = "info"; - break; case 'dropped': $row['row_context'] = "danger"; break; - case NULL: - $row['create_status'] = 'NULL'; - break; } $mirrors[$row['create_status']][] = $row; } @@ -117,41 +107,43 @@ * */ private function _updateMirrors() { - $ids = array(); $mirror_status = filter_var($this->App->getHTTPParameter('status', 'POST'), FILTER_SANITIZE_STRING); - $mirrors = $this->getMirrors($mirror_status); - foreach ($mirrors as $mirror) { - $status = filter_var($this->App->getHTTPParameter('status_update_' . $mirror['mirror_id'], 'POST'), FILTER_SANITIZE_STRING); - if ($status != $mirror['create_status']) { - $ids[] = array( - 'mirror_id' => $mirror['mirror_id'], - 'create_status' => $status - ); - } - } - - if (!empty($ids[0]['mirror_id']) && !empty($ids[0]['create_status'])) { - $sql = "UPDATE mirrors SET create_status = CASE "; - $in = array(); - foreach ($ids as $id) { - $create_status = $this->App->returnQuotedString($this->App->sqlSanitize($id['create_status'])); - if ($id['create_status'] === 'NULL') { - $create_status = 'NULL'; + if (in_array($mirror_status, $this->getMirrorStatuses())) { + $mirrors = $this->getMirrors($mirror_status); + $ids = array(); + foreach ($mirrors as $mirror) { + $status = filter_var($this->App->getHTTPParameter('status_update_' . $mirror['mirror_id'], 'POST'), FILTER_SANITIZE_STRING); + if ($status != $mirror['create_status']) { + $ids[] = array( + 'mirror_id' => $mirror['mirror_id'], + 'create_status' => $status + ); } - $mirror_id = $this->App->returnQuotedString($this->App->sqlSanitize($id['mirror_id'])); - $sql .= " WHEN mirror_id = " . $mirror_id . " THEN " . $create_status; - $in[] = $mirror_id; } - $in = implode(', ', $in); - $sql .= " END WHERE mirror_id in (" . $in . ")"; - $result = $this->App->eclipse_sql($sql); - $this->_fetchMirrors(); - $this->App->setSystemMessage('mirror_updated', 'You have successfully updated ' . count($ids) .' mirror(s).', 'success'); + if (!empty($ids[0]['mirror_id']) && !empty($ids[0]['create_status'])) { + $sql = "UPDATE mirrors SET create_status = CASE "; + $in = array(); + foreach ($ids as $id) { + $create_status = $this->App->returnQuotedString($this->App->sqlSanitize($id['create_status'])); + $mirror_id = $this->App->returnQuotedString($this->App->sqlSanitize($id['mirror_id'])); + $sql .= " WHEN mirror_id = " . $mirror_id . " THEN " . $create_status; + $in[] = $mirror_id; + } + $in = implode(', ', $in); + $sql .= " END WHERE mirror_id in (" . $in . ")"; + + $result = $this->App->eclipse_sql($sql); + $this->_fetchMirrors(); + $this->App->setSystemMessage('mirror_updated', 'You have successfully updated ' . count($ids) .' mirror(s).', 'success'); + } + else { + $this->App->setSystemMessage('mirror_updated', "The mirrors could not be updated.(#webmaster-mirrors-001)", 'danger'); + } } else { - $this->App->setSystemMessage('mirror_updated', "The mirrors could not be updated.(#webmaster-mirrors-001)", 'danger'); + $this->App->setSystemMessage('mirror_updated', "The mirror status is not valid.(#webmaster-mirrors-002)", 'danger'); } } } \ No newline at end of file
diff --git a/eclipse.org-common/classes/webmaster/tpl/firewall.tpl.php b/eclipse.org-common/classes/webmaster/tpl/firewall.tpl.php index c5dd4e1..11bce27 100644 --- a/eclipse.org-common/classes/webmaster/tpl/firewall.tpl.php +++ b/eclipse.org-common/classes/webmaster/tpl/firewall.tpl.php
@@ -37,7 +37,7 @@ <div class="tab-content"> <div role="tabpanel" class="tab-pane active" id="firewall-recent-block"> <p><strong>Show last:</strong></p> - <form action="<?php print $this->getFormActionUrl();?>" method="POST"> + <form action="<?php print $this->getFormActionUrl();?>#firewall-recent-block" method="POST"> <input type="hidden" name="form_name" value="webmaster-firewall"> <div class="form-group"> @@ -103,7 +103,7 @@ </div> <div role="tabpanel" class="tab-pane" id="firewall-insert-block"> - <form class="form-horizontal" method="POST" action="<?php print $this->getFormActionUrl();?>"> + <form class="form-horizontal" method="POST" action="<?php print $this->getFormActionUrl();?>#firewall-insert-block"> <input type="hidden" name="form_name" value="webmaster-firewall"> <div class="form-group"> <label for="inputEmail3" class="col-sm-2 control-label">IP:<span class="required">*</span></label>
diff --git a/eclipse.org-common/classes/webmaster/tpl/mailinglists/mailinglists-new.tpl.php b/eclipse.org-common/classes/webmaster/tpl/mailinglists/mailinglists-new.tpl.php index 43a377a..f451138 100644 --- a/eclipse.org-common/classes/webmaster/tpl/mailinglists/mailinglists-new.tpl.php +++ b/eclipse.org-common/classes/webmaster/tpl/mailinglists/mailinglists-new.tpl.php
@@ -24,5 +24,36 @@ unset($newsgroups['completed']); } -print $this->getMailingListTable($mailing_lists, 'mailing_lists'); -print $this->getMailingListTable($newsgroups, 'newsgroups'); +?> +<p>Choose a date range:</p> +<form method="GET" action="<?php print $this->getFormActionUrl();?>#mailinglists-new"> + <div class="form-group"> + <label class="radio-inline"> + <input type="radio" name="date-range" value="5"> 5 days + </label> + <label class="radio-inline"> + <input type="radio" name="date-range" value="7"> 7 days + </label> + <label class="radio-inline"> + <input type="radio" name="date-range" value="14"> 14 days + </label> + </div> + <div class="form-group"> + <input type="hidden" name="form_name" value="webmaster-mailinglists"> + <input type="hidden" name="state" value="date-range"> + <input type="submit" class="btn btn-primary"> + </div> +</form> +<?php + if (empty($mailing_lists)) { + print '0 mailinglists have been found.<br>'; + } + else { + print $this->getMailingListTable($mailing_lists, 'mailing_lists'); + } + if (empty($newsgroups)) { + print '0 newsgroups have been found.<br>'; + } + else { + print $this->getMailingListTable($newsgroups, 'newsgroups'); + }
diff --git a/eclipse.org-common/classes/webmaster/webmaster.class.php b/eclipse.org-common/classes/webmaster/webmaster.class.php index dfaac02..a3d26a5 100644 --- a/eclipse.org-common/classes/webmaster/webmaster.class.php +++ b/eclipse.org-common/classes/webmaster/webmaster.class.php
@@ -66,6 +66,9 @@ 'ProjectID' => $row['ProjectID'] ); } + // Add Foundation as first item of the array + array_unshift($projects, array('ProjectID' => 'Foundation')); + $this->projects = $projects; return $projects; }