|
From: Greg M. <bli...@us...> - 2008-06-22 15:55:01
|
Update of /cvsroot/phpwebsite-comm/modules/ads/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19791/class Modified Files: ad.php advertiser.php campaign.php Log Message: Override needs to be passed from advertiser to campaign to ad. Index: campaign.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/ads/class/campaign.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** campaign.php 28 May 2007 21:21:49 -0000 1.10 --- campaign.php 22 Jun 2008 15:55:07 -0000 1.11 *************** *** 37,48 **** function Ads_Campaign($id=NULL) { ! if (empty($id)) { ! return; ! } ! $this->setId($id); ! $db = new PHPWS_DB('ads_campaigns'); ! $db->loadObject($this); } --- 37,47 ---- function Ads_Campaign($id=NULL) { ! if (!empty($id)) { ! $this->setId($id); ! $db = new PHPWS_DB('ads_campaigns'); ! $db->loadObject($this); ! } } *************** *** 129,174 **** } ! function clearAds() { $db = new PHPWS_DB('ads'); $db->addWhere('campaign_id', $this->id); $ads = $db->getObjects('Ads_Ad'); ! if (PEAR::isError($ads)) ! { ! PHPWS_Error::log($ads); ! } ! else if ($ads != NULL) { foreach ($ads as $ad) { ! $ad->kill(); } } } ! function kill() { ! $db = new PHPWS_DB('ads_advertisers'); ! $db->addWhere('id', $this->advertiser_id); ! $db->addColumn('username'); ! $result = $db->select('col'); ! if (($result[0] != Current_User::getUsername()) && !Current_User::authorized('ads')) { ! Current_User::disallow(); ! return; } $this->clearPins(); ! $this->clearAds(); $db = new PHPWS_DB('ads_campaigns'); $db->addWhere('id', $this->id); ! $result = $db->delete(); ! if (PEAR::isError($result)) ! { ! PHPWS_Error::log($result); ! return FALSE; ! } ! return TRUE; } --- 128,172 ---- } ! function clearAds($override) { $db = new PHPWS_DB('ads'); $db->addWhere('campaign_id', $this->id); $ads = $db->getObjects('Ads_Ad'); ! ! if (!PHPWS_Error::logIfError($ads) && ($ads != NULL)) { foreach ($ads as $ad) { ! $ad->kill($override); } } } ! /** ! * Removes campaign and associated ads from the database. ! * ! * @param override Should ONLY be used when user being deleted (see remove_user.php). ! */ ! function kill($override=false) { ! if (!$override) { ! $db = new PHPWS_DB('ads_advertisers'); ! $db->addWhere('id', $this->advertiser_id); ! $db->addColumn('username'); ! $result = $db->select('col'); ! if (($result[0] != Current_User::getUsername()) && !Current_User::authorized('ads')) ! { ! Current_User::disallow(); ! return; ! } } $this->clearPins(); ! $this->clearAds($override); $db = new PHPWS_DB('ads_campaigns'); $db->addWhere('id', $this->id); ! return !PHPWS_Error::logIfError($db->delete()); } *************** *** 183,189 **** $db->addWhere('ad_type', $zone->ad_type); $result = $db->getObjects('Ads_Ad'); ! if (PEAR::isError($result)) { - PHPWS_Error::log($result); return FALSE; } --- 181,186 ---- $db->addWhere('ad_type', $zone->ad_type); $result = $db->getObjects('Ads_Ad'); ! if (PHPWS_Error::logIfError($result)) { return FALSE; } *************** *** 250,256 **** $db->addWhere('campaign_id', $this->getId()); $result = $db->count(); ! if (PEAR::isError($result)) { - PHPWS_Error::log($result); return dgettext('ads', 'N/A'); } --- 247,252 ---- $db->addWhere('campaign_id', $this->getId()); $result = $db->count(); ! if (PHPWS_Error::logIfError($result)) { return dgettext('ads', 'N/A'); } Index: advertiser.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/ads/class/advertiser.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** advertiser.php 22 Jun 2008 14:27:46 -0000 1.7 --- advertiser.php 22 Jun 2008 15:55:07 -0000 1.8 *************** *** 109,113 **** } ! function clearCampaigns() { $db = new PHPWS_DB('ads_campaigns'); --- 109,113 ---- } ! function clearCampaigns($override) { $db = new PHPWS_DB('ads_campaigns'); *************** *** 119,123 **** foreach ($campaigns as $campaign) { ! $campaign->kill(); } } --- 119,123 ---- foreach ($campaigns as $campaign) { ! $campaign->kill($override); } } *************** *** 137,141 **** } ! $this->clearCampaigns(); $db = new PHPWS_DB('ads_advertisers'); $db->addWhere('id', $this->id); --- 137,141 ---- } ! $this->clearCampaigns($override); $db = new PHPWS_DB('ads_advertisers'); $db->addWhere('id', $this->id); Index: ad.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/ads/class/ad.php,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ad.php 28 May 2007 21:21:48 -0000 1.13 --- ad.php 22 Jun 2008 15:55:07 -0000 1.14 *************** *** 41,52 **** function Ads_Ad($id=NULL) { ! if (empty($id)) { ! return; ! } ! $this->setId($id); ! $db = new PHPWS_DB('ads'); ! $db->loadObject($this); } --- 41,51 ---- function Ads_Ad($id=NULL) { ! if (!empty($id)) { ! $this->setId($id); ! $db = new PHPWS_DB('ads'); ! $db->loadObject($this); ! } } *************** *** 139,146 **** return PHPWS_Text::parseOutput($this->ad_text); } ! else ! { ! return $this->ad_text; ! } } --- 138,143 ---- return PHPWS_Text::parseOutput($this->ad_text); } ! ! return $this->ad_text; } *************** *** 157,186 **** function getActive() { ! $vars['ad_id'] = $this->getId(); ! if ($this->active) ! { ! if (Current_User::allow('ads', 'hide_ads') && ($_REQUEST['module'] == 'ads')) ! { ! $vars['action'] = 'hideAd'; ! return PHPWS_Text::secureLink(dgettext('ads', 'Active'), 'ads', $vars); ! } ! else ! { ! return dgettext('ads', 'Active'); ! } ! } ! else { ! if (Current_User::allow('ads', 'hide_ads') && ($_REQUEST['module'] == 'ads')) ! { ! $vars['action'] = 'hideAd'; ! return PHPWS_Text::secureLink(dgettext('ads', 'Inactive'), 'ads', $vars); ! } ! else ! { ! return dgettext('ads', 'Inactive'); ! } } } --- 154,168 ---- function getActive() { ! $active = dgettext('ads', 'Active'); ! $inactive = dgettext('ads', 'Inactive'); ! if (Current_User::allow('ads', 'hide_ads') && ($_REQUEST['module'] == 'ads')) { ! $vars['ad_id'] = $this->getId(); ! $vars['action'] = 'hideAd'; ! return PHPWS_Text::secureLink(($this->active ? $active : $inactive), 'ads', $vars); } + + return ($this->active ? $active : $inactive); } *************** *** 255,265 **** $db = new PHPWS_DB('ads_stats'); $db->addWhere('id', $this->id); ! $result = $db->incrementColumn($stat); ! if (PEAR::isError($result)) ! { ! PHPWS_Error::log($result); ! return FALSE; ! } ! return TRUE; } --- 237,241 ---- $db = new PHPWS_DB('ads_stats'); $db->addWhere('id', $this->id); ! return !PHPWS_Error::logIfError($db->incrementColumn($stat)); } *************** *** 272,284 **** } ! if ($this->active) ! { ! $this->active = 0; ! } ! else ! { ! $this->active = 1; ! } ! return $this->save(FALSE); } --- 248,252 ---- } ! $this->active = ($this->active ? 0 : 1); return $this->save(FALSE); } *************** *** 331,347 **** } ! function kill() { PHPWS_Core::initModClass('version', 'Version.php'); ! $db = new PHPWS_DB('ads_campaigns'); ! $db->addWhere('ads_campaigns.id', $this->campaign_id); ! $db->addWhere('ads_advertisers.id', 'ads_campaigns.advertiser_id'); ! $db->addColumn('ads_advertisers.username'); ! $result = $db->select('col'); ! if (($result[0] != Current_User::getUsername()) && !Current_User::authorized('ads')) { ! Current_User::disallow(); ! return; } --- 299,323 ---- } ! /** ! * Removes ads and associated stats from the database. ! * ! * @param override Should ONLY be used when user being deleted (see remove_user.php). ! */ ! function kill($override=false) { PHPWS_Core::initModClass('version', 'Version.php'); ! if (!$override) { ! $db = new PHPWS_DB('ads_campaigns'); ! $db->addWhere('ads_campaigns.id', $this->campaign_id); ! $db->addWhere('ads_advertisers.id', 'ads_campaigns.advertiser_id'); ! $db->addColumn('ads_advertisers.username'); ! $result = $db->select('col'); ! if (($result[0] != Current_User::getUsername()) && !Current_User::authorized('ads')) ! { ! Current_User::disallow(); ! return; ! } } *************** *** 355,373 **** $db = new PHPWS_DB('ads_stats'); $db->addWhere('id', $this->id); ! $result = $db->delete(); ! if (PEAR::isError($result)) ! { ! PHPWS_Error::log($result); ! } $db = new PHPWS_DB('ads'); $db->addWhere('id', $this->id); ! $result = $db->delete(); ! if (PEAR::isError($result)) ! { ! PHPWS_Error::log($result); ! return FALSE; ! } ! return TRUE; } --- 331,339 ---- $db = new PHPWS_DB('ads_stats'); $db->addWhere('id', $this->id); ! PHPWS_Error::logIfError($db->delete()); $db = new PHPWS_DB('ads'); $db->addWhere('id', $this->id); ! return !PHPWS_Error::logIfError($db->delete()); } |