-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscriptfile.php
More file actions
80 lines (68 loc) · 2.13 KB
/
scriptfile.php
File metadata and controls
80 lines (68 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Script file
*
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
// No direct access to this file
defined('_JEXEC') or die;
if (!class_exists('ScriptAry'))
{
include dirname(__FILE__) . '/scriptary.php';
}
class plgsystemmvcoverrideInstallerScript extends ScriptAry {
/**
* Method to run after an install/update/uninstall method
*
* @return void
*/
public function postflight($type, $parent, $publishPlugin = true) {
$manifest = $parent->getParent()->getManifest();
if ($type == 'install') {
//Get the smallest order value
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query
->select($db->quoteName(array('extension_id','element','ordering')))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('type').'='.$db->Quote($manifest['type']))
->where($db->quoteName('folder').'='.$db->Quote($manifest['group']))
->order($db->quoteName('ordering').' ASC');
$db->setQuery($query,0,1);
$row = $db->loadAssoc();
$ordering = $row['ordering']-1;
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('ordering').'='.$db->Quote($ordering)
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('type').'='.$db->Quote($manifest['type']),
$db->quoteName('folder').'='.$db->Quote($manifest['group']),
$db->quoteName('element').'='.$db->Quote('mvcoverride')
);
$query->update($db->quoteName('#__extensions'))->set($fields)->where($conditions);
$db->setQuery($query);
try {// It's a DB usage construction to contain J2.5 and J3.0 approaches
if ($result = $db->execute() ) {
if ($db->getAffectedRows()>0) {
$this->messages[] = JText::_('GJ_INSTALL_ORDERING_SET');
}
else {
throw new Exception(JText::_('GJ_INSTALL_ORDERING_SET_FAILED'));
}
}
else {
throw new Exception($db->getErrorMsg());
}
} catch (Exception $e) {
// Catch the error.
JError::raiseWarning(100, $e->getMessage(), $db->stderr(true));
}
}
parent::postflight($type, $parent, $publishPlugin);
}
}
?>