Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • 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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  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:         $group = new NewsletterRecipientGroup();
 48: 
 49:         // _arrInFilters = array('urlencode', 'htmlspecialchars', 'addslashes');
 50: 
 51:         $mangledGroupName = $group->_inFilter($groupname);
 52:         $this->setWhere("idclient", $client);
 53:         $this->setWhere("idlang", $lang);
 54:         $this->setWhere("groupname", $mangledGroupName);
 55:         $this->query();
 56: 
 57:         if ($obj = $this->next()) {
 58:             $groupname = $groupname . md5(rand());
 59:         }
 60: 
 61:         $item = $this->createNewItem();
 62: 
 63:         $item->set("idclient", $client);
 64:         $item->set("idlang", $lang);
 65:         $item->set("groupname", $groupname);
 66:         $item->set("defaultgroup", $defaultgroup);
 67:         $item->store();
 68: 
 69:         return $item;
 70:     }
 71: 
 72:     /**
 73:      * Overridden delete method to remove groups from groupmember table
 74:      * before deleting group
 75:      *
 76:      * @param $itemID int specifies the newsletter recipient group
 77:      */
 78:     public function delete($itemID) {
 79:         $oAssociations = new NewsletterRecipientGroupMemberCollection();
 80:         $oAssociations->setWhere("idnewsgroup", $itemID);
 81:         $oAssociations->query();
 82: 
 83:         while ($oItem = $oAssociations->next()) {
 84:             $oAssociations->delete($oItem->get("idnewsgroupmember"));
 85:         }
 86:         parent::delete($itemID);
 87:     }
 88: 
 89: }
 90: 
 91: /**
 92:  * Single RecipientGroup Item
 93:  */
 94: class NewsletterRecipientGroup extends Item {
 95: 
 96:     /**
 97:      * Constructor Function
 98:      *
 99:      * @param mixed $mId Specifies the ID of item to load
100:      */
101:     public function __construct($mId = false) {
102:         global $cfg;
103:         parent::__construct($cfg["tab"]["news_groups"], "idnewsgroup");
104:         if ($mId !== false) {
105:             $this->loadByPrimaryKey($mId);
106:         }
107:     }
108: 
109:     /**
110:      * Overriden store() method to ensure, that there is only one default group
111:      */
112:     public function store() {
113:         global $client, $lang;
114: 
115:         $client = cSecurity::toInteger($client);
116:         $lang = cSecurity::toInteger($lang);
117: 
118:         if ($this->get("defaultgroup") == 1) {
119:             $oItems = new NewsletterRecipientGroupCollection();
120:             $oItems->setWhere("idclient", $client);
121:             $oItems->setWhere("idlang", $lang);
122:             $oItems->setWhere("defaultgroup", 1);
123:             $oItems->setWhere("idnewsgroup", $this->get("idnewsgroup"), "<>");
124:             $oItems->query();
125: 
126:             while ($oItem = $oItems->next()) {
127:                 $oItem->set("defaultgroup", 0);
128:                 $oItem->store();
129:             }
130:         }
131:         return parent::store();
132:     }
133:     
134:     /**
135:      * Userdefined setter for newsletter recipient group fields.
136:      *
137:      * @param string $name
138:      * @param mixed $value
139:      * @param bool $bSafe Flag to run defined inFilter on passed value
140:      */
141:     public function setField($name, $value, $bSafe = true) {
142:         switch ($name) {
143:             case 'idclient':
144:                 $value = (int) $value;
145:                 break;
146:             case 'idlang':
147:                 $value = (int) $value;
148:                 break;
149:         }
150: 
151:         return parent::setField($name, $value, $bSafe);
152:     }
153: 
154: }
155: 
156: /**
157:  * Recipient group member management class
158:  */
159: class NewsletterRecipientGroupMemberCollection extends ItemCollection {
160: 
161:     /**
162:      * Constructor Function
163:      *
164:      * @param none
165:      */
166:     public function __construct() {
167:         global $cfg;
168:         parent::__construct($cfg["tab"]["news_groupmembers"], "idnewsgroupmember");
169:         $this->_setJoinPartner('NewsletterRecipientGroupCollection');
170:         $this->_setJoinPartner('NewsletterRecipientCollection');
171:         $this->_setItemClass("NewsletterRecipientGroupMember");
172:     }
173: 
174:     /**
175:      * Creates a new association
176:      *
177:      * @param $idrecipientgroup int specifies the newsletter group
178:      * @param $idrecipient int specifies the newsletter user
179:      */
180:     public function create($idrecipientgroup, $idrecipient) {
181: 
182:         $this->setWhere("idnewsgroup", $idrecipientgroup);
183:         $this->setWhere("idnewsrcp", $idrecipient);
184:         $this->query();
185: 
186:         if ($this->next()) {
187:             return false;
188:         }
189: 
190:         $oItem = parent::createNewItem();
191: 
192:         $oItem->set("idnewsrcp", $idrecipient);
193:         $oItem->set("idnewsgroup", $idrecipientgroup);
194:         $oItem->store();
195: 
196:         return $oItem;
197:     }
198: 
199:     /**
200:      * Removes an association
201:      *
202:      * @param $idrecipientgroup int specifies the newsletter group
203:      * @param $idrecipient int specifies the newsletter user
204:      */
205:     public function remove($idrecipientgroup, $idrecipient) {
206:         $idrecipientgroup = cSecurity::toInteger($idrecipientgroup);
207:         $idrecipient = cSecurity::toInteger($idrecipient);
208: 
209:         $this->setWhere("idnewsgroup", $idrecipientgroup);
210:         $this->setWhere("idnewsrcp", $idrecipient);
211:         $this->query();
212: 
213:         if ($oItem = $this->next()) {
214:             $this->delete($oItem->get("idnewsgroupmember"));
215:         }
216:     }
217: 
218:     /**
219:      * Removes all associations from any newsletter group
220:      *
221:      * @param $idrecipient int specifies the newsletter recipient
222:      */
223:     public function removeRecipientFromGroups($idrecipient) {
224:         $idrecipient = cSecurity::toInteger($idrecipient);
225: 
226:         $this->setWhere("idnewsrcp", $idrecipient);
227:         $this->query();
228: 
229:         while ($oItem = $this->next()) {
230:             $this->delete($oItem->get("idnewsgroupmember"));
231:         }
232:     }
233: 
234:     /**
235:      * Removes all associations of a newsletter group
236:      *
237:      * @param $idgroup int specifies the newsletter recipient group
238:      */
239:     public function removeGroup($idgroup) {
240:         $idgroup = cSecurity::toInteger($idgroup);
241: 
242:         $this->setWhere("idnewsgroup", $idgroup);
243:         $this->query();
244: 
245:         while ($oItem = $this->next()) {
246:             $this->delete($oItem->get("idnewsgroupmember"));
247:         }
248:     }
249: 
250:     /**
251:      * Returns all recipients in a single group
252:      *
253:      * @param $idrecipientgroup int specifies the newsletter group
254:      * @param $asObjects boolean specifies if the function should return objects
255:      * @return array RecipientRecipient items
256:      */
257:     public function getRecipientsInGroup($idrecipientgroup, $asObjects = true) {
258:         $idrecipientgroup = cSecurity::toInteger($idrecipientgroup);
259: 
260:         $this->setWhere("idnewsgroup", $idrecipientgroup);
261:         $this->query();
262: 
263:         $aObjects = array();
264: 
265:         while ($oItem = $this->next()) {
266:             if ($asObjects) {
267:                 $oRecipient = new NewsletterRecipient();
268:                 $oRecipient->loadByPrimaryKey($oItem->get("idnewsrcp"));
269: 
270:                 $aObjects[] = $oRecipient;
271:             } else {
272:                 $aObjects[] = $oItem->get("idnewsrcp");
273:             }
274:         }
275: 
276:         return ($aObjects);
277:     }
278: 
279: }
280: 
281: /**
282:  * Single RecipientGroup Item
283:  */
284: class NewsletterRecipientGroupMember extends Item {
285: 
286:     /**
287:      * Constructor Function
288:      *
289:      * @param mixed $mId Specifies the ID of item to load
290:      */
291:     public function __construct($mId = false) {
292:         global $cfg;
293:         parent::__construct($cfg["tab"]["news_groupmembers"], "idnewsgroupmember");
294:         if ($mId !== false) {
295:             $this->loadByPrimaryKey($mId);
296:         }
297:     }
298: 
299:     /**
300:      * Userdefined setter for newsletter recipient group member fields.
301:      *
302:      * @param string $name
303:      * @param mixed $value
304:      * @param bool $bSafe Flag to run defined inFilter on passed value
305:      */
306:     public function setField($name, $value, $bSafe = true) {
307:         switch ($name) {
308:             case 'idnewsgroup':
309:                 $value = (int) $value;
310:                 break;
311:             case 'idnewsrcp':
312:                 $value = (int) $value;
313:                 break;
314:         }
315: 
316:         return parent::setField($name, $value, $bSafe);
317:     }
318:     
319: }
320: ?>
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen