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

Commit f4603d7

Browse files
author
Jamie Snape
committed
Minor tweaks and fixes
1 parent 53a4c40 commit f4603d7

File tree

11 files changed

+13
-41
lines changed

11 files changed

+13
-41
lines changed

core/GlobalController.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,7 @@ public function loadElements()
243243
*/
244244
public function isDebug()
245245
{
246-
$config = Zend_Registry::get('config');
247-
if ($config->environment == 'production') {
248-
return true;
249-
} else {
250-
return false;
251-
}
246+
return Zend_Registry::get('configGlobal')->environment !== 'production';
252247
}
253248

254249
/**
@@ -258,9 +253,7 @@ public function isDebug()
258253
*/
259254
public function getEnvironment()
260255
{
261-
$config = Zend_Registry::get('configGlobal');
262-
263-
return $config->environment;
256+
return Zend_Registry::get('configGlobal')->environment;
264257
}
265258

266259
/**

core/Notification.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public function init()
4141
public function getDasboard()
4242
{
4343
$return = array();
44-
$return['Config Folder Writable'] = array(is_writable(LOCAL_CONFIGS_PATH));
4544
$return['Data Folder Writable'] = array(is_writable(UtilityComponent::getDataDirectory()));
4645
// pass in empty string since we want to check the overall root temp directory
4746
$return['Temporary Folder Writable'] = array(is_writable(UtilityComponent::getTempDirectory('')));

core/controllers/AdminController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function init()
3333
{
3434
$config = Zend_Registry::get('configGlobal'); // set admin part to english
3535
$config->application->lang = 'en';
36-
Zend_Registry::get('configGlobal', $config);
36+
Zend_Registry::set('configGlobal', $config);
3737
if ($this->isDemoMode()) {
3838
$this->disableView();
3939

core/controllers/UserController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ public function settingsAction()
986986
$this->Component->Sortdao->order = 'asc';
987987
usort($communities, array($this->Component->Sortdao, 'sortByName'));
988988

989+
$this->view->useGravatar = Zend_Registry::get('configGlobal')->gravatar;
989990
$this->view->isGravatar = $this->User->getGravatarUrl($userDao->getEmail());
990991

991992
$this->view->communities = $communities;

core/controllers/components/ApihelperComponent.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public function getApiSetup()
6161
{
6262
$apiSetup = array();
6363
$apiSetup['testing'] = Zend_Registry::get('configGlobal')->environment == 'testing';
64-
$utilityComponent = MidasLoader::loadComponent('Utility');
65-
$apiSetup['tmpDirectory'] = $utilityComponent->getTempDirectory();
64+
$apiSetup['tmpDirectory'] = UtilityComponent::getTempDirectory();
6665

6766
return $apiSetup;
6867
}

core/controllers/components/ApisystemComponent.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ public function uploadGeneratetoken($args)
392392
$uploadComponent = MidasLoader::loadComponent('Httpupload');
393393
$apiSetup = $apihelperComponent->getApiSetup();
394394
$uploadComponent->setTestingMode($apiSetup['testing']);
395-
$uploadComponent->setTmpDirectory($apiSetup['tmpDirectory']);
396395

397396
return $uploadComponent->generateToken($args, $userDao->getKey().'/'.$item->getKey());
398397
}
@@ -462,7 +461,6 @@ public function uploadPerform($args)
462461
$httpUploadComponent = MidasLoader::loadComponent('Httpupload');
463462
$apiSetup = $apihelperComponent->getApiSetup();
464463
$httpUploadComponent->setTestingMode($apiSetup['testing']);
465-
$httpUploadComponent->setTmpDirectory($apiSetup['tmpDirectory']);
466464

467465
if (array_key_exists('testingmode', $args)) {
468466
$httpUploadComponent->setTestingMode(true);
@@ -558,7 +556,6 @@ public function uploadGetoffset($args)
558556
$apihelperComponent = MidasLoader::loadComponent('Apihelper');
559557
$apiSetup = $apihelperComponent->getApiSetup();
560558
$uploadComponent->setTestingMode($apiSetup['testing']);
561-
$uploadComponent->setTmpDirectory($apiSetup['tmpDirectory']);
562559

563560
return $uploadComponent->getOffset($args);
564561
}

core/controllers/components/HttpuploadComponent.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,9 @@
3434
*/
3535
class HttpuploadComponent extends AppComponent
3636
{
37-
public $tmpDirectory = '';
3837
public $tokenParamName = 'uploadtoken';
3938
public $testingEnable = false;
4039

41-
/** Set the upload temporary directory */
42-
public function setTmpDirectory($dir)
43-
{
44-
$this->tmpDirectory = $dir;
45-
}
46-
4740
/** Set whether we are in testing mode or not (boolean) */
4841
public function setTestingMode($testing)
4942
{
@@ -68,7 +61,7 @@ public function generateToken($args, $dirname = '')
6861
throw new Exception('Parameter filename is not defined', MIDAS_HTTPUPLOAD_FILENAME_PARAM_UNDEFINED);
6962
}
7063
$dir = $dirname == '' ? '' : '/'.$dirname;
71-
$dir = $this->tmpDirectory.$dir;
64+
$dir = UtilityComponent::getTempDirectory().$dir;
7265

7366
if (!file_exists($dir)) {
7467
if (!mkdir($dir, 0700, true)) {
@@ -79,10 +72,10 @@ public function generateToken($args, $dirname = '')
7972
if ($dirname != '') {
8073
$unique_identifier = $dirname.'/'.$unique_identifier;
8174
}
82-
if (file_exists($this->tmpDirectory.'/'.$unique_identifier)) {
75+
if (file_exists(UtilityComponent::getTempDirectory().'/'.$unique_identifier)) {
8376
throw new Exception('Failed to generate upload token', MIDAS_HTTPUPLOAD_UPLOAD_TOKEN_GENERATION_FAILED);
8477
}
85-
touch($this->tmpDirectory.'/'.$unique_identifier);
78+
touch(UtilityComponent::getTempDirectory().'/'.$unique_identifier);
8679

8780
return array('token' => $unique_identifier);
8881
}
@@ -113,7 +106,7 @@ public function process($args)
113106
}
114107

115108
// check if the temporary file exists
116-
$pathTemporaryFilename = $this->tmpDirectory.'/'.$uploadToken;
109+
$pathTemporaryFilename = UtilityComponent::getTempDirectory().'/'.$uploadToken;
117110
if (!file_exists($pathTemporaryFilename)) {
118111
throw new Exception(
119112
'Invalid upload token '.$pathTemporaryFilename, MIDAS_HTTPUPLOAD_INVALID_UPLOAD_TOKEN
@@ -192,7 +185,7 @@ public function getOffset($args)
192185
);
193186
}
194187
$uploadToken = $args[$this->tokenParamName];
195-
$offset = UtilityComponent::fileSize($this->tmpDirectory.'/'.$uploadToken);
188+
$offset = UtilityComponent::fileSize(UtilityComponent::getTempDirectory().'/'.$uploadToken);
196189

197190
return array('offset' => $offset);
198191
}

core/controllers/components/InternationalizationComponent.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ public static function translate($text)
6262
*/
6363
public static function isDebug()
6464
{
65-
$config = Zend_Registry::get('config');
66-
if ($config->mode->debug == 1) {
67-
return true;
68-
} else {
69-
return false;
70-
}
65+
return Zend_Registry::get('configGlobal')->environment !== 'production';
7166
}
7267
}

core/models/MIDASModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function getLogger()
146146
* Initialize a DAO.
147147
*
148148
* @param string $name name of the DAO
149-
* @param array $data array of values
149+
* @param array|Zend_Db_Table_Row_Abstract $data array or table row of values
150150
* @param string $module
151151
* @returns false|MIDAS_GlobalDao
152152
* @throws Zend_Exception

core/views/user/settings.phtml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ foreach ($this->customTabs as $moduleName => $module) {
156156
<input type="submit" name='modifyPicture' value="<?php echo $this->t('Upload new avatar') ?>">
157157
<br/>
158158
<?php
159-
$useGravatar = Zend_Registry::get('configGlobal')->gravatar;
160-
if ($useGravatar) {
159+
if ($this->useGravatar) {
161160
echo "<br/>";
162161
if (strpos($this->thumbnail, 'http://') === false && $this->isGravatar
163162
) {

0 commit comments

Comments
 (0)