-
Notifications
You must be signed in to change notification settings - Fork 30
/
ImpExController.php
159 lines (141 loc) · 3.92 KB
/
ImpExController.php
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/*======================================================================*\
|| ####################################################################
|| # vBulletin Impex
|| # ----------------------------------------------------------------
|| # All PHP code in this file is Copyright 2000-2014 vBulletin Solutions Inc.
|| # This code is made available under the Modified BSD License -- see license.txt
|| # http://www.vbulletin.com
|| ####################################################################
\*======================================================================*/
/**
* The controller mediates between the display and the session and deals with POST variables
*
*
* @package ImpEx
*
*/
if (!defined('IDIR')) { die; }
class ImpExController
{
/**
* Class version
*
* This will allow the checking for interoprability of class version in diffrent
* versions of ImpEx
*
* @var string
*/
var $_version = '0.0.1';
/**
* Constructor
*
* Empty
*
*/
function ImpExController()
{
}
/**
* Places the $_POST values in the session array
*
* @param object sessionobject The current session object
* @param array mixed The $_POST array
*
* @return none
*/
function get_post_values(&$sessionobject, $postarray)
{
// TODO: Need some checking and error handling in here.
// NOTE: hard coded the avaiable passable values that can be handeled by interfacing with the modules
// NOTE : could handel it in a 000.php check
foreach ($postarray as $key => $value)
{
$sessionobject->add_session_var($key, $value);
}
}
/**
* Modifyes the display depending on the state of the session object.
*
* @param object sessionobject The current session object
* @param object displayobject The display object to be updated
*
* @return none
*/
function updateDisplay(&$sessionobject, &$displayobject)
{
if ($sessionobject->_session_vars['system'] == 'NONE')
{
$displayobject->update_basic('status', 'Please choose a system to import from');
$displayobject->update_basic('displaymodules', 'FALSE');
$displayobject->update_basic('choosesystem', 'TRUE');
}
else
{
$displayobject->update_basic('system', $sessionobject->_session_vars['system']);
}
for ($i = 0; $i <= $sessionobject->get_number_of_modules(); $i++)
{
$position = str_pad($i, 3, '0', STR_PAD_LEFT);
if ($sessionobject->_session_vars[$position] == 'WORKING')
{
$displayobject->update_basic('displaylinks', 'FALSE');
}
}
}
/**
* Returns the current session or false if there isn't a current one
*
* @param object databaseobject The database object connected to the dB where the session is stored
* @param string mixed Table prefix
*
* @return object|boolean
*/
function return_session(&$Db_object, &$targettableprefix)
{
$getsession = null;
$session_db = null;
$session_data = false;
if (forcesqlmode)
{
$Db_object->query("set sql_mode = ''");
}
$session_db = $Db_object->query("SELECT data FROM {$targettableprefix}datastore WHERE title = 'ImpExSession'");
// TODO: switch on database type.
if (mysql_num_rows($session_db))
{
$session_data = mysql_result($session_db, 0, 'data');
}
if ($session_data)
{
return unserialize($session_data);
}
else
{
return false;
}
}
/**
* Stores the current session
*
* @param object databaseobject The database object connected to the dB where the session is stored
* @param string mixed Table prefix
* @param object sessionobject The session to store
*
* @return none
*/
function store_session(&$Db_object, &$targettableprefix, &$ImpExSession)
{
// TODO: Need a return values and assurace that it was committed
if (forcesqlmode)
{
$Db_object->query("set sql_mode = ''");
}
$Db_object->query("
REPLACE INTO " . $targettableprefix . "datastore (title, data)
VALUES ('ImpExSession', '" . addslashes(serialize($ImpExSession)) . "')
");
}
}
/*======================================================================*/
?>