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