1
|
|
|
<?php |
2
|
|
|
// |
3
|
|
|
// ------------------------------------------------------------------------ // |
4
|
|
|
// XOOPS - PHP Content Management System // |
5
|
|
|
// Copyright (c) 2000-2016 XOOPS.org // |
6
|
|
|
// <http://xoops.org/> // |
7
|
|
|
// ------------------------------------------------------------------------ // |
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
11
|
|
|
// (at your option) any later version. // |
12
|
|
|
|
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
14
|
|
|
// of supporting developers from this source code or any supporting // |
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
16
|
|
|
// original comment or credit authors. // |
17
|
|
|
// This program is distributed in the hope that it will be useful, // |
18
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
19
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
20
|
|
|
// GNU General Public License for more details. // |
21
|
|
|
|
22
|
|
|
// You should have received a copy of the GNU General Public License // |
23
|
|
|
// along with this program; if not, write to the Free Software // |
24
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
25
|
|
|
// ------------------------------------------------------------------------ // |
26
|
|
|
// URL: http://xoops.org/ // |
27
|
|
|
// Project: XOOPS Project // |
28
|
|
|
// -------------------------------------------------------------------------// |
29
|
|
|
|
30
|
|
|
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
31
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
32
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjecthandler.php'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Class SmartpartnerPartnerCatLink |
36
|
|
|
*/ |
37
|
|
View Code Duplication |
class SmartpartnerPartner_cat_link extends SmartObject |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* SmartpartnerPartnerCatLink constructor. |
41
|
|
|
*/ |
42
|
|
|
public function __construct() |
43
|
|
|
{ |
44
|
|
|
$this->initVar('partner_cat_linkid', XOBJ_DTYPE_INT, '', true); |
45
|
|
|
$this->initVar('partnerid', XOBJ_DTYPE_INT, '', true); |
46
|
|
|
$this->initVar('categoryid', XOBJ_DTYPE_INT, '', true); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Class SmartpartnerPartnerCatLinkHandler |
52
|
|
|
*/ |
53
|
|
View Code Duplication |
class SmartpartnerPartner_cat_linkHandler extends SmartPersistableObjectHandler |
|
|
|
|
54
|
|
|
{ |
55
|
|
|
/** |
56
|
|
|
* SmartpartnerPartnerCatLinkHandler constructor. |
57
|
|
|
* @param object|XoopsDatabase $db |
58
|
|
|
*/ |
59
|
|
|
public function __construct(XoopsDatabase $db) |
60
|
|
|
{ |
61
|
|
|
parent::__construct($db, 'partner_cat_link', array('partnerid', 'categoryid'), '', false, 'smartpartner'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param $partnerid |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
|
|
public function getParentIds($partnerid) |
69
|
|
|
{ |
70
|
|
|
$criteria = new CriteriaCompo(); |
71
|
|
|
$criteria->add(new Criteria('partnerid', $partnerid)); |
72
|
|
|
$links = $this->getObjects($criteria); |
73
|
|
|
$parent_array = array(); |
74
|
|
|
foreach ($links as $link) { |
75
|
|
|
$parent_array[] = $link->getVar('categoryid'); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return implode('|', $parent_array); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.