1: <?php
2: /**
3: * This file contains the groupselect extension of the frontend user plugin.
4: *
5: * @package Plugin
6: * @subpackage FrontendUsers
7: * @author Timo Trautmann
8: * @copyright four for business AG <www.4fb.de>
9: * @license http://www.contenido.org/license/LIZENZ.txt
10: * @link http://www.4fb.de
11: * @link http://www.contenido.org
12: */
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: global $db;
17:
18: /**
19: * @return string
20: */
21: function frontendusers_groupselect_getTitle () {
22: return i18n("Groupname");
23: }
24:
25: /**
26: * @return string
27: * @throws cDbException
28: * @throws cException
29: */
30: function frontendusers_groupselect_display () {
31: global $client;
32: $iIdfrontenduser = (int)$_REQUEST['idfrontenduser'];
33:
34: //render select
35: $fegroups = new cApiFrontendGroupCollection();
36: $fegroups->setWhere("idclient", $client);
37: $fegroups->query();
38:
39: $aFEGroups = array();
40:
41: while ($fegroup = $fegroups->next())
42: {
43: $aFEGroups[$fegroup->get("idfrontendgroup")] = $fegroup->get("groupname");
44: }
45:
46: $oSelect = new cHTMLSelectElement("groupselect[]");
47: $oSelect->autoFill($aFEGroups);
48: $oSelect->setMultiselect();
49: $oSelect->setSize(5);
50: $oSelect->setStyle('width:265px;');
51:
52: //mark groups
53: $oFEGroupMemberCollection = new cApiFrontendGroupMemberCollection;
54: $oFEGroupMemberCollection->setWhere('idfrontenduser', $iIdfrontenduser);
55: $oFEGroupMemberCollection->addResultField('idfrontendgroup');
56: $oFEGroupMemberCollection->query();
57:
58: $aFEGroup = array();
59: while ($oFEGroup = $oFEGroupMemberCollection->next())
60: {
61: $aFEGroup[] = $oFEGroup->get("idfrontendgroup");
62: }
63:
64: $oSelect->setDefault($aFEGroup);
65:
66: return $oSelect->render();
67: }
68:
69: /**
70: * @return array
71: */
72: function frontendusers_groupselect_wantedVariables () {
73: return (array("groupselect"));
74: }
75:
76: /**
77: * @param $variables
78: *
79: * @return bool
80: * @throws cDbException
81: * @throws cException
82: * @throws cInvalidArgumentException
83: */
84: function frontendusers_groupselect_store ($variables) {
85: global $client;
86:
87: $groups = $_REQUEST['groupselect'];
88: $iIdfrontenduser = (int)$_REQUEST['idfrontenduser'];
89: if (!is_array($groups)) {
90: $groups = array();
91: }
92:
93: $groupmembers = new cApiFrontendGroupMemberCollection();
94:
95: $fegroups = new cApiFrontendGroupCollection();
96: $fegroups->setWhere("idclient", $client);
97: $fegroups->query();
98:
99: $aFEGroups = array();
100:
101: while ($fegroup = $fegroups->next())
102: {
103: $groupmembers->remove($fegroup->get("idfrontendgroup"), $iIdfrontenduser);
104: if (in_array($fegroup->get("idfrontendgroup"), $groups)) {
105: $groupmembers->create($fegroup->get("idfrontendgroup"), $iIdfrontenduser);
106: }
107: }
108:
109: return true;
110: }
111:
112: /**
113: * @return array
114: */
115: function frontendusers_groupselect_canonicalVariables () {
116: //FFBCON-812
117: return array();
118: }
119:
120: /**
121: * @param $key
122: *
123: * @return string
124: */
125: function frontendusers_groupselect_getvalue ($key) {
126: return '';
127: }
128:
129: ?>