Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #1049 : adding config param sslSelfSigned to make use of self sign... #1067

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/configs/template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ mySqlTablePrefix="{mySqlTablePrefix}"
[localfs]
fsRoot="{fsRoot}"
fsHost="{fsHost}"
sslSelfSigned="0"

[modules]
image="{imageLibrary}"
Expand Down
6 changes: 5 additions & 1 deletion src/libraries/controllers/OAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public function flow()
$consumer = getDb()->getCredential($token);
$oauth = new OAuth($consumerKey,$consumerSecret,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);
$oauth->setVersion('1.0a');
if ($this->config->localfs->sslSelfSigned)
$oauth->disableSSLChecks();
$oauth->setToken($token, $tokenSecret);
$accessToken = $oauth->getAccessToken(sprintf('%s://%s/v1/oauth/token/access', $this->utility->getProtocol(false), $_SERVER['HTTP_HOST']), null, $verifier);
$accessToken['oauth_consumer_key'] = $consumerKey;
Expand Down Expand Up @@ -135,8 +137,10 @@ public function flow()
parse_str($_COOKIE['oauth']);
$consumer = getDb()->getCredential($oauth_token);
$oauth = new OAuth($oauth_consumer_key,$oauth_consumer_secret,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);
if ($this->config->localfs->sslSelfSigned)
$oauth->disableSSLChecks();
$oauth->setToken($oauth_token,$oauth_token_secret);
$oauth->fetch(sprintf('http://%s/v1/oauth/test?oauth_consumer_key=%s', $_SERVER['HTTP_HOST'], $oauth_consumer_key));
$oauth->fetch(sprintf('%s://%s/v1/oauth/test?oauth_consumer_key=%s', $this->utility->getProtocol(false), $_SERVER['HTTP_HOST'], $oauth_consumer_key));
$response_info = $oauth->getLastResponseInfo();
header("Content-Type: {$response_info["content_type"]}");
echo $oauth->getLastResponse();
Expand Down
7 changes: 7 additions & 0 deletions src/libraries/models/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,13 @@ public function plural($int, $word = null, $write = true)
return $this->returnValue(($int != 1 ? "{$word}s" : $word), $write);
}

public function selectPlural($int, $singularForm, $pluralForm, $write = true)
{
$singularForm = $this->safe($singularForm, false);
$pluralForm = $this->safe($pluralForm, false);
return $this->returnValue(($int != 1 ? $pluralForm : $singularForm), $write);
}

public function posessive($noun, $write = true)
{
if(substr($noun, -1) === 's')
Expand Down
2 changes: 1 addition & 1 deletion src/templates/uploadConfirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<?php if(count($successPhotos) > 0) { ?>
<h3>Here's a breakdown of your upload</h3>
<strong><span class="label label-success"><?php printf('%d %s', count($successPhotos), $this->utility->plural(count($successPhotos), 'photo', false)); ?> were uploaded successfully.</span></strong>
<strong><span class="label label-success"><?php printf('%d %s %s', count($successPhotos), $this->utility->plural(count($successPhotos), 'photo', false), $this->utility->selectPlural(count($successPhotos), 'was', 'were', false)); ?> uploaded successfully.</span></strong>
<div class="upload-preview">
<ul class="thumbnails">
<?php foreach($successPhotos as $photo) { ?>
Expand Down
12 changes: 12 additions & 0 deletions src/tests/libraries/models/UtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ public function testPlural()
$this->assertEquals('words', $res, 'plural for word with 2 incorrect');
}

public function testSelectPlural()
{
$res = $this->utility->selectPlural(0, 'was', 'were', false);
$this->assertEquals('were', $res, 'plural for word with 0 selected incorrectly');

$res = $this->utility->selectPlural(1, 'was', 'were', false);
$this->assertEquals('was', $res, 'plural for word with 1 selected incorrectly');

$res = $this->utility->selectPlural(2, 'was', 'were', false);
$this->assertEquals('were', $res, 'plural for word with 2 selected incorrectly');
}

public function testReturnValue()
{
$res = $this->utility->returnValue('foo', false);
Expand Down