public function deliver_featured() { // send feature notifications global $init; require_once PATH_FACEBOOK . "/classes/app.class.php"; $app = new app(NULL, true); $facebook =& $app->loadFacebookLibrary(); require_once PATH_CORE . '/classes/subscriptions.class.php'; $subObj = new SubscriptionsManager($db); $subObj->loadFacebook($facebook); $subObj->deliverFeatures(); set_flash(array('notice' => "Feature notifications sent.")); redirect(url_for($this->name, 'index')); }
public static function getInstance() { if (self::$instance == null) { self::$instance = new SubscriptionsManager(); } return self::$instance; }
public function execute(Request $request) { if (LOGGING) { Log::log(LoggingConstants::DEBUG, "commandmessage " . $this->operation . " operation"); } /*Object*/ $returnValue = null; if ($this->operation == "0") { /*IDestination*/ $destObj = ORBConfig::getInstance()->getDataServices()->getDestinationManager()->getDestination($this->destination); /*Hashtable*/ $headers = array(); if ($destObj != null) { /*String*/ $selectorName = $this->headers["DSSelector"]; /*String*/ $subtopic = $this->headers["DSSubtopic"]; /*String*/ $dsId = $this->headers["DSId"]; /*Subscriber*/ $subscriber = new Subscriber($selectorName, $destObj); $subscriber->setDSId($dsId); $subscriber->setSubtopic($subtopic); $guid = new GUID(); $subscriber->setClientId($guid->toString()); SubscriptionsManager::getInstance()->addSubscriber($dsId, $subscriber); $destObj->getServiceHandler()->handleSubscribe($subscriber); } else { /*String*/ $error = "Unknown destination " . $this->destination . ". Cannot handle subscription request"; if (LOGGING) { Log::log(LoggingConstants::ERROR, $error); } return new ErrMessage($this->messageId, new Exception($error)); } return new AckMessage($this->messageId, $clientId, null, $headers); } else { if ($this->operation == "1") { /*String*/ $dsId = $this->headers["DSId"]; /*Subscriber*/ $subscriber = SubscriptionsManager::getInstance()->getSubscriber($dsId); if ($subscriber == null) { return new ErrMessage($this->messageId, new Exception("Unable to unsubscribe - unknown client")); } /*IDestination*/ $destination = $subscriber->getDestination(); $destination->getServiceHandler()->handleUnsubscribe($subscriber); SubscriptionsManager::getInstance()->removeSubscriber($dsId); } else { if ($this->operation == "2") { /*String*/ $dsId = $this->headers["DSId"]; /*Subscriber*/ $subscriber = SubscriptionsManager::getInstance()->getSubscriber($dsId); if ($subscriber == null) { /*String*/ $error = "Invalid client id " . $dsId; if (LOGGING) { Log::log(LoggingConstants::ERROR, $error); } return new ErrMessage($this->messageId, new Exception($error)); } /*IDestination*/ $destination = $subscriber->getDestination(); //Log::log( LoggingConstants::INFO, "Getting messages from " . $destination->getServiceHandler() ); /*ArrayList*/ $messages = $destination->getServiceHandler()->getMessages($subscriber); $subscriber->setLastRequestTime(microtime(true)); if (count($messages) == 0) { return new AckMessage(null, null, null, array()); } return $this->createCmdMessage("4", $messages); } else { if ($this->operation == "5") { /*Hashtable*/ $headers = array(); $guid = new GUID(); $headers["DSId"] = $guid->toString(); return new AckMessage($this->messageId, $this->clientId, null, $headers); } else { if ($this->operation == "9") { ThreadContext::setCallerCredentials(null); } else { if ($this->operation == "8") { $arr = $this->body->getBody(); $adaptingType = $arr[0]; $authData = split(":", base64_decode($adaptingType->defaultAdapt())); $credentials = new Credentials($authData[0], $authData[1]); $authHandler = ORBSecurity::getAuthenticationHandler(ThreadContext::getORBConfig()); if (LOGGING) { Log::log(LoggingConstants::DEBUG, "got auth handler " . get_class($authHandler)); } if ($authHandler == null) { $errorMessage = new ErrMessage($this->messageId, new ServiceException("Missing authentication handler")); $errorMessage->faultCode = "Client.Authentication"; return $errorMessage; } try { $authHandler->checkCredentials($credentials->getUserId(), $credentials->getPassword(), $request); if (LOGGING) { Log::log(LoggingConstants::DEBUG, "credentials are valid "); } ThreadContext::setCallerCredentials($credentials); } catch (Exception $e) { if (LOGGING) { Log::log(LoggingConstants::EXCEPTION, "authentication exception" . $e); } $errorMessage = new ErrMessage($this->messageId, $e); $errorMessage->faultCode = "Client.Authentication"; return $errorMessage; } return new AckMessage($this->messageId, $this->clientId, null); } } } } } } //echo $this->operation; exit; return new AckMessage($this->messageId, $this->clientId, $returnValue, array()); }
echo 'Uploading settings in SystemStatus table up to Facebook Developer application<br />'; require_once PATH_CORE . '/classes/systemStatus.class.php'; $ssObj = new systemStatus(); $propList = $ssObj->loadFacebookProperties(); echo 'These settings will be uploaded:<br />'; print_r($propList); echo '<br />'; require_once PATH_FACEBOOK . "/classes/app.class.php"; $app = new app(NULL, true); $facebook =& $app->loadFacebookLibrary(); $props = $facebook->api_client->admin_setAppProperties($propList); echo 'Completed settings upload. Visit the <a href="http://www.facebook.com/developers/apps.php?app_id=' . $init['fbAppId'] . '">Facebook Developer app</a> to review them.<br />'; break; case 'populateSubscriptions': require_once PATH_CORE . '/classes/subscriptions.class.php'; $subObj = new SubscriptionsManager($db); $subObj->populateSubscriptions(); break; case 'resetDB': require_once PATH_CORE . '/classes/cleanup.class.php'; $cObj = new cleanup($db); $cObj->flushDatabase(); if (MODULE_FACEBOOK) { echo 'cleaning up fb tables<br />'; require_once PATH_FACEBOOK . '/classes/cleanupFacebook.class.php'; $cleanupObj = new cleanupFacebook($db, ''); $cleanupObj->flushDatabase(); echo 'fb/st Database cleansed<br />'; } break; case 'resetLog':