|
From: Greg M. <bli...@us...> - 2008-08-16 23:07:52
|
Update of /cvsroot/phpwebsite-comm/modules/ads/boost In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7344/boost Modified Files: boost.php update.php Log Message: Preparing for 1.3.0 Index: boost.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/ads/boost/boost.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** boost.php 22 Jun 2008 20:04:15 -0000 1.5 --- boost.php 16 Aug 2008 23:07:57 -0000 1.6 *************** *** 24,28 **** $proper_name = 'Ads'; ! $version = '1.2.0'; $register = FALSE; $unregister = FALSE; --- 24,28 ---- $proper_name = 'Ads'; ! $version = '1.3.0'; $register = FALSE; $unregister = FALSE; Index: update.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/ads/boost/update.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** update.php 22 Jun 2008 20:04:15 -0000 1.2 --- update.php 16 Aug 2008 23:07:57 -0000 1.3 *************** *** 42,45 **** --- 42,86 ---- $content[] = '- Added empty messages to DBPager.'; $content[] = '- Corrected a few phrases that were not being translated.'; + + case version_compare($currentVersion, '1.3.0', '<'): + /* Step 1: Update advertiser ids in campaign table to user ids. */ + $db = new PHPWS_DB('ads_campaigns'); + PHPWS_Error::logIfError($db->query('UPDATE ads_campaigns,ads_advertisers + SET ads_campaigns.advertiser_id = ads_advertisers.user_id + WHERE ( ads_campaigns.advertiser_id = ads_advertisers.id )')); + + /* Step 2: Read out current contents of advertisers table. */ + $db2 = new PHPWS_DB('ads_advertisers'); + $results = $db2->select(); + PHPWS_Error::logIfError($results); + + /* Step 3: Change advertisers table to new structure. */ + PHPWS_Error::logIfError($db2->dropTableColumn('id')); + PHPWS_Error::logIfError($db2->dropTableColumn('business')); + PHPWS_Error::logIfError($db2->createTableIndex('user_id', 'userid_idx', true)); + + /* Step 4: Update demographics table with advertiser business name. */ + if (!empty($results)) + { + PHPWS_Core::initModClass('ads', 'advertiser.php'); + Demographics::register('ads'); + + foreach ($results as $row) + { + $advertiser = new Ads_Advertiser($row['user_id']); + $advertiser->setBusinessName($row['business']); + PHPWS_Error::logIfError($advertiser->save()); + } + } + + /* Step 5: Update the templates. */ + $files = array('templates/advertiser/list.tpl', + 'templates/advertiser/select.tpl', + 'templates/advertiser/add.tpl'); + ads_update_files($files, $content); + + /* Done */ + $content[] = '- Now use demographics module to store the business name of advertisers.'; + $content[] = '- Removed call to help module which wasn\'t working anyway.'; } |