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

Commit

Permalink
Various small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Sep 24, 2015
1 parent fe37dcc commit 7663c78
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 53 deletions.
2 changes: 1 addition & 1 deletion core/models/dao/FeedDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getResource()
case MIDAS_FEED_DELETE_ITEM:
return $this->resource;
default:
throw new Zend_Exception('Unable to define the type of feed.');
return false;
}
}

Expand Down
14 changes: 8 additions & 6 deletions core/views/element/feed.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ if (!isset($feeds) || empty($feeds)) {

echo "<div class='feedContainer'>";
foreach ($feeds as $key => $feed) {
echo "<div class='feedElement' element='{$feed->getKey()}'>";
if (isset($this->lastFeedVisit) && $this->lastFeedVisit < strtotime($feed->getDate())
) {
echo "<img class='newFeedElement' src='{$this->coreWebroot}/public/images/icons/new.png' alt=''/>";
if ($feed->getResource() !== false) {
echo "<div class='feedElement' element='{$feed->getKey()}'>";
if (isset($this->lastFeedVisit) && $this->lastFeedVisit < strtotime($feed->getDate())
) {
echo "<img class='newFeedElement' src='{$this->coreWebroot}/public/images/icons/new.png' alt=''/>";
}
createFeedElement($this, $feed);
echo "</div>";
}
createFeedElement($this, $feed);
echo "</div>";
}
echo "</div>";
5 changes: 3 additions & 2 deletions library/Midas/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ public function getBcc()
* Add one or more "CC" email addresses.
*
* @param array|string $emails "CC" email address or addresses
* @param string $name provided for compatibility with Zend Mail
* @return $this this mail instance
*/
public function addCc($emails)
public function addCc($emails, $name = '')
{
parent::addCc($emails);
parent::addCc($emails, $name);

if (!is_array($emails)) {
$emails = array($emails);
Expand Down
58 changes: 14 additions & 44 deletions modules/googleauth/controllers/CallbackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,58 +90,28 @@ protected function _getUserInfo($code)
)
);

// Make the request for the access token
if (extension_loaded('curl')) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, GOOGLE_AUTH_OAUTH2_URL);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_PORT, 443);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ($status != 200) {
throw new Zend_Exception('Access token request failed: '.$response);
}
} else {
$context = array('http' => array('method' => 'POST', 'header' => $headers, 'content' => $content));
$context = stream_context_create($context);
$response = file_get_contents(GOOGLE_AUTH_OAUTH2_URL, false, $context);
// Make the request for the access token.
$context = array('http' => array('method' => 'POST', 'header' => $headers, 'content' => $content));
$context = stream_context_create($context);
$response = file_get_contents(GOOGLE_AUTH_OAUTH2_URL, false, $context);

if ($response === false) {
throw new Zend_Exception('Access token request failed.');
}
if ($response === false) {
throw new Zend_Exception('Access token request failed.');
}

$response = json_decode($response);
$accessToken = $response->access_token;
$tokenType = $response->token_type;

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

if (extension_loaded('curl')) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, GOOGLE_AUTH_PLUS_URL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_PORT, 443);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ($status != 200) {
throw new Zend_Exception('Get Google user info request failed: '.$response);
}
} else {
$context = array('http' => array('header' => $headers));
$context = stream_context_create($context);
$response = file_get_contents(GOOGLE_AUTH_PLUS_URL, false, $context);

if ($response === false) {
throw new Zend_Exception('Get Google user info request failed.');
}
if ($response === false) {
throw new Zend_Exception('Get Google user info request failed.');
}

$response = json_decode($response);
Expand Down Expand Up @@ -172,7 +142,7 @@ protected function _createOrGetUser($info)
$closeRegistration = (int) $this->Setting->getValueByNameWithDefault('close_registration', 1);
if ($closeRegistration === 1) {
throw new Zend_Exception(
'Access to this instance is by invitation '.'only, please contact an administrator.'
'Access to this instance is by invitation only, please contact an administrator.'
);
}
$user = $this->User->createUser($info['email'], null, $info['firstName'], $info['lastName'], 0, '');
Expand Down
2 changes: 2 additions & 0 deletions modules/mail/forms/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function init()

$sendGridPassword = new Zend_Form_Element_Password(MAIL_SEND_GRID_PASSWORD_KEY);
$sendGridPassword->setLabel('SendGrid Password');
$sendGridPassword->setRenderPassword(true);
$sendGridPassword->addValidator('NotEmpty', true);

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

$smtpPassword = new Zend_Form_Element_Password(MAIL_SMTP_PASSWORD_KEY);
$smtpPassword->setLabel('Password');
$smtpPassword->setRenderPassword(true);
$smtpPassword->addValidator('NotEmpty', true);

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

0 comments on commit 7663c78

Please sign in to comment.