Exemplo n.º 1
0
 public static function getSongs($serviceType)
 {
     $transient = self::TRANSIENT_CACHE_PREFIX . $serviceType;
     $cache = get_transient($transient);
     if (!$cache) {
         // cache doesn't exist, let's try to re-query PCO
         $pco = new PCOAccess();
         if ($pco->okay()) {
             // we've got PCO access
             $songs = self::queryForSongs($pco->api, $serviceType);
             // cache the song list again
             set_transient($transient, serialize($songs), 60 * 60 * 24);
             return $songs;
         } else {
             // we're not connected to PCO yet
             return false;
         }
     } else {
         $cache = maybe_unserialize($cache);
         if (!is_array($cache)) {
             return false;
         }
         return $cache;
     }
 }
Exemplo n.º 2
0
    function adminPageContent()
    {
        $pco = new PCOAccess();
        ?>
<div class="wrap">
			<div id="icon-options-general" class="icon32"><br></div>
			<h2>Planning Center Online Connection</h2>
			<form method="post" action="options.php">
				<?php 
        settings_fields('pco-connection-group');
        // This prints out all hidden setting fields
        do_settings_sections('pco-connection-admin');
        // prints out form options
        ?>
				<?php 
        submit_button();
        ?>
			</form>
			<div style="background-color: #EEE; padding: 10px;">
				<?php 
        if ($pco->okay()) {
            echo '<h3>Connection Status: <span style="color: #090">Connected!</span></h3>';
            $o = $pco->api->getOrganization();
            echo '<p>';
            echo 'Organization: ' . $o->name . "<br />\n";
            echo 'Account Owner: ' . $o->owner_name . "\n";
            echo '</p>';
            echo '<a class="button" href="?page=pco_connect&amp;pco-action=logout">Log out</a>';
        } else {
            echo '<h3>Connection Status: <span style="color: #900">Disconnected</span></h3>';
            if ($pco->hasCredentials()) {
                echo '<p>Press the button below to authenticate with the above key and secret:</p>';
                echo '<a class="button" href="?page=pco_connect&amp;pco-action=auth">Authenticate</a>';
            } else {
                echo '<p>Please enter a consumer key and secret to authenticate.</p>';
            }
        }
        ?>
			</div>
		</div>
		<?php 
    }