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

Commit 9a62f4f

Browse files
committed
Merge pull request #124 from midasplatform/various-small-fixes
Various small fixes
2 parents fe37dcc + 90c6026 commit 9a62f4f

File tree

10 files changed

+52
-68
lines changed

10 files changed

+52
-68
lines changed

.styleci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ disabled:
2626
- phpdoc_params
2727
- phpdoc_separation
2828
- phpdoc_to_comment
29+
- phpdoc_types
2930
- phpdoc_var_without_name
30-
- pre_increment
31+
3132

3233
finder:
3334
exclude:

core/models/base/FeedModelBase.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/** Feed Model Base */
2222
abstract class FeedModelBase extends AppModel
2323
{
24-
/** Constructor */
24+
/** Constructor. */
2525
public function __construct()
2626
{
2727
parent::__construct();
@@ -72,37 +72,45 @@ abstract protected function getFeeds(
7272
$limit = 20
7373
);
7474

75-
/** add a community */
75+
/** Add a community. */
7676
abstract protected function addCommunity($feed, $community);
7777

78-
/** Check policy */
78+
/** Check policy. */
7979
abstract public function policyCheck($feedDao, $userDao = null, $policy = 0);
8080

81-
/** get feeds (filtered by policies)
82-
* @return Array of FeedDao
81+
/**
82+
* Get feeds (filtered by policies).
83+
*
84+
* @return array feed DAOs
8385
*/
8486
public function getGlobalFeeds($loggedUserDao, $policy = 0, $limit = 20)
8587
{
8688
return $this->getFeeds($loggedUserDao, null, null, $policy, $limit);
8789
}
8890

89-
/** get feeds by user (filtered by policies)
90-
* @return Array of FeedDao
91+
/**
92+
* Get feeds by user (filtered by policies).
93+
*
94+
* @return array feed DAOs
9195
*/
9296
public function getFeedsByUser($loggedUserDao, $userDao, $policy = 0, $limit = 20)
9397
{
9498
return $this->getFeeds($loggedUserDao, $userDao, null, $policy, $limit);
9599
}
96100

97-
/** get feeds by community (filtered by policies)
98-
* @return Array of FeedDao
101+
/**
102+
* Get feeds by community (filtered by policies).
103+
*
104+
* @return array feed DAOs
99105
*/
100106
public function getFeedsByCommunity($loggedUserDao, $communityDao, $policy = 0, $limit = 20)
101107
{
102108
return $this->getFeeds($loggedUserDao, null, $communityDao, $policy, $limit);
103109
}
104110

105-
/** Create a feed
111+
/**
112+
* Create a feed.
113+
*
106114
* @return FeedDao
107115
*/
108116
public function createFeed($userDao, $type, $resource, $communityDao = null)

core/models/base/UserModelBase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,9 @@ public function createUser($email, $password, $firstname, $lastname, $admin = 0,
394394
* @param string $s Size in pixels, defaults to 80px [ 1 - 512 ]
395395
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
396396
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
397-
* @param boole $img True to return a complete IMG tag False for just the URL
397+
* @param bool $img True to return a complete IMG tag False for just the URL
398398
* @param array $atts Optional, additional key/value attributes to include in the IMG tag
399-
* @return String containing either just a URL or a complete image tag
399+
* @return string containing either just a URL or a complete image tag
400400
* @source http://gravatar.com/site/implement/images/php/
401401
*/
402402
public function getGravatarUrl($email, $s = 32, $d = '404', $r = 'g', $img = false, $atts = array())

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/models/pdo/UserModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public function getUsersFromSearch($search, $userDao, $limit = 14, $group = true
305305
* NOTE: This may ONLY be used to authenticate site admins. This is meant to be
306306
* used during the upgrade process only, not for general authentication.
307307
*
308-
* @return True or false: whether the authentication succeeded
308+
* @return bool True if the authentication succeeded
309309
*/
310310
public function legacyAuthenticate($userDao, $instanceSalt, $password, $hash = false)
311311
{

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');

modules/packages/models/pdo/PackageModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Packages_PackageModel extends Packages_PackageModelBase
2727
* Return all the record in the table.
2828
*
2929
* @param params Optional associative array specifying an 'os', 'arch', 'submissiontype' and 'packagetype'.
30-
* @return Array of package Daos
30+
* @return array Package DAOs
3131
*/
3232
public function get(
3333
$params = array(

0 commit comments

Comments
 (0)