-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.php
57 lines (49 loc) · 1.41 KB
/
helper.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
<?php
/**
* @package mod_perfectcontact
*
* @copyright Copyright (C) 2015 Perfect Web Team, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
class ModPerfectContactHelper
{
public static function getContactDetails($contactid)
{
// Get connection.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Make query
$query->select("*");
$query->from("#__contact_details");
$query->where("id = '" . $contactid . "'");
// Set query
$db->setQuery($query);
return $db->loadObject();
}
public static function addContactDetails($item)
{
// Get component parameters
$links = json_decode($item->params, true);
// Add link parameters to $item attribute
foreach (range("a", "e") as $char)
{
if ($links["link" . $char] != '')
{
$item->{"link" . $char} = $links["link" . $char];
}
else
{
$item->{"link" . $char} = "";
}
if ($links["link" . $char . "_name"] != '')
{
$item->{"link" . $char . "_name"} = $links["link" . $char . "_name"];
}
else
{
$item->{"link" . $char . "_name"} = "";
}
}
}
}