/
process.class.php
204 lines (168 loc) · 5.77 KB
/
process.class.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
/**
* [NULLED BY DARKGOTH 2014]
*/
defined('PHPFOX') or exit('NO DICE!');
/**
*
*
* @copyright [PHPFOX_COPYRIGHT]
* @author Raymond Benc
* @package Phpfox_Service
* @version $Id: process.class.php 5582 2013-03-28 08:33:43Z Raymond_Benc $
*/
class Core_Service_Process extends Phpfox_Service
{
/**
* Class constructor
*/
public function __construct()
{
}
public function addGender($aVals)
{
(($sPlugin = Phpfox_Plugin::get('core.service_process_addGender_start')) ? eval($sPlugin) : false);
(($sPlugin = Phpfox_Plugin::get('core.service_process_addGender_end')) ? eval($sPlugin) : false);
}
public function updateComponentSetting($aVals)
{
Phpfox::isUser(true);
if (isset($aVals['var_name']))
{
$aParts = explode('.', $aVals['var_name']);
if (!Phpfox::isModule($aParts[0]))
{
return Phpfox_Error::set(Phpfox::getPhrase('core.module_is_not_a_valid_module', array('module' => $aParts[0])));
}
$aParts[1] = str_replace(' ', '', ucwords(str_replace('_', ' ', $aParts[1])));
$oObject = Phpfox::getService($aParts[0] . '.block');
if (!isset($aVals['user_value']))
{
$sPrepare = 'prepare' . $aParts[1];
$aVals['user_value'] = $oObject->$sPrepare($aVals);
}
if ($oObject->$aParts[1]($aVals['user_value']))
{
Phpfox::getLib('cache')->remove(array('csetting', Phpfox::getUserId()));
$this->database()->delete(Phpfox::getT('component_setting'), 'user_id = ' . Phpfox::getUserId() . ' AND var_name = \'' . $this->database()->escape($aVals['var_name']) . '\'');
$this->database()->insert(Phpfox::getT('component_setting'), array('user_id' => Phpfox::getUserId(), 'var_name' => $aVals['var_name'], 'user_value' => $aVals['user_value']));
return true;
}
}
return false;
}
/**
* Hides blocks by issuing a callback
* @param type $sBlockId
* @param type $sTypeId
* @return type
*/
public function hideBlock($sBlockId, $sTypeId, $sController)
{
$sBlockId = str_replace('clone_', '', $sBlockId);
$sBlockId = str_replace('js_block_border_', '', $sBlockId);
$aParts = explode('_', $sBlockId);
if (!Phpfox::isModule($aParts[0]))
{
return Phpfox_Error::set(Phpfox::getPhrase('core.module_is_not_a_valid_module', array('module' => $aParts[0])));
}
$sModule = $aParts[0];
unset($aParts[0]);
$sTable = 'user_design_order';
if ($sController == 'core.index-member')
{
$sTable = 'user_dashboard';
}
$iHasEntry = $this->database()->select('COUNT(*)')
->from(Phpfox::getT($sTable))
->where('user_id = ' . Phpfox::getUserId())// . ' AND cache_id = \'js_block_border_' . $this->database()->escape($sBlockId) . '\'')
->execute('getSlaveField');
if (!$iHasEntry)
{
$aBlocks = $this->database()->select('module_id, component, location, ordering')
->from(Phpfox::getT('block'))
->where('is_active = 1 && m_connection = "'.$sController.'" AND location IN (1,2,3)')
->execute('getSlaveRows');
foreach ($aBlocks as $aBlock)
{
$this->database()->insert(Phpfox::getT($sTable), array(
'user_id' => Phpfox::getUserId(),
'cache_id' => 'js_block_border_' . $aBlock['module_id'] . '_' . $aBlock['component'],
'block_id' => $aBlock['location'],
'ordering' => $aBlock['ordering'],
'is_hidden' => 0));
}
}
else
{
$iCount = $this->database()->select('COUNT(*)')
->from(Phpfox::getT($sTable))
->where('user_id = ' . Phpfox::getUserId() . ' AND cache_id = \'js_block_border_' . $this->database()->escape($sBlockId) . '\'')
->execute('getSlaveField');
if (!$iCount)
{
$this->database()->insert(Phpfox::getT($sTable), array(
'user_id' => Phpfox::getUserId(),
'cache_id' => 'js_block_border_' . $sBlockId,
'block_id' => null
));
}
}
$this->database()->update(Phpfox::getT($sTable), array('is_hidden' => '1'),
'user_id = ' . Phpfox::getUserId() . ' AND cache_id = \'js_block_border_' . $this->database()->escape($sBlockId) . '\'');
}
public function updateOrdering($aParams)
{
$iCnt = 0;
foreach ($aParams['values'] as $mKey => $mOrdering)
{
$iCnt++;
$this->database()->update(Phpfox::getT($aParams['table']), array('ordering' => $iCnt), $aParams['key'] . ' = \'' . $this->database()->escape($mKey) . '\'');
}
return true;
}
public function updateActivity($aParams)
{
$this->database()->update(Phpfox::getT($aParams['table']), array('is_active' => ($aParams['active'] ? '1' : '0')), $aParams['key'] . ' = \'' . $this->database()->escape($aParams['value']) . '\'');
return true;
}
/**
* This function inserts into phpfox_upload_track to identify a user when uploading via the massuploader
*/
public function trackUpload($sFile, $bInsert = true)
{
Phpfox::isUser();
$this->database()->delete(Phpfox::getT('upload_track'),'user_id = ' . Phpfox::getUserId());
if ($bInsert == true)
{
$this->database()->insert(Phpfox::getT('upload_track'),array(
'user_id' => Phpfox::getUserId(),
'user_hash' => Phpfox::getCookie('user_hash'),
'file_hash' => md5($sFile)
));
}
}
/**
* If a call is made to an unknown method attempt to connect
* it to a specific plug-in with the same name thus allowing
* plug-in developers the ability to extend classes.
*
* @param string $sMethod is the name of the method
* @param array $aArguments is the array of arguments of being passed
*/
public function __call($sMethod, $aArguments)
{
/**
* Check if such a plug-in exists and if it does call it.
*/
if ($sPlugin = Phpfox_Plugin::get('core.service_process__call'))
{
return eval($sPlugin);
}
/**
* No method or plug-in found we must throw a error.
*/
Phpfox_Error::trigger('Call to undefined method ' . __CLASS__ . '::' . $sMethod . '()', E_USER_ERROR);
}
}
?>