-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhosting.class.php
More file actions
184 lines (157 loc) · 5.63 KB
/
Copy pathhosting.class.php
File metadata and controls
184 lines (157 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
/* Hosting module -> $Id: $ */
require_once( $AppUI->getSystemClass ('dp' ) );
require_once( $AppUI->getLibraryClass( 'PEAR/Date' ) );
require_once( $AppUI->getModuleClass( 'companies' ) );
/**
* The Project Class
*/
class CHosting extends CDpObject {
var $domain_id = null;
var $company_id = null;
var $domain_name = null;
var $domain_expiry_date = null;
var $domain_registrar = null;
var $domain_status = null;
var $domain_notes = null;
var $hosting_id = null;
var $hosting_package_name = null;
var $hosting_expiry_date = null;
var $hosting_status = null;
var $hosting_notes = null;
function CHosting() {
$this->CDpObject( 'hosting', 'domain_id' );
}
function canDelete($message = null, $domain_id = null){
return true;
}
function load($domain_id){
$q = new DBQuery;
$q->addTable('domains');
$q->addQuery("domains.domain_id, company_id, domain_name, domain_expiry_date, domain_registrar, domain_status,
domain_notes, hosting_id, hosting_package_name, hosting_expiry_date, hosting_status, hosting_notes");
$q->addJoin('hosting', 'h', 'h.domain_id = domains.domain_id');
$q->addWhere('domains.domain_id = '.$domain_id);
$results = $q->exec();
$row = db_fetch_assoc($results);
$this->domain_id = $row['domains.domain_id'];
$this->company_id = $row['company_id'];
$this->domain_name = $row['domain_name'];
$this->domain_expiry_date = $row['domain_expiry_date'];
$this->domain_registrar = $row['domain_registrar'];
$this->domain_status = $row['domain_status'];
$this->domain_notes = $row['domain_notes'];
$this->hosting_id = $row['hosting_id'];
$this->hosting_package_name = $row['hosting_package_name'];
$this->hosting_expiry_date = $row['hosting_expiry_date'];
$this->hosting_status = $row['hosting_status'];
$this->hosting_notes = $row['hosting_notes'];
}
function delete(){
$q = new DBQuery;
$q->setDelete('domains');
$q->addWhere('domain_id='.$this->domain_id);
$q->exec();
$q->clear();
$q->setDelete('hosting');
$q->addWhere('domain_id='.$this->domain_id);
$q->exec();
$q->clear();
}
function store(){
$q = new DBQuery;
$q->addTable('domains');
$q->addInsert('company_id', $this->company_id);
$q->addInsert('domain_name', $this->domain_name);
$q->addInsert('domain_expiry_date', $this->domain_expiry_date);
$q->addInsert('domain_registrar', $this->domain_registrar);
$q->addInsert('domain_status', $this->domain_status);
$q->addInsert('domain_notes', $this->domain_notes);
$q->exec();
$domainID = db_insert_id();
$q->clear();
$q->addTable('hosting');
$q->addInsert('domain_id', $domainID);
$q->addInsert('hosting_package_name', $this->hosting_package_name);
$q->addInsert('hosting_expiry_date', $this->hosting_expiry_date);
$q->addInsert('hosting_status', $this->hosting_status);
$q->addInsert('hosting_notes', $this->hosting_notes);
$q->exec();
$q->clear();
}
}
function getCompanies(){
// retrieve list of records
// modified for speed
// by Pablo Roca (pabloroca@mvps.org)
// 16 August 2003
// get the list of permitted companies
global $AppUI, $buffer, $company, $company_id, $company_prefix, $deny, $department, $dept_ids, $dPconfig, $orderby, $orderdir, $projects, $tasks_critical, $tasks_problems, $tasks_sum, $tasks_summy;
$obj = new CCompany();
$companies = $obj->getAllowedRecords( $AppUI->user_id, 'company_id,company_name', 'company_name' );
if(count($companies) == 0) $companies = array(0);
// get the list of permitted companies
$companies = arrayMerge( array( '0'=>$AppUI->_('All') ), $companies );
//get list of all departments, filtered by the list of permitted companies.
$q = new DBQuery;
$q->clear();
$q->addTable('companies');
$q->addQuery('company_id, company_name, dep.*');
$q->addJoin('departments', 'dep', 'companies.company_id = dep.dept_company');
$q->addOrder('company_name,dept_parent,dept_name');
$obj->setAllowedSQL($AppUI->user_id, $q);
$rows = $q->loadList();
//display the select list
$buffer = '<select name="company_id" onChange="document.pickCompany.submit()" class="text">';
$buffer .= '<option value="company_0" style="font-weight:bold;">'.$AppUI->_('All').'</option>'."\n";
$company = '';
foreach ($rows as $row) {
if ($row["dept_parent"] == 0) {
if($company!=$row['company_id']){
$buffer .= '<option value="'.$company_prefix.$row['company_id'].'" style="font-weight:bold;"'.($company_id==$row['company_id']?'selected="selected"':'').'>'.$row['company_name'].'</option>'."\n";
$company=$row['company_id'];
}
if($row["dept_parent"]!=null){
showchilddept( $row );
findchilddept( $rows, $row["dept_id"] );
}
}
}
$buffer .= '</select>';
}
//writes out a single <option> element for display of departments
function showchilddept( &$a, $level=1 ) {
Global $buffer, $department;
$s = '<option value="'.$a["dept_id"].'"'.(isset($department)&&$department==$a["dept_id"]?'selected="selected"':'').'>';
for ($y=0; $y < $level; $y++) {
if ($y+1 == $level) {
$s .= '';
} else {
$s .= ' ';
}
}
$s .= ' '.$a["dept_name"]."</option>\n";
$buffer .= $s;
// echo $s;
}
//recursive function to display children departments.
function findchilddept( &$tarr, $parent, $level=1 ){
$level = $level+1;
$n = count( $tarr );
for ($x=0; $x < $n; $x++) {
if($tarr[$x]["dept_parent"] == $parent && $tarr[$x]["dept_parent"] != $tarr[$x]["dept_id"]){
showchilddept( $tarr[$x], $level );
findchilddept( $tarr, $tarr[$x]["dept_id"], $level);
}
}
}
function addDeptId($dataset, $parent){
Global $dept_ids;
foreach ($dataset as $data){
if($data['dept_parent']==$parent){
$dept_ids[] = $data['dept_id'];
addDeptId($dataset, $data['dept_id']);
}
}
}
?>