1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: global $db;
19:
20: function frontendusers_groupselect_getTitle () {
21: return i18n("Groupname");
22: }
23:
24: function frontendusers_groupselect_display () {
25: global $client;
26: $iIdfrontenduser = (int)$_REQUEST['idfrontenduser'];
27:
28:
29: $fegroups = new cApiFrontendGroupCollection();
30: $fegroups->setWhere("idclient", $client);
31: $fegroups->query();
32:
33: $aFEGroups = array();
34:
35: while ($fegroup = $fegroups->next())
36: {
37: $aFEGroups[$fegroup->get("idfrontendgroup")] = $fegroup->get("groupname");
38: }
39:
40: $oSelect = new cHTMLSelectElement("groupselect[]");
41: $oSelect->autoFill($aFEGroups);
42: $oSelect->setMultiselect();
43: $oSelect->setSize(5);
44: $oSelect->setStyle('width:265px;');
45:
46:
47: $oFEGroupMemberCollection = new cApiFrontendGroupMemberCollection;
48: $oFEGroupMemberCollection->setWhere('idfrontenduser', $iIdfrontenduser);
49: $oFEGroupMemberCollection->addResultField('idfrontendgroup');
50: $oFEGroupMemberCollection->query();
51:
52: $aFEGroup = array();
53: while ($oFEGroup = $oFEGroupMemberCollection->next())
54: {
55: $aFEGroup[] = $oFEGroup->get("idfrontendgroup");
56: }
57:
58: $oSelect->setDefault($aFEGroup);
59:
60: return $oSelect->render();
61: }
62:
63: function frontendusers_groupselect_wantedVariables () {
64: return (array("groupselect"));
65: }
66:
67: function frontendusers_groupselect_store ($variables) {
68: global $client;
69:
70: $groups = $_REQUEST['groupselect'];
71: $iIdfrontenduser = (int)$_REQUEST['idfrontenduser'];
72: if (!is_array($groups)) {
73: $groups = array();
74: }
75:
76: $groupmembers = new cApiFrontendGroupMemberCollection();
77:
78: $fegroups = new cApiFrontendGroupCollection();
79: $fegroups->setWhere("idclient", $client);
80: $fegroups->query();
81:
82: $aFEGroups = array();
83:
84: while ($fegroup = $fegroups->next())
85: {
86: $groupmembers->remove($fegroup->get("idfrontendgroup"), $iIdfrontenduser);
87: if (in_array($fegroup->get("idfrontendgroup"), $groups)) {
88: $groupmembers->create($fegroup->get("idfrontendgroup"), $iIdfrontenduser);
89: }
90: }
91:
92: return true;
93: }
94:
95: function frontendusers_groupselect_canonicalVariables () {
96:
97: return array();
98: }
99:
100: function frontendusers_groupselect_getvalue ($key) {
101: return '';
102: }
103: ?>