@@ -2,11 +2,10 @@ var plugin = {},
2
2
fs = require ( 'fs' ) ,
3
3
path = require ( 'path' ) ,
4
4
common = require ( '../../../api/utils/common.js' ) ,
5
- async = require ( 'async' ) ,
6
5
parser = require ( 'properties-parser' ) ,
7
6
plugins = require ( '../../pluginManager.js' ) ;
8
7
9
- ( function ( plugin ) {
8
+ ( function ( ) {
10
9
plugins . register ( '/i/plugins' , function ( ob ) {
11
10
var params = ob . params ;
12
11
var validateUserForWriteAPI = ob . validateUserForWriteAPI ;
@@ -15,7 +14,7 @@ var plugin = {},
15
14
common . returnMessage ( params , 401 , 'User is not a global administrator' ) ;
16
15
return false ;
17
16
}
18
- if ( typeof params . qstring . plugin !== 'undefined' && params . qstring . plugin != 'plugins' ) {
17
+ if ( typeof params . qstring . plugin !== 'undefined' && params . qstring . plugin !== 'plugins' ) {
19
18
try {
20
19
params . qstring . plugin = JSON . parse ( params . qstring . plugin ) ;
21
20
}
@@ -70,51 +69,53 @@ var plugin = {},
70
69
list . forEach ( function ( file ) {
71
70
if ( ! ignore [ file ] ) {
72
71
var fullpath = dir + '/' + file ;
73
- fs . stat ( fullpath , function ( err , stat ) {
72
+ fs . stat ( fullpath , function ( fsError , stat ) {
74
73
if ( stat && stat . isDirectory ( ) ) {
75
74
var data ;
76
75
try {
77
76
data = require ( fullpath + '/package.json' ) ;
78
77
}
79
- catch ( ex ) { }
80
- var ob = { } ;
78
+ catch ( ex ) {
79
+ // Error
80
+ }
81
+ var resultObj = { } ;
81
82
if ( pluginList . indexOf ( file ) > - 1 ) {
82
- ob . enabled = true ;
83
+ resultObj . enabled = true ;
83
84
}
84
85
else {
85
- ob . enabled = false ;
86
+ resultObj . enabled = false ;
86
87
}
87
- ob . code = file ;
88
+ resultObj . code = file ;
88
89
if ( data ) {
89
- ob . title = data . title || file ;
90
- ob . name = data . name || file ;
91
- ob . description = data . description || file ;
92
- ob . version = data . version || "unknown" ;
93
- ob . author = data . author || "unknown" ;
94
- ob . homepage = data . homepage || "" ;
90
+ resultObj . title = data . title || file ;
91
+ resultObj . name = data . name || file ;
92
+ resultObj . description = data . description || file ;
93
+ resultObj . version = data . version || "unknown" ;
94
+ resultObj . author = data . author || "unknown" ;
95
+ resultObj . homepage = data . homepage || "" ;
95
96
96
97
//we need to get localization only if plugin is disabled
97
- if ( ! ob . enabled ) {
98
- var local_path = fullpath + "/frontend/public/localization/" + ob . code + ".properties" ;
99
- if ( params . member . lang && params . member . lang != "en" ) {
100
- local_path = fullpath + "/frontend/public/localization/" + ob . code + "_" + params . member . lang + ".properties" ;
98
+ if ( ! resultObj . enabled ) {
99
+ var local_path = fullpath + "/frontend/public/localization/" + resultObj . code + ".properties" ;
100
+ if ( params . member . lang && params . member . lang !== "en" ) {
101
+ local_path = fullpath + "/frontend/public/localization/" + resultObj . code + "_" + params . member . lang + ".properties" ;
101
102
}
102
103
if ( fs . existsSync ( local_path ) ) {
103
104
var local_properties = fs . readFileSync ( local_path ) ;
104
105
local_properties = parser . parse ( local_properties ) ;
105
- ob . title = local_properties [ ob . code + ".plugin-title" ] || local_properties [ ob . code + ".title" ] || ob . title ;
106
- ob . description = local_properties [ ob . code + ".plugin-description" ] || local_properties [ ob . code + ".description" ] || ob . description ;
106
+ resultObj . title = local_properties [ resultObj . code + ".plugin-title" ] || local_properties [ resultObj . code + ".title" ] || resultObj . title ;
107
+ resultObj . description = local_properties [ resultObj . code + ".plugin-description" ] || local_properties [ resultObj . code + ".description" ] || resultObj . description ;
107
108
}
108
109
}
109
110
}
110
111
else {
111
- ob = { name : file , title : file , description : file , version : "unknown" , author : "unknown" , homepage : "" , code : file , enabled : false } ;
112
+ resultObj = { name : file , title : file , description : file , version : "unknown" , author : "unknown" , homepage : "" , code : file , enabled : false } ;
112
113
}
113
114
if ( global . enclose ) {
114
115
var eplugin = global . enclose . plugins [ file ] ;
115
- ob . prepackaged = eplugin && eplugin . prepackaged ;
116
+ resultObj . prepackaged = eplugin && eplugin . prepackaged ;
116
117
}
117
- results . push ( ob ) ;
118
+ results . push ( resultObj ) ;
118
119
if ( ! -- pending ) {
119
120
done ( null , results ) ;
120
121
}
@@ -174,9 +175,9 @@ var plugin = {},
174
175
updateArr . ends = data . frontend . session_timeout * 60 + Math . round ( Date . now ( ) / 1000 ) ;
175
176
updateArr . ttl = data . frontend . session_timeout * 60 ;
176
177
}
177
- if ( params . member . settings && params . member . settings . frontend && typeof data . frontend . session_timeout !== "undefined" ) { }
178
+ if ( params . member . settings && params . member . settings . frontend && typeof data . frontend . session_timeout !== "undefined" ) { } //eslint-disable-line no-empty
178
179
else { //if not set member value
179
- common . db . collection ( "auth_tokens" ) . update ( { "owner" : ob . params . member . _id + "" , "purpose" : "LoggedInAuth" } , { $set : updateArr } , function ( err , res1 ) {
180
+ common . db . collection ( "auth_tokens" ) . update ( { "owner" : ob . params . member . _id + "" , "purpose" : "LoggedInAuth" } , { $set : updateArr } , function ( err ) {
180
181
if ( err ) {
181
182
console . log ( err ) ;
182
183
}
@@ -233,7 +234,7 @@ var plugin = {},
233
234
updateArr . ttl = data . frontend . session_timeout * 60 ;
234
235
}
235
236
236
- common . db . collection ( "auth_tokens" ) . update ( { "owner" : ob . params . member . _id + "" , "purpose" : "LoggedInAuth" } , { $set : updateArr } , function ( err , res1 ) {
237
+ common . db . collection ( "auth_tokens" ) . update ( { "owner" : ob . params . member . _id + "" , "purpose" : "LoggedInAuth" } , { $set : updateArr } , function ( err ) {
237
238
if ( err ) {
238
239
console . log ( err ) ;
239
240
}
0 commit comments