diff -r a3ac0b28bf15a547854822fecc1e4468cae13003 -r 6ea7cbeb38007f69a3e96f1808d7a2762347ef88 indefero/src/IDF/Migrations/Install.php --- a/indefero/src/IDF/Migrations/Install.php Sat Jul 27 19:38:12 2013 -0500 +++ b/indefero/src/IDF/Migrations/Install.php Tue Jul 30 19:15:42 2013 -0500 @@ -55,6 +55,7 @@ 'IDF_Gconf', 'IDF_EmailAddress', 'IDF_IssueRelation', + 'IDF_ProjectRequest' ); $db = Pluf::db(); $schema = new Pluf_DB_Schema($db); @@ -121,6 +122,7 @@ 'IDF_Project', 'IDF_EmailAddress', 'IDF_IssueRelation', + 'IDF_ProjectRequest' ); $db = Pluf::db(); $schema = new Pluf_DB_Schema($db); diff -r a3ac0b28bf15a547854822fecc1e4468cae13003 -r 6ea7cbeb38007f69a3e96f1808d7a2762347ef88 indefero/src/IDF/Project.php --- a/indefero/src/IDF/Project.php Sat Jul 27 19:38:12 2013 -0500 +++ b/indefero/src/IDF/Project.php Tue Jul 30 19:15:42 2013 -0500 @@ -109,7 +109,7 @@ 'default' => null, 'verbose' => __('current project activity'), ), - 'enableads' => + 'enableads' => array( 'type' => 'Pluf_DB_Field_Integer', 'blank' => false, diff -r a3ac0b28bf15a547854822fecc1e4468cae13003 -r 6ea7cbeb38007f69a3e96f1808d7a2762347ef88 indefero/src/IDF/Views.php --- a/indefero/src/IDF/Views.php Sat Jul 27 19:38:12 2013 -0500 +++ b/indefero/src/IDF/Views.php Tue Jul 30 19:15:42 2013 -0500 @@ -460,6 +460,29 @@ )); } + public static function getOwnedProjects($user) + { + $db =& Pluf::db(); + $false = Pluf_DB_BooleanToDb(false, $db); + $permSql = new Pluf_SQL( + "model_class='IDF_Project' AND owner_class='Pluf_User' ". + "AND owner_id=%s AND negative=".$false, $user->id + ); + $rows = Pluf::factory('Pluf_RowPermission')->getList(array('filter' => $permSql->gen())); + $ids = array(); + if ($rows->count() > 0) { + foreach ($rows as $row) { + if (in_array($row->model_id, $ids)) + continue; + $ids[] = $row->model_id; + } + } + $sql = new Pluf_SQL(sprintf("id IN (%s)", implode(", ", $ids))); + return Pluf::factory('IDF_Project')->getList(array( + 'filter'=> $sql->gen(), + )); + } + /** * Returns a list of global tags each carrying the number of projects that have the * particular tag set diff -r a3ac0b28bf15a547854822fecc1e4468cae13003 -r 6ea7cbeb38007f69a3e96f1808d7a2762347ef88 indefero/src/IDF/Views/Admin.php --- a/indefero/src/IDF/Views/Admin.php Sat Jul 27 19:38:12 2013 -0500 +++ b/indefero/src/IDF/Views/Admin.php Tue Jul 30 19:15:42 2013 -0500 @@ -174,6 +174,63 @@ $request); } + public $projectRequestCreate_precond = array('Pluf_Precondition::staffRequired'); + public function projectRequestCreate($request, $match) + { + $title = __('Create Requested Project'); + $createdtext = ""; + $form = null; + $errors = null; + if (count($match) == 2) + { + + $projreqobj = new IDF_ProjectRequest($match[1]); + $form = new IDF_Form_Admin_ProjectCreate(array( + "name" => $projreqobj->shortname, + "shortname" => $projreqobj->shortname, + "shortdesc" => $projreqobj->desc, + "scm" => $projreqobj->repotype, + "owners" => $projreqobj->get_submitter->login, + "template" => "--" + ), array("user" => $projreqobj->get_submitter)); + if ($form->isValid()) + { + + + + Pluf::loadFunction('Pluf_HTTP_URL_urlForView'); + $from_email = Pluf::f('from_email'); + $tmpl = new Pluf_Template('idf/admin/request-email.txt'); + $context = new Pluf_Template_Context(array("user" => $projreqobj->get_submitter, "shortname" => $projreqobj->shortname)); + $text_email = $tmpl->render($context); + $email = new Pluf_Mail($from_email, $projreqobj->get_submitter->email, + __('Status of repository request')); + $email->addTextMessage($text_email); + $email->sendMail(); + + $form->save(); + $projreqobj->delete(); + $createdtext = "Repo was created!"; + } else { + $errors = $form->errors; + $createdtext = "There was an error creating the repo!"; + } + } + + $projectreqs = Pluf::factory("IDF_ProjectRequest")->getList(); + //$projectreqs[0]->creation_dtime = "123"; + //print_r($projectreqs[0]->creation_dtime); + foreach($projectreqs as $p) { + $p->creation_dtime = Pluf_Date::gmDateToString($p->creation_dtime); + } + return Pluf_Shortcuts_RenderToResponse('idf/admin/approveprojects.html', array ( + 'page_title' => $title, + 'requests' => $projectreqs, + 'createdtext' => $createdtext, + 'form' => $form, + 'errors' => $errors + ), $request); + } /** * Creation of a project. * diff -r a3ac0b28bf15a547854822fecc1e4468cae13003 -r 6ea7cbeb38007f69a3e96f1808d7a2762347ef88 indefero/src/IDF/Views/Issue.php --- a/indefero/src/IDF/Views/Issue.php Sat Jul 27 19:38:12 2013 -0500 +++ b/indefero/src/IDF/Views/Issue.php Tue Jul 30 19:15:42 2013 -0500 @@ -61,9 +61,11 @@ 'id' => __('Id'), array('summary', 'IDF_Views_Issue_SummaryAndLabels', __('Summary')), array('status', 'IDF_Views_Issue_ShowStatus', __('Status')), + array('submitter', 'Pluf_Paginator_FkToString', __('submitter')), + array('owner', 'Pluf_Paginator_FkToString', __('owner')), array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')), ); - $pag->configure($list_display, array(), array('id', 'status', 'modif_dtime')); + $pag->configure($list_display, array(), array('id', 'status', 'owner', 'submitter', 'modif_dtime')); $pag->items_per_page = 10; $pag->no_results_text = __('No issues were found.'); $pag->setFromRequest($request); diff -r a3ac0b28bf15a547854822fecc1e4468cae13003 -r 6ea7cbeb38007f69a3e96f1808d7a2762347ef88 indefero/src/IDF/Views/Source.php --- a/indefero/src/IDF/Views/Source.php Sat Jul 27 19:38:12 2013 -0500 +++ b/indefero/src/IDF/Views/Source.php Tue Jul 30 19:15:42 2013 -0500 @@ -378,7 +378,12 @@ $previous = substr($request_file, 0, -strlen($l.' ')); $scmConf = $request->conf->getVal('scm', 'git'); $props = $scm->getProperties($commit, $request_file); - $content = IDF_FileUtil::highLight($extra['mime'], $scm->getFile($request_file_info)); + $cache = Pluf_Cache::factory(); + $key = sha1($request_file.$commit); + if (null === ($content=$cache->get($key))) { + $content = IDF_FileUtil::highLight($extra['mime'], $scm->getFile($request_file_info)); + $cache->set($key, $content); + } return Pluf_Shortcuts_RenderToResponse('idf/source/'.$scmConf.'/file.html', array( 'page_title' => $page_title, diff -r a3ac0b28bf15a547854822fecc1e4468cae13003 -r 6ea7cbeb38007f69a3e96f1808d7a2762347ef88 indefero/src/IDF/Views/User.php --- a/indefero/src/IDF/Views/User.php Sat Jul 27 19:38:12 2013 -0500 +++ b/indefero/src/IDF/Views/User.php Tue Jul 30 19:15:42 2013 -0500 @@ -32,6 +32,37 @@ */ class IDF_Views_User { + public $requestproject_precond = array('Pluf_Precondition::loginRequired'); + public function requestproject($request) + { + $params = array("user" => $request->user); + $title = __('Request Project'); + $success = false; + $error = false; + if ($request->method == 'POST') { + $form = new IDF_Form_ProjectRequest((array)$request->POST, $params); + if ($form->isValid()) { + $check = $form->save(); + if ($check) + { + $form = new IDF_Form_ProjectRequest(null, $params); + $success = true; + } else { + $error = "Repository shortname has already been taken."; + } + } + + } else { + $form = new IDF_Form_ProjectRequest(null, $params); + } + return Pluf_Shortcuts_RenderToResponse('idf/user/projectrequest.html', + array('page_title' => $title, + 'form' => $form, + 'success' => $success, + 'error' => $error), + $request); + + } /** * Dashboard of a user. * @@ -83,7 +114,7 @@ array('summary', 'IDF_Views_IssueSummaryAndLabels', __('Summary')), array('status', 'IDF_Views_Issue_ShowStatus', __('Status')), array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')), - ); + ); $pag->configure($list_display, array(), array('status', 'modif_dtime')); $pag->items_per_page = 10; $pag->no_results_text = ($working) ? __('No issues are assigned to you, yeah!') : __('All the issues you submitted are fixed, yeah!'); @@ -240,6 +271,7 @@ */ public function view($request, $match) { + $db =& Pluf::db(); $sql = new Pluf_SQL('login=%s', array($match[1])); $users = Pluf::factory('Pluf_User')->getList(array('filter'=>$sql->gen())); if (count($users) != 1 or !$users[0]->active) { @@ -248,20 +280,46 @@ $user = $users[0]; $user_data = IDF_UserData::factory($user); - //$projects = $request->user->getAllPermissions(); - //print_r($request->user->permissions); - //print_r($projects[0]); - //$projects = array(); - //foreach (IDF_Views::getProjects($request->user) as $project) { - // $projects[] = $project; - //} - $projects = IDF_Views::getProjects($request->user); - //print_r($projects); - return Pluf_Shortcuts_RenderToResponse('idf/user/public.html', + + $false = Pluf_DB_BooleanToDb(false, $db); + $sql_results = $db->select( + 'SELECT id FROM '.$db->pfx.'idf_projects '. + 'WHERE '.$db->qn('private').'='.$false + ); + + $ids = array(); + foreach ($sql_results as $id) { + $ids[] = $id['id']; + } + $f_sql = new Pluf_SQL('owner=%s AND project IN (' . implode(', ', $ids) . ' )', array($user->id)); + + $pag = new Pluf_Paginator(new IDF_Issue()); + $pag->class = 'recent-issues'; + $pag->item_extra_props = array('current_user' => $request->user); + $pag->summary = __('This table shows the open issues.'); + $pag->forced_where = $f_sql; + $pag->action = 'idf_dashboard'; + $pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted + $pag->sort_reverse_order = array('modif_dtime'); + $list_display = array( + 'id' => __('Id'), + array('project', 'Pluf_Paginator_FkToString', __('Project')), + array('summary', 'IDF_Views_IssueSummaryAndLabels', __('Summary')), + array('status', 'IDF_Views_Issue_ShowStatus', __('Status')), + array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')), + ); + $pag->configure($list_display, array(), array('status', 'modif_dtime')); + $pag->items_per_page = 10; + $pag->no_results_text = __('This user has no issues assigned to them!'); + $pag->setFromRequest($request); + + $projects = IDF_Views::getOwnedProjects($user); + return Pluf_Shortcuts_RenderToResponse('idf/user/public.html', array('page_title' => (string) $user, 'member' => $user, 'user_data' => $user_data, - 'projects' => $projects + 'projects' => $projects, + 'issues' => $pag ), $request); } diff -r a3ac0b28bf15a547854822fecc1e4468cae13003 -r 6ea7cbeb38007f69a3e96f1808d7a2762347ef88 indefero/src/IDF/conf/urls.php --- a/indefero/src/IDF/conf/urls.php Sat Jul 27 19:38:12 2013 -0500 +++ b/indefero/src/IDF/conf/urls.php Tue Jul 30 19:15:42 2013 -0500 @@ -56,6 +56,12 @@ 'method' => 'dashboard', 'name' => 'idf_dashboard'); +$ctl[] = array('regex' => '#^/requestproject/$#', + 'base' => $base, + 'model' => 'IDF_Views_User', + 'method' => 'requestproject', + 'name' => 'idf_requestproject'); + $ctl[] = array('regex' => '#^/dashboard/submitted/$#', 'base' => $base, 'model' => 'IDF_Views_User', @@ -503,6 +509,16 @@ 'model' => 'IDF_Views_Admin', 'method' => 'projectCreate'); +$ctl[] = array('regex' => '#^/admin/projects/createrequest/$#', + 'base' => $base, + 'model' => 'IDF_Views_Admin', + 'method' => 'projectRequestCreate'); + +$ctl[] = array('regex' => '#^/admin/projects/createrequest/(\d+/)?$#', + 'base' => $base, + 'model' => 'IDF_Views_Admin', + 'method' => 'projectRequestCreate'); + $ctl[] = array('regex' => '#^/admin/projects/(\d+)/delete/$#', 'base' => $base, 'model' => 'IDF_Views_Admin', diff -r a3ac0b28bf15a547854822fecc1e4468cae13003 -r 6ea7cbeb38007f69a3e96f1808d7a2762347ef88 indefero/src/IDF/templates/idf/gadmin/base.html --- a/indefero/src/IDF/templates/idf/gadmin/base.html Sat Jul 27 19:38:12 2013 -0500 +++ b/indefero/src/IDF/templates/idf/gadmin/base.html Tue Jul 30 19:15:42 2013 -0500 @@ -42,6 +42,7 @@ {trans 'Forge'} {trans 'Projects'} {trans 'People'} + Approve Repo {if $usherConfigured} {trans 'Usher'} {/if} diff -r a3ac0b28bf15a547854822fecc1e4468cae13003 -r 6ea7cbeb38007f69a3e96f1808d7a2762347ef88 indefero/src/IDF/templates/idf/main-menu.html --- a/indefero/src/IDF/templates/idf/main-menu.html Sat Jul 27 19:38:12 2013 -0500 +++ b/indefero/src/IDF/templates/idf/main-menu.html Tue Jul 30 19:15:42 2013 -0500 @@ -3,7 +3,9 @@ {if !$user.isAnonymous()} {aurl 'url', 'idf_dashboard'}