/** * Pub view for project files, notes etc. * * @return void */ public function displayTask() { require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'tables' . DS . 'publicstamp.php'; // Incoming $stamp = Request::getVar('s', ''); // Clean up stamp value (only numbers and letters) $regex = array('/[^a-zA-Z0-9]/'); $stamp = preg_replace($regex, '', $stamp); // Load item reference $objSt = new Tables\Stamp($this->database); if (!$stamp || !$objSt->loadItem($stamp)) { App::redirect(Route::url('index.php?option=' . $this->_option)); return; } // Can only serve files or notes at the moment if (!in_array($objSt->type, array('files', 'notes', 'publications'))) { App::redirect(Route::url('index.php?option=' . $this->_option)); return; } // Serve requested item $content = Event::trigger('projects.serve', array($objSt->type, $objSt->projectid, $objSt->reference)); // Output foreach ($content as $out) { if ($out) { return $out; } } // Redirect if nothing fetched App::redirect(Route::url('index.php?option=' . $this->_option)); return; }
/** * Get public stamp for note * * @return object */ public function getPublicStamp($id = 0, $register = false, $listed = NULL) { if (!is_file(PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'tables' . DS . 'publicstamp.php')) { return false; } $page = $this->page($id); if (!$page) { return false; } require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'tables' . DS . 'publicstamp.php'; $objSt = new Tables\Stamp($this->_db); // Build reference for latest revision of page $reference = array('pageid' => $page->get('id'), 'pagename' => $page->get('pagename'), 'revision' => NULL); // Check valid stamp $objSt->checkStamp($this->_project_id, json_encode($reference), 'notes'); $list = $listed !== NULL && $listed != $objSt->listed ? true : false; if ($list == true) { return $objSt->registerStamp($this->_project_id, json_encode($reference), 'notes', $listed); } // Register new stamp? if (!$objSt->id && $register == true) { $objSt->registerStamp($this->_project_id, json_encode($reference), 'notes', $listed); $objSt->checkStamp($this->_project_id, json_encode($reference), 'notes'); } return $objSt; }