Example #1
0
 protected function retrieveResponse()
 {
     if (!class_exists('ZipArchive')) {
         throw new KurogoException("class ZipArchive (php-zip) not available");
     }
     $tmpFile = Kurogo::tempFile();
     // this is the same as parent
     if (!($this->requestURL = $this->url())) {
         throw new KurogoDataException("URL could not be determined");
     }
     $this->requestParameters = $this->parameters();
     // the following are private functions in URLDataRetriever
     //$this->requestMethod = $this->setContextMethod();
     //$this->requestHeaders = $this->setContextHeaders();
     //$this->requestData = $this->setContextData();
     Kurogo::log(LOG_INFO, "Retrieving {$this->requestURL}", 'url_retriever');
     // the creation of $data is different from parent
     copy($this->requestURL, $tmpFile);
     $zip = new ZipArchive();
     $zip->open($tmpFile);
     $data = $zip->getFromIndex(0);
     unlink($tmpFile);
     // this is the same as parent
     $http_response_header = isset($http_response_header) ? $http_response_header : array();
     $response = $this->initResponse();
     $response->setRequest($this->requestMethod, $this->requestURL, $this->requestParameters, $this->requestHeaders, null);
     $response->setResponse($data);
     $response->setResponseHeaders($http_response_header);
     Kurogo::log(LOG_DEBUG, sprintf("Returned status %d and %d bytes", $response->getCode(), strlen($data)), 'url_retriever');
     return $response;
 }
 public static function formatDate($date, $dateStyle, $timeStyle)
 {
     $dateStyleConstant = self::getDateConstant($dateStyle);
     $timeStyleConstant = self::getTimeConstant($timeStyle);
     if ($date instanceof DateTime) {
         $date = $date->format('U');
     }
     $string = '';
     if ($dateStyleConstant) {
         $string .= strftime(Kurogo::getLocalizedString($dateStyleConstant), $date);
         if ($timeStyleConstant) {
             $string .= " ";
         }
     }
     if ($timeStyleConstant) {
         // Work around lack of %P support in Mac OS X
         $format = Kurogo::getLocalizedString($timeStyleConstant);
         $lowercase = false;
         if (strpos($format, '%P') !== false) {
             $format = str_replace('%P', '%p', $format);
             $lowercase = true;
         }
         $formatted = strftime($format, $date);
         if ($lowercase) {
             $formatted = strtolower($formatted);
         }
         // Work around leading spaces that come from use of %l (but don't exist in date())
         if (strpos($format, '%l') !== false) {
             $formatted = trim($formatted);
         }
         $string .= $formatted;
     }
     return $string;
 }
 public function url()
 {
     if (empty($this->startDate) || empty($this->endDate)) {
         throw new KurogoConfigurationException('Start or end date cannot be blank');
     }
     $diff = $this->endTimestamp() - $this->startTimestamp();
     if ($diff < 86400 || $diff == 89999) {
         // fix for DST
         if (count($this->trumbaFilters) > 0) {
             $this->setRequiresDateFilter(false);
             $this->addFilter('startdate', $this->startDate->format('Ymd'));
             $this->addFilter('days', 1);
         } else {
             $this->setRequiresDateFilter(true);
             $this->addFilter('startdate', $this->startDate->format('Ym') . '01');
             $this->addFilter('months', 1);
         }
     } elseif ($diff % 86400 == 0) {
         $this->setRequiresDateFilter(false);
         $this->addFilter('startdate', $this->startDate->format('Ymd'));
         $this->addFilter('days', $diff / 86400);
     } else {
         Kurogo::log(LOG_WARNING, "Non day integral duration specified {$diff}", 'calendar');
     }
     return parent::url();
 }
 protected function parseEntry($entry)
 {
     switch ($this->response->getContext('retriever')) {
         case 'feed':
             $photo = new FlickrFeedPhotoObject();
             $photo->setID($entry['guid']);
             $photo->setAuthor($entry['author_name']);
             $photo->setMimeType($entry['photo_mime']);
             $photo->setURL($entry['photo_url']);
             $photo->setHeight($entry['height']);
             $photo->setWidth($entry['width']);
             $photo->setThumbnailURL($entry['thumb_url']);
             $published = new DateTime($entry['date_taken']);
             $photo->setPublished($published);
             $photo->setDescription($entry['description']);
             break;
         case 'api':
             $photo = new FlickrAPIPhotoObject();
             $photo->setUserID(Kurogo::arrayVal($entry, 'owner'));
             $photo->setID($entry['id']);
             $photo->setFarm($entry['farm']);
             $photo->setServer($entry['server']);
             $photo->setSecret($entry['secret']);
             $photo->setDescription($entry['description']['_content']);
             $photo->setAuthor($entry['ownername']);
             $published = new DateTime($entry['datetaken']);
             $photo->setPublished($published);
             $photo->setThumbnailURL($photo->getFlickrUrl('s'));
             $photo->setURL($photo->getFlickrUrl('z'));
             break;
     }
     $photo->setTitle($entry['title']);
     $photo->setTags($entry['tags']);
     return $photo;
 }
Example #5
0
 public function init($args)
 {
     $args['ID'] = $this->id;
     $this->title = Kurogo::arrayVal($args, 'TITLE', $this->id);
     $this->description = Kurogo::arrayVal($args, 'DESCRIPTION');
     $this->rule = UserContextRule::factory($args);
 }
Example #6
0
 protected function initializeForPage()
 {
     $this->handleRequest($this->args);
     $modules = $this->getModuleCustomizeList();
     $moduleIDs = array();
     $disabledModuleIDs = array();
     foreach ($modules as $id => $info) {
         $moduleIDs[] = $id;
         if ($info['disabled']) {
             $disabledModuleIDs[] = $id;
         }
     }
     switch ($this->pagetype) {
         case 'compliant':
         case 'tablet':
             $this->addInlineJavascript('var modules = ' . json_encode($moduleIDs) . ';' . 'var disabledModules = ' . json_encode($disabledModuleIDs) . ';' . 'var MODULE_ORDER_COOKIE = "' . self::MODULE_ORDER_COOKIE . '";' . 'var DISABLED_MODULES_COOKIE = "' . self::DISABLED_MODULES_COOKIE . '";' . 'var MODULE_ORDER_COOKIE_LIFESPAN = ' . Kurogo::getSiteVar('MODULE_ORDER_COOKIE_LIFESPAN') . ';' . 'var COOKIE_PATH = "' . COOKIE_PATH . '";');
             $this->addInlineJavascriptFooter('init();');
             break;
         case 'touch':
         case 'basic':
             foreach ($moduleIDs as $index => $id) {
                 $modules[$id]['toggleDisabledURL'] = $this->buildBreadcrumbURL('index', array('action' => $modules[$id]['disabled'] ? 'on' : 'off', 'module' => $id), false);
                 if ($index > 0) {
                     $modules[$id]['swapUpURL'] = $this->buildBreadcrumbURL('index', array('action' => 'swap', 'module1' => $id, 'module2' => $moduleIDs[$index - 1]), false);
                 }
                 if ($index < count($moduleIDs) - 1) {
                     $modules[$id]['swapDownURL'] = $this->buildBreadcrumbURL('index', array('action' => 'swap', 'module1' => $id, 'module2' => $moduleIDs[$index + 1]), false);
                 }
             }
             break;
         default:
             break;
     }
     $this->assignByRef('modules', $modules);
 }
 public function auth($options, &$userArray)
 {
     if (isset($options['startOver']) && $options['startOver']) {
         $this->reset();
     }
     if (isset($_REQUEST['openid_mode'])) {
         if (isset($_REQUEST['openid_identity'])) {
             if ($ns = $this->getOpenIDNamespace('http://specs.openid.net/extensions/oauth/1.0', $_REQUEST)) {
                 if ($request_token = $this->getOpenIDValue('request_token', $ns, $_REQUEST)) {
                     $this->setToken(OAuthProvider::TOKEN_TYPE_REQUEST, $request_token);
                     if (!$this->getAccessToken($options)) {
                         throw new KurogoDataServerException("Error getting OAuth Access token");
                     }
                 }
             }
             $userArray = $_REQUEST;
             return AUTH_OK;
         } else {
             Kurogo::log(LOG_WARNING, "openid_identity not found", 'auth');
             return AUTH_FAILED;
         }
     } else {
         //redirect to auth page
         $url = $this->getAuthURL($options);
         header("Location: " . $url);
         exit;
     }
 }
Example #8
0
 protected function initializeForPage()
 {
     $this->assign('deviceName', Kurogo::getOptionalSiteVar($this->platform, null, 'deviceNames'));
     $this->assign('introduction', $this->getOptionalModuleVar('introduction', null, $this->platform, 'apps'));
     $this->assign('instructions', $this->getOptionalModuleVar('instructions', null, $this->platform, 'apps'));
     $this->assign('downloadUrl', $this->getOptionalModuleVar('url', null, $this->platform, 'apps'));
 }
Example #9
0
function _outputTypeFile($matches) { 
  $file = $matches[3];

  $platform = Kurogo::deviceClassifier()->getPlatform();
  $pagetype = Kurogo::deviceClassifier()->getPagetype();
  
  $testDirs = array(
    THEME_DIR.'/'.$matches[1].$matches[2],
    SITE_DIR.'/'.$matches[1].$matches[2],
    APP_DIR.'/'.$matches[1].$matches[2],
  );
  
  $testFiles = array(
    "$pagetype-$platform/$file",
    "$pagetype/$file",
    "$file",
  );
  
  foreach ($testDirs as $dir) {
    foreach ($testFiles as $file) {
      if ($file = realpath_exists("$dir/$file")) {
          _outputFile($file);
      }
    }
  }

  _404();
}
Example #10
0
    protected function getDataController($categoryPath, &$listItemPath) {
        if (!$this->feeds)
            $this->feeds = $this->loadFeedData();

        if ($categoryPath === NULL) {
            return MapDataController::factory('MapDataController', array(
                'JS_MAP_CLASS' => 'GoogleJSMap',
                'DEFAULT_ZOOM_LEVEL' => $this->getOptionalModuleVar('DEFAULT_ZOOM_LEVEL', 10)
                ));

        } else {
            $listItemPath = $categoryPath;
            if ($this->numGroups > 0) {
                if (count($categoryPath) < 2) {
                    $path = implode(MAP_CATEGORY_DELIMITER, $categoryPath);
                    throw new Exception("invalid category path $path for multiple feed groups");
                }
                $feedIndex = array_shift($listItemPath).MAP_CATEGORY_DELIMITER.array_shift($listItemPath);
            } else {
                $feedIndex = array_shift($listItemPath);
            }
            $feedData = $this->feeds[$feedIndex];
            $controller = MapDataController::factory($feedData['CONTROLLER_CLASS'], $feedData);
            $controller->setCategory($feedIndex);
            $controller->setDebugMode(Kurogo::getSiteVar('DATA_DEBUG'));
            return $controller;
        }
    }
Example #11
0
 public function init($args)
 {
     $this->baseURL = $args['BASE_URL'];
     $this->diskCache = new DiskCache(Kurogo::getSiteVar('WMS_CACHE', 'maps'), 86400 * 7, true);
     $this->diskCache->preserveFormat();
     $filename = md5($this->baseURL);
     $metafile = $filename . '-meta.txt';
     if (!$this->diskCache->isFresh($filename)) {
         $params = array('request' => 'GetCapabilities', 'service' => 'WMS');
         $query = $this->baseURL . '?' . http_build_query($params);
         file_put_contents($this->diskCache->getFullPath($metafile), $query);
         $contents = file_get_contents($query);
         $this->diskCache->write($contents, $filename);
     } else {
         $contents = $this->diskCache->read($filename);
     }
     $this->wmsParser = new WMSDataParser();
     $this->wmsParser->parseData($contents);
     $this->enableAllLayers();
     // TODO make sure this projection is supported by the server
     $projections = $this->wmsParser->getProjections();
     if (count($projections)) {
         // make sure this is a projection we can handle
         foreach ($projections as $proj) {
             $contents = MapProjector::getProjSpecs($proj);
             if ($contents) {
                 $this->setMapProjection($proj);
             }
         }
     } else {
         $this->setMapProjection(GEOGRAPHIC_PROJECTION);
     }
 }
Example #12
0
 public function init($args)
 {
     if (isset($args['HALT_ON_PARSE_ERRORS'])) {
         $this->haltOnParseErrors($args['HALT_ON_PARSE_ERRORS']);
     }
     $this->setDebugMode(Kurogo::getSiteVar('DATA_DEBUG'));
 }
Example #13
0
 public function log($priority, $message, $area, $backTrace = null)
 {
     if (!self::isValidPriority($priority)) {
         throw new Exception("Invalid logging priority {$priority}");
     }
     if (!preg_match("/^[a-z0-9_-]+\$/i", $area)) {
         throw new Exception("Invalid area {$area}");
     }
     //don't log items above the current logging level
     $loggingLevel = isset($this->areaLevel[$area]) ? $this->areaLevel[$area] : $this->defaultLevel;
     if ($priority > $loggingLevel) {
         return;
     }
     if (!$backTrace) {
         $backTrace = debug_backtrace();
     }
     $compactTrace = self::compactTrace($backTrace);
     if (isset($_SERVER['REQUEST_URI'])) {
         $request = $_SERVER['REQUEST_URI'];
     } elseif (defined('KUROGO_SHELL')) {
         $request = json_encode(Kurogo::getArrayForRequest());
     } else {
         $request = null;
     }
     $content = sprintf("%s\t%s:%s\t%s\t%s\t%s", date(Kurogo::getSiteVar('LOG_DATE_FORMAT')), $area, self::priorityToString($priority), $compactTrace, $request, $message) . PHP_EOL;
     self::fileAppend($this->logFile, $content);
 }
 /**
  * Returns a base filename for the cache file that will be used. The default implementation uses
  * a hash of the value returned from the url
  * @return string
  */
 protected function cacheFilename($url = null)
 {
     $url = $url ? $url : $this->url();
     // Add the user's id to the cache-key for a per-user cache.
     $session = Kurogo::getSession();
     $user = $session->getUser();
     return md5($url . $user->getUserID());
 }
 public static function errorFromException(Exception $exception) {
     $error = new KurogoError($exception->getCode(), 'Exception', $exception->getMessage());
     if(!Kurogo::getSiteVar('PRODUCTION_ERROR_HANDLER_ENABLED')) {
         $error->file = $exception->getFile();
         $error->line = $exception->getLine();
         $error->trace = $exception->getTrace();
     }
     return $error;
 }
Example #16
0
 public function initializeForCommand()
 {
     if (!Kurogo::getSiteVar('AUTHENTICATION_ENABLED')) {
         throw new KurogoConfigurationException("Authentication is not enabled on this site");
     }
     switch ($this->command) {
         case 'logout':
             if (!$this->isLoggedIn()) {
                 $this->redirectTo('session');
             } else {
                 $session = $this->getSession();
                 $user = $this->getUser();
                 $hard = $this->getArg('hard', false);
                 $authorityIndex = $this->getArg('authority', false);
                 if ($authorityIndex) {
                     $authority = AuthenticationAuthority::getAuthenticationAuthority($authorityIndex);
                 } else {
                     $authority = $user->getAuthenticationAuthority();
                 }
                 $session->logout($authority, $hard);
                 $this->redirectTo('session');
             }
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'getuserdata':
             $key = $this->getArg('key', null);
             $user = $this->getUser();
             $response = $user->getUserData($key);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'session':
             $session = $this->getSession();
             $response = array('session_id' => $session->getSessionID(), 'token' => $session->getLoginToken());
             // version 2 implements multiple identities into the response
             if ($this->requestedVersion == 2) {
                 $response['users'] = array();
                 $users = $session->getUsers();
                 foreach ($users as $user) {
                     $authority = $user->getAuthenticationAuthority();
                     $response['users'][$authority->getAuthorityIndex()] = array('authority' => $authority->getAuthorityIndex(), 'authorityTitle' => $authority->getAuthorityTitle(), 'userID' => $user->getUserID(), 'name' => $user->getFullName(), 'sessiondata' => $user->getSessionData());
                 }
                 $this->setResponseVersion(2);
             } else {
                 // version 1 assumes only 1 user
                 $user = $this->getUser();
                 $response['user'] = array('authority' => $user->getAuthenticationAuthorityIndex(), 'userID' => $user->getUserID(), 'name' => $user->getFullName(), 'sessiondata' => $user->getSessionData());
                 $this->setResponseVersion(1);
             }
             $this->setResponse($response);
             break;
         default:
             $this->invalidCommand();
             break;
     }
 }
Example #17
0
 public function display()
 {
     $json = $this->getJSONOutput();
     $size = strlen($json);
     header("Content-Type: application/json; charset=" . Kurogo::getCharset());
     header("Content-Length: " . $size);
     echo $json;
     return $json;
 }
Example #18
0
 public function initializeForCommand()
 {
     switch ($this->command) {
         case 'notice':
             $response = null;
             $responseVersion = 1;
             if ($this->getOptionalModuleVar('BANNER_ALERT', false, 'notice')) {
                 $noticeData = $this->getOptionalModuleSection('notice');
                 if ($noticeData) {
                     $response = array('notice' => '', 'moduleID' => null, 'link' => $this->getOptionalModuleVar('BANNER_ALERT_MODULE_LINK', false, 'notice'));
                     // notice can either take a module or data model class or retriever class. The section is passed on. It must implement the HomeAlertInterface interface
                     if (isset($noticeData['BANNER_ALERT_MODULE'])) {
                         $moduleID = $noticeData['BANNER_ALERT_MODULE'];
                         $controller = WebModule::factory($moduleID);
                         $response['moduleID'] = $moduleID;
                         $string = "Module {$moduleID}";
                     } elseif (isset($noticeData['BANNER_ALERT_MODEL_CLASS'])) {
                         $controller = DataModel::factory($noticeData['BANNER_ALERT_MODEL_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_MODEL_CLASS'];
                     } elseif (isset($noticeData['BANNER_ALERT_RETRIEVER_CLASS'])) {
                         $controller = DataRetriever::factory($noticeData['BANNER_ALERT_RETRIEVER_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_RETRIEVER_CLASS'];
                     } else {
                         throw new KurogoConfigurationException("Banner alert not properly configured");
                     }
                     if (!$controller instanceof HomeAlertInterface) {
                         throw new KurogoConfigurationException("{$string} does not implement HomeAlertModule interface");
                     }
                     $response['notice'] = $controller->getHomeScreenAlert();
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion($responseVersion);
             break;
         case 'modules':
             if ($setcontext = $this->getArg('setcontext')) {
                 Kurogo::sharedInstance()->setUserContext($setcontext);
             }
             $responseVersion = 2;
             $response = array('primary' => array(), 'secondary' => array(), 'customize' => $this->getOptionalModuleVar('ALLOW_CUSTOMIZE', true), 'displayType' => $this->getOptionalModuleVar('display_type', 'springboard'));
             $allmodules = $this->getAllModules();
             $navModules = Kurogo::getSiteSections('navigation', Config::APPLY_CONTEXTS_NAVIGATION);
             foreach ($navModules as $moduleID => $moduleData) {
                 if ($module = Kurogo::arrayVal($allmodules, $moduleID)) {
                     $title = Kurogo::arrayVal($moduleData, 'title', $module->getModuleVar('title'));
                     $type = Kurogo::arrayVal($moduleData, 'type', 'primary');
                     $visible = Kurogo::arrayVal($moduleData, 'visible', 1);
                     $response[$type][] = array('tag' => $moduleID, 'title' => $title, 'visible' => (bool) $visible);
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion($responseVersion);
             break;
         default:
             $this->invalidCommand();
     }
 }
Example #19
0
 protected function initializeForPage()
 {
     if ($url = $this->getModuleVar('url')) {
         $this->logView();
         Kurogo::redirectToURL($url);
     } else {
         throw new KurogoConfigurationException("URL not specified");
     }
 }
 public function initializeForCommand()
 {
     switch ($this->command) {
         case 'version':
             $this->out(KUROGO_VERSION);
             return 0;
             break;
         case 'clearCaches':
             $result = Kurogo::sharedInstance()->clearCaches();
             return 0;
             break;
         case 'fetchAllData':
             $allModules = $this->getAllModules();
             $time = 0;
             $this->out("Fetching data for site: " . SITE_NAME);
             $start = microtime(true);
             foreach ($allModules as $moduleID => $module) {
                 if ($module->isEnabled() && $module->getOptionalModuleVar('PREFETCH_DATA')) {
                     $module->setDispatcher($this->Dispatcher());
                     try {
                         $module->init('fetchAllData');
                         $module->executeCommand();
                     } catch (KurogoException $e) {
                         $this->out("Error: " . $e->getMessage());
                     }
                 }
             }
             $end = microtime(true);
             $diff = $end - $start;
             $time += $diff;
             $this->out("Total: " . sprintf("%.2f", $end - $start) . " seconds.");
             return 0;
             break;
         case 'deployPostFlight':
             $this->verbose = $this->getArg('v');
             $this->out('Running KurogoShell kurogo deployPostFlight');
             $postFlightFilePath = SITE_SCRIPTS_DIR . DIRECTORY_SEPARATOR . 'deployPostFlight.sh';
             if (!file_exists($postFlightFilePath)) {
                 $this->out("{$postFlightFilePath} does not exist, skipping execution");
                 return 0;
             } elseif (!is_executable($postFlightFilePath)) {
                 $this->out("{$postFlightFilePath} exists, but is not executable. This must be fixed");
                 return 126;
             }
             $outputLines = array();
             exec(sprintf("%s %s %s", escapeshellcmd($postFlightFilePath), escapeshellarg(ROOT_DIR), escapeshellarg(SITE_DIR)), $outputLines, $returnValue);
             foreach ($outputLines as $lineNumber => $line) {
                 $this->out($line);
             }
             return $returnValue;
             break;
         default:
             $this->invalidCommand();
             break;
     }
 }
 protected function getScheduleFeed($sport)
 {
     $scheduleData = $this->loadScheduleData();
     if ($feedData = Kurogo::arrayVal($scheduleData, $sport)) {
         $dataModel = Kurogo::arrayVal($feedData, 'MODEL_CLASS', self::$defaultEventModel);
         $this->scheduleFeed = AthleticEventsDataModel::factory($dataModel, $feedData);
         return $this->scheduleFeed;
     }
     return null;
 }
 public static function getPhoneURL($value)
 {
     // add the local area code if missing
     if (preg_match('/^\\d{3}-?\\d{4}/', $value)) {
         $phone = Kurogo::getSiteVar('LOCAL_AREA_CODE') . $value;
     }
     // remove all non-digit characters except the character '+' for international phone numbers
     $phone = 'tel:' . preg_replace('/[^0-9\\+]/', '', $value);
     return $phone;
 }
 public function setBoundingBox($xmin, $ymin, $xmax, $ymax)
 {
     if ($xmax - $xmin > 0 && $ymax - $ymin > 0) {
         $this->bbox = array('xmin' => $xmin, 'ymin' => $ymin, 'xmax' => $xmax, 'ymax' => $ymax);
         $this->center = array('lat' => ($ymin + $ymax) / 2, 'lon' => ($xmin + $xmax) / 2);
         $this->zoomLevel = log(360 / ($xmax - $xmin), 2);
     } else {
         Kurogo::log(LOG_WARNING, "invalid bounding box {xmin={$xmin}, ymin={$ymin}, xmax={$xmax}, ymax={$ymax}}", "maps");
     }
 }
 public function getStaticNotificationContexts()
 {
     $contexts = array();
     $appData = Kurogo::getAppData();
     foreach ($appData as $platform => $data) {
         $version = $data['version'];
         $contexts[] = $platform . ':' . $version;
     }
     return $contexts;
 }
Example #25
0
 public static function getPhoneURL($value)
 {
     // add the local area code if missing
     if (preg_match('/^\\d{3}-?\\d{4}/', $value)) {
         $phone = Kurogo::getSiteVar('LOCAL_AREA_CODE') . $value;
     }
     // remove all non-word characters from the number
     $phone = 'tel:' . preg_replace('/\\W/', '', $value);
     return $phone;
 }
 protected function initializeForCommand()
 {
     // retrieve all Data for the About screen
     $stringArray = $this->getModuleArray('strings');
     $textArray = array('orgtext' => $this->getSiteAboutHTML(), 'abouttext' => $this->getAboutHTML(), 'orgname' => Kurogo::getSiteString('ORGANIZATION_NAME'), 'email' => Kurogo::getSiteString('FEEDBACK_EMAIL'), 'website' => Kurogo::getSiteString('COPYRIGHT_LINK'), 'copyright' => Kurogo::getSiteString('COPYRIGHT_NOTICE'));
     switch ($this->command) {
         case 'index':
             $dictionaryOfSections = $this->getModuleSections('api-index');
             $response = array();
             foreach ($dictionaryOfSections as $key => $value) {
                 $response[] = $value;
             }
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'about_site':
             $response = '<p>' . implode('</p><p>', $textArray['orgtext']) . '</p>';
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'about':
             $response = '<p>' . implode('</p><p>', $textArray['abouttext']) . '</p>';
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'credits':
             $response = $this->getCreditsHTML();
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'orgname':
         case 'orgtext':
         case 'abouttext':
         case 'copyright':
         case 'email':
         case 'website':
             $response = array($this->command => $textArray[$this->command]);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
             // Use 'alldata' to get everything in one API-CALL
         // Use 'alldata' to get everything in one API-CALL
         case 'alldata':
             $textArray['credits'] = $this->getCreditsHTML();
             $response = $textArray;
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         default:
             $this->invalidCommand();
             $this->setResponseVersion(1);
             break;
     }
 }
 public function addFilter($var, $value)
 {
     switch ($var)
     {
         case 'category':
             $this->addTrumbaFilter(Kurogo::getSiteVar('CALENDAR_CATEGORY_FILTER_FIELD'), $value);
             break;
         default:
             return parent::addFilter($var, $value);
     }
 }
Example #28
0
 protected function retrieveResponse()
 {
     $response = $this->initResponse();
     if (strpos($this->fileStem, '.zip') !== false) {
         if (!class_exists('ZipArchive')) {
             throw new KurogoException("class ZipArchive (php-zip) not available");
         }
         $response->setContext('zipped', true);
         $zip = new ZipArchive();
         if (strpos($this->fileStem, 'http') === 0 || strpos($this->fileStem, 'ftp') === 0) {
             $tmpFile = Kurogo::tempFile();
             copy($this->fileStem, $tmpFile);
             $zip->open($tmpFile);
         } else {
             $zip->open($this->fileStem);
         }
         // locate valid shapefile components
         $shapeNames = array();
         for ($i = 0; $i < $zip->numFiles; $i++) {
             if (preg_match('/(.+)\\.(shp|dbf|prj)$/', $zip->getNameIndex($i), $matches)) {
                 $shapeName = $matches[1];
                 $extension = $matches[2];
                 if (!isset($shapeNames[$shapeName])) {
                     $shapeNames[$shapeName] = array();
                 }
                 $shapeNames[$shapeName][] = $extension;
             }
         }
         $responseData = array();
         foreach ($shapeNames as $shapeName => $extensions) {
             if (in_array('dbf', $extensions) && in_array('shp', $extensions)) {
                 $fileData = array('dbf' => $zip->getFromName("{$shapeName}.dbf"), 'shp' => $zip->getFromName("{$shapeName}.shp"));
                 if (in_array('prj', $extensions)) {
                     $prjData = $zip->getFromName("{$shapeName}.prj");
                     $fileData['projection'] = new MapProjection($prjData);
                 }
                 $responseData[$shapeName] = $fileData;
             }
         }
         $response->setResponse($responseData);
     } elseif (realpath_exists("{$this->fileStem}.shp") && realpath_exists("{$this->fileStem}.dbf")) {
         $response->setContext('zipped', false);
         $response->setContext('shp', "{$this->fileStem}.shp");
         $response->setContext('dbf', "{$this->fileStem}.dbf");
         if (realpath_exists("{$this->fileStem}.prj")) {
             $prjData = file_get_contents("{$this->fileStem}.prj");
             $response->setContext('projection', new MapProjection($prjData));
         }
     } else {
         throw new KurogoDataException("Cannot find {$this->fileStem}");
     }
     return $response;
 }
Example #29
0
    public function initializeForCommand() {  
        if (!Kurogo::getSiteVar('AUTHENTICATION_ENABLED')) {
            throw new Exception("Authentication is not enabled on this site");
        }
        
        switch ($this->command) {
            case 'logout':
                if (!$this->isLoggedIn()) {
                    $this->redirectTo('session');
                } else {
                    $user = $this->getUser();
                    $authority = $user->getAuthenticationAuthority();
                    $authority->logout($this);
                    $this->redirectTo('session');
                }

                $this->setResponse($response);
                $this->setResponseVersion(1);
                break;
                
           case 'getuserdata':
                $key = $this->getArg('key', null);
                $user = $this->getUser();
                $response = $user->getUserData($key);
                $this->setResponse($response);
                $this->setResponseVersion(1);
                break;
                
           case 'session':
                $session = $this->getSession();
                $user = $this->getUser();
                
                $response = array(
                    'session_id'=>$session->getSessionID(),
                    'token'=>$session->getLoginToken(),
                    'user'=>array(
                        'authority'=>$user->getAuthenticationAuthorityIndex(),
                        'userID'=>$user->getUserID(),
                        'name'=>$user->getFullName(),
                        'sessiondata'=>$user->getSessionData()
                    )
                        
                );

                $this->setResponse($response);
                $this->setResponseVersion(1);
                break;
                
            default:
                $this->invalidCommand();
                break;
        }
    }
Example #30
0
 protected function init($args)
 {
     parent::init($args);
     $this->fieldMap = array('userid' => isset($args['KUROGO_USERID_FIELD']) ? $args['KUROGO_USERID_FIELD'] : 'uid', 'email' => isset($args['KUROGO_EMAIL_FIELD']) ? $args['KUROGO_EMAIL_FIELD'] : 'mail', 'fullname' => isset($args['KUROGO_FULLNAME_FIELD']) ? $args['KUROGO_FULLNAME_FIELD'] : '', 'firstname' => isset($args['KUROGO_FIRSTNAME_FIELD']) ? $args['KUROGO_FIRSTNAME_FIELD'] : 'givenname', 'lastname' => isset($args['KUROGO_LASTNAME_FIELD']) ? $args['KUROGO_LASTNAME_FIELD'] : 'sn', 'photodata' => isset($args['KUROGO_PHOTODATA_FIELD']) ? $args['KUROGO_PHOTODATA_FIELD'] : 'jpegphoto', 'phone' => isset($args['KUROGO_PHONE_FIELD']) ? $args['KUROGO_PHONE_FIELD'] : 'telephonenumber');
     if (isset($args['SORTFIELDS']) && is_array($args['SORTFIELDS'])) {
         $this->sortFields = $args['SORTFIELDS'];
     }
     if (isset($args['BASE_URL']) && $args['BASE_URL']) {
         $this->peopleAPI = rtrim($args['BASE_URL'], '/');
     }
     $this->feed = Kurogo::arrayVal($args, 'FEED');
     $this->setContext('fieldMap', $this->fieldMap);
 }