コード例 #1
0
    /**
     * Displays the administrator's MailChimp Integration configuration form to retrieve the MailChimp API Key
     *
     * @param array $errors, if provided, will list the errors in a list format, with the 'red_alert' stylesheet class.
     * @param boolean $success, if true, will create a success message with the 'green_alert' stylesheet class.
     *
     */
    function configuration($errors = null, $success = false)
    {
        //define the current key.  If current key is now invalid, reset to null and display error
        $currentKey = MailChimpController::get_valid_mailchimp_key();
        if (MailChimpController::mailchimp_is_error($currentKey)) {
            $errors = $currentKey;
            $currentKey = null;
        }
        ?>
		 <form method="post" action="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
">
		 <ul>
		 <?php 
        //if errors occurred, display them here.
        if (MailChimpController::mailchimp_is_error($errors)) {
            echo "<li style='width: 40%' class='red_alert'>";
            foreach ($errors as $error) {
                echo "<p>{$error}</p>";
            }
            echo "</li>";
        }
        //if the credentials were successfully modified with no errors, let the user know.
        if ($success) {
            echo "<li style='width: 40%' class='green_alert'>";
            echo "<p>MailChimp API Key Updated</p>";
            echo "</li>";
        }
        ?>
		 <li>MailChimp API Key</li>
		 <li><input size="45" type="text" name="mailchimp_api_key" value="<?php 
        echo $currentKey;
        ?>
" /> <a class="thickbox"  href="#TB_inline?height=400&amp;width=500&amp;inlineId=api-key-help" target="_blank"><img src="<?php 
        echo EVENT_ESPRESSO_PLUGINFULLURL;
        ?>
images/question-frame.png" width="16" height="16" alt="Help Link" /></a></li>
		 <li><input class="button-primary" name="update_mailchimp_settings_post" value="Save MailChimp API Key" type="submit" /></li>
		 </ul>
		 </form>
    <?php 
        ### help dialogue ###
        ?>
			<div id="api-key-help" style="display:none">
			 <div class="TB-ee-frame">
    	 <h2><?php 
        _e("MailChimp API Key", "event_espresso");
        ?>
 </h2>
    	 <p><?php 
        _e("If you do not have a MailChimp API key, please <a href='http://kb.mailchimp.com/article/where-can-i-find-my-api-key/' target='_blank'>click here</a> to learn how to create one. </p><p>An API key is required for this plugin.", 'event-espresso');
        ?>
 </p>
     </div>
			</div>
		 
		 <?php 
    }
コード例 #2
0
    /**
     * Displays the administrator's MailChimp Integration configuration form to retrieve the MailChimp API Key
     *
     * @param array $errors, if provided, will list the errors in a list format, with the 'red_alert' stylesheet class.
     * @param boolean $success, if true, will create a success message with the 'green_alert' stylesheet class.
     *
     */
    function configuration($errors = null, $success = false)
    {
        //define the current key.  If current key is now invalid, reset to null and display error
        $currentKey = MailChimpController::get_valid_mailchimp_key();
        if (MailChimpController::mailchimp_is_error($currentKey)) {
            $errors = $currentKey;
            $currentKey = null;
        }
        ?>
		 <form method="post" action="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
">
		 <ul>
		 <?php 
        //if errors occurred, display them here.
        if (MailChimpController::mailchimp_is_error($errors)) {
            echo "<li style='width: 40%' class='red_alert'>";
            foreach ($errors as $error) {
                echo "<p>{$error}</p>";
            }
            echo "</li>";
        }
        //if the credentials were successfully modified with no errors, let the user know.
        if ($success) {
            echo "<li style='width: 40%' class='green_alert'>";
            echo "<p>MailChimp API Key Updated</p>";
            echo "</li>";
        }
        ?>
		 <li>MailChimp API Key</li>
		 <li><input type="text" name="mailchimp_api_key" value="<?php 
        echo $currentKey;
        ?>
" /> &nbsp;<a class="ev_reg-fancylink" href="#api-key"><img src="<?php 
        echo EVENT_ESPRESSO_PLUGINFULLURL;
        ?>
/images/question-frame.png" width="16" height="16" /></a></li>
		 <li><input class="button-primary" name="update_mailchimp_settings_post" value="Save MailChimp API Key" type="submit"></li>
		 </ul>
		 <?php 
    }
コード例 #3
0
 /**
  * Subscribes new attendees to the MailChimp List associated with the corresponding Event.  Upon successful subscription, adds an attendee_id to event_id
  * relationship for possible backward integration.
  *
  * @param string $event_id, Event Espresso event id
  * @param string $attendee_id, Event Espresso new Attendee ID
  * @param string $attendee_fname Event Espresso new Attendee First Name
  * @param string $attendee_lname Event Espresso new Attendee Last Name
  * @param string $attendee_email Event Espresso new Attendee Email Address
  * 
  */
 function list_subscribe($event_id, $attendee_id, $attendee_fname, $attendee_lname, $attendee_email)
 {
     global $wpdb;
     $mailChimpListID = MailChimpController::get_mailchimp_list_id_by_event($event_id);
     //check to make sure the list ID is valid and available
     if ($mailChimpListID) {
         $mailChimpKey = MailChimpController::get_valid_mailchimp_key();
         //make certain the key is still valid with the MailChimp Servers
         if (!is_array($mailChimpKey) && !empty($mailChimpKey)) {
             $api = new MCAPI($mailChimpKey);
             $merge_vars = array("FNAME" => $attendee_fname, "LNAME" => $attendee_lname);
             //subscribe the attendee to the selected MailChimp list
             $api->listSubscribe($mailChimpListID, $attendee_email, $merge_vars);
             if ($api->errorCode == "") {
                 //now create an attendee / mailchimp list relationshp for future backward integration
                 $sql = array("event_id" => $event_id, "attendee_id" => $attendee_id, "mailchimp_list_id" => $mailChimpListID);
                 $wpdb->insert(EVENTS_MAILCHIMP_ATTENDEE_REL_TABLE, $sql);
             }
         }
     }
 }