From ef58d4135f3d43770f94af12dadeee7e47ef3921 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sat, 27 Jul 2013 19:17:56 -0500 Subject: [PATCH 1/6] Fixing issue with indefero repo and removing registration key --- indefero/src/IDF/Form/Register.php | 9 +-------- indefero/src/IDF/Scm/Git.php | 17 +++++++++++++++-- .../src/IDF/templates/idf/register/index.html | 7 ------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/indefero/src/IDF/Form/Register.php b/indefero/src/IDF/Form/Register.php index 085cd7e..47bfafd 100644 --- a/indefero/src/IDF/Form/Register.php +++ b/indefero/src/IDF/Form/Register.php @@ -55,12 +55,6 @@ class IDF_Form_Register extends Pluf_Form 'help_text' => __('We will never send you any unsolicited emails. We hate spam too!'), )); - $this->fields['regkey'] = new Pluf_Form_Field_Varchar( - array('required' => true, - 'label' => __('Registration Key'), - 'initial' => '', - 'help_text' => __('Please enter the key given to you by adamsna[at]datanethost.net'), - )); $this->fields['terms'] = new Pluf_Form_Field_Boolean( array('required' => true, @@ -71,8 +65,7 @@ class IDF_Form_Register extends Pluf_Form public function clean_regkey() { - if ($this->cleaned_data['regkey'] != "2rv9o4nb5") - throw new Pluf_Form_Invalid("The regkey was incorrect - please contact Nathan for the key!"); + } /** diff --git a/indefero/src/IDF/Scm/Git.php b/indefero/src/IDF/Scm/Git.php index e357988..6117d1b 100644 --- a/indefero/src/IDF/Scm/Git.php +++ b/indefero/src/IDF/Scm/Git.php @@ -74,9 +74,11 @@ class IDF_Scm_Git extends IDF_Scm foreach ($out as $line) { $line = trim($line); + if ($line != '') { $action = $line[0]; - + #echo "line = " . $line . "\n"; + #echo "action = " . $action; if ($action == 'A') { $filename = trim(substr($line, 1)); $return->additions[] = $filename; @@ -87,8 +89,19 @@ class IDF_Scm_Git extends IDF_Scm $filename = trim(substr($line, 1)); $return->patches[] = $filename; } else if ($action == 'R') { + // This patch is needed because it seems + // that under a merge git may show a status + // of RC and not say the location of the original file $matches = preg_split("/\t/", $line); - $return->renames[$matches[1]] = $matches[2]; + if (count($matches) != 3) + { + $return->additions[] = $matches[1]; + } + else + { + $return->renames[$matches[1]] = $matches[2]; + } + } else if ($action == 'C') { $matches = preg_split("/\t/", $line); $return->copies[$matches[1]] = $matches[2]; diff --git a/indefero/src/IDF/templates/idf/register/index.html b/indefero/src/IDF/templates/idf/register/index.html index 0d63a4f..a5f9f64 100644 --- a/indefero/src/IDF/templates/idf/register/index.html +++ b/indefero/src/IDF/templates/idf/register/index.html @@ -19,13 +19,6 @@ -{$form.f.regkey.labelTag}: -{if $form.f.regkey.errors}{$form.f.regkey.fieldErrors}{/if} -{$form.f.regkey|unsafe}
-{$form.f.regkey.help_text} - - - {$form.f.email.labelTag}: {if $form.f.email.errors}{$form.f.email.fieldErrors}{/if} {$form.f.email|unsafe}
From def4ce728385a367c2b2ce7752db15f7adbf934e Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sat, 27 Jul 2013 19:38:12 -0500 Subject: [PATCH 2/6] Removing uneeded comments --- indefero/src/IDF/Scm/Git.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/indefero/src/IDF/Scm/Git.php b/indefero/src/IDF/Scm/Git.php index 6117d1b..be98d89 100644 --- a/indefero/src/IDF/Scm/Git.php +++ b/indefero/src/IDF/Scm/Git.php @@ -77,8 +77,6 @@ class IDF_Scm_Git extends IDF_Scm if ($line != '') { $action = $line[0]; - #echo "line = " . $line . "\n"; - #echo "action = " . $action; if ($action == 'A') { $filename = trim(substr($line, 1)); $return->additions[] = $filename; From d4994854c95f154d857d3bddf1e34f6d3910ddb2 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Tue, 30 Jul 2013 19:15:42 -0500 Subject: [PATCH 3/6] Fixing APC with latest version of PHP Adding ability for user to request repo and staff members to approve repos - issue 9 Fixing issue 11 adding caching for requesting file contents with mercurial Fixing issue 10 user profiles only show the projects that they are an owner on --- indefero/src/IDF/Migrations/Install.php | 2 + indefero/src/IDF/Project.php | 2 +- indefero/src/IDF/Views.php | 23 ++++++ indefero/src/IDF/Views/Admin.php | 57 +++++++++++++ indefero/src/IDF/Views/Issue.php | 4 +- indefero/src/IDF/Views/Source.php | 7 +- indefero/src/IDF/Views/User.php | 82 ++++++++++++++++--- indefero/src/IDF/conf/urls.php | 16 ++++ .../src/IDF/templates/idf/gadmin/base.html | 1 + indefero/src/IDF/templates/idf/main-menu.html | 4 +- .../src/IDF/templates/idf/user/public.html | 2 + pluf/src/Pluf/Cache/Apc.php | 2 +- pluf/src/Pluf/Search/ResultSet.php | 3 +- 13 files changed, 187 insertions(+), 18 deletions(-) diff --git a/indefero/src/IDF/Migrations/Install.php b/indefero/src/IDF/Migrations/Install.php index 89b5880..80496ec 100644 --- a/indefero/src/IDF/Migrations/Install.php +++ b/indefero/src/IDF/Migrations/Install.php @@ -55,6 +55,7 @@ function IDF_Migrations_Install_setup($params=null) 'IDF_Gconf', 'IDF_EmailAddress', 'IDF_IssueRelation', + 'IDF_ProjectRequest' ); $db = Pluf::db(); $schema = new Pluf_DB_Schema($db); @@ -121,6 +122,7 @@ function IDF_Migrations_Install_teardown($params=null) 'IDF_Project', 'IDF_EmailAddress', 'IDF_IssueRelation', + 'IDF_ProjectRequest' ); $db = Pluf::db(); $schema = new Pluf_DB_Schema($db); diff --git a/indefero/src/IDF/Project.php b/indefero/src/IDF/Project.php index c298047..e2232c1 100644 --- a/indefero/src/IDF/Project.php +++ b/indefero/src/IDF/Project.php @@ -109,7 +109,7 @@ class IDF_Project extends Pluf_Model 'default' => null, 'verbose' => __('current project activity'), ), - 'enableads' => + 'enableads' => array( 'type' => 'Pluf_DB_Field_Integer', 'blank' => false, diff --git a/indefero/src/IDF/Views.php b/indefero/src/IDF/Views.php index 1e1b22f..3940567 100644 --- a/indefero/src/IDF/Views.php +++ b/indefero/src/IDF/Views.php @@ -460,6 +460,29 @@ class IDF_Views )); } + 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 --git a/indefero/src/IDF/Views/Admin.php b/indefero/src/IDF/Views/Admin.php index 9b68e7b..30ed598 100644 --- a/indefero/src/IDF/Views/Admin.php +++ b/indefero/src/IDF/Views/Admin.php @@ -174,6 +174,63 @@ class IDF_Views_Admin $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 --git a/indefero/src/IDF/Views/Issue.php b/indefero/src/IDF/Views/Issue.php index f1f0100..ae56313 100644 --- a/indefero/src/IDF/Views/Issue.php +++ b/indefero/src/IDF/Views/Issue.php @@ -61,9 +61,11 @@ class IDF_Views_Issue '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 --git a/indefero/src/IDF/Views/Source.php b/indefero/src/IDF/Views/Source.php index 225d74a..225f662 100644 --- a/indefero/src/IDF/Views/Source.php +++ b/indefero/src/IDF/Views/Source.php @@ -378,7 +378,12 @@ class IDF_Views_Source $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 --git a/indefero/src/IDF/Views/User.php b/indefero/src/IDF/Views/User.php index 6e5f446..59543cd 100644 --- a/indefero/src/IDF/Views/User.php +++ b/indefero/src/IDF/Views/User.php @@ -32,6 +32,37 @@ Pluf::loadFunction('Pluf_Shortcuts_RenderToResponse'); */ 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 @@ class IDF_Views_User 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 @@ class IDF_Views_User */ 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 @@ class IDF_Views_User $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 --git a/indefero/src/IDF/conf/urls.php b/indefero/src/IDF/conf/urls.php index eac28ae..000723e 100644 --- a/indefero/src/IDF/conf/urls.php +++ b/indefero/src/IDF/conf/urls.php @@ -56,6 +56,12 @@ $ctl[] = array('regex' => '#^/dashboard/$#', '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 @@ $ctl[] = array('regex' => '#^/admin/projects/create/$#', '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 --git a/indefero/src/IDF/templates/idf/gadmin/base.html b/indefero/src/IDF/templates/idf/gadmin/base.html index 641b34f..fba97e2 100644 --- a/indefero/src/IDF/templates/idf/gadmin/base.html +++ b/indefero/src/IDF/templates/idf/gadmin/base.html @@ -42,6 +42,7 @@ {trans 'Forge'} {trans 'Projects'} {trans 'People'} + Approve Repo {if $usherConfigured} {trans 'Usher'} {/if} diff --git a/indefero/src/IDF/templates/idf/main-menu.html b/indefero/src/IDF/templates/idf/main-menu.html index b4ae475..fc17ea1 100644 --- a/indefero/src/IDF/templates/idf/main-menu.html +++ b/indefero/src/IDF/templates/idf/main-menu.html @@ -3,7 +3,9 @@ {if !$user.isAnonymous()} {aurl 'url', 'idf_dashboard'}
  • {blocktrans}Welcome, {$user}.{/blocktrans} -{trans 'Sign Out'}
  • {else}
  • + {trans 'Sign Out'}
  • +
  • Request Project
  • + {else} {trans 'Sign in or create your account'} {/if}{if $customForgePageEnabled}
  • {trans 'Home'}
  • diff --git a/indefero/src/IDF/templates/idf/user/public.html b/indefero/src/IDF/templates/idf/user/public.html index 4021211..f5bd5e1 100644 --- a/indefero/src/IDF/templates/idf/user/public.html +++ b/indefero/src/IDF/templates/idf/user/public.html @@ -56,6 +56,8 @@ Projects: {/if} {/foreach} +Issues user is working on:

    +{$issues.render} {/block} {block context}
    diff --git a/pluf/src/Pluf/Cache/Apc.php b/pluf/src/Pluf/Cache/Apc.php index ca559dc..20079ed 100644 --- a/pluf/src/Pluf/Cache/Apc.php +++ b/pluf/src/Pluf/Cache/Apc.php @@ -94,7 +94,7 @@ class Pluf_Cache_Apc extends Pluf_Cache public function get($key, $default=null) { $success = false; - $value = apc_fetch($this->keyprefix.$key, &$success); + $value = apc_fetch($this->keyprefix.$key, $success); if (!$success) return $default; if ($this->compress) $value = gzinflate($value); return unserialize($value); diff --git a/pluf/src/Pluf/Search/ResultSet.php b/pluf/src/Pluf/Search/ResultSet.php index 54977ad..05f2479 100644 --- a/pluf/src/Pluf/Search/ResultSet.php +++ b/pluf/src/Pluf/Search/ResultSet.php @@ -27,7 +27,8 @@ */ class Pluf_Search_ResultSet implements Iterator { - protected $results = array(); + // Needs to be public for using in Wiki when there are over 100 pages + public $results = array(); public function __construct($search_res) { From f62d20f0d19785335546010e2e0d312c1ee6e258 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Tue, 30 Jul 2013 19:45:33 -0500 Subject: [PATCH 4/6] Adding migration for project request --- .../src/IDF/Migrations/27ProjectRequest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 indefero/src/IDF/Migrations/27ProjectRequest.php diff --git a/indefero/src/IDF/Migrations/27ProjectRequest.php b/indefero/src/IDF/Migrations/27ProjectRequest.php new file mode 100644 index 0000000..7f727eb --- /dev/null +++ b/indefero/src/IDF/Migrations/27ProjectRequest.php @@ -0,0 +1,17 @@ +model = new IDF_ProjectRequest(); + $schema->createTables(); +} + +function IDF_Migrations_27ProjectRequest_down($params=null) +{ + $db = Pluf::db(); + $schema = new Pluf_DB_Schema($db); + $schema->model = new IDF_ProjectRequest(); + $schema->dropTables(); + +} \ No newline at end of file From 2f981e42e5307f4bad045149eb28a6fa5248bd8d Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Tue, 30 Jul 2013 19:50:05 -0500 Subject: [PATCH 5/6] Adding projectrequest files --- indefero/src/IDF/Form/ProjectRequest.php | 72 ++++++++++++++++ indefero/src/IDF/ProjectRequest.php | 85 +++++++++++++++++++ .../templates/idf/admin/approveprojects.html | 60 +++++++++++++ .../IDF/templates/idf/admin/request-email.txt | 10 +++ .../templates/idf/user/projectrequest.html | 60 +++++++++++++ 5 files changed, 287 insertions(+) create mode 100644 indefero/src/IDF/Form/ProjectRequest.php create mode 100644 indefero/src/IDF/ProjectRequest.php create mode 100644 indefero/src/IDF/templates/idf/admin/approveprojects.html create mode 100644 indefero/src/IDF/templates/idf/admin/request-email.txt create mode 100644 indefero/src/IDF/templates/idf/user/projectrequest.html diff --git a/indefero/src/IDF/Form/ProjectRequest.php b/indefero/src/IDF/Form/ProjectRequest.php new file mode 100644 index 0000000..782cd6c --- /dev/null +++ b/indefero/src/IDF/Form/ProjectRequest.php @@ -0,0 +1,72 @@ + __('git'), + 'svn' => __('Subversion'), + 'mercurial' => __('mercurial'), + 'mtn' => __('monotone'), + ); + foreach (Pluf::f('allowed_scm', array()) as $key => $class) { + $choices[$options[$key]] = $key; + } + + $this->fields['shortname'] = new Pluf_Form_Field_Varchar( + array('required' => true, + 'label' => __('Name'), + 'initial' => '', + 'help_text' => __('This will be the name of your repo and of your project - however - you can change the project name later.'), + )); + + $this->fields['repotype'] = new Pluf_Form_Field_Varchar( + array('required' => true, + 'label' => __('Repository type'), + 'initial' => 'git', + 'widget_attrs' => array('choices' => $choices), + 'widget' => 'Pluf_Form_Widget_SelectInput', + )); + + $this->fields['desc'] = new Pluf_Form_Field_Varchar( + array('required' => true, + 'label' => __('Short description'), + 'help_text' => __('A one line description of the project.'), + 'initial' => '', + 'widget_attrs' => array('size' => '35'), + )); + + $this->user = $extra['user']; + } + + + function save($commit=true) + { + if (!$this->isValid()) { + throw new Exception(__('Cannot save the model from an invalid form.')); + } + + $checksql = new Pluf_SQL(sprintf("shortname='%s'", $this->cleaned_data['shortname'])); + $requestcheck = Pluf::factory("IDF_Project")->getCount(array('filter'=>$checksql->gen())); + if ($requestcheck == 1) + return false; + try + { + $request = new IDF_ProjectRequest(); + $request->shortname = $this->cleaned_data['shortname']; + $request->repotype = $this->cleaned_data['repotype']; + $request->desc = $this->cleaned_data['desc']; + $request->submitter = $this->user; + $request->create(); + return true; + } catch (Exception $e) + { + return false; + } + } + +} \ No newline at end of file diff --git a/indefero/src/IDF/ProjectRequest.php b/indefero/src/IDF/ProjectRequest.php new file mode 100644 index 0000000..3301ea5 --- /dev/null +++ b/indefero/src/IDF/ProjectRequest.php @@ -0,0 +1,85 @@ +_a['table'] = 'idf_projectrequest'; + $this->_a['model'] = __CLASS__; + + $this->_a['cols'] = array( + // It is mandatory to have an "id" column. + 'id' => + array( + 'type' => 'Pluf_DB_Field_Sequence', + 'blank' => true, + ), + 'shortname' => + array( + 'type' => 'Pluf_DB_Field_Varchar', + 'blank' => false, + 'size' => 50, + 'verbose' => __('shortname'), + 'unique' => true, + ), + 'repotype' => + array( + 'type' => 'Pluf_DB_Field_Varchar', + 'blank' => false, + 'size' => 25, + 'verbose' => __('Repository Type'), + ), + 'desc' => + array( + 'type' => 'Pluf_DB_Field_Varchar', + 'blank' => false, + 'size' => 250, + 'verbose' => __('Description'), + ), + 'creation_dtime' => + array( + 'type' => 'Pluf_DB_Field_Datetime', + 'blank' => true, + 'verbose' => __('creation date'), + ), + 'submitter' => + array( + 'type' => 'Pluf_DB_Field_Foreignkey', + 'model' => 'Pluf_User', + 'blank' => false, + 'verbose' => __('submitter'), + )); + } + + /** + * String representation of the abstract. + */ + function __toString() + { + return $this->shortname; + } + + /** + * String ready for indexation. + */ + function _toIndex() + { + return ''; + } + + function preSave($create=false) + { + if ($this->id == '') { + $this->creation_dtime = gmdate('Y-m-d H:i:s'); + } + + } +} \ No newline at end of file diff --git a/indefero/src/IDF/templates/idf/admin/approveprojects.html b/indefero/src/IDF/templates/idf/admin/approveprojects.html new file mode 100644 index 0000000..77dcd28 --- /dev/null +++ b/indefero/src/IDF/templates/idf/admin/approveprojects.html @@ -0,0 +1,60 @@ +{extends "idf/gadmin/base.html"} +{block request} class="active"{/block} + +{block body} +{if $createdtext} +{$createdtext} +
    +
    +{/if} +{if $errors} +{foreach $errors as $error} +{$error} +{/foreach} +{/if} + + + + + + + + + +{foreach $requests as $req} + + + + + + + + +{/foreach} +
    + Short Name + + Description + + Repotype + + Submitter + + Date + + Approve +
    + {$req.shortname} + + {$req.desc} + + {$req.repotype} + + {$req.get_submitter.login} + + {$req.creation_dtime} + + Approve +
    + +{/block} \ No newline at end of file diff --git a/indefero/src/IDF/templates/idf/admin/request-email.txt b/indefero/src/IDF/templates/idf/admin/request-email.txt new file mode 100644 index 0000000..d10613b --- /dev/null +++ b/indefero/src/IDF/templates/idf/admin/request-email.txt @@ -0,0 +1,10 @@ +Hello {$user}, + +You are receiving this email because you have requested a repository. +Your request for {$shortname|safe} was approved! + +If you have any questions please feel free to email a member of the development team. + +Yours faithfully, +The development team. + diff --git a/indefero/src/IDF/templates/idf/user/projectrequest.html b/indefero/src/IDF/templates/idf/user/projectrequest.html new file mode 100644 index 0000000..42f9ab5 --- /dev/null +++ b/indefero/src/IDF/templates/idf/user/projectrequest.html @@ -0,0 +1,60 @@ +{extends "idf/base-simple.html"} +{block body} + +{if $form.errors} +
    +

    {trans 'Oops, please check the errors on the form.'}

    + {if $form.get_top_errors} + {$form.render_top_errors|unsafe} + {/if} +
    +{/if} +{if $success} +
    +

    + Thank you - your request has been received and will be approved by an admin shortly. +

    +
    +{/if} +{if $error} +
    +{$error} +
    +{/if} + +
    + + + + + + + + + + + + + + + + + +
    {$form.f.shortname.labelTag}:{if $form.f.shortname.errors}{$form.f.shortname.fieldErrors}{/if} + {$form.f.shortname|unsafe}
    + {$form.f.shortname.help_text} +
    {$form.f.repotype.labelTag}:{if $form.f.repotype.errors}{$form.f.repotype.fieldErrors}{/if} + {$form.f.repotype|unsafe}
    + {$form.f.repotype.help_text} +
    {$form.f.desc.labelTag}:{if $form.f.desc.errors}{$form.f.desc.fieldErrors}{/if} + {$form.f.desc|unsafe}
    + {$form.f.desc.help_text} +
     
    + +
    + +{/block} +{block context} + + +{/block} \ No newline at end of file From 7ebce22300ef35c81ba043a55494c83a9c4c1b18 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Thu, 1 Aug 2013 22:28:19 -0500 Subject: [PATCH 6/6] Adding the ability to add tabs to documentation and issue editing Adding the ability to have syntax highlighted wiki (ie documentation) ex:
    int main()
    {
    	cout << "test" << endl;
    }
    
    --- indefero/src/IDF/Views/User.php | 9 ++++++++- indefero/src/IDF/templates/idf/source/git/file.html | 5 ++--- .../src/IDF/templates/idf/source/mercurial/file.html | 5 ++--- indefero/src/IDF/templates/idf/source/svn/file.html | 5 ++--- indefero/www/media/idf/js/allowtabs.js | 11 +++++++++++ 5 files changed, 25 insertions(+), 10 deletions(-) create mode 100755 indefero/www/media/idf/js/allowtabs.js diff --git a/indefero/src/IDF/Views/User.php b/indefero/src/IDF/Views/User.php index 59543cd..50ae5c6 100644 --- a/indefero/src/IDF/Views/User.php +++ b/indefero/src/IDF/Views/User.php @@ -281,6 +281,13 @@ class IDF_Views_User $user = $users[0]; $user_data = IDF_UserData::factory($user); + $otags = array(); + // Note that this approach does not scale, we will need to add + // a table to cache the meaning of the tags for large forges. + foreach (IDF_Views::getProjects($user) as $project) { + $otags = array_merge($otags, $project->getTagIdsByStatus('open')); + } + $false = Pluf_DB_BooleanToDb(false, $db); $sql_results = $db->select( 'SELECT id FROM '.$db->pfx.'idf_projects '. @@ -291,7 +298,7 @@ class IDF_Views_User foreach ($sql_results as $id) { $ids[] = $id['id']; } - $f_sql = new Pluf_SQL('owner=%s AND project IN (' . implode(', ', $ids) . ' )', array($user->id)); + $f_sql = new Pluf_SQL('owner=%s AND status IN (' .implode(', ', $otags) . ') AND project IN (' . implode(', ', $ids) . ' )', array($user->id)); $pag = new Pluf_Paginator(new IDF_Issue()); $pag->class = 'recent-issues'; diff --git a/indefero/src/IDF/templates/idf/source/git/file.html b/indefero/src/IDF/templates/idf/source/git/file.html index 01691ad..7aec286 100644 --- a/indefero/src/IDF/templates/idf/source/git/file.html +++ b/indefero/src/IDF/templates/idf/source/git/file.html @@ -1,5 +1,5 @@ {extends "idf/source/base.html"} -{block extraheader}{/block} +{block extraheader} {/block} {block docclass}yui-t1{assign $inSourceTree=true}{/block} {block body}

    {trans 'Root'}/{if $breadcrumb}{$breadcrumb|safe}{/if}

    @@ -26,6 +26,5 @@ {/block} {block javascript} - - + {/block} diff --git a/indefero/src/IDF/templates/idf/source/mercurial/file.html b/indefero/src/IDF/templates/idf/source/mercurial/file.html index 25d4572..8a870b6 100644 --- a/indefero/src/IDF/templates/idf/source/mercurial/file.html +++ b/indefero/src/IDF/templates/idf/source/mercurial/file.html @@ -1,5 +1,5 @@ {extends "idf/source/base.html"} -{block extraheader}{/block} +{block extraheader} {/block} {block docclass}yui-t1{assign $inSourceTree=true}{/block} {block body} @@ -27,6 +27,5 @@ {/block} {block javascript} - - + {/block} diff --git a/indefero/src/IDF/templates/idf/source/svn/file.html b/indefero/src/IDF/templates/idf/source/svn/file.html index 4e08bdc..c309f02 100644 --- a/indefero/src/IDF/templates/idf/source/svn/file.html +++ b/indefero/src/IDF/templates/idf/source/svn/file.html @@ -1,5 +1,5 @@ {extends "idf/source/base.html"} -{block extraheader}{/block} +{block extraheader} {/block} {block docclass}yui-t1{assign $inSourceTree=true}{/block} {block body}

    {trans 'Root'}/{if $breadcrumb}{$breadcrumb|safe}{/if}

    @@ -43,6 +43,5 @@ {/block} {block javascript} - - + {/block} diff --git a/indefero/www/media/idf/js/allowtabs.js b/indefero/www/media/idf/js/allowtabs.js new file mode 100755 index 0000000..d782940 --- /dev/null +++ b/indefero/www/media/idf/js/allowtabs.js @@ -0,0 +1,11 @@ +$("textarea").keydown(function(e) { + var $this, end, start; + if (e.keyCode === 9) { + start = this.selectionStart; + end = this.selectionEnd; + $this = $(this); + $this.val($this.val().substring(0, start) + "\t" + $this.val().substring(end)); + this.selectionStart = this.selectionEnd = start + 1; + return false; + } +}); \ No newline at end of file