Refactoring the vault

This commit is contained in:
Karl Cordes 2011-01-11 19:52:52 +11:00
parent bbb547199d
commit 643d5c1a1d
94 changed files with 382 additions and 280 deletions

1
.gitignore vendored
View file

@ -9,3 +9,4 @@ tmp/*
*.swp
*.swo
vendors/tcpdf/cache/*
tests/*

0
controllers/documents_controller.php Normal file → Executable file
View file

0
controllers/invoices_controller.php Normal file → Executable file
View file

0
controllers/issue_actions_controller.php Normal file → Executable file
View file

0
controllers/issues_controller.php Normal file → Executable file
View file

0
controllers/jobs_controller.php Normal file → Executable file
View file

0
controllers/line_items_controller.php Normal file → Executable file
View file

0
controllers/pages_controller.php Normal file → Executable file
View file

0
controllers/purchase_orders_controller.php Normal file → Executable file
View file

0
models/document.php Normal file → Executable file
View file

0
models/invoice.php Normal file → Executable file
View file

0
models/job.php Normal file → Executable file
View file

0
models/line_item.php Normal file → Executable file
View file

0
models/page.php Normal file → Executable file
View file

0
models/purchase_order.php Normal file → Executable file
View file

View file

@ -3,7 +3,6 @@ class User extends AppModel {
var $name = 'User';
var $belongsTo = array('Group');
var $displayField = 'username';
@ -37,23 +36,17 @@ class User extends AppModel {
);
var $actsAs = array('Acl' => array('requester'));
var $belongsTo = array(
'Principle' => array('className'=>'Principle',
'foreignKey' =>'principle_id',
),
'Customer' => array('className'=>'Customer',
'foreignKey' =>'customer_id',
)
);
function parentNode() {
if (!$this->id && empty($this->data)) {
return null;
}
$data = $this->data;
if (empty($this->data)) {
$data = $this->read();
}
if (!$data['User']['group_id']) {
return null;
}
else {
return array('Group' => array('id' => $data['User']['group_id']));
}
}

0
vendors/shells/firstpass.php vendored Normal file → Executable file
View file

50
vendors/shells/users_migrate.php vendored Normal file → Executable file
View file

@ -24,7 +24,55 @@ class UsersMigrateShell extends Shell {
$this->printCountLine($usersCount, 'Users');
$totalCount = $principleContactsCount + $contactsCount + $usersCount;
$this->printCountLine($totalCount, 'Total Users after migration');
$this->printCountLine($totalCount, 'Total Users we should have after migration');
$principleContacts = $this->PrincipleContact->find('all');
$newPrincipleUsers = array();
foreach($principleContacts as $contact) {
$newUser = array();
$newUser['User']['principle_id'] = $contact['PrincipleContact']['principle_id'];
$newUser['User']['type'] = 'principle';
$newUser['User']['username'] = trim($contact['PrincipleContact']['first_name']).' '.trim($contact['PrincipleContact']['last_name']);
$newUser['User']['first_name'] = $contact['PrincipleContact']['first_name'];
$newUser['User']['last_name'] = $contact['PrincipleContact']['last_name'];
$newUser['User']['email'] = $contact['PrincipleContact']['email'];
$newUser['User']['phone'] = $contact['PrincipleContact']['phone'];
$newUser['User']['fax'] = $contact['PrincipleContact']['fax'];
$newUser['User']['notes'] = $contact['PrincipleContact']['notes'];
$newUser['User']['job_title'] = $contact['PrincipleContact']['job_title'];
$this->User->create();
//$newPrincipleUsers[] = $newUser;
$this->User->save($newUser);
}
$customerContacts = $this->Contact->find('all');
$newCustomerUsers = array();
foreach($customerContacts as $contact) {
$newUser = array();
$newUser['User']['customer_id'] = $contact['Contact']['customer_id'];
$newUser['User']['type'] = 'contact';
$newUser['User']['username'] = trim($contact['Contact']['first_name']).' '.trim($contact['Contact']['last_name']);
$newUser['User']['first_name'] = $contact['Contact']['first_name'];
$newUser['User']['last_name'] = $contact['Contact']['last_name'];
$newUser['User']['email'] = $contact['Contact']['email'];
$newUser['User']['phone'] = $contact['Contact']['phone'];
$newUser['User']['fax'] = $contact['Contact']['fax'];
$newUser['User']['notes'] = $contact['Contact']['notes'];
$newUser['User']['job_title'] = $contact['Contact']['job_title'];
$newUser['User']['phone_extension'] = $contact['Contact']['phone_extension'];
$newUser['User']['direct_phone'] = $contact['Contact']['direct_phone'];
$this->User->create();
//$newPrincipleUsers[] = $newUser;
$this->User->save($newUser);
}
$newCount = $this->User->find('count');
$this->printCountLine($newCount, 'Now have Total Users after migration');
//print_r($newPrincipleUsers);
//$this->User->save($newPrincipleUsers);
}

View file

@ -370,6 +370,66 @@ class VaultShell extends Shell {
}
/**
* Adapted from
* http://www.electrictoolbox.com/function-extract-email-attachments-php-imap/
* @param <type> $connection
* @param <type> $message_number
* @return <type>
*/
function extract_attachments($connection, $message_number) {
$attachments = array();
$structure = imap_fetchstructure($connection, $message_number);
if(isset($structure->parts) && count($structure->parts)) {
for($i = 0; $i < count($structure->parts); $i++) {
$attachments[$i] = array(
'is_attachment' => false,
'filename' => '',
'name' => '',
'attachment' => ''
);
if($structure->parts[$i]->ifparameters) {
foreach($structure->parts[$i]->dparameters as $object) {
if(strtolower($object->attribute) == 'filename') {
$attachments[$i]['is_attachment'] = true;
$attachments[$i]['filename'] = $object->value;
}
}
}
if($structure->parts[$i]->ifparameters) {
foreach($structure->parts[$i]->parameters as $object) {
if(strtolower($object->attribute) == 'name') {
$attachments[$i]['is_attachment'] = true;
$attachments[$i]['name'] = $object->value;
}
}
}
if($attachments[$i]['is_attachment']) {
$attachments[$i]['attachment'] = imap_fetchbody($connection, $message_number, $i+1);
if($structure->parts[$i]->encoding == 3) { // 3 = BASE64
$attachments[$i]['attachment'] = base64_decode($attachments[$i]['attachment']);
}
elseif($structure->parts[$i]->encoding == 4) { // 4 = QUOTED-PRINTABLE
$attachments[$i]['attachment'] = quoted_printable_decode($attachments[$i]['attachment']);
}
}
}
}
return $attachments;
}
}
?>

0
vendors/shells/vault_two.php vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/classtrees_com-tecnick-tcpdf.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/com-tecnick-tcpdf/TCPDF.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/com-tecnick-tcpdf/TCPDFBarcode.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/com-tecnick-tcpdf/_barcodes.php.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/com-tecnick-tcpdf/_config---tcpdf_config.php.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/com-tecnick-tcpdf/_htmlcolors.php.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/com-tecnick-tcpdf/_tcpdf.php.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/com-tecnick-tcpdf/_unicode_data.php.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/elementindex.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/elementindex_com-tecnick-tcpdf.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/errors.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/index.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/li_com-tecnick-tcpdf.html vendored Normal file → Executable file
View file

0
vendors/tcpdf/doc/media/background.png vendored Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

0
vendors/tcpdf/doc/media/empty.png vendored Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 206 B

After

Width:  |  Height:  |  Size: 206 B

0
vendors/tcpdf/doc/media/style.css vendored Normal file → Executable file
View file

0
vendors/xfpdi.php vendored Normal file → Executable file
View file

0
views/countries/complete_country.ctp Normal file → Executable file
View file

0
views/currencies/jsonlist.ctp Normal file → Executable file
View file

0
views/customers/csv.ctp Normal file → Executable file
View file

0
views/customers/similar_customers.ctp Normal file → Executable file
View file

0
views/documents/add.ctp Normal file → Executable file
View file

0
views/documents/edit.ctp Normal file → Executable file
View file

0
views/documents/index.ctp Normal file → Executable file
View file

0
views/documents/view.ctp Normal file → Executable file
View file

0
views/documents/viewDEFAULT.ctp Normal file → Executable file
View file

0
views/elements/info_table.ctp Normal file → Executable file
View file

0
views/elements/isEmptyDate.ctp Normal file → Executable file
View file

0
views/elements/issue_priority_select.ctp Normal file → Executable file
View file

0
views/enquiries/do_search.ctp Normal file → Executable file
View file

0
views/enquiries/search.ctp Normal file → Executable file
View file

0
views/invoices/add.ctp Normal file → Executable file
View file

0
views/invoices/edit.ctp Normal file → Executable file
View file

0
views/invoices/index.ctp Normal file → Executable file
View file

0
views/invoices/view.ctp Normal file → Executable file
View file

0
views/jobs/add.ctp Normal file → Executable file
View file

0
views/jobs/edit.ctp Normal file → Executable file
View file

0
views/jobs/index.ctp Normal file → Executable file
View file

0
views/jobs/view.ctp Normal file → Executable file
View file

0
views/layouts/csv.ctp Normal file → Executable file
View file

0
views/line_items/view_table.ctp Normal file → Executable file
View file

0
views/pages/add.ctp Normal file → Executable file
View file

0
views/pages/edit.ctp Normal file → Executable file
View file

0
views/pages/index.ctp Normal file → Executable file
View file

0
views/pages/view.ctp Normal file → Executable file
View file

0
views/products/.LCKindex.ctp~ Normal file → Executable file
View file

0
views/products/get_principle_products.ctp Normal file → Executable file
View file

0
views/products/get_product_options.ctp Normal file → Executable file
View file

0
views/products/view_principle.ctp Normal file → Executable file
View file

0
views/purchase_orders/add.ctp Normal file → Executable file
View file

0
views/purchase_orders/edit.ctp Normal file → Executable file
View file

0
views/purchase_orders/index.ctp Normal file → Executable file
View file

0
views/purchase_orders/view.ctp Normal file → Executable file
View file

0
views/quotes/ajaxpdf.ctp Normal file → Executable file
View file

0
views/statuses/status_list.ctp Normal file → Executable file
View file

0
webroot/js/addLineItem.js Normal file → Executable file
View file

0
webroot/js/add_costing.js Normal file → Executable file
View file

0
webroot/js/addjob.js Normal file → Executable file
View file

0
webroot/js/addpurchaseorder.js Normal file → Executable file
View file

0
webroot/js/autocomplete-customer.js Normal file → Executable file
View file

0
webroot/js/costing_dialog.js Normal file → Executable file
View file

0
webroot/js/editLineItem.js Normal file → Executable file
View file

0
webroot/js/email_table.js Normal file → Executable file
View file

0
webroot/js/enquiry_table.js Normal file → Executable file
View file

0
webroot/js/findcustomer.js Normal file → Executable file
View file

0
webroot/js/globalsearch.js Normal file → Executable file
View file

0
webroot/js/jobindex.js Normal file → Executable file
View file

0
webroot/js/jquery.form.js Normal file → Executable file
View file

0
webroot/js/jquery.jeditable.mini.js Normal file → Executable file
View file

0
webroot/js/jquery.validate.min.js vendored Normal file → Executable file
View file

0
webroot/js/lineItemPriceNoCosting.js Normal file → Executable file
View file

0
webroot/js/menu.js Normal file → Executable file
View file

0
webroot/js/product-model-number-builder.js Normal file → Executable file
View file

0
webroot/js/search.js Normal file → Executable file
View file