예제 #1
0
 * @link      http://www.familycms.com/wiki/
 * @since     2.4
 */
session_start();
define('URL_PREFIX', '');
define('GALLERY_PREFIX', 'gallery/');
require 'fcms.php';
load('datetime', 'socialmedia', 'foursquare');
init();
$templateParams = array('currentUserId' => $fcmsUser->id, 'sitename' => getSiteName(), 'nav-link' => getNavLinks(), 'pagetitle' => T_('Where Is Everyone'), 'pageId' => 'whereiseveryone-page', 'path' => URL_PREFIX, 'displayname' => $fcmsUser->displayName, 'version' => getCurrentVersion(), 'year' => date('Y'));
$options = array('modules' => array('livevalidation'));
displayPageHeader($templateParams, $options);
//-------------------------------------
// Show Latest checkins
//-------------------------------------
$users = getFoursquareUsersData();
$config = getFoursquareConfigData();
if (count($users[0]) <= 0) {
    echo '
            <div class="info-alert">
                <p>' . T_('No users with foursquare data found.') . '</p>
            </div>';
    loadTemplate('global', 'footer', $templateParams);
    return;
}
// Foursquare hasn't been setup or is invalid
if (empty($config['fs_client_id']) or empty($config['fs_client_secret'])) {
    // If admin is viewing, alert them that the config is missing/messed up
    if ($fcmsUser->access < 2) {
        echo '
            <div class="info-alert">
예제 #2
0
파일: utils.php 프로젝트: lmcro/fcms
/**
 * getFoursquareWhatsNewData 
 * 
 * Adds foursquare data to the whats new data array.
 * 
 * @param array $whatsNewData 
 * 
 * @return mixed - array on success or false on failure
 */
function getFoursquareWhatsNewData($whatsNewData)
{
    $fcmsError = FCMS_Error::getInstance();
    $fcmsDatabase = Database::getInstance($fcmsError);
    $fcmsUser = User::getInstance($fcmsError, $fcmsDatabase);
    include_once 'socialmedia.php';
    include_once 'thirdparty/foursquare/EpiFoursquare.php';
    include_once 'thirdparty/foursquare/EpiCurl.php';
    $users = getFoursquareUsersData();
    $config = getFoursquareConfigData();
    // TODO
    // Move this check inside the getFoursquareConfigData and have it return false on failure.
    // Foursquare hasn't been setup or is invalid
    if (empty($config['fs_client_id']) or empty($config['fs_client_secret'])) {
        // If admin is viewing, alert them that the config is missing/messed up
        if ($fcmsUser->access < 2) {
            echo '
                    <div class="info-alert">
                        <h2>' . T_('Foursquare is not configured correctly.') . '</h2>
                        <p>' . T_('The "Where Is Everyone" feature cannot work without Foursquare.  Please configure Foursquare or turn off "Where Is Everyone".') . '</p>
                        <p><a href="admin/foursquare.php">' . T_('Configure Foursquare') . '</a></p>
                        <p><a href="admin/config.php?view=plugins">' . T_('Turn Off "Where is Everyone"') . '</a></p>
                    </div>';
        }
        return $whatsNewData;
    }
    $foursquareData = array();
    if (count($users[0]) > 0) {
        $timeago = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
        $i = 0;
        foreach ($users as $k => $data) {
            // Skip users who don't have foursquare setup
            if (empty($data['access_token'])) {
                continue;
            }
            $fsObj = new EpiFoursquare($config['fs_client_id'], $config['fs_client_secret'], $data['access_token']);
            try {
                $params = array('afterTimestamp' => $timeago);
                $creds = $fsObj->get('/users/' . $data['user_id'] . '/checkins', $params);
            } catch (EpiFoursquareException $e) {
                echo 'We caught an EpiOAuthException';
                echo $e->getMessage();
                return false;
            } catch (Exception $e) {
                echo 'We caught an unexpected Exception';
                echo $e->getMessage();
                return false;
            }
            foreach ($creds->response->checkins->items as $checkin) {
                // Skip shouts, etc
                if ($checkin->type != 'checkin') {
                    continue;
                }
                $date = date('Y-m-d H:i:s', $checkin->createdAt);
                $sort = $checkin->createdAt;
                $shout = isset($checkin->shout) ? $checkin->shout : '';
                // Save data
                $whatsNewData[] = array('id' => '', 'date' => $date, 'title' => $checkin->venue->name, 'userid' => $data['fcms_user_id'], 'id2' => $shout, 'id3' => '', 'type' => 'WHEREISEVERYONE');
            }
        }
    }
    // Order is messed up now, so fix it
    $whatsNewData = subval_sort($whatsNewData, 'date');
    $whatsNewData = array_reverse($whatsNewData);
    return $whatsNewData;
}