sync eclipse.org-common
Signed-off-by: Christopher Guindon <chris.guindon@eclipse.org>
diff --git a/eclipse.org-common/classes/friends/friend.class.php b/eclipse.org-common/classes/friends/friend.class.php
index 4fb1d0d..c5eab94 100755
--- a/eclipse.org-common/classes/friends/friend.class.php
+++ b/eclipse.org-common/classes/friends/friend.class.php
@@ -313,8 +313,10 @@
$this->setIsBenefit ($myrow["is_benefit"]);
$this->setLDAPUID ($myrow["uid"]);
$this->setBenefitExpires($myrow["date_expired"]);
+ return TRUE;
}
}
+ return FALSE;
}
function selectFriendID($_fieldname, $_searchfor) {
diff --git a/eclipse.org-common/classes/rest/committerpaperwork.class.php b/eclipse.org-common/classes/rest/committerpaperwork.class.php
index 86b4533..6d02db5 100644
--- a/eclipse.org-common/classes/rest/committerpaperwork.class.php
+++ b/eclipse.org-common/classes/rest/committerpaperwork.class.php
@@ -42,49 +42,7 @@
* @param array $data
*/
public function createCommitterPaperwork($username = NULL, $data = array()) {
- // Make sure the user is logged in.
- if (!$this->loginSSO()) {
- return $this->_errorNotLoggedIn();
- }
-
- // Validate username.
- $username = filter_var($username, FILTER_SANITIZE_STRING);
- if (empty($username) || !is_string($username)) {
- return $this->_errorBadRequest('username');
- }
-
- // As of PHP 5.4.11, the numbers +0 and -0 validate as both integers
- // as well as floats (using FILTER_VALIDATE_FLOAT and FILTER_VALIDATE_INT).
- // Before PHP 5.4.11 they only validated as floats (using
- // FILTER_VALIDATE_FLOAT).
- $required_field = array(
- 'project_url' => FILTER_VALIDATE_URL,
- 'election_url' => FILTER_VALIDATE_URL,
- 'forge' => FILTER_SANITIZE_STRING,
- 'project_id' => FILTER_SANITIZE_STRING,
- 'election_status' => FILTER_VALIDATE_FLOAT
- );
-
- foreach ($data as $field_name => $field_value) {
- // Unknown field.
- if (!isset($required_field[$field_name])) {
- return $this->_errorBadRequest($field_name, 'unknown');
- }
- }
-
- foreach ($required_field as $field_name => $validator) {
- if (!isset($data[$field_name])) {
- // Missing field.
- return $this->_errorBadRequest($field_name);
- }
-
- // Validate field.
- if (filter_var($data[$field_name], $validator) === FALSE) {
- return $this->_errorBadRequest($field_name, 'validation failed');
- }
- }
-
- return $this->post('committer_paperwork/' . $username, json_encode($data));
+ return $this->post('committer/paperwork/' . $username, json_encode($data));
}
/**
@@ -94,30 +52,7 @@
* @param unknown $id
*/
public function deleteCommitterPaperwork($username = "", $id = "", $etag = "") {
- // Make sure the user is logged in.
- if (!$this->loginSSO()) {
- return $this->_errorNotLoggedIn();
- }
-
- // Validate username.
- $username = filter_var($username, FILTER_SANITIZE_STRING);
- if (empty($username) || !is_string($username)) {
- return $this->_errorBadRequest('username');
- }
-
- // Validate id.
- $id = filter_var($id, FILTER_SANITIZE_NUMBER_INT);
- if (empty($id) && !is_int($id)) {
- return $this->_errorBadRequest('id');
- }
-
- if (!empty($etag)) {
- $this->setHeader(array(
- 'If-Match' => $etag
- ));
- }
-
- $response = $this->delete('committer_paperwork/' . $username . '/' . $id);
+ $response = $this->delete('committer/paperwork/' . $username . '/' . $id);
$this->unsetHeader('If-Match');
return $response;
}
@@ -129,23 +64,6 @@
* @param string $id
*/
public function retrieveCommitterPaperwork($username = "", $id = "", $etag = "") {
- // Make sure the user is logged in.
- if (!$this->loginSSO()) {
- return $this->_errorNotLoggedIn();
- }
-
- // Validate username.
- $username = filter_var($username, FILTER_SANITIZE_STRING);
- if (empty($username) || !is_string($username)) {
- return $this->_errorBadRequest('username');
- }
-
- // Validate id.
-
- $id = filter_var($id, FILTER_SANITIZE_NUMBER_INT);
- if (empty($id) && !is_int($id)) {
- return $this->_errorBadRequest('id');
- }
if (!empty($etag)) {
$this->setHeader(array(
@@ -153,7 +71,7 @@
));
}
- $response = $this->get('committer_paperwork/' . $username . '/' . $id);
+ $response = $this->get('committer/paperwork/' . $username . '/' . $id);
if (isset($response->code) && $response->code == 200) {
$data = json_decode($response->body);
$this->data[$data->id] = $data;
@@ -171,64 +89,12 @@
* @param string $etag
*/
public function updateCommitterPaperwork($username = NULL, $id = NULL, $data = array(), $etag = "") {
- if (!$this->loginSSO()) {
- return $this->_errorNotLoggedIn();
- }
- // Validate username.
- $username = filter_var($username, FILTER_SANITIZE_STRING);
- if (empty($username) || !is_string($username)) {
- return $this->_errorBadRequest('username');
- }
- // Validate id.
- $id = filter_var($id, FILTER_SANITIZE_NUMBER_INT);
- if (empty($id) && !is_int($id)) {
- return $this->_errorBadRequest('id');
- }
+ $this->setHeader(array(
+ 'If-Match' => '"' . $etag . '"',
+ ));
- // As of PHP 5.4.11, the numbers +0 and -0 validate as both integers
- // as well as floats (using FILTER_VALIDATE_FLOAT and FILTER_VALIDATE_INT).
- // Before PHP 5.4.11 they only validated as floats (using
- // FILTER_VALIDATE_FLOAT).
- $fields = array(
- 'project_url' => FILTER_VALIDATE_URL,
- 'election_url' => FILTER_VALIDATE_URL,
- 'forge' => FILTER_SANITIZE_STRING,
- 'project_id' => FILTER_SANITIZE_STRING,
- 'election_status' => FILTER_VALIDATE_FLOAT,
- 'committer_paperwork_url' => FILTER_VALIDATE_URL,
- 'committer_paperwork_status' => FILTER_VALIDATE_FLOAT
- );
-
- foreach ($fields as $field_name => $field_value) {
- // Unknown field.
- if (!isset($fields[$field_name])) {
- return $this->_errorBadRequest($field_name, 'unknown');
- }
- }
-
- foreach ($fields as $field_name => $validator) {
- // Validate field.
- if (isset($data[$field_name]) && filter_var($data[$field_name], $validator) === FALSE) {
- return $this->_errorBadRequest($field_name, 'validation failed');
- }
- }
-
- if (empty($this->data[$id]->etag) && empty($etag)) {
- return $this->_errorConflict();
- }
-
- if (empty($etag)) {
- $etag = $this->data[$id]->etag;
- }
-
- if (!empty($etag)) {
- $this->setHeader(array(
- 'If-Match' => $etag
- ));
- }
-
- $response = $this->put('committer_paperwork/' . $username . '/' . $id, json_encode($data));
+ $response = $this->put('committer/paperwork/' . $username . '/' . $id, json_encode($data));
$this->unsetHeader('If-Match');
return $response;
}
@@ -238,62 +104,174 @@
*
* @param unknown $username
* @param array $params
- * @param number $page
- * @param number $pagesize
+ *
+ * @return array
*/
- public function indexCommitterPaperwork($username = NULL, $params = array(), $page = 1, $pagesize = 20) {
- if (!$this->loginSSO()) {
- return $this->_errorNotLoggedIn();
- }
+ public function indexCommitterPaperwork($username = NULL, $params = array()) {
- $url = 'committer_paperwork';
- // Validate username.
- $username = filter_var($username, FILTER_SANITIZE_STRING);
- if (!empty($username) && !is_string($username)) {
- return $this->_errorBadRequest('username', 'invalid');
- }
- else {
+ $url = 'committer/paperwork';
+ if (!is_null($username) && is_string($username)) {
$url .= '/' . $username;
}
- $allowed_params = array(
- 'election_status' => FILTER_VALIDATE_INT,
- 'committer_paperwork_status' => FILTER_VALIDATE_INT
- );
-
- foreach ($params as $param => $validator) {
- if (!isset($allowed_params[$param])) {
- return $this->_errorBadRequest($param, 'invalid parameter');
- }
- }
-
- foreach ($allowed_params as $param => $validator) {
- if (!isset($params[$param])) {
- continue;
- }
- // Validate field.
- if (filter_var($params[$param], $validator) === FALSE) {
- return $this->_errorBadRequest($param, 'parameter validation failed');
- }
- }
-
- if (!is_int($page)) {
- return $this->_errorBadRequest('page', 'invalid');
- }
-
- if (!is_int($pagesize)) {
- return $this->_errorBadRequest('pagesize', 'invalid');
- }
-
- $query_array = array();
- $query_array['parameters'] = $params;
- $query_array['page'] = $page;
- $query_array['pagesize'] = $pagesize;
-
- $query = http_build_query($query_array);
-
+ $query = http_build_query($params);
$response = $this->get($url . '?' . $query);
return $response;
}
+ /**
+ * Fetch all Committer Paperwork index
+ *
+ * @param unknown $username
+ * @param array $params
+ *
+ * @return array
+ */
+ public function indexAllCommitterPaperwork($username = NULL, $params = array()) {
+
+ $data = $this->indexCommitterPaperwork($username, $params);
+
+ $return = array();
+ $return[] = $data;
+ if (!isset($data->error) && !empty($data->body) && $data) {
+ while ($data = $this->_getNextPage($data)) {
+ $return[] = $data;
+ }
+ }
+ return $return;
+ }
+
+ /**
+ * Validate a username
+ *
+ * @param string $username
+ *
+ * @return bool
+ */
+ function validateCommitterPaperworkUsername($username) {
+ if (empty($username) || !is_string($username)) {
+ return FALSE;
+ }
+
+ // Validate that the username is in LDAP
+ require_once("/home/data/httpd/eclipse-php-classes/system/ldapconnection.class.php");
+ $LDAPConnection = new LDAPConnection();
+ $dn = $LDAPConnection->getDNFromUID($username);
+
+ if (empty($dn)) {
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * Validate an id
+ *
+ * @param string $id
+ *
+ * @return bool
+ */
+ function validateCommitterPaperworkId($id) {
+ $id = filter_var($id, FILTER_VALIDATE_INT);
+ if (empty($id) && !is_int($id) && $id !== 0) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Validate an etag
+ *
+ * @param string $etag
+ *
+ * @return bool
+ */
+ function validateCommitterPaperworkEtag($etag) {
+ if (empty($etag) || !is_string($etag)) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Validate a page number
+ *
+ * @param int $page
+ *
+ * @return bool
+ */
+ function validateCommitterPaperworkPage($page) {
+ if (!is_int($page)) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Validate a pagesize
+ *
+ * @param string $pagesize
+ *
+ * @return bool
+ */
+ function validateCommitterPaperworkPagesize($pagesize) {
+ if (!is_int($pagesize) || $pagesize > 100) {
+ return FALSE;
+ }
+
+ return $pagesize;
+ }
+
+ /**
+ * Validate fields
+ *
+ * @param array $data
+ *
+ * @return bool
+ */
+ function validateCommitterPaperworkFields($data = array()) {
+
+ // If there are no parameters passed this is still valid
+ // but we can quit here
+ if (empty($data)) {
+ return TRUE;
+ }
+
+ $float_fields = array(
+ 'id',
+ 'election_nid',
+ 'election_status',
+ 'committer_paperwork_nid',
+ 'committer_paperwork_status'
+ );
+
+ $string_fields = array(
+ 'project_id',
+ 'forge',
+ );
+
+ foreach ($data['parameters'] as $data_field_name => $field_value) {
+ // Verify the the field name exist in the float and string fields
+ if (!in_array($data_field_name, $float_fields) && !in_array($data_field_name, $string_fields)) {
+ return FALSE;
+ }
+
+ foreach ($float_fields as $float_field_name) {
+ // If the default field name exist in the data array,
+ // Make sure it validates with the appropriate filter
+ if (isset($data[$float_field_name]) && filter_var($data[$float_field_name], FILTER_VALIDATE_FLOAT) === FALSE) {
+ return FALSE;
+ }
+ }
+
+ // Making sure we are dealing with strings
+ foreach ($string_fields as $string_field_name) {
+ if (isset($data[$string_field_name]) && !is_string($data[$string_field_name])) {
+ return FALSE;
+ }
+ }
+ }
+ return TRUE;
+ }
}
\ No newline at end of file
diff --git a/eclipse.org-common/classes/rest/lib/eclipseussblob.class.php b/eclipse.org-common/classes/rest/lib/eclipseussblob.class.php
index ef96d91..4586349 100644
--- a/eclipse.org-common/classes/rest/lib/eclipseussblob.class.php
+++ b/eclipse.org-common/classes/rest/lib/eclipseussblob.class.php
@@ -129,7 +129,6 @@
$url = 'uss/blob/' . $application_token . '?page=' . $page . '&pagesize=' . $pagesize;
$data = $this->get($url);
- $pages = $this->_getHeaderLink($data->headers['Link']);
$return = array();
$return[] = $data;
if (!isset($data->error) && !empty($data->body) && $data) {
diff --git a/eclipse.org-common/classes/rest/lib/restclient.class.php b/eclipse.org-common/classes/rest/lib/restclient.class.php
index a058fd0..1bd33ea 100644
--- a/eclipse.org-common/classes/rest/lib/restclient.class.php
+++ b/eclipse.org-common/classes/rest/lib/restclient.class.php
@@ -374,7 +374,7 @@
*
* @return Response $return
*/
- protected function _getNextPage($data) {
+ public function _getNextPage($data) {
if (!isset($data->error) && !empty($data->body) && $data) {
$pages = $this->_getHeaderLink($data->headers['Link']);
if (($pages['self'] !== $pages['last']) && !empty($pages['next'])){
diff --git a/eclipse.org-common/themes/Nova/header.php b/eclipse.org-common/themes/Nova/header.php
index 9032a81..4d6ab7c 100644
--- a/eclipse.org-common/themes/Nova/header.php
+++ b/eclipse.org-common/themes/Nova/header.php
@@ -19,14 +19,15 @@
print $this->getDoctype();
?>
<head>
- <title><?= $pageTitle ?></title><meta name="author" content="<?= $pageAuthor ?>" />
- <?php
- if ($App->OGTitle != "") {
- echo($App->getOGTitle());
- }
- echo($App->getOGDescription());
- echo($App->getOGImage());
- ?>
+ <title><?= $pageTitle ?></title>
+ <meta name="author" content="<?= $pageAuthor ?>" />
+ <?php if ($App->getOGTitle() != "") :?>
+ <meta property="og:title" content="<?php print $App->getOGTitle(); ?>" />
+ <?php else: ?>
+ <meta property="og:title" content="<?php print $pageTitle; ?>" />
+ <?php endif;?>
+ <meta property="og:description" content="<?php print $App->getOGDescription();?>"/>
+ <meta property="og:image" content="<?php print $App->getOGImage();?>"/>
<meta name="keywords" content="<?= $pageKeywords ?>" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/eclipse.org-common/yui/2.6.0/build/reset-fonts-grids/reset-fonts-grids.css" media="screen" />
diff --git a/eclipse.org-common/themes/solstice/public/images/favicon.ico b/eclipse.org-common/themes/solstice/public/images/favicon.ico
index bb43f00..12c8777 100644
--- a/eclipse.org-common/themes/solstice/public/images/favicon.ico
+++ b/eclipse.org-common/themes/solstice/public/images/favicon.ico
Binary files differ