Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 7663c78

Browse files
author
Jamie Snape
committed
Various small fixes
1 parent fe37dcc commit 7663c78

File tree

5 files changed

+28
-53
lines changed

5 files changed

+28
-53
lines changed

core/models/dao/FeedDao.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function getResource()
9292
case MIDAS_FEED_DELETE_ITEM:
9393
return $this->resource;
9494
default:
95-
throw new Zend_Exception('Unable to define the type of feed.');
95+
return false;
9696
}
9797
}
9898

core/views/element/feed.phtml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,14 @@ if (!isset($feeds) || empty($feeds)) {
118118

119119
echo "<div class='feedContainer'>";
120120
foreach ($feeds as $key => $feed) {
121-
echo "<div class='feedElement' element='{$feed->getKey()}'>";
122-
if (isset($this->lastFeedVisit) && $this->lastFeedVisit < strtotime($feed->getDate())
123-
) {
124-
echo "<img class='newFeedElement' src='{$this->coreWebroot}/public/images/icons/new.png' alt=''/>";
121+
if ($feed->getResource() !== false) {
122+
echo "<div class='feedElement' element='{$feed->getKey()}'>";
123+
if (isset($this->lastFeedVisit) && $this->lastFeedVisit < strtotime($feed->getDate())
124+
) {
125+
echo "<img class='newFeedElement' src='{$this->coreWebroot}/public/images/icons/new.png' alt=''/>";
126+
}
127+
createFeedElement($this, $feed);
128+
echo "</div>";
125129
}
126-
createFeedElement($this, $feed);
127-
echo "</div>";
128130
}
129131
echo "</div>";

library/Midas/Mail.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ public function getBcc()
6262
* Add one or more "CC" email addresses.
6363
*
6464
* @param array|string $emails "CC" email address or addresses
65+
* @param string $name provided for compatibility with Zend Mail
6566
* @return $this this mail instance
6667
*/
67-
public function addCc($emails)
68+
public function addCc($emails, $name = '')
6869
{
69-
parent::addCc($emails);
70+
parent::addCc($emails, $name);
7071

7172
if (!is_array($emails)) {
7273
$emails = array($emails);

modules/googleauth/controllers/CallbackController.php

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -90,58 +90,28 @@ protected function _getUserInfo($code)
9090
)
9191
);
9292

93-
// Make the request for the access token
94-
if (extension_loaded('curl')) {
95-
$curl = curl_init();
96-
curl_setopt($curl, CURLOPT_URL, GOOGLE_AUTH_OAUTH2_URL);
97-
curl_setopt($curl, CURLOPT_POST, 1);
98-
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
99-
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
100-
curl_setopt($curl, CURLOPT_PORT, 443);
101-
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
102-
$response = curl_exec($curl);
103-
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
104-
105-
if ($status != 200) {
106-
throw new Zend_Exception('Access token request failed: '.$response);
107-
}
108-
} else {
109-
$context = array('http' => array('method' => 'POST', 'header' => $headers, 'content' => $content));
110-
$context = stream_context_create($context);
111-
$response = file_get_contents(GOOGLE_AUTH_OAUTH2_URL, false, $context);
93+
// Make the request for the access token.
94+
$context = array('http' => array('method' => 'POST', 'header' => $headers, 'content' => $content));
95+
$context = stream_context_create($context);
96+
$response = file_get_contents(GOOGLE_AUTH_OAUTH2_URL, false, $context);
11297

113-
if ($response === false) {
114-
throw new Zend_Exception('Access token request failed.');
115-
}
98+
if ($response === false) {
99+
throw new Zend_Exception('Access token request failed.');
116100
}
117101

118102
$response = json_decode($response);
119103
$accessToken = $response->access_token;
120104
$tokenType = $response->token_type;
121105

122-
// Use the access token to request info about the user
106+
// Use the access token to request info about the user.
123107
$headers = 'Authorization: '.$tokenType.' '.$accessToken;
108+
$context = array('http' => array('header' => $headers));
109+
$context = stream_context_create($context);
110+
$params = 'fields=emails/value,id,name(familyName,givenName)';
111+
$response = file_get_contents(GOOGLE_AUTH_PLUS_URL.'?'.urlencode($params), false, $context);
124112

125-
if (extension_loaded('curl')) {
126-
$curl = curl_init();
127-
curl_setopt($curl, CURLOPT_URL, GOOGLE_AUTH_PLUS_URL);
128-
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
129-
curl_setopt($curl, CURLOPT_PORT, 443);
130-
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
131-
$response = curl_exec($curl);
132-
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
133-
134-
if ($status != 200) {
135-
throw new Zend_Exception('Get Google user info request failed: '.$response);
136-
}
137-
} else {
138-
$context = array('http' => array('header' => $headers));
139-
$context = stream_context_create($context);
140-
$response = file_get_contents(GOOGLE_AUTH_PLUS_URL, false, $context);
141-
142-
if ($response === false) {
143-
throw new Zend_Exception('Get Google user info request failed.');
144-
}
113+
if ($response === false) {
114+
throw new Zend_Exception('Get Google user info request failed.');
145115
}
146116

147117
$response = json_decode($response);
@@ -172,7 +142,7 @@ protected function _createOrGetUser($info)
172142
$closeRegistration = (int) $this->Setting->getValueByNameWithDefault('close_registration', 1);
173143
if ($closeRegistration === 1) {
174144
throw new Zend_Exception(
175-
'Access to this instance is by invitation '.'only, please contact an administrator.'
145+
'Access to this instance is by invitation only, please contact an administrator.'
176146
);
177147
}
178148
$user = $this->User->createUser($info['email'], null, $info['firstName'], $info['lastName'], 0, '');

modules/mail/forms/Admin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function init()
5959

6060
$sendGridPassword = new Zend_Form_Element_Password(MAIL_SEND_GRID_PASSWORD_KEY);
6161
$sendGridPassword->setLabel('SendGrid Password');
62+
$sendGridPassword->setRenderPassword(true);
6263
$sendGridPassword->addValidator('NotEmpty', true);
6364

6465
$this->addDisplayGroup(array($sendGridUsername, $sendGridPassword), 'send_grid');
@@ -84,6 +85,7 @@ public function init()
8485

8586
$smtpPassword = new Zend_Form_Element_Password(MAIL_SMTP_PASSWORD_KEY);
8687
$smtpPassword->setLabel('Password');
88+
$smtpPassword->setRenderPassword(true);
8789
$smtpPassword->addValidator('NotEmpty', true);
8890

8991
$this->addDisplayGroup(array($smtpHost, $smtpPort, $smtpUseSsl, $smtpUsername, $smtpPassword), 'smtp');

0 commit comments

Comments
 (0)