oxnewssubscribed.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxNewsSubscribed extends oxBase
00009 {
00015     protected $_blWasSubscribed = false;
00016 
00022     protected $_sClassName = 'oxnewssubscribed';
00023 
00024 
00028     public function __construct()
00029     {
00030 
00031         parent::__construct();
00032 
00033         $this->init( 'oxnewssubscribed' );
00034     }
00035 
00036 
00044     public function load( $oxId )
00045     {
00046         $blRet = parent::load( $oxId );
00047 
00048         if ( $this->oxnewssubscribed__oxdboptin->value == 1) {
00049             $this->_blWasSubscribed = true;
00050         }
00051 
00052         return $blRet;
00053     }
00054 
00062     public function loadFromEmail( $sEmailAddress )
00063     {
00064             $sOxId = oxDb::getDb( true )->getOne( "select oxid from oxnewssubscribed where oxemail = '$sEmailAddress' " );
00065 
00066         return $this->load( $sOxId );
00067     }
00068 
00076     public function loadFromUserId( $sOxUserId )
00077     {
00078         $sOxId = oxDb::getDb( true )->getOne( "select oxid from oxnewssubscribed where oxuserid = '$sOxUserId' " );
00079         return $this->load( $sOxId );
00080     }
00081 
00087     protected function _insert()
00088     {
00089         // set subscription date
00090         $this->oxnewssubscribed__oxsubscribed = new oxField(date( 'Y-m-d H:i:s' ), oxField::T_RAW);
00091         return parent::_insert();
00092     }
00093 
00099     protected function _update()
00100     {
00101         if ( $this->_blWasSubscribed && !$this->oxnewssubscribed__oxdboptin->value ) {
00102             // set unsubscription date
00103             $this->oxnewssubscribed__oxunsubscribed->setValue(date( 'Y-m-d H:i:s' ));
00104         } else {
00105             // don't update date
00106             $this->_aSkipSaveFields[] = 'oxunsubscribed';
00107         }
00108 
00109         return parent::_update();
00110     }
00111 
00117     public function getOptInStatus()
00118     {
00119         return $this->oxnewssubscribed__oxdboptin->value;
00120     }
00121 
00129     public function setOptInStatus( $iStatus )
00130     {
00131         $this->oxnewssubscribed__oxdboptin = new oxField($iStatus, oxField::T_RAW);
00132         $this->save();
00133     }
00134 
00140     public function getOptInEmailStatus()
00141     {
00142         return $this->oxnewssubscribed__oxemailfailed->value;
00143     }
00144 
00152     public function setOptInEmailStatus( $iStatus )
00153     {
00154         $this->oxnewssubscribed__oxemailfailed = new oxField($iStatus, oxField::T_RAW);
00155         $this->save();
00156     }
00157 
00166     public function updateSubscription( $oUser )
00167     {
00168         // user email changed ?
00169         if ( $oUser->oxuser__oxusername->value && $this->oxnewssubscribed__oxemail->value != $oUser->oxuser__oxusername->value ) {
00170             $this->oxnewssubscribed__oxemail = new oxField( $oUser->oxuser__oxusername->value, oxField::T_RAW );
00171         }
00172 
00173         // updating some other fields
00174         $this->oxnewssubscribed__oxsal   = new oxField( $oUser->oxuser__oxsal->value, oxField::T_RAW );
00175         $this->oxnewssubscribed__oxfname = new oxField( $oUser->oxuser__oxfname->value, oxField::T_RAW );
00176         $this->oxnewssubscribed__oxlname = new oxField( $oUser->oxuser__oxlname->value, oxField::T_RAW );
00177 
00178         return (bool) $this->save();
00179     }
00180 }

Generated on Wed Apr 22 12:26:31 2009 for OXID eShop CE by  doxygen 1.5.5