Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • Newsletter
  • NewsletterCollection
  • NewsletterJob
  • NewsletterJobCollection
  • NewsletterLog
  • NewsletterLogCollection
  • NewsletterRecipient
  • NewsletterRecipientCollection
  • NewsletterRecipientGroup
  • NewsletterRecipientGroupCollection
  • NewsletterRecipientGroupMember
  • NewsletterRecipientGroupMemberCollection
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the Recipient groups class.
  4:  *
  5:  * @package Plugin
  6:  * @subpackage Newsletter
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Bjoern Behrens
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Recipient group management class.
 20:  *
 21:  * @package Plugin
 22:  * @subpackage Newsletter
 23:  */
 24: class NewsletterRecipientGroupCollection extends ItemCollection {
 25: 
 26:     /**
 27:      * Constructor Function
 28:      *
 29:      * @param none
 30:      */
 31:     public function __construct() {
 32:         global $cfg;
 33:         parent::__construct($cfg["tab"]["news_groups"], "idnewsgroup");
 34:         $this->_setItemClass("NewsletterRecipientGroup");
 35:     }
 36: 
 37:     /**
 38:      * Creates a new group
 39:      *
 40:      * @param $groupname string Specifies the groupname
 41:      * @param $defaultgroup integer Specfies, if group is default group
 42:      *        (optional)
 43:      */
 44:     public function create($groupname, $defaultgroup = 0) {
 45:         global $client, $lang;
 46: 
 47:         $client = cSecurity::toInteger($client);
 48:         $lang = cSecurity::toInteger($lang);
 49: 
 50:         $group = new NewsletterRecipientGroup();
 51: 
 52:         // _arrInFilters = array('urlencode', 'htmlspecialchars', 'addslashes');
 53: 
 54:         $mangledGroupName = $group->_inFilter($groupname);
 55:         $this->setWhere("idclient", $client);
 56:         $this->setWhere("idlang", $lang);
 57:         $this->setWhere("groupname", $mangledGroupName);
 58:         $this->query();
 59: 
 60:         if ($obj = $this->next()) {
 61:             $groupname = $groupname . md5(rand());
 62:         }
 63: 
 64:         $item = parent::createNewItem();
 65: 
 66:         $item->set("idclient", $client);
 67:         $item->set("idlang", $lang);
 68:         $item->set("groupname", $groupname);
 69:         $item->set("defaultgroup", $defaultgroup);
 70:         $item->store();
 71: 
 72:         return $item;
 73:     }
 74: 
 75:     /**
 76:      * Overridden delete method to remove groups from groupmember table
 77:      * before deleting group
 78:      *
 79:      * @param $itemID int specifies the newsletter recipient group
 80:      */
 81:     public function delete($itemID) {
 82:         $oAssociations = new NewsletterRecipientGroupMemberCollection();
 83:         $oAssociations->setWhere("idnewsgroup", $itemID);
 84:         $oAssociations->query();
 85: 
 86:         while ($oItem = $oAssociations->next()) {
 87:             $oAssociations->delete($oItem->get("idnewsgroupmember"));
 88:         }
 89:         parent::delete($itemID);
 90:     }
 91: 
 92: }
 93: 
 94: /**
 95:  * Single RecipientGroup Item
 96:  */
 97: class NewsletterRecipientGroup extends Item {
 98: 
 99:     /**
100:      * Constructor Function
101:      *
102:      * @param mixed $mId Specifies the ID of item to load
103:      */
104:     public function __construct($mId = false) {
105:         global $cfg;
106:         parent::__construct($cfg["tab"]["news_groups"], "idnewsgroup");
107:         if ($mId !== false) {
108:             $this->loadByPrimaryKey($mId);
109:         }
110:     }
111: 
112:     /**
113:      * Overriden store() method to ensure, that there is only one default group
114:      */
115:     public function store() {
116:         global $client, $lang;
117: 
118:         $client = cSecurity::toInteger($client);
119:         $lang = cSecurity::toInteger($lang);
120: 
121:         if ($this->get("defaultgroup") == 1) {
122:             $oItems = new NewsletterRecipientGroupCollection();
123:             $oItems->setWhere("idclient", $client);
124:             $oItems->setWhere("idlang", $lang);
125:             $oItems->setWhere("defaultgroup", 1);
126:             $oItems->setWhere("idnewsgroup", $this->get("idnewsgroup"), "<>");
127:             $oItems->query();
128: 
129:             while ($oItem = $oItems->next()) {
130:                 $oItem->set("defaultgroup", 0);
131:                 $oItem->store();
132:             }
133:         }
134:         return parent::store();
135:     }
136: 
137: }
138: 
139: /**
140:  * Recipient group member management class
141:  */
142: class NewsletterRecipientGroupMemberCollection extends ItemCollection {
143: 
144:     /**
145:      * Constructor Function
146:      *
147:      * @param none
148:      */
149:     public function __construct() {
150:         global $cfg;
151:         parent::__construct($cfg["tab"]["news_groupmembers"], "idnewsgroupmember");
152:         $this->_setJoinPartner('NewsletterRecipientGroupCollection');
153:         $this->_setJoinPartner('NewsletterRecipientCollection');
154:         $this->_setItemClass("NewsletterRecipientGroupMember");
155:     }
156: 
157:     /**
158:      * Creates a new association
159:      *
160:      * @param $idrecipientgroup int specifies the newsletter group
161:      * @param $idrecipient int specifies the newsletter user
162:      */
163:     public function create($idrecipientgroup, $idrecipient) {
164:         $idrecipientgroup = cSecurity::toInteger($idrecipientgroup);
165:         $idrecipient = cSecurity::toInteger($idrecipient);
166: 
167:         $this->setWhere("idnewsgroup", $idrecipientgroup);
168:         $this->setWhere("idnewsrcp", $idrecipient);
169:         $this->query();
170: 
171:         if ($this->next()) {
172:             return false;
173:         }
174: 
175:         $oItem = parent::createNewItem();
176: 
177:         $oItem->set("idnewsrcp", $idrecipient);
178:         $oItem->set("idnewsgroup", $idrecipientgroup);
179:         $oItem->store();
180: 
181:         return $oItem;
182:     }
183: 
184:     /**
185:      * Removes an association
186:      *
187:      * @param $idrecipientgroup int specifies the newsletter group
188:      * @param $idrecipient int specifies the newsletter user
189:      */
190:     public function remove($idrecipientgroup, $idrecipient) {
191:         $idrecipientgroup = cSecurity::toInteger($idrecipientgroup);
192:         $idrecipient = cSecurity::toInteger($idrecipient);
193: 
194:         $this->setWhere("idnewsgroup", $idrecipientgroup);
195:         $this->setWhere("idnewsrcp", $idrecipient);
196:         $this->query();
197: 
198:         if ($oItem = $this->next()) {
199:             $this->delete($oItem->get("idnewsgroupmember"));
200:         }
201:     }
202: 
203:     /**
204:      * Removes all associations from any newsletter group
205:      *
206:      * @param $idrecipient int specifies the newsletter recipient
207:      */
208:     public function removeRecipientFromGroups($idrecipient) {
209:         $idrecipient = cSecurity::toInteger($idrecipient);
210: 
211:         $this->setWhere("idnewsrcp", $idrecipient);
212:         $this->query();
213: 
214:         while ($oItem = $this->next()) {
215:             $this->delete($oItem->get("idnewsgroupmember"));
216:         }
217:     }
218: 
219:     /**
220:      * Removes all associations of a newsletter group
221:      *
222:      * @param $idgroup int specifies the newsletter recipient group
223:      */
224:     public function removeGroup($idgroup) {
225:         $idgroup = cSecurity::toInteger($idgroup);
226: 
227:         $this->setWhere("idnewsgroup", $idgroup);
228:         $this->query();
229: 
230:         while ($oItem = $this->next()) {
231:             $this->delete($oItem->get("idnewsgroupmember"));
232:         }
233:     }
234: 
235:     /**
236:      * Returns all recipients in a single group
237:      *
238:      * @param $idrecipientgroup int specifies the newsletter group
239:      * @param $asObjects boolean specifies if the function should return objects
240:      * @return array RecipientRecipient items
241:      */
242:     public function getRecipientsInGroup($idrecipientgroup, $asObjects = true) {
243:         $idrecipientgroup = cSecurity::toInteger($idrecipientgroup);
244: 
245:         $this->setWhere("idnewsgroup", $idrecipientgroup);
246:         $this->query();
247: 
248:         $aObjects = array();
249: 
250:         while ($oItem = $this->next()) {
251:             if ($asObjects) {
252:                 $oRecipient = new NewsletterRecipient();
253:                 $oRecipient->loadByPrimaryKey($oItem->get("idnewsrcp"));
254: 
255:                 $aObjects[] = $oRecipient;
256:             } else {
257:                 $aObjects[] = $oItem->get("idnewsrcp");
258:             }
259:         }
260: 
261:         return ($aObjects);
262:     }
263: 
264: }
265: 
266: /**
267:  * Single RecipientGroup Item
268:  */
269: class NewsletterRecipientGroupMember extends Item {
270: 
271:     /**
272:      * Constructor Function
273:      *
274:      * @param mixed $mId Specifies the ID of item to load
275:      */
276:     public function __construct($mId = false) {
277:         global $cfg;
278:         parent::__construct($cfg["tab"]["news_groupmembers"], "idnewsgroupmember");
279:         if ($mId !== false) {
280:             $this->loadByPrimaryKey($mId);
281:         }
282:     }
283: 
284: }
285: ?>
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0