Mercurial > public > src > phphgadmin
annotate admin/application/libraries/hgphp.php @ 41:2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
- error suppression when invalid absolute paths set
- auto-insertion bug which re-added all folders in the repo directory on create/delete, even if not formally registered
- blacklists creation of a repo derived from config 'base_url' instead of value "admin"
where $config['base_url'] = http://www.contoso.com/hgadmin will blacklist "hgadmin"
- missed translation items in hgdir controller
- add the default /lock directory to source controll
author | joshjcarrier |
---|---|
date | Thu, 03 Jun 2010 20:37:04 -0700 |
parents | 4543c151a667 |
children | 46961a5f545c |
rev | line source |
---|---|
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
1 <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
2 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
3 /** |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
4 * CodeIgniter Mercurial Repository Management class |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
5 * |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
6 * Scans file system and Mercurial projects directory, allowing |
11
2ec108f96fad
Cleaned up config. UI tidy up. Commenting. Still missing caching and concurrency checks.
joshjcarrier
parents:
10
diff
changeset
|
7 * web-based manipulation of the hgweb.config and hgrc configuration files. |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
8 * |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
9 * Depends on the HgConf2Ini library. |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
10 * |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
11 * @package CodeIgniter |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
12 * @subpackage Libraries |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
13 * @category Libraries |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
14 * @author Josh Carrier |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
15 * @link blog.joshjcarrier.com |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
16 * |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
17 */ |
7 | 18 class HgPHP |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
19 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
20 private $_ci; |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
21 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
22 function __construct($config = array()) |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
23 { |
28
4543c151a667
Added additional configuration options. Fixed last possible concurrency error, removing a single hgweb.config.lock with per-save temporary files.
joshjcarrier
parents:
24
diff
changeset
|
24 $this->_ci =& get_instance(); |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
25 if(!empty($config)) |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
26 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
27 $this->initialize($config); |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
28 } |
28
4543c151a667
Added additional configuration options. Fixed last possible concurrency error, removing a single hgweb.config.lock with per-save temporary files.
joshjcarrier
parents:
24
diff
changeset
|
29 else |
4543c151a667
Added additional configuration options. Fixed last possible concurrency error, removing a single hgweb.config.lock with per-save temporary files.
joshjcarrier
parents:
24
diff
changeset
|
30 { |
4543c151a667
Added additional configuration options. Fixed last possible concurrency error, removing a single hgweb.config.lock with per-save temporary files.
joshjcarrier
parents:
24
diff
changeset
|
31 $this->_ci->config->load('hgphp', TRUE); |
4543c151a667
Added additional configuration options. Fixed last possible concurrency error, removing a single hgweb.config.lock with per-save temporary files.
joshjcarrier
parents:
24
diff
changeset
|
32 $this->initialize($this->_ci->config->item('hgphp')); |
4543c151a667
Added additional configuration options. Fixed last possible concurrency error, removing a single hgweb.config.lock with per-save temporary files.
joshjcarrier
parents:
24
diff
changeset
|
33 } |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
34 |
7 | 35 $this->_ci->lang->load('hgphp'); |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
36 $this->_ci->load->library('hgconf2ini'); |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
37 log_message('debug', 'HgPHP class Initialized'); |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
38 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
39 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
40 function initialize($config = array()) |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
41 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
42 foreach($config as $key=>$val) |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
43 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
44 $this->{'_'.$key} = $val; |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
45 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
46 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
47 |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
48 /** |
4 | 49 * Public accessors - hgweb.config |
50 */ | |
51 | |
52 /** | |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
53 * Returns a list of available repositories. |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
54 * Will show up if: detected in repo directory |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
55 * Will have status "enabled" if: detected in hgweb.config |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
56 * |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
57 * @param ofl_lock_hgwebconf (updated by reference) the current optimistic file lock value |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
58 * @return an array of 0 or more detected repositories |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
59 */ |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
60 function lsdir(&$ofl_lock_hgwebconf) |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
61 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
62 $realdir = $this->__realdirscan(); |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
63 $hgwebdir_compat = $this->_ci->hgconf2ini->getHgWebDirCollections($ofl_lock_hgwebconf); |
2
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
64 |
41
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
65 $allrepo = $realdir; |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
66 if(!is_integer($hgwebdir_compat)) |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
67 { |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
68 $allrepo = array_merge($realdir, $hgwebdir_compat); |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
69 } |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
70 else |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
71 { |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
72 // error code |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
73 return $hgwebdir_compat; |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
74 } |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
75 |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
76 $hgrepos = array(); |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
77 foreach($allrepo as $repo) |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
78 { |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
79 $hgrepos[$repo]['name'] = $repo; |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
80 |
2
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
81 if(isset($realdir[$repo]) && isset($hgwebdir_compat[$repo])) |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
82 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
83 $hgrepos[$repo]['status'] = HGPHP_REPO_STATUS_ENABLED; |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
84 } |
2
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
85 else if(isset($realdir[$repo]) && !isset($hgwebdir_compat[$repo])) |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
86 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
87 $hgrepos[$repo]['status'] = HGPHP_REPO_STATUS_DISABLED; |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
88 } |
2
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
89 else if(!isset($realdir[$repo]) && isset($hgwebdir_compat[$repo])) |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
90 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
91 $hgrepos[$repo]['status'] = HGPHP_REPO_STATUS_MISSING; |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
92 } |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
93 } |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
94 |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
95 return $hgrepos; |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
96 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
97 |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
98 /** |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
99 * Create a Hg repository by: |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
100 * - adding an entry in hgrc if not present |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
101 * - creating a bare repository if not present |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
102 * @param r_name name of the new repository to create, used as folder name |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
103 * @param hg_lock_hgwebconf (updated by reference) the last known optimistic file lock value of hgwebconf |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
104 * @param hg_lock_hgrc (updated by reference) value of hgrc's lock value |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
105 * @return status code |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
106 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
107 function create_repository($r_name, &$ofl_lock_hgwebconf, &$hg_lock_hgrc) |
3
53341b414217
Ability to create repository entry (via uri), which updates live hgweb.config + sets up an empty directory to push to.
joshjcarrier
parents:
2
diff
changeset
|
108 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
109 if(!$this->can_create($r_name)) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
110 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
111 return HGPHP_ERR_PERM_USR; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
112 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
113 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
114 $create_status = HGPHP_OK; |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
115 $ofl_dummylock_hgwebconf = ''; |
41
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
116 $lsdir = $this->_ci->hgconf2ini->getHgWebDirCollections($ofl_dummylock_hgwebconf); // don't want to update the lock yet |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
117 |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
118 // simplifies repo list into array where name is both key and value |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
119 // this is how hgweb.config wants it |
41
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
120 $existingdir = array(); |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
121 |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
122 if(!is_integer($lsdir)) |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
123 { |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
124 $existingdir = array_keys($lsdir); |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
125 } |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
126 else |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
127 { |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
128 // error code |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
129 return $lsdir; |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
130 } |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
131 |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
132 $tempexistingdir = array(); |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
133 foreach($existingdir as $repo_name) |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
134 { |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
135 $tempexistingdir[$repo_name] = $repo_name; |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
136 } |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
137 $existingdir = $tempexistingdir; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
138 |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
139 // not registered in hgweb.config |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
140 if(!isset($lsdir[$r_name])) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
141 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
142 // edit the directory |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
143 $existingdir[$r_name] = $r_name; |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
144 $create_status = $this->_ci->hgconf2ini->setHgWebDirCollections($existingdir, $ofl_lock_hgwebconf); |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
145 if($create_status == HGPHP_OK) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
146 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
147 // then create the repository |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
148 $create_status = $this->create_repository_dir($r_name, $hg_lock_hgrc); |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
149 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
150 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
151 else |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
152 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
153 // repository already exists |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
154 $create_status = HGPHP_ERR_FS_PREEXISTS; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
155 } |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
156 return $create_status; |
3
53341b414217
Ability to create repository entry (via uri), which updates live hgweb.config + sets up an empty directory to push to.
joshjcarrier
parents:
2
diff
changeset
|
157 } |
53341b414217
Ability to create repository entry (via uri), which updates live hgweb.config + sets up an empty directory to push to.
joshjcarrier
parents:
2
diff
changeset
|
158 |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
159 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
160 * update_repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
161 * Update repository's hgrc |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
162 * @param r_name name of the repository to update hgrc for |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
163 * @param hgrc_data array representing new hgrc file |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
164 * @param ofl_lock_hgrc (updated by reference) the current optimistic file lock value |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
165 * @return status code |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
166 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
167 function update_repository($r_name, $hgrc_data, &$ofl_lock_hgrc) |
10 | 168 { |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
169 if(!$this->can_update($r_name)) |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
170 { |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
171 return HGPHP_ERR_PERM_USR; |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
172 } |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
173 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
174 return $this->_ci->hgconf2ini->setHGRC($r_name, $hgrc_data, $ofl_lock_hgrc); |
10 | 175 } |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
176 |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
177 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
178 * delete_repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
179 * Deletes a repository from the file system and unregisters it from hgweb.config |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
180 * @param r_name name of the repo to delete permanently |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
181 * @param $ofl_lock_hgwebconf (updated by reference) the current optimistic file lock value |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
182 * @return status code |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
183 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
184 function delete_repository($r_name, &$ofl_lock_hgwebconf) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
185 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
186 if(!$this->can_delete($r_name)) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
187 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
188 return HGPHP_ERR_PERM_USR; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
189 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
190 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
191 $del_status = HGPHP_OK; |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
192 $ofl_dummylock_hgwebconf = ''; |
41
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
193 $lsdir = $this->_ci->hgconf2ini->getHgWebDirCollections($ofl_dummylock_hgwebconf); // don't want to update lock yet |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
194 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
195 // simplifies repo list into array where name is both key and value |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
196 // this is how hgweb.config wants it |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
197 $existingdir = array_keys($lsdir); |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
198 $tempexistingdir = array(); |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
199 foreach($existingdir as $repo_name) |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
200 { |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
201 $tempexistingdir[$repo_name] = $repo_name; |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
202 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
203 $existingdir = $tempexistingdir; |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
204 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
205 if(isset($lsdir[$r_name])) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
206 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
207 // edit the directory |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
208 unset($existingdir[$r_name]); |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
209 // remove hgweb.config |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
210 $del_status = $this->_ci->hgconf2ini->setHgWebDirCollections($existingdir, $ofl_lock_hgwebconf); |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
211 |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
212 // remove from hgweb.config |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
213 if($del_status == HGPHP_OK) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
214 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
215 // existing filesystem is not missing, thus needs to be deleted |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
216 if($lsdir[$r_name]['status'] != HGPHP_REPO_STATUS_MISSING) |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
217 { |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
218 // unregister hgrc from transaction manager to keep index small |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
219 $del_status = $this->_ci->hgconf2ini->unlinkHGRC($r_name); |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
220 |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
221 if($del_status == HGPHP_OK) |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
222 { |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
223 $del_status = $this->delete_repository_dir($r_name); |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
224 } |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
225 } |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
226 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
227 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
228 else |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
229 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
230 $del_status = HGPHP_ERR_FS_PREEXISTS; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
231 } |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
232 return $del_status; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
233 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
234 |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
235 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
236 * stat_repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
237 * Returns the HGRC represented as an array for the specified repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
238 * @param r_name name of the project whose hgrc to retrieve |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
239 * @param ofl_lock_hgrc (updated by reference) the current optimistic file lock value will be updated |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
240 * @return array representing hgrc or status code |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
241 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
242 function stat_repository($r_name, &$ofl_lock_hgrc) |
9 | 243 { |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
244 if(!$this->can_view($r_name)) |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
245 { |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
246 return HGPHP_ERR_PERM_USR; |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
247 } |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
248 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
249 return $this->_ci->hgconf2ini->getHGRC($r_name, $ofl_lock_hgrc); |
9 | 250 } |
4 | 251 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
252 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
253 /** |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
254 * can_create |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
255 * Checks if user has permissions to create this repository. |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
256 * Requires view permission. |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
257 * @param r_name name of repository wanting to be created |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
258 * @return true if allowed |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
259 */ |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
260 function can_create($r_name) |
4 | 261 { |
24
26ff1899349f
Bug fix: improper can_view function call causing script crash.
joshjcarrier
parents:
23
diff
changeset
|
262 return $this->can_view($r_name) && $this->_hgwebconf_allow_repo_create; |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
263 } |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
264 |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
265 /** |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
266 * can_update |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
267 * Checks if user has permissions to update this repository |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
268 * Requires view permission. |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
269 * @param r_name name of repository wanting to be updated |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
270 * @return true if allowed |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
271 */ |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
272 function can_update($r_name) |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
273 { |
24
26ff1899349f
Bug fix: improper can_view function call causing script crash.
joshjcarrier
parents:
23
diff
changeset
|
274 return $this->can_view($r_name) && $this->_hgwebconf_allow_repo_update; |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
275 } |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
276 |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
277 /** |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
278 * can_create |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
279 * Checks if user has permissions to view this repository |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
280 * @param r_name name of repository wanting to be created |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
281 * @return true if allowed |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
282 */ |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
283 function can_view($r_name) |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
284 { |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
285 return $this->_hgwebconf_allow_repo_view; |
4 | 286 } |
7 | 287 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
288 /** |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
289 * can_delete |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
290 * Checks if user has permissions to delete this repository |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
291 * Requires view permission. |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
292 * @param r_name name of repository wanting to be deleted |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
293 * @return true if allowed |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
294 */ |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
295 function can_delete($r_name) |
7 | 296 { |
24
26ff1899349f
Bug fix: improper can_view function call causing script crash.
joshjcarrier
parents:
23
diff
changeset
|
297 return $this->can_view($r_name) && $this->_hgwebconf_allow_repo_delete; |
7 | 298 } |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
299 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
300 /** |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
301 * create_repository_dir |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
302 * Creates a whole repository directory, with hgrc |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
303 * @param r_name name of repository to create directory for |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
304 * @param ofl_lock_hgrc (updated by reference) the current optimistic file lock value will be updated |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
305 * @return status code |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
306 */ |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
307 function create_repository_dir($r_name, &$ofl_lock_hgrc) |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
308 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
309 if(!$this->can_create($r_name)) |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
310 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
311 return HGPHP_ERR_PERM_USR; |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
312 } |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
313 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
314 // create repo directory structure recursively |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
315 $create_status = mkdir($this->_repositories_abs_dir . $r_name . '/.hg/store/data/', 0755, TRUE); |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
316 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
317 if($create_status == TRUE) |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
318 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
319 // create hgrc |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
320 $create_status = $this->_ci->hgconf2ini->touchHGRC($r_name, $ofl_lock); |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
321 } |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
322 else |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
323 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
324 // system couldn't make directory |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
325 $create_status = HGPHP_ERR_PERM_SYS_REPODIR; |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
326 } |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
327 return $create_status; |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
328 } |
7 | 329 |
4 | 330 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
331 * delete_repository_dir |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
332 * Deletes a whole repository directory including hgrc and data files |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
333 * @param r_name name of repository to delete directory of |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
334 * @return status code |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
335 */ |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
336 function delete_repository_dir($repository_name) |
4 | 337 { |
7 | 338 if(!$this->can_delete($repository_name)) |
339 { | |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
340 return HGPHP_ERR_PERM_USR; |
7 | 341 } |
4 | 342 |
11
2ec108f96fad
Cleaned up config. UI tidy up. Commenting. Still missing caching and concurrency checks.
joshjcarrier
parents:
10
diff
changeset
|
343 $cd = $this->_repositories_abs_dir . $repository_name; |
7 | 344 $this->recursiveDelete($cd . '/.hg/'); |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
345 $del_status = $this->recursiveDelete($cd); |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
346 if($del_status == TRUE) |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
347 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
348 $del_status = HGPHP_OK; |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
349 } |
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
350 else |
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
351 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
352 $del_status = HGPHP_ERR_PERM_SYS_REPODIR; |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
353 } |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
354 return $del_status; |
4 | 355 } |
3
53341b414217
Ability to create repository entry (via uri), which updates live hgweb.config + sets up an empty directory to push to.
joshjcarrier
parents:
2
diff
changeset
|
356 |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
357 /** |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
358 * Performs a real directory scan where the projects are suppose to reside. |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
359 * |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
360 * @return the array containing 0 or more valid directories |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
361 */ |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
362 function __realdirscan() |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
363 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
364 $this->_ci->load->helper('directory'); |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
365 |
11
2ec108f96fad
Cleaned up config. UI tidy up. Commenting. Still missing caching and concurrency checks.
joshjcarrier
parents:
10
diff
changeset
|
366 $realdir = directory_map($this->_repositories_abs_dir, TRUE); |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
367 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
368 $verifiedrealdir = array(); |
41
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
369 if(is_array($realdir)) |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
370 { |
41
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
371 foreach($realdir as $file) |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
372 { |
41
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
373 // checks if we detected a folder |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
374 if(is_dir($this->_repositories_abs_dir . $file)) |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
375 { |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
376 $verifiedrealdir[$file] = $file; |
2cf4300b3541
- hgweb.config and the repositories can now exist in separate directories
joshjcarrier
parents:
28
diff
changeset
|
377 } |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
378 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
379 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
380 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
381 return $verifiedrealdir; |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
382 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
383 |
7 | 384 /** |
385 * Delete a file or recursively delete a directory | |
386 * | |
387 * @param string $str Path to file or directory | |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
388 * @return true on successful deletion |
7 | 389 */ |
390 function recursiveDelete($str){ | |
391 if(is_file($str)){ | |
392 return @unlink($str); | |
393 } | |
394 elseif(is_dir($str)){ | |
395 $scan = glob(rtrim($str,'/').'/*'); | |
396 foreach($scan as $index=>$path){ | |
397 $this->recursiveDelete($path); | |
398 } | |
399 return @rmdir($str); | |
400 } | |
401 } | |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
402 } |