Changeset 730 for trunk/phpbms/modules
- Timestamp:
- 01/07/10 18:13:51 (2 years ago)
- Location:
- trunk/phpbms/modules/mailchimp
- Files:
-
- 7 modified
-
adminsettings.php (modified) (14 diffs)
-
include/list_sync.php (modified) (34 diffs)
-
install/tableoptions.sql (modified) (1 diff)
-
manual_list_sync.php (modified) (1 diff)
-
manual_list_sync_ajax.php (modified) (1 diff)
-
report/basic_mc.php (modified) (1 diff)
-
scheduler_list_sync.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpbms/modules/mailchimp/adminsettings.php
r686 r730 1 1 <?php 2 /* 3 $Rev: 267 $ | $LastChangedBy: brieb $ 4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 5 +-------------------------------------------------------------------------+ 6 | Copyright (c) 2004 - 2010, Kreotek LLC | 7 | All rights reserved. | 8 +-------------------------------------------------------------------------+ 9 | | 10 | Redistribution and use in source and binary forms, with or without | 11 | modification, are permitted provided that the following conditions are | 12 | met: | 13 | | 14 | - Redistributions of source code must retain the above copyright | 15 | notice, this list of conditions and the following disclaimer. | 16 | | 17 | - Redistributions in binary form must reproduce the above copyright | 18 | notice, this list of conditions and the following disclaimer in the | 19 | documentation and/or other materials provided with the distribution. | 20 | | 21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 22 | be used to endorse or promote products derived from this software | 23 | without specific prior written permission. | 24 | | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 36 | | 37 +-------------------------------------------------------------------------+ 38 */ 2 39 class mailchimpUpdate{ 3 40 4 41 function updateSettings($variables){ 5 42 6 43 if(!isset($variables["mailchimp_secure"])) 7 44 $variables["mailchimp_secure"] = 0; 8 45 9 46 /** 10 47 * Check for a valid api key. … … 12 49 if($variables["apikey_changed"] == "1" && $variables["mailchimp_apikey"] != ""){ 13 50 include_once("include/MCAPI.class.php"); 14 51 15 52 $api = new MCAPI($variables["mailchimp_apikey"]); 16 53 $api->ping(); … … 20 57 return $variables; 21 58 }//end if 22 59 23 60 }//end if 24 25 61 62 26 63 /** 27 * Check for valid list id 64 * Check for valid list id 28 65 */ 29 66 if($variables["apilist_changed"] == "1" && $variables["mailchimp_list_id"] != ""){ 30 67 include_once("include/MCAPI.class.php"); 31 68 32 69 /** 33 70 * Check to see if api is already defined (from a possible api key check) … … 43 80 }//end if 44 81 }//end if 45 82 46 83 /** 47 84 * Look up the lists … … 53 90 return $variables; 54 91 }else{ 55 92 56 93 /** 57 * Check to see if list id is valid 94 * Check to see if list id is valid 58 95 */ 59 96 $validId = false; … … 63 100 break; 64 101 }//endif 65 102 66 103 if(!$validId){ 67 104 unset($variables["mailchimp_list_id"]); … … 69 106 return $variables; 70 107 }else{ 71 72 /** 73 * Check to see if the list has a uuid. 108 109 /** 110 * Check to see if the list has a uuid. 74 111 */ 75 112 $hasUuid = false; … … 82 119 return $variables; 83 120 }//end if 84 121 85 122 $req = array(); 86 123 foreach($mergeVars as $mergeVar){ 87 124 88 125 switch($mergeVar["tag"]){ 89 126 90 127 case "UUID": 91 128 $hasUuid = true; 92 129 break; 93 130 94 131 case "COMPANY": 95 132 $hasCompany = true; 96 133 break; 97 134 98 135 case "TYPE": 99 136 $hasType = true; 100 137 break; 101 138 102 139 }//end switch 103 140 104 141 }//end foreach 105 106 /** 107 * If it doesn't have a uuid field, create it. 142 143 /** 144 * If it doesn't have a uuid field, create it. 108 145 */ 109 146 if(!$hasUuid){ … … 119 156 return $variables; 120 157 }//end if 121 122 }//end if 123 124 /** 125 * If it doesn't have a company field, create it. 158 159 }//end if 160 161 /** 162 * If it doesn't have a company field, create it. 126 163 */ 127 164 if(!$hasCompany){ … … 137 174 return $variables; 138 175 }//end if 139 140 }//end if 141 142 /** 143 * If it doesn't have a type field, create it. 176 177 }//end if 178 179 /** 180 * If it doesn't have a type field, create it. 144 181 */ 145 182 if(!$hasType){ … … 155 192 return $variables; 156 193 }//end if 157 158 }//end if 159 160 161 /** 162 * If the date list id has changed, the last sync date must be reset: 194 195 }//end if 196 197 198 /** 199 * If the date list id has changed, the last sync date must be reset: 163 200 */ 164 201 $variables["mailchimp_last_sync_date"] = ""; 165 202 166 203 }//end if 167 204 168 205 }//end if 169 206 170 207 }//end if 171 208 172 209 return $variables; 173 210 174 211 }//end function 175 176 212 213 177 214 }//end class 178 215 … … 186 223 $theinput = new inputField("mailchimp_apikey",$therecord["mailchimp_apikey"],"mailchimp apikey", false, NULL, 48); 187 224 $fields[] = $theinput; 188 225 189 226 $theinput = new inputCheckbox("mailchimp_secure", $therecord["mailchimp_secure"], "use ssl connection"); 190 227 $fields[] = $theinput; 191 228 192 229 $theinput = new inputField("mailchimp_list_id", $therecord["mailchimp_list_id"], "list id"); 193 230 $fields[] = $theinput; 194 231 195 232 $theinput = new inputField("mailchimp_last_sync_date", $therecord["mailchimp_last_sync_date"], "last sync date"); 196 233 $theinput->setAttribute("class", "uneditable"); … … 207 244 <legend>Main</legend> 208 245 209 246 210 247 <input type="hidden" id="apikey_changed" name="apikey_changed" value="0" /> 211 248 212 249 <p> 213 250 <span class="notes"> … … 216 253 </span> 217 254 </p> 218 255 219 256 <p> 220 257 <?php echo $theform->showField("mailchimp_apikey");?> -
trunk/phpbms/modules/mailchimp/include/list_sync.php
r684 r730 1 1 <?php 2 /* 3 $Rev: 267 $ | $LastChangedBy: brieb $ 4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 5 +-------------------------------------------------------------------------+ 6 | Copyright (c) 2004 - 2010, Kreotek LLC | 7 | All rights reserved. | 8 +-------------------------------------------------------------------------+ 9 | | 10 | Redistribution and use in source and binary forms, with or without | 11 | modification, are permitted provided that the following conditions are | 12 | met: | 13 | | 14 | - Redistributions of source code must retain the above copyright | 15 | notice, this list of conditions and the following disclaimer. | 16 | | 17 | - Redistributions in binary form must reproduce the above copyright | 18 | notice, this list of conditions and the following disclaimer in the | 19 | documentation and/or other materials provided with the distribution. | 20 | | 21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 22 | be used to endorse or promote products derived from this software | 23 | without specific prior written permission. | 24 | | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 36 | | 37 +-------------------------------------------------------------------------+ 38 */ 2 39 class listSync{ 3 40 4 41 /** 5 42 * $lastSyncDate … … 18 55 */ 19 56 var $listId; 20 57 21 58 /** 22 59 * $api … … 41 78 */ 42 79 var $stopScript = false; 43 44 80 81 45 82 /** 46 83 * function listSync … … 54 91 * @param bool $secure Whether to send info over ssl 55 92 */ 56 93 57 94 function listSync($db, $apiKey, $listId, $lastSyncDate = NULL, $batchlimit = NULL, $secure = false){ 58 95 59 96 $this->db = $db; 60 97 $this->listId = $listId; 61 98 62 99 /** 63 100 * Check for a valid datetime format? … … 65 102 if($lastSyncDate) 66 103 $this->lastSyncDate = $lastSyncDate; 67 104 68 105 if((int)$batchlimit > 0) 69 106 $this->batchlimit = (int)$batchlimit; 70 107 71 108 $this->api = new MCAPI($apiKey, NULL, $secure); 72 109 $this->api->ping(); … … 75 112 return false; 76 113 }//end if 77 114 78 115 /** 79 116 * check to see if there is a uuid field … … 85 122 return false; 86 123 }//end if 87 124 88 125 foreach($mergeVars as $mergeVar){ 89 126 90 127 if($mergeVar["tag"] == "UUID"){ 91 128 $hasUuid = true; 92 129 break; 93 130 }//end if 94 131 95 132 }//end foreach 96 133 97 134 if(!$hasUuid){ 98 135 $this->_addError("The list does not have a merge variable with tag of 'UUID'.", NULL, true); 99 136 return false; 100 137 } 101 138 102 139 }//end function 103 140 104 141 /** 105 142 * function _addError 106 143 * 107 144 * Add an error to the class' error array. 108 * 145 * 109 146 * @param string $message Text of error message 110 147 * @param int $errorCode Error number … … 112 149 * function needs to be stopped. 113 150 */ 114 151 115 152 function _addError($message, $errorCode = NULL, $fatal = false){ 116 153 117 154 $tempArray["message"] = $message; 118 155 $tempArray["code"] = $errorCode; 119 156 120 157 if($fatal){ 121 158 $this->stopScript = true; … … 124 161 $tempArray["errorType"] = "warning"; 125 162 }//end if 126 163 127 164 $this->errors[] = $tempArray; 128 165 129 166 }//end function 130 131 167 168 132 169 /** 133 170 * function _reportResult … … 140 177 * code pairs. 141 178 */ 142 179 143 180 function _reportResult(){ 144 181 145 182 $return = array(); 146 183 147 184 if(count($this->errors)){ 148 185 149 186 if($this->stopScript) 150 187 $return["type"] = "error"; 151 188 else 152 189 $return["type"] = "warning"; 153 190 154 191 $return["details"] = $this->errors; 155 192 156 193 }else{ 157 194 158 195 $return["type"] = "success"; 159 196 $return["details"] = array(); 160 161 }//end if 162 197 198 }//end if 199 163 200 return $return; 164 201 165 202 }//end foreach 166 167 203 204 168 205 /** 169 206 * function pullChanges … … 173 210 * address. 174 211 */ 175 212 176 213 function pullChanges(){ 177 178 /** 179 * pull all the unsubscribed 214 215 /** 216 * pull all the unsubscribed 180 217 */ 181 218 $unsubscribed = array(); 182 219 $start = 0; 183 220 do{ 184 221 185 222 $members = $this->api->listMembers($this->listId, 'unsubscribed', $this->lastSyncDate, $start, $this->batchLimit); 186 223 if($this->api->errorCode){ … … 188 225 return false; 189 226 }//end if 190 227 191 228 foreach($members as $member){ 192 229 193 230 $info = $this->api->listMemberInfo($this->listId, $member["email"]); 194 231 if($this->api->errorCode){ … … 196 233 return false; 197 234 }//end if 198 235 199 236 $unsubscribed[] = $info["merges"]["UUID"]; 200 237 201 238 }//end foreach 202 239 203 240 $start++; 204 241 }while(count($members) == $this->batchLimit); 205 206 /** 207 * pull all the cleaned 242 243 /** 244 * pull all the cleaned 208 245 */ 209 246 $start = 0; 210 247 do{ 211 248 212 249 $members = $this->api->listMembers($this->listId, 'cleaned', $this->lastSyncDate, $start, $this->batchLimit); 213 250 if($this->api->errorCode){ … … 215 252 return false; 216 253 }//end ifd 217 254 218 255 foreach($members as $member){ 219 256 220 257 $info = $this->api->listMemberInfo($this->listId, $member["email"]); 221 258 if($this->api->errorCode){ … … 224 261 }//end if 225 262 $unsubscribed[] = $info["merges"]["UUID"]; 226 263 227 264 }//end foreach 228 265 229 266 $start++; 230 267 }while(count($members) == $this->batchLimit); 231 232 268 269 233 270 /** 234 271 * If there are records to unsubscribe, set their `canemail` to '0' 235 272 */ 236 273 if(count($unsubscribed)){ 237 274 238 275 /** 239 * construct the in statement 276 * construct the in statement 240 277 */ 241 278 $inValues = ""; 242 279 foreach($unsubscribed as $uuid) 243 280 $inValues .= ",'".$uuid."'"; 244 281 245 282 $inValues = substr($inValues, 1); 246 283 247 284 /** 248 285 * set the cleaned/unsubscribed to canemail = 0 … … 256 293 `uuid` IN (".$inValues.") 257 294 "; 258 295 259 296 $queryresult = $this->db->query($querystatement); 260 261 }//end if 262 297 298 }//end if 299 263 300 }//end function 264 301 265 302 /** 266 303 * function unsubscribeInvalid 267 * 304 * 268 305 * Unsubscribe the emails that are related to 269 306 * client records those that don't have an email (or don't exist), 270 307 * or that can't be emailed anymore. 271 308 */ 272 309 273 310 function unsubscribeInvalid(){ 274 311 275 312 /** 276 313 * Get rid of the temorary table. … … 281 318 "; 282 319 $this->db->query($dropTableStatement); 283 284 /** 285 * Create a temporary table 320 321 /** 322 * Create a temporary table 286 323 */ 287 324 $createTableStatement = " … … 291 328 `email` varchar(128) default NULL 292 329 ) ENGINE=INNODB"; 293 330 294 331 $this->db->query($createTableStatement); 295 296 /** 297 * pull all the subscribed 332 333 /** 334 * pull all the subscribed 298 335 */ 299 336 $start = 0; 300 do{ 337 do{ 301 338 $valuesClause = ""; 302 339 303 340 $members = $this->api->listMembers($this->listId, 'subscribed', NULL, $start, $this->batchLimit); 304 341 … … 307 344 return false; 308 345 }//end if 309 346 310 347 foreach($members as $member) 311 348 $valuesClause .= ",('".$member["email"]."')"; 312 349 313 350 $valuesClause = substr($valuesClause, 1); 314 315 351 352 316 353 /** 317 * Put the subscribed into a temporary table 354 * Put the subscribed into a temporary table 318 355 */ 319 356 if($valuesClause){ … … 324 361 VALUES 325 362 ".$valuesClause; 326 363 327 364 $this->db->query($insertStatement); 328 365 }//end if 329 366 330 367 $start++; 331 368 }while(count($members) == $this->batchLimit); 332 369 333 370 334 371 /** 335 372 * Get all the emails of client records that are subscribed … … 346 383 `clients`.`email` IS NULL 347 384 "; 348 385 349 386 $selectresult = $this->db->query($selectStatement); 350 387 351 388 /** 352 389 * Unsubscribe them from the mailchimp list … … 355 392 while($therecord = $this->db->fetchArray($selectresult)) 356 393 $unsubscribeList[] = $therecord["email"]; 357 358 /** 359 * If there are records to unsubscribe (deleted), do so. 394 395 /** 396 * If there are records to unsubscribe (deleted), do so. 360 397 */ 361 398 if(count($unsubscribeList)){ 362 399 363 400 $return = $this->api->listBatchUnsubscribe($this->listId, $unsubscribeList, true, false); 364 401 if ($this->api->errorCode){ … … 368 405 foreach($return['errors'] as $val) 369 406 $this->_addError("Unsubscribing email ".$val["email"]." failed: ".$val["message"], $val["code"]); 370 371 }//end if 372 407 408 }//end if 409 373 410 /** 374 411 * Get rid of the temorary table. … … 379 416 "; 380 417 $this->db->query($dropTableStatement); 381 418 382 419 }//end function 383 384 420 421 385 422 /** 386 423 * function pushChanges … … 390 427 */ 391 428 function pushChanges(){ 392 429 393 430 /** 394 431 * Get the changed records / fields … … 411 448 `canemail` != '0' 412 449 "; 413 450 414 451 /** 415 452 * If there is a last sync *date*, limit the records by their modified … … 418 455 if($this->lastSyncDate) 419 456 $querystatement .= " AND `modifieddate` > '".$this->lastSyncDate."'"; 420 421 457 458 422 459 $queryresult = $this->db->query($querystatement); 423 460 424 461 /** 425 462 * Format the variables to be interpreted by Mailchimp. … … 427 464 $batchVars = array(); 428 465 while($therecord = $this->db->fetchArray($queryresult)){ 429 466 430 467 $tempArray["EMAIL"] = $therecord["email"]; 431 468 $tempArray["FNAME"] = $therecord["firstname"]; … … 434 471 $tempArray["TYPE"] = $therecord["type"]; 435 472 $tempArray["UUID"] = $therecord["uuid"]; 436 473 437 474 $batchVars[] = $tempArray; 438 475 }//end while 439 440 /** 441 * Update / Insert the changes 476 477 /** 478 * Update / Insert the changes 442 479 */ 443 480 if(count($batchVars)){ 444 481 445 482 $return = $this->api->listBatchSubscribe($this->listId, $batchVars, false, true); 446 483 if($this->api->errorCode){ … … 448 485 return false; 449 486 }else{ 450 487 451 488 $instatement = ""; 452 489 453 490 foreach($return['errors'] as $val){ 454 491 455 492 $this->_addError("Subscribing or updating uuid '".$val["row"]["UUID"]."' failed: ".$val["message"], $val["code"]); 456 493 457 494 $memberInfo = $this->api->listMemberInfo($this->listId, $val["row"]["EMAIL"]); 458 495 459 496 if($memberInfo["status"] != "subcribed") 460 497 $instatement .= ", '".$val["row"]["UUID"]."'"; 461 498 462 499 }//end foreach 463 500 464 501 if($instatement){ 465 502 466 503 $instatement = substr($instatement, 2); 467 504 $instatement = "(".$instatement.")"; 468 505 469 506 $updatestatement = " 470 507 UPDATE … … 475 512 WHERE 476 513 `uuid` IN ".$instatement; 477 514 478 515 $this->db->query($updatestatement); 479 516 480 517 }//end if 481 518 482 519 }//end if 483 484 }//end if 485 520 521 }//end if 522 486 523 }//end function 487 488 524 525 489 526 /* 490 527 * function resetSyncDate … … 492 529 * Set the last sync date in the settings table to be NOW() 493 530 */ 494 531 495 532 function resetSyncDate() { 496 533 497 534 $querystatement = " 498 535 UPDATE … … 503 540 `name` = 'mailchimp_last_sync_date' 504 541 "; 505 542 506 543 $queryresult = $this->db->query($querystatement); 507 544 508 545 }//end if 509 510 546 547 511 548 /** 512 549 * function process 513 * 550 * 514 551 * Perform the list sync 515 552 */ 516 553 function process(){ 517 554 518 555 if(!$this->stopScript) 519 556 $this->pullChanges(); … … 524 561 if(!$this->stopScript) 525 562 $this->resetSyncDate(); 526 563 527 564 return $this->_reportResult(); 528 565 529 566 }//end function 530 567 531 568 }//end class 532 569 ?> -
trunk/phpbms/modules/mailchimp/install/tableoptions.sql
r682 r730 1 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', 'massEmail', 'sync to MailChimp', '0', '1', ' ', '100');1 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', 'massEmail', 'sync to MailChimp', '0', '1', 'Admin', '100'); -
trunk/phpbms/modules/mailchimp/manual_list_sync.php
r717 r730 1 1 <?php 2 /* 3 $Rev: 267 $ | $LastChangedBy: brieb $ 4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 5 +-------------------------------------------------------------------------+ 6 | Copyright (c) 2004 - 2010, Kreotek LLC | 7 | All rights reserved. | 8 +-------------------------------------------------------------------------+ 9 | | 10 | Redistribution and use in source and binary forms, with or without | 11 | modification, are permitted provided that the following conditions are | 12 | met: | 13 | | 14 | - Redistributions of source code must retain the above copyright | 15 | notice, this list of conditions and the following disclaimer. | 16 | | 17 | - Redistributions in binary form must reproduce the above copyright | 18 | notice, this list of conditions and the following disclaimer in the | 19 | documentation and/or other materials provided with the distribution. | 20 | | 21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 22 | be used to endorse or promote products derived from this software | 23 | without specific prior written permission. | 24 | | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 36 | | 37 +-------------------------------------------------------------------------+ 38 */ 2 39 require_once("../../include/session.php"); 40 41 $querystatement = " 42 SELECT 43 roleid 44 FROM 45 tableoptions 46 WHERE 47 name= 'massemail' 48 AND tabledefid = 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083' 49 "; 50 51 $queryresult = $this->db->query($querystatement); 52 53 $therecord = $this->db->fetchArray($queryresult); 54 55 if(!hasRights($therecord["roleid"])) 56 goURL(APP_PATH."noaccess.php"); 3 57 4 58 $pageTitle = "MailChimp List Sync"; -
trunk/phpbms/modules/mailchimp/manual_list_sync_ajax.php
r686 r730 1 1 <?php 2 require("../../include/session.php"); 3 include("include/MCAPI.class.php");//for MCAPI CLASS (listSync class uses it) 4 include("include/list_sync.php");//for listSync class 2 /* 3 $Rev: 267 $ | $LastChangedBy: brieb $ 4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 5 +-------------------------------------------------------------------------+ 6 | Copyright (c) 2004 - 2010, Kreotek LLC | 7 | All rights reserved. | 8 +-------------------------------------------------------------------------+ 9 | | 10 | Redistribution and use in source and binary forms, with or without | 11 | modification, are permitted provided that the following conditions are | 12 | met: | 13 | | 14 | - Redistributions of source code must retain the above copyright | 15 | notice, this list of conditions and the following disclaimer. | 16 | | 17 | - Redistributions in binary form must reproduce the above copyright | 18 | notice, this list of conditions and the following disclaimer in the | 19 | documentation and/or other materials provided with the distribution. | 20 | | 21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 22 | be used to endorse or promote products derived from this software | 23 | without specific prior written permission. | 24 | | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 36 | | 37 +-------------------------------------------------------------------------+ 38 */ 39 40 class manualSync{ 41 42 var $db; 43 44 function manualSync($db){ 45 46 $this->db = $db; 47 $this->db->errorFormat = "json"; 48 49 }//end function init 5 50 6 51 7 $listSync = new listSync( 8 $db, 9 MAILCHIMP_APIKEY, 10 MAILCHIMP_LIST_ID, 11 MAILCHIMP_LAST_SYNC_DATE, 12 NULL, 13 MAILCHIMP_SECURE 14 ); 52 function checkSecurity(){ 15 53 16 $response = $listSync->process(); 54 $querystatement = " 55 SELECT 56 roleid 57 FROM 58 tableoptions 59 WHERE 60 name= 'massemail' 61 AND tabledefid = 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083' 62 "; 17 63 18 if(!isset($response["type"])){ 19 $response = array(); 20 $response["type"] = "error"; 21 $response["details"] = array("message"=>"Fatal error: no valid response from script.", "code"=>NULL); 22 }//end if 64 $queryresult = $this->db->query($querystatement); 23 65 24 $response = json_encode($response); 25 echo($response); 26 exit; 66 $therecord = $this->db->fetchArray($queryresult); 67 68 if(hasRights($therecord["roleid"])) 69 return true; 70 else 71 return false; 72 73 }//end function checkSecurity 74 75 76 function sync(){ 77 78 $listSync = new listSync( 79 $this->db, 80 MAILCHIMP_APIKEY, 81 MAILCHIMP_LIST_ID, 82 MAILCHIMP_LAST_SYNC_DATE, 83 NULL, 84 MAILCHIMP_SECURE 85 ); 86 87 $response = $listSync->process(); 88 89 if(!isset($response["type"])){ 90 $response = array(); 91 $response["type"] = "error"; 92 $response["details"] = array("message"=>"Fatal error: no valid response from script.", "code"=>NULL); 93 }//end if 94 95 $response = json_encode($response); 96 echo($response); 97 98 }//end function sync 99 100 }//end class 101 102 /** 103 * PROCESSING ================================================================== 104 */ 105 if(!isset($noOutput)){ 106 107 require("../../include/session.php"); 108 include("include/MCAPI.class.php");//for MCAPI CLASS (listSync class uses it) 109 include("include/list_sync.php");//for listSync class 110 111 $sync = new manualSync($db); 112 113 if($sync->checkSecurity()) 114 $sync->sync(); 115 else{ 116 117 $response = array(); 118 $response["type"] = "error"; 119 $response["details"] = array("message"=>"No rights to run script", "code"=>NULL); 120 echo json_encode($response); 121 122 }//endif 123 124 }//endif 125 126 27 127 ?> -
trunk/phpbms/modules/mailchimp/report/basic_mc.php
r677 r730 1 1 <?php 2 /* 3 $Rev: 267 $ | $LastChangedBy: brieb $ 4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 5 +-------------------------------------------------------------------------+ 6 | Copyright (c) 2004 - 2010, Kreotek LLC | 7 | All rights reserved. | 8 +-------------------------------------------------------------------------+ 9 | | 10 | Redistribution and use in source and binary forms, with or without | 11 | modification, are permitted provided that the following conditions are | 12 | met: | 13 | | 14 | - Redistributions of source code must retain the above copyright | 15 | notice, this list of conditions and the following disclaimer. | 16 | | 17 | - Redistributions in binary form must reproduce the above copyright | 18 | notice, this list of conditions and the following disclaimer in the | 19 | documentation and/or other materials provided with the distribution. | 20 | | 21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 22 | be used to endorse or promote products derived from this software | 23 | without specific prior written permission. | 24 | | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 36 | | 37 +-------------------------------------------------------------------------+ 38 */ 2 39 $_POST["columns"] = array(5,4,3,2,1,0); 3 40 $_POST["columns"] = json_encode($_POST["columns"]); 4 41 5 require("client_mailchimp_export.php");42 require("client_mailchimp_export.php"); 6 43 7 44 ?> -
trunk/phpbms/modules/mailchimp/scheduler_list_sync.php
r686 r730 1 1 <?php 2 /* 3 $Rev: 267 $ | $LastChangedBy: brieb $ 4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 5 +-------------------------------------------------------------------------+ 6 | Copyright (c) 2004 - 2010, Kreotek LLC | 7 | All rights reserved. | 8 +-------------------------------------------------------------------------+ 9 | | 10 | Redistribution and use in source and binary forms, with or without | 11 | modification, are permitted provided that the following conditions are | 12 | met: | 13 | | 14 | - Redistributions of source code must retain the above copyright | 15 | notice, this list of conditions and the following disclaimer. | 16 | | 17 | - Redistributions in binary form must reproduce the above copyright | 18 | notice, this list of conditions and the following disclaimer in the | 19 | documentation and/or other materials provided with the distribution. | 20 | | 21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 22 | be used to endorse or promote products derived from this software | 23 | without specific prior written permission. | 24 | | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 36 | | 37 +-------------------------------------------------------------------------+ 38 */ 39 2 40 //uncomment if need debug 3 41 if(!class_exists("appError")) 4 include_once("../../include/session.php");5 42 include_once("../../include/session.php"); 43 6 44 include("include/MCAPI.class.php");//for MCAPI CLASS (listSync class uses it) 7 45 include("include/list_sync.php");//for listSync class 8 46 47 $querystatement = " 48 SELECT 49 roleid 50 FROM 51 tableoptions 52 WHERE 53 name= 'massemail' 54 AND tabledefid = 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083' 55 "; 56 57 $queryresult = $this->db->query($querystatement); 58 59 $therecord = $this->db->fetchArray($queryresult); 60 61 if(!hasRights($therecord["roleid"])) 62 exit(false); 9 63 10 64 $listSync = new listSync( … … 20 74 21 75 if(isset($response["type"])){ 22 76 23 77 if($response["type"] != "success") 24 78 foreach($response["details"] AS $errorArray){ 25 79 26 80 $message = "MailChimp sync ".$response["type"].": ".$errorArray["message"]." (".$errorArray["code"].")"; 27 81 $log = new phpbmsLog($message, "SCHEDULER", NULL, $db); 28 82 29 83 }//end if 30 84 31 85 }//end if 32 86 ?>