Ejemplo n.º 1
0
 public static function addAutoresponder($nid, $name)
 {
     global $wpdb;
     if (!Newsletter::whetherNewsletterIDExists($nid)) {
         throw new NonExistentNewsletterAutoresponderAdditionException();
     }
     if (!Autoresponder::whetherValidAutoresponderName(array("nid" => $nid, "name" => $name))) {
         throw new InvalidArgumentException("Invalid autoresponder arguments");
     }
     $createAutoresponderQuery = sprintf("INSERT INTO `{$wpdb->prefix}wpr_autoresponders` (`nid`, `name`) VALUES (%d, '%s');", $nid, $name);
     $wpdb->query($createAutoresponderQuery);
     $autoresponder_id = $wpdb->insert_id;
     return new Autoresponder($autoresponder_id);
 }
Ejemplo n.º 2
0
 public static function validateAddFormPostData($post_data, &$errors)
 {
     $name = $post_data['name'];
     if (!Autoresponder::whetherValidAutoresponderName(array('name' => $name))) {
         $errors[] = __("The name for the autoresponder you've entered is invalid");
     }
     if (!Newsletter::whetherNewsletterIDExists($post_data['nid'])) {
         $errors[] = __("The newsletter you've selected doesn't exist");
         return $errors;
     }
 }
Ejemplo n.º 3
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testWhetherLackOfArgumentForWhetherValidAutoresponderResultsInException()
 {
     Autoresponder::whetherValidAutoresponderName("");
 }