function _wpr_subscriptionforms_list() { global $wpdb; $tprefix = $wpdb->prefix; $query = "SELECT a.* FROM " . $tprefix . "wpr_subscription_form a, " . $tprefix . "wpr_newsletters b where a.nid=b.id;"; $forms = $wpdb->get_results($query); ?> <div class="wrap"> <h2>Subscription Forms</h2> </div> <script> function selectAllFormsCheckBox(state) { jQuery(".forms_check").attr({ checked: state}); } </script> <ul style="padding:20px;"> <li>Click on <em>Create New Form</em> button below to create a new subscription form. To place the newly created subscription form in the sidebar of your blog, go to the <a href="widgets.php">Widgets section</a>. To place the subscription form in a separate page or another website, copy the generated HTML code for the form and paste the code it in your own HTML page. </ul> <form name="formslist" action="admin.php?page=wpresponder/subscriptionforms.php&action=delete" method="post"> <table class="widefat" style="margin: 10px; margin:10px 0px;;"> <thead> <tr> <th><input type="checkbox" name="selectall" value="1" onclick="selectAllFormsCheckBox(this.checked);" /></th> <th scope="col">Name</th> <th>Newsletter</th> <th>Follow-Up</th> <th>Blog Subscription</th> <th scope="col">Actions</th> </tr> </thead> <?php if (count($forms) > 0) { foreach ($forms as $form) { ?> <tr> <td align="center"width="20"><input type="checkbox" name="forms[]" class="forms_check" value="<?php echo $form->id; ?> " /></td> <td><?php echo $form->name; ?> </td> <td><a href="admin.php?page=wpresponder/subscribers.php&action=nmanage&nid=<?php echo $form->nid; ?> "> <?php $newsletter = _wpr_newsletter_get($form->nid); echo $newsletter->name; ?> </a></td> <td><?php switch ($form->followup_type) { case 'postseries': $postseries = _wpr_postseries_get($form->followup_id); echo "Subscribe to the '" . $postseries->name . "' post series"; break; case 'autoresponder': $autoresponder = Autoresponder::getAutoresponder((int) $form->followup_id); echo sprintf("Subscribe to the '%s' autoresponder.", $autoresponder->getName()); break; case 'none': echo "None"; break; } ?> </td> <td><?php switch ($form->blogsubscription_type) { case 'cat': $category = get_category($form->blogsubscription_id); echo "Posts in the " . $category->name . " category"; break; case 'all': echo "All Blog Posts "; break; case 'none': echo "No blog subscription"; break; } ?> <td><a href="admin.php?page=wpresponder/subscriptionforms.php&action=edit&fid=<?php echo $form->id; ?> " class="button">Edit</a> <a href="admin.php?page=wpresponder/subscriptionforms.php&action=form&fid=<?php echo $form->id; ?> " class="button">Get Form HTML</a></td> </tr> <?php } } else { ?> <tr> <td colspan="10"><div align="center"><big>--No subscription forms defined. <a href="admin.php?page=wpresponder/subscriptionforms.php&action=create">Click here</a> to create one now--</big> </div></td> </tr> <?php } ?> </td></td> </table> <input type="submit" name="submit" value="Delete Forms" class="button" onclick="return confirm('Are you sure you want to delete the selected subscription forms?');" /> <input type="button" onclick="window.location='admin.php?page=wpresponder/subscriptionforms.php&action=create';" class="button" value="Create New Form"> </form> <?php }
public function getAutoresponder() { return Autoresponder::getAutoresponder($this->autoresponder_id); }
public static function add_message() { $autoresponder_id = intval($_GET['id']); $autoresponderObject = Autoresponder::getAutoresponder($autoresponder_id); $custom_fields = $autoresponderObject->getNewsletter()->getCustomFieldKeyLabelPair(); self::enqueue_wysiwyg(); //TODO: THIS METHOD DEF SHOULDN'T BE WHERE IT IS RIGHT NOW _wpr_set("custom_fields", $custom_fields); _wpr_set("autoresponder", $autoresponderObject); _wpr_setview("autoresponder_add_message"); }
public function testDeleteAutoresponderMessageDeletesOnlyItsOwnFromQueue() { global $wpdb; $addAutoresponderQuery = sprintf("INSERT INTO %swpr_autoresponders (nid, name) VALUES (%d,'%s' )", $wpdb->prefix, $this->newsletterId, md5(microtime())); $results = $wpdb->query($addAutoresponderQuery); $autoresponder = Autoresponder::getAutoresponder($wpdb->insert_id); $autoresponder_message = array('textbody' => 'This is a test', 'htmlbody' => 'This is a <test>body</test>', 'subject' => 'Test Subject', 'offset' => 3); try { $message = $autoresponder->addMessage($autoresponder_message); } catch (Exception $exc) { throw new BadFunctionCallException(); } //add 10 of these messages in the queue. for ($iter = 0; $iter < 10; $iter++) { $addMessageToQueueQuery = sprintf("INSERT INTO %swpr_queue (`to`, `meta_key`, `sent`, `hash`) VALUES ('%s','AR-%d-%d-%d-%d', 0, '%s')", $wpdb->prefix, 'test' . microtime() . '@test.com', $autoresponder->getId(), $iter, $message->getId(), $iter, md5(microtime())); $wpdb->query($addMessageToQueueQuery); } $getNumberOfUnsentMessagesForMessage = sprintf("SELECT COUNT(*) num FROM %swpr_queue WHERE sent=0 AND meta_key LIKE 'AR-%%%%-%%%%-%d-%%';", $wpdb->prefix, $message->getId()); $resultSet = $wpdb->get_results($getNumberOfUnsentMessagesForMessage); $numOfUnsentMessages = $resultSet[0]->num; $this->assertEquals(10, $numOfUnsentMessages); //add 10 of these messages in the queue. for ($iter = 10; $iter < 20; $iter++) { $addMessageToQueueQuery = sprintf("INSERT INTO %swpr_queue (`to`, `meta_key`, `sent`, `hash`) VALUES ('%s','AR-%d-%d-%d-%d', 1, '%s')", $wpdb->prefix, 'test' . microtime() . '@test.com', $autoresponder->getId(), $iter, 9801, $iter, md5(microtime())); $wpdb->query($addMessageToQueueQuery); } $getNumberOfUnsentMessagesForMessage = sprintf("SELECT COUNT(*) num FROM %swpr_queue WHERE sent=1 AND meta_key LIKE 'AR-%%%%-%%%%-%d-%%';", $wpdb->prefix, 9801); $resultSet = $wpdb->get_results($getNumberOfUnsentMessagesForMessage); $numOfUnsentMessages = $resultSet[0]->num; $this->assertEquals(10, $numOfUnsentMessages); $autoresponder->deleteMessage($message); $getNumberOfUnsentMessagesForMessage = sprintf("SELECT COUNT(*) num FROM %swpr_queue WHERE sent=0 AND meta_key LIKE 'AR-%%%%-%%%%-%d-%%';", $wpdb->prefix, $message->getId()); $resultSet = $wpdb->get_results($getNumberOfUnsentMessagesForMessage); $numOfUnsentMessages = $resultSet[0]->num; $this->assertEquals(0, $numOfUnsentMessages); $getNumberOfUnsentMessagesForMessage = sprintf("SELECT COUNT(*) num FROM %swpr_queue WHERE sent=1 AND meta_key LIKE 'AR-%%%%-%%%%-%d-%%';", $wpdb->prefix, 9801); $resultSet = $wpdb->get_results($getNumberOfUnsentMessagesForMessage); $numOfUnsentMessages = $resultSet[0]->num; $this->assertEquals(10, $numOfUnsentMessages); }