Zend - The PHP Company




Email

Add Code


Icon Subscriber Class  

Type: class
Added by: iconinteractive
Entered: 10/09/2004
Last modified: 09/12/2003
Rating: - (fewer than 3 votes)
Views: 3921
The Subscription class provides functionality for managing subscrbers to Internet mailing lists. Zip archive containing all HTML files can be downloaded from http://www.iconinteractive.com/freeware/


<?php
Database functionality is hard
-coded into the class. The class assumes the following database information:
   
   
CREATE TABLE `blacklisted` (
    `
emailvarchar(75NOT NULL default '',
     
PRIMARY KEY  (`email`)
   ) 
TYPE=MyISAM;
   
   
CREATE TABLE `subscribers` (
    `
idbigint(20NOT NULL auto_increment,
    `
emailvarchar(75NOT NULL default '',
    `
namevarchar(75NOT NULL default '',
    `
activesmallint(1NOT NULL default '0',
    `
blacklistedsmallint(1NOT NULL default '0',
    `
timestampbigint(20NOT NULL default '0',
    
PRIMARY KEY  (`id`)
   ) 
TYPE=MyISAM;
   
   
CREATE TABLE `subscriptions` (
    `
idbigint(20NOT NULL auto_increment,
    `
subscriberidbigint(20NOT NULL default '0',
    `
topicidbigint(20NOT NULL default '0',
    `
activesmallint(1NOT NULL default '0',
    
PRIMARY KEY  (`id`)
   ) 
TYPE=MyISAM;
   
   
CREATE TABLE `topics` (
    `
idbigint(20NOT NULL auto_increment,
    `
topicvarchar(50NOT NULL default '',
    `
descriptiontext NOT NULL,
     
PRIMARY KEY  (`id`)
   ) 
TYPE=MyISAM
   
   
Public members
   
-------------------------------
   
$nameThe subscriber's name. Defaults to NULL
   $email: The subscriber'
s email addressDefaults to NULL
   
   
Public methods
   
-------------------------------
   
Subscription($subscriberemail,$subscribername)
     
Subscription is the constructor for this class. It takes two arguments$subscriberemail,
     and 
$subscribernameBoth argument's values are by default NULL. $subscriberemail needs to
     be set for the public method getSubscribeID() to return an id. $subscribername only needs to
     be set when running public method addSubscriber().
     
   printNewSubscriptionForm()
     prints out a form for new subscriptions
     
   printUnsubscribeForm()
     prints the form for unsubscribing to topics
     
   addSubscriber($topics)
     adds a new subscriber to the database and subscribes it to the topics contain in the argument $topics (array)
     
   addSubscription($topicid)
     subscribes the subscriber to the topic matching the argument $topicid
     
   removeSubscription($topicid)
     removes the topic matching the argument $topicid from the subscribers list of subscriptions
     
   getSubscriberID()
     returns the subscriber'
s id$this->email must be set before this will return a true value
     
   activate
()
     
activates a subscriber's account as well as all inactive subscriptions
     
   unsubscribe($blacklist=0)
     removes a subscriber'
s email and subscriptions from the system. If the argument $blacklist is setthe user's
     email address will be added to the blacklist. $blacklist'
s value is 0 by default
     
   
printSubscriptionForm()
     
prints the form for updating subscriptions
 
?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories