Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1168284
modules_tag_processor.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Sep 24, 10:13 AM
Size
3 KB
Mime Type
text/x-php
Expires
Fri, Sep 26, 10:13 AM (22 h, 48 m)
Engine
blob
Format
Raw Data
Handle
756829
Attached To
rINP In-Portal
modules_tag_processor.php
View Options
<?php
/**
* @version $Id: modules_tag_processor.php 16513 2017-01-20 14:10:53Z alex $
* @package In-Portal
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined
(
'FULL_PATH'
)
or
die
(
'restricted access!'
);
class
ModulesTagProcessor
extends
kDBTagProcessor
{
function
ModuleInstalled
(
$params
)
{
return
$this
->
Application
->
isModuleEnabled
(
$params
[
'name'
]);
}
function
_hasPrivileges
()
{
return
$this
->
Application
->
RecallVar
(
'user_id'
)
==
USER_ROOT
;
}
function
AlreadyInstalled
(
$params
)
{
if
(!
$this
->
_hasPrivileges
())
{
// don't show licenses status for non-privileged users
return
true
;
}
/** @var kDBList $object */
$object
=
$this
->
getObject
(
$params
);
/** @var kModulesHelper $modules_helper */
$modules_helper
=
$this
->
Application
->
recallObject
(
'ModulesHelper'
);
return
$modules_helper
->
moduleInstalled
(
$object
->
GetDBField
(
'Name'
)
);
}
function
ModuleLicensed
(
$params
)
{
if
(!
$this
->
_hasPrivileges
())
{
// don't show licenses status for non-privileged users
return
true
;
}
/** @var kDBList $object */
$object
=
$this
->
getObject
(
$params
);
/** @var kModulesHelper $modules_helper */
$modules_helper
=
$this
->
Application
->
recallObject
(
'ModulesHelper'
);
$licensed_modules
=
array_map
(
'strtolower'
,
$modules_helper
->
_GetModules
());
return
in_array
(
strtolower
(
$object
->
GetDBField
(
'Name'
)),
$licensed_modules
);
}
function
PrerequisitesMet
(
$params
)
{
return
!
$this
->
_getPrerequisitesErrors
(
$params
);
}
function
_getPrerequisitesErrors
(
$params
)
{
static
$errors
=
Array
();
/** @var kDBList $object */
$object
=
$this
->
getObject
(
$params
);
$module_path
=
$object
->
GetDBField
(
'Path'
);
if
(!
array_key_exists
(
$module_path
,
$errors
))
{
require_once
FULL_PATH
.
'/core/install/install_toolkit.php'
;
$toolkit
=
new
kInstallToolkit
();
$module_version
=
$toolkit
->
GetMaxModuleVersion
(
$module_path
);
$errors
[
$module_path
]
=
$toolkit
->
CheckPrerequisites
(
$module_path
,
Array
(
$module_version
),
'standalone'
);
}
return
$errors
[
$module_path
];
}
function
ListPrerequisites
(
$params
)
{
$errors
=
$this
->
_getPrerequisitesErrors
(
$params
);
$ret
=
''
;
$block_params
=
$this
->
prepareTagParams
(
$params
);
$block_params
[
'name'
]
=
$params
[
'render_as'
];
foreach
(
$errors
as
$error
)
{
$block_params
[
'error'
]
=
$error
;
$ret
.=
$this
->
Application
->
ParseBlock
(
$block_params
);
}
return
$ret
;
}
function
InstallLink
(
$params
)
{
/** @var kDBList $object */
$object
=
$this
->
getObject
(
$params
);
$module_path
=
strtolower
(
$object
->
GetDBField
(
'Path'
)
);
$url_params
=
Array
(
'redirect'
=>
1
,
'admin'
=>
1
);
return
$this
->
Application
->
HREF
(
'dummy'
,
'_FRONT_END_'
,
$url_params
,
$module_path
.
'install.php'
);
}
}
Event Timeline
Log In to Comment