Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ disabled:
- phpdoc_params
- phpdoc_separation
- phpdoc_to_comment
- phpdoc_types
- phpdoc_var_without_name
- pre_increment


finder:
exclude:
Expand Down
28 changes: 18 additions & 10 deletions core/models/base/FeedModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/** Feed Model Base */
abstract class FeedModelBase extends AppModel
{
/** Constructor */
/** Constructor. */
public function __construct()
{
parent::__construct();
Expand Down Expand Up @@ -72,37 +72,45 @@ abstract protected function getFeeds(
$limit = 20
);

/** add a community */
/** Add a community. */
abstract protected function addCommunity($feed, $community);

/** Check policy */
/** Check policy. */
abstract public function policyCheck($feedDao, $userDao = null, $policy = 0);

/** get feeds (filtered by policies)
* @return Array of FeedDao
/**
* Get feeds (filtered by policies).
*
* @return array feed DAOs
*/
public function getGlobalFeeds($loggedUserDao, $policy = 0, $limit = 20)
{
return $this->getFeeds($loggedUserDao, null, null, $policy, $limit);
}

/** get feeds by user (filtered by policies)
* @return Array of FeedDao
/**
* Get feeds by user (filtered by policies).
*
* @return array feed DAOs
*/
public function getFeedsByUser($loggedUserDao, $userDao, $policy = 0, $limit = 20)
{
return $this->getFeeds($loggedUserDao, $userDao, null, $policy, $limit);
}

/** get feeds by community (filtered by policies)
* @return Array of FeedDao
/**
* Get feeds by community (filtered by policies).
*
* @return array feed DAOs
*/
public function getFeedsByCommunity($loggedUserDao, $communityDao, $policy = 0, $limit = 20)
{
return $this->getFeeds($loggedUserDao, null, $communityDao, $policy, $limit);
}

/** Create a feed
/**
* Create a feed.
*
* @return FeedDao
*/
public function createFeed($userDao, $type, $resource, $communityDao = null)
Expand Down
4 changes: 2 additions & 2 deletions core/models/base/UserModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ public function createUser($email, $password, $firstname, $lastname, $admin = 0,
* @param string $s Size in pixels, defaults to 80px [ 1 - 512 ]
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
* @param boole $img True to return a complete IMG tag False for just the URL
* @param bool $img True to return a complete IMG tag False for just the URL
* @param array $atts Optional, additional key/value attributes to include in the IMG tag
* @return String containing either just a URL or a complete image tag
* @return string containing either just a URL or a complete image tag
* @source http://gravatar.com/site/implement/images/php/
*/
public function getGravatarUrl($email, $s = 32, $d = '404', $r = 'g', $img = false, $atts = array())
Expand Down
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
2 changes: 1 addition & 1 deletion core/models/pdo/UserModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public function getUsersFromSearch($search, $userDao, $limit = 14, $group = true
* NOTE: This may ONLY be used to authenticate site admins. This is meant to be
* used during the upgrade process only, not for general authentication.
*
* @return True or false: whether the authentication succeeded
* @return bool True if the authentication succeeded
*/
public function legacyAuthenticate($userDao, $instanceSalt, $password, $hash = 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
2 changes: 1 addition & 1 deletion modules/packages/models/pdo/PackageModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Packages_PackageModel extends Packages_PackageModelBase
* Return all the record in the table.
*
* @param params Optional associative array specifying an 'os', 'arch', 'submissiontype' and 'packagetype'.
* @return Array of package Daos
* @return array Package DAOs
*/
public function get(
$params = array(
Expand Down