Mercurial > public > src > phphgadmin
annotate admin/application/libraries/hgphp.php @ 23:6f38dd98ff78
View and update permission checks (all permissions default to true atm)
author | joshjcarrier |
---|---|
date | Sat, 15 May 2010 15:47:59 -0700 |
parents | 51f6d4415b09 |
children | 26ff1899349f |
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 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
24 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
|
25 { |
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 $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
|
27 } |
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 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
29 $this->_ci =& get_instance(); |
7 | 30 $this->_ci->lang->load('hgphp'); |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
31 $this->_ci->load->library('hgconf2ini'); |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
32 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
|
33 } |
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 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
35 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
|
36 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
37 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
|
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 $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
|
40 } |
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 |
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
|
43 /** |
4 | 44 * Public accessors - hgweb.config |
45 */ | |
46 | |
47 /** | |
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
|
48 * 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
|
49 * 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
|
50 * 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
|
51 * |
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
|
52 * @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
|
53 * @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
|
54 */ |
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
|
55 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
|
56 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
57 $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
|
58 $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
|
59 |
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
60 $allrepo = array_merge($realdir, $hgwebdir_compat); |
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
|
61 |
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
|
62 $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
|
63 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
|
64 { |
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
|
65 $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
|
66 |
2
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
67 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
|
68 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
69 $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
|
70 } |
2
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
71 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
|
72 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
73 $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
|
74 } |
2
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
75 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
|
76 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
77 $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
|
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 } |
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 |
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
|
81 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
|
82 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
83 |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
84 /** |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
85 * Create a Hg repository by: |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
86 * - adding an entry in hgrc if not present |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
87 * - 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
|
88 * @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
|
89 * @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
|
90 * @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
|
91 * @return status code |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
92 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
93 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
|
94 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
95 if(!$this->can_create($r_name)) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
96 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
97 return HGPHP_ERR_PERM_USR; |
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 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
100 $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
|
101 $ofl_dummylock_hgwebconf = ''; |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
102 $lsdir = $this->lsdir($ofl_dummylock_hgwebconf); // don't want to update the lock yet |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
103 |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
104 // 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
|
105 // this is how hgweb.config wants it |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
106 $existingdir = array_keys($lsdir); |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
107 $tempexistingdir = array(); |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
108 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
|
109 { |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
110 $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
|
111 } |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
112 $existingdir = $tempexistingdir; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
113 |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
114 // not registered in hgweb.config |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
115 if(!isset($lsdir[$r_name])) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
116 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
117 // 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
|
118 $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
|
119 $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
|
120 if($create_status == HGPHP_OK) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
121 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
122 // 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
|
123 $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
|
124 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
125 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
126 else |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
127 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
128 // repository already exists |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
129 $create_status = HGPHP_ERR_FS_PREEXISTS; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
130 } |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
131 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
|
132 } |
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
|
133 |
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
|
134 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
135 * update_repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
136 * Update repository's hgrc |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
137 * @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
|
138 * @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
|
139 * @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
|
140 * @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
|
141 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
142 function update_repository($r_name, $hgrc_data, &$ofl_lock_hgrc) |
10 | 143 { |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
144 if(!$this->can_update($r_name)) |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
145 { |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
146 return HGPHP_ERR_PERM_USR; |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
147 } |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
148 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
149 return $this->_ci->hgconf2ini->setHGRC($r_name, $hgrc_data, $ofl_lock_hgrc); |
10 | 150 } |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
151 |
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
|
152 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
153 * delete_repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
154 * 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
|
155 * @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
|
156 * @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
|
157 * @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
|
158 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
159 function delete_repository($r_name, &$ofl_lock_hgwebconf) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
160 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
161 if(!$this->can_delete($r_name)) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
162 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
163 return HGPHP_ERR_PERM_USR; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
164 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
165 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
166 $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
|
167 $ofl_dummylock_hgwebconf = ''; |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
168 $lsdir = $this->lsdir($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
|
169 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
170 // 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
|
171 // this is how hgweb.config wants it |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
172 $existingdir = array_keys($lsdir); |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
173 $tempexistingdir = array(); |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
174 foreach($existingdir as $repo_name) |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
175 { |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
176 $tempexistingdir[$repo_name] = $repo_name; |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
177 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
178 $existingdir = $tempexistingdir; |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
179 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
180 if(isset($lsdir[$r_name])) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
181 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
182 // 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
|
183 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
|
184 // 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
|
185 $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
|
186 |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
187 // remove from hgweb.config |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
188 if($del_status == HGPHP_OK) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
189 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
190 // 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
|
191 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
|
192 { |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
193 // 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
|
194 $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
|
195 |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
196 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
|
197 { |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
198 $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
|
199 } |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
200 } |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
201 } |
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 else |
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 $del_status = HGPHP_ERR_FS_PREEXISTS; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
206 } |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
207 return $del_status; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
208 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
209 |
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
|
210 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
211 * stat_repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
212 * 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
|
213 * @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
|
214 * @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
|
215 * @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
|
216 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
217 function stat_repository($r_name, &$ofl_lock_hgrc) |
9 | 218 { |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
219 if(!$this->can_view($r_name)) |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
220 { |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
221 return HGPHP_ERR_PERM_USR; |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
222 } |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
223 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
224 return $this->_ci->hgconf2ini->getHGRC($r_name, $ofl_lock_hgrc); |
9 | 225 } |
4 | 226 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
227 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
228 /** |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
229 * can_create |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
230 * 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
|
231 * Requires view permission. |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
232 * @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
|
233 * @return true if allowed |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
234 */ |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
235 function can_create($r_name) |
4 | 236 { |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
237 return can_view($r_name) && $this->_hgwebconf_allow_repo_create; |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
238 } |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
239 |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
240 /** |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
241 * can_update |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
242 * 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
|
243 * Requires view permission. |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
244 * @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
|
245 * @return true if allowed |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
246 */ |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
247 function can_update($r_name) |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
248 { |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
249 return can_view($r_name) && $this->_hgwebconf_allow_repo_update; |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
250 } |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
251 |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
252 /** |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
253 * can_create |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
254 * 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
|
255 * @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
|
256 * @return true if allowed |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
257 */ |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
258 function can_view($r_name) |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
259 { |
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
260 return $this->_hgwebconf_allow_repo_view; |
4 | 261 } |
7 | 262 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
263 /** |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
264 * can_delete |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
265 * 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
|
266 * Requires view permission. |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
267 * @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
|
268 * @return true if allowed |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
269 */ |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
270 function can_delete($r_name) |
7 | 271 { |
23
6f38dd98ff78
View and update permission checks (all permissions default to true atm)
joshjcarrier
parents:
19
diff
changeset
|
272 return can_view($r_name) && $this->_hgwebconf_allow_repo_delete; |
7 | 273 } |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
274 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
275 /** |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
276 * create_repository_dir |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
277 * Creates a whole repository directory, with hgrc |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
278 * @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
|
279 * @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
|
280 * @return status code |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
281 */ |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
282 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
|
283 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
284 if(!$this->can_create($r_name)) |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
285 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
286 return HGPHP_ERR_PERM_USR; |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
287 } |
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 // create repo directory structure recursively |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
290 $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
|
291 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
292 if($create_status == TRUE) |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
293 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
294 // create hgrc |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
295 $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
|
296 } |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
297 else |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
298 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
299 // system couldn't make directory |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
300 $create_status = HGPHP_ERR_PERM_SYS_REPODIR; |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
301 } |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
302 return $create_status; |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
303 } |
7 | 304 |
4 | 305 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
306 * delete_repository_dir |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
307 * 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
|
308 * @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
|
309 * @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
|
310 */ |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
311 function delete_repository_dir($repository_name) |
4 | 312 { |
7 | 313 if(!$this->can_delete($repository_name)) |
314 { | |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
315 return HGPHP_ERR_PERM_USR; |
7 | 316 } |
4 | 317 |
11
2ec108f96fad
Cleaned up config. UI tidy up. Commenting. Still missing caching and concurrency checks.
joshjcarrier
parents:
10
diff
changeset
|
318 $cd = $this->_repositories_abs_dir . $repository_name; |
7 | 319 $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
|
320 $del_status = $this->recursiveDelete($cd); |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
321 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
|
322 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
323 $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
|
324 } |
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
|
325 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
|
326 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
327 $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
|
328 } |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
329 return $del_status; |
4 | 330 } |
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
|
331 |
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
|
332 /** |
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
|
333 * 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
|
334 * |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
335 * @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
|
336 */ |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
337 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
|
338 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
339 $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
|
340 |
11
2ec108f96fad
Cleaned up config. UI tidy up. Commenting. Still missing caching and concurrency checks.
joshjcarrier
parents:
10
diff
changeset
|
341 $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
|
342 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
343 $verifiedrealdir = 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
|
344 foreach($realdir as $file) |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
345 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
346 // checks if we detected a folder |
11
2ec108f96fad
Cleaned up config. UI tidy up. Commenting. Still missing caching and concurrency checks.
joshjcarrier
parents:
10
diff
changeset
|
347 if(is_dir($this->_repositories_abs_dir . $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
|
348 { |
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
|
349 $verifiedrealdir[$file] = $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
|
350 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
351 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
352 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
353 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
|
354 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
355 |
7 | 356 /** |
357 * Delete a file or recursively delete a directory | |
358 * | |
359 * @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
|
360 * @return true on successful deletion |
7 | 361 */ |
362 function recursiveDelete($str){ | |
363 if(is_file($str)){ | |
364 return @unlink($str); | |
365 } | |
366 elseif(is_dir($str)){ | |
367 $scan = glob(rtrim($str,'/').'/*'); | |
368 foreach($scan as $index=>$path){ | |
369 $this->recursiveDelete($path); | |
370 } | |
371 return @rmdir($str); | |
372 } | |
373 } | |
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
|
374 } |