public function init() { if (!Zend_Registry::isRegistered('user')) { if ($user = $this->getRequest()->getParam("user")) { $users = new Users(); if ($user = $users->getUserFromUsername($user)) { Zend_Registry::set("user", $user); } } } $this->_user = Zend_Registry::get("user"); if (!Zend_Registry::isRegistered('shard')) { Zend_Registry::set("shard", $this->_user->id); } if (Zend_Registry::isRegistered("cache")) { $this->_cache = Zend_Registry::get("cache"); } if (Zend_Registry::isRegistered("root")) { $this->_root = Zend_Registry::get("root"); } if (Zend_Registry::isRegistered("configuration")) { $this->_config = Zend_Registry::get("configuration"); } // Other global variables $this->_application = Stuffpress_Application::getInstance(); $this->_properties = new Properties(array(Stuffpress_Db_Properties::KEY => $this->_user->id)); $this->_admin = $this->_application->user && $this->_application->user->id == $this->_user->id ? true : false; // Disable layout if XMLHTTPRequest if ($this->_request->isXmlHttpRequest()) { $this->_helper->layout->disableLayout(); } }
public function hasRole($role) { $application = Stuffpress_Application::getInstance(); // TODO this is temporary as it will only work in our // current simple scenario return $role == $application->role; }
public function init() { $this->_application = Stuffpress_Application::getInstance(); // If request is from a bookmarklet, we use another layout if ($this->_hasParam('bookmarklet') && $this->_getParam('bookmarklet')) { $this->_helper->layout->setlayout('bookmarklet'); $this->_bookmarklet = true; $this->view->bookmarklet = true; } }
public function indexAction() { $application = Stuffpress_Application::getInstance(); // If we are not logged in, we have a problem if ($application->role != 'guest') { $sources = new Sources(array(Stuffpress_Db_Table::USER => $application->user->id)); $mysources = $sources->getSources(); if (count($mysources) > 1) { return $this->_forward('index', 'post', 'admin'); } else { return $this->_forward('index', 'services', 'admin'); } } else { return $this->_forward('index', 'auth', 'admin'); } }
public function init() { if (Zend_Registry::isRegistered("cache")) { $this->_cache = Zend_Registry::get("cache"); } if (Zend_Registry::isRegistered("configuration")) { $this->_config = Zend_Registry::get("configuration"); } $this->_application = Stuffpress_Application::getInstance(); if (!Zend_Registry::isRegistered('shard')) { Zend_Registry::set("shard", $this->_application->user->id); } if (Zend_Registry::isRegistered("root")) { $this->_root = Zend_Registry::get("root"); } $this->_properties = new Properties(array(Stuffpress_Db_Properties::KEY => $this->_application->user->id)); // Disable layout if XMLHTTPRequest if ($this->_request->isXmlHttpRequest()) { $this->_helper->layout->disableLayout(); $this->_ajax = true; } }
public function submitAction() { if (!$this->getRequest()->isPost()) { return $this->_helper->json->sendJson(true); } $form = $this->getForm(); if (!$form->isValid($_POST)) { return $this->_helper->json->sendJson($form->getErrorArray()); } // Get the values and proceed $values = $form->getValues(); $title = $values['title']; $id = $values['id']; // Get the user $application = Stuffpress_Application::getInstance(); // Get the widget properties $properties = new WidgetsProperties(array(Properties::KEY => $id, Properties::USER => $application->user->id)); // Save the new properties $properties->setProperty('title', $title); // Ok send the result return $this->_helper->json->sendJson(false); }
/** * Returns an entry of comment * * @param Comment $comment * @param AtomEntryAdapter|null $entry * @return AtomEntryAdapter */ public function buildCommentEntry($comment, $item, $entry = null) { $entry = $this->_prepareEntry($entry); $entry->id = $this->_getCommentId($comment); $entry->title = $comment->getAuthorName() . "\\'s comment"; $entry->updated = toAtomDate(strtotime($comment->getPublished())); //actually this is published $entry->published = toAtomDate(strtotime($comment->getPublished())); $entry->content = $this->xmlentities($comment->getText()); $entry->content->type = AtomNS::TYPE_HTML; // build the activity entry $activityEntry = $entry->getExtension(ActivityNS::NS); /* @var $activityEntry ActivityEntryExtension */ $activityEntry->addVerb(ActivityNS::POST_VERB); //build the activity object $activityObject = $activityEntry->addObject(); $activityObject->addObjectType(ActivityNS::COMMENT_OBJECT_TYPE); $activityObject->id = $comment->getCommentId($comment); $activityObject->title = ''; $author = $activityObject->addAuthor(); $name = $comment->getAuthorName(); $uri = $comment->getAuthorWebsite(); $email = $comment->getAuthorEmail(); if ($name != '') { $author->name = $name; } if ($uri != '') { $author->uri = $uri; } if ($email != '') { $author->email = $email; } $activityObject->content = $comment->getText(); $activityObject->content->type = AtomNS::TYPE_HTML; // Set Alternative Link $objectAltLink = $activityObject->addLink(); $objectAltLink->setRel(AtomNS::REL_ALTERNATE); $objectAltLink->setType('text/html'); $objectAltLink->setHref(''); $application = Stuffpress_Application::getInstance(); $href = 'http://' . $this->_domain . '/api/comments/' . $this->_getObjectId($item) . '/' . $this->_getCommentId($comment); // Set Edit Link $ObjectEditLink = $activityObject->addLink(); $ObjectEditLink->setRel(AtomNS::REL_EDIT); $ObjectEditLink->setHref($href); return $entry; }
public function preDispatch() { $this->_application = Stuffpress_Application::getInstance(); }
public static function parseDomain() { $config = Zend_Registry::get('configuration'); $our_host = $config->web->host; $this_host = @$_SERVER['HTTP_HOST']; $uri = @$_SERVER['REQUEST_URI']; $application = Stuffpress_Application::getInstance(); $users = new Users(); // Save the uri for debug purposes self::$registry->uri = $uri; // Do we hit our main domain ? if ($our_host == $this_host) { self::$registry->host = $our_host; // Is a user specified in the config ? if (isset($config->app->user)) { if ($user = $users->getUserFromUsername($config->app->user)) { self::$registry->user = $user; } } return; } // A user storytlr page if (preg_match("/(?<user>[a-zA-Z0-9]+).{$our_host}\$/", $this_host, $matches)) { $username = $matches['user']; if ($user = $users->getUserFromUsername($username)) { if ($config->web->redirect && strlen($user->domain) > 0) { if (!isset($application->user) || $application->user->id != $user->id) { $url = "http://{$user->domain}{$uri}"; header("Location: {$url}"); exit; } } self::$registry->host = $this_host; self::$registry->user = $user; return; } else { header("Location: http://{$our_host}"); exit; } } // A or CNAME ? if ($user = $users->getUserFromDomain($this_host)) { self::$registry->host = $this_host; self::$registry->user = $user; return; } // Maybe we should strip the www in front ? $matches = array(); if (preg_match("/www.(.*)/", $this_host, $matches)) { if ($user = $users->getUserFromDomain($matches[1])) { self::$registry->host = $this_host; self::$registry->user = $user; return; } } // Last chance header("Location: http://{$our_host}"); exit; }
public function myDomain($cname = true) { $application = Stuffpress_Application::getInstance(); return $application->getPublicDomain($cname); }
public function getAccountName() { return Stuffpress_Application::getInstance()->user->username; }
public function init() { $this->_application = Stuffpress_Application::getInstance(); }
public function init() { $this->_application = Stuffpress_Application::getInstance(); $this->view->section = 'tools'; }