private static function _getObject(Resultset $rs, Project $project) { $ret = new Project_Log($project); $ret->setId($rs->getId()); $ret->setDate($rs->getDate()); $ret->setType($rs->getType()); $ret->setMessage($rs->getMessage()); $ret->setUsername($rs->getUsername()); $ret->resetSignature(); return $ret; }
public static function project() { // // Setting a new project? // if (isset($_GET['pid']) && !empty($_GET['pid'])) { $GLOBALS['project'] = Project::getById($GLOBALS['user'], $_GET['pid']); } if (!isset($GLOBALS['project']) || !$GLOBALS['project'] instanceof Project) { SystemEvent::raise(SystemEvent::ERROR, "Problems fetching requested project.", __METHOD__); // // TODO: Notification // // // TODO: this should really be a redirect to the previous page. // Redirector::redirectToUri(UrlManager::getForDashboard()); exit; } $_SESSION['projectId'] = $GLOBALS['project']->getId(); $GLOBALS['smarty']->assign('project_buildStats', Project_Build::getStats($GLOBALS['project'], $GLOBALS['user'])); $GLOBALS['smarty']->assign('project_log', Project_Log::getList($GLOBALS['project'], $GLOBALS['user'])); $GLOBALS['smarty']->assign('project_buildList', Project_Build::getList($GLOBALS['project'], $GLOBALS['user'])); $GLOBALS['smarty']->assign('project_build', Project_Build::getLatest($GLOBALS['project'], $GLOBALS['user'])); }
public static function dashboard_project() { SystemEvent::raise(SystemEvent::DEBUG, "Called.", __METHOD__); if (!isset($_REQUEST['pid'])) { $msg = 'Invalid request'; SystemEvent::raise(SystemEvent::INFO, $msg, __METHOD__); echo json_encode(array('success' => false, 'error' => $msg)); exit; } if (!($project = Project::getById($GLOBALS['user'], $_REQUEST['pid'], Access::READ)) instanceof Project) { $msg = 'Invalid request'; SystemEvent::raise(SystemEvent::INFO, $msg, __METHOD__); echo json_encode(array('success' => false, 'error' => $msg)); exit; } // The following is probably redundant because above the project is // already fetched with the Access constriction. if (!$project->userHasAccessLevel($GLOBALS['user'], Access::READ) && !$GLOBALS['user']->hasCos(UserCos::ROOT)) { $msg = 'Not authorized'; SystemEvent::raise(SystemEvent::INFO, $msg, __METHOD__); echo json_encode(array('success' => false, 'error' => $msg)); exit; } // // We need to process a Smarty file... // TODO: Centralize this // require_once CINTIENT_SMARTY_INCLUDE; $smarty = new Smarty(); $smarty->setAllowPhpTag(true); $smarty->setCacheLifetime(0); $smarty->setDebugging(SMARTY_DEBUG); $smarty->setForceCompile(SMARTY_FORCE_COMPILE); $smarty->setCompileCheck(SMARTY_COMPILE_CHECK); $smarty->setTemplateDir(SMARTY_TEMPLATE_DIR); $smarty->setCompileDir(SMARTY_COMPILE_DIR); $smarty->error_reporting = error_reporting(); Framework_SmartyPlugin::init($smarty); $smarty->assign('project_buildStats', Project_Build::getStats($project, $GLOBALS['user'])); $smarty->assign('project_log', Project_Log::getList($project, $GLOBALS['user'])); $smarty->assign('project_build', Project_Build::getLatest($project, $GLOBALS['user'])); $smarty->assign('project_builds', Project_Build::getList($project, $GLOBALS['user'], Access::READ, array('buildStatus' => Project_Build::STATUS_OK_WITH_PACKAGE, 'pageLength' => 5))); $smarty->assign('project', $project); $smarty->display('includes/dashboardProject.inc.tpl'); exit; }
/** * Logs an event to the project log. * * @param string $msg */ public function log($msg, $username = '', $type = 0) { $projectLog = new Project_Log($this); $projectLog->setType($type); $projectLog->setMessage($msg); $projectLog->setUsername($username); }