Skip to content

Commit

Permalink
fixing the Address class clash with the Dummy data plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jun 20, 2012
1 parent f41d498 commit c63674a
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 86 deletions.
22 changes: 11 additions & 11 deletions Core/Contact/Controller/AddressesController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
class AddressesController extends ContactAppController {
class ContactAddressesController extends ContactAppController {
public function add(){
if(!$this->Auth->user('id')) {
$this->notice(
Expand All @@ -11,18 +11,18 @@ public function add(){
}

if (!empty($this->request->data)) {
$this->Address->create();
if ($this->Address->saveAll($this->request->data)) {
$this->{$this->modelClass}->create();
if ($this->{$this->modelClass}->saveAll($this->request->data)) {
$this->Infintias->noticeSaved();
$this->redirect('/');
}
}

$this->request->data['Address']['plugin'] = 'management';
$this->request->data['Address']['model'] = 'user';
$this->request->data['Address']['foreign_key'] = $this->Auth->user('id');
$this->request->data[$this->modelClass]['plugin'] = 'management';
$this->request->data[$this->modelClass]['model'] = 'user';
$this->request->data[$this->modelClass]['foreign_key'] = $this->Auth->user('id');

$countries = $this->Address->Country->find('list');
$countries = $this->{$this->modelClass}->Country->find('list');
$continents = array(0 => 'Other', 1 => 'Africa');
$this->set(compact('referer', 'countries', 'continents'));
}
Expand All @@ -33,16 +33,16 @@ public function edit($id = null){
}

if (!empty($this->request->data)) {
if ($this->Address->save($this->request->data)) {
if ($this->{$this->modelClass}->save($this->request->data)) {
$this->notice('saved');
}
}

if ($id && empty($this->request->data)) {
$this->request->data = $this->Address->read(null, $id);
$this->request->data = $this->{$this->modelClass}->read(null, $id);
}

$countries = $this->Address->Country->find('list');
$countries = $this->{$this->modelClass}->Country->find('list');
$continents = array(0 => 'Other', 1 => 'Africa');
$this->set(compact('countries', 'continents'));
}
Expand All @@ -63,7 +63,7 @@ public function admin_index(){
'city',
'province',
'postal',
'country_id' => $this->Address->Country->find('list'),
'country_id' => $this->{$this->modelClass}->Country->find('list'),
'continent' => Configure::read('Contact.continents'),
'active' => (array)Configure::read('CORE.active_options')
);
Expand Down
6 changes: 3 additions & 3 deletions Core/Contact/Controller/BranchesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class BranchesController extends ContactAppController {
/**
* The Branch model
*
*
* @var Branch
* @access public
*/
Expand Down Expand Up @@ -70,9 +70,9 @@ public function view(){
'Branch.active' => 1
),
'contain' => array(
'Address' => array(
'ContactAddress' => array(
'fields' => array(
'Address.address'
'ContactAddress.address'
),
'Country' => array(
'fields' => array(
Expand Down
6 changes: 3 additions & 3 deletions Core/Contact/Controller/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function view(){
'slug',
'active'
),
'Address' => array(
'ContactAddress' => array(
'Country'
)
)
Expand All @@ -62,7 +62,7 @@ public function admin_index(){
'Branch'
)
);

$contacts = $this->Paginator->paginate(
null,
$this->Filter->filter
Expand All @@ -80,7 +80,7 @@ public function admin_index(){

public function admin_add(){
parent::admin_add();

$branches = $this->Contact->Branch->find('list');
if(empty($branches)){
$this->notice(__('Please add a branch first'), array('level' => 'notice','redirect' => array('controller' => 'branches')));
Expand Down
2 changes: 1 addition & 1 deletion Core/Contact/Model/Branch.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Branch extends ContactAppModel {
* @access public
*/
public $belongsTo = array(
'Contact.Address'
'Contact.ContactAddress'
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/**
*
*/
class Address extends ContactAppModel {
class ContactAddress extends ContactAppModel {
public $virtualFields = array(
'address' => 'CONCAT(Address.street, ", ", Address.city, ", ", Address.province)'
'address' => 'CONCAT(ContactAddress.street, ", ", ContactAddress.city, ", ", ContactAddress.province)'
);

public $belongsTo = array(
Expand All @@ -15,7 +15,7 @@ public function getAddressByUser($userId = null, $type = 'list'){
if(!$userId){
return false;
}

$contain = array();
if($type === 'all'){
$contain = array(
Expand All @@ -27,9 +27,9 @@ public function getAddressByUser($userId = null, $type = 'list'){
$type,
array(
'conditions' => array(
'Address.foreign_key' => $userId,
'Address.plugin' => 'management',
'Address.model' => 'user'
'ContactAddress.foreign_key' => $userId,
'ContactAddress.plugin' => 'management',
'ContactAddress.model' => 'user'
),
'contain' => $contain
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BranchesControllerTest extends CakeTestCase {

'plugin.contact.branch',
'plugin.contact.contact',
'plugin.contact.address',
'plugin.contact.contact_address',
'plugin.users.user',
'plugin.users.group',
'plugin.management.ticket',
Expand Down
18 changes: 0 additions & 18 deletions Core/Contact/Test/Case/Model/AddressTest.php

This file was deleted.

18 changes: 18 additions & 0 deletions Core/Contact/Test/Case/Model/ContactAddressTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/* Address Test cases generated on: 2010-03-13 11:03:14 : 1268471054*/
App::uses('ContactAddress', 'Contact.Model');

class ContactAddressTest extends CakeTestCase {

function startTest() {
$this->ContactAddress = ClassRegistry::init('Contact.ContactAddress');
}

function testDummy() {}

function endTest() {
unset($this->ContactAddress);
ClassRegistry::flush();
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/* CoreAddress Fixture generated on: 2010-08-17 14:08:08 : 1282055108 */
class AddressFixture extends CakeTestFixture {
var $name = 'Address';
class ContactAddressFixture extends CakeTestFixture {
var $name = 'ContactAddress';

var $table = 'contact_addresses';

Expand Down
18 changes: 9 additions & 9 deletions Core/Contact/View/Addresses/admin_index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @since 0.5a
*/

echo $this->Form->create('Address', array('action' => 'mass'));
echo $this->Form->create(null, array('action' => 'mass'));
$massActions = $this->Infinitas->massActionButtons(
array(
'add',
Expand Down Expand Up @@ -66,31 +66,31 @@
<tr class="<?php echo $this->Infinitas->rowClass(); ?>">
<td><?php echo $this->Infinitas->massActionCheckBox($address); ?>&nbsp;</td>
<td>
<?php echo sprintf('%s.%s', $address['Address']['plugin'], $address['Address']['model']); ?>&nbsp;
<?php echo sprintf('%s.%s', $address['ContactAddress']['plugin'], $address['ContactAddress']['model']); ?>&nbsp;
</td>
<td>
<?php echo $this->Html->link($address['Address']['name'], array('action' => 'edit', $address['Address']['id'])); ?>&nbsp;
<?php echo $this->Html->link($address['ContactAddress']['name'], array('action' => 'edit', $address['ContactAddress']['id'])); ?>&nbsp;
</td>
<td>
<?php echo $address['Address']['street']; ?>&nbsp;
<?php echo $address['ContactAddress']['street']; ?>&nbsp;
</td>
<td>
<?php echo $address['Address']['city']; ?>&nbsp;
<?php echo $address['ContactAddress']['city']; ?>&nbsp;
</td>
<td>
<?php echo $address['Address']['province']; ?>&nbsp;
<?php echo $address['ContactAddress']['province']; ?>&nbsp;
</td>
<td>
<?php echo $address['Address']['postal']; ?>&nbsp;
<?php echo $address['ContactAddress']['postal']; ?>&nbsp;
</td>
<td>
<?php echo $address['Country']['name']; ?>&nbsp;
</td>
<td>
<?php echo __(Configure::read('Contact.continents.' . $address['Address']['continent_id'])); ?>&nbsp;
<?php echo __(Configure::read('Contact.continents.' . $address['ContactAddress']['continent_id'])); ?>&nbsp;
</td>
<td>
<?php echo $this->Time->niceShort($address['Address']['modified']); ?>&nbsp;
<?php echo $this->Time->niceShort($address['ContactAddress']['modified']); ?>&nbsp;
</td>
</tr>
<?php
Expand Down
2 changes: 1 addition & 1 deletion Core/Contact/View/Addresses/form.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/

echo $this->Form->create('Address');
echo $this->Form->create();
echo $this->Form->input('id');
echo $this->Form->input('name');
echo $this->Form->input('continent_id', array('empty' => Configure::read('Website.empty_select')));
Expand Down
12 changes: 6 additions & 6 deletions Core/Contact/View/Branches/vcf/view.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
echo $this->Vcf->attr('url', env('SERVER_NAME'));
echo $this->Vcf->attr('image', $this->Html->url('/img/content/contact/branch/'.$branch['Branch']['image'], true));
echo $this->Vcf->address(
$branch['Address']['name'],
$branch['ContactAddress']['name'],
array(
'country' => $branch['Address']['Country']['name'],
'province' => $branch['Address']['province'],
'postal' => $branch['Address']['postal'],
'city' => $branch['Address']['city'],
'street' => $branch['Address']['street']
'country' => $branch['ContactAddress']['Country']['name'],
'province' => $branch['ContactAddress']['province'],
'postal' => $branch['ContactAddress']['postal'],
'city' => $branch['ContactAddress']['city'],
'street' => $branch['ContactAddress']['street']
)
);
echo $this->Vcf->end();
Expand Down
4 changes: 2 additions & 2 deletions Core/Contact/View/Branches/view.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<?php
echo $this->StaticMap->draw(
array(
'location' => $branch['Address']['address'],
'location' => $branch['ContactAddress']['address'],
'size' => array(
'width' => '600',
'height' => '200'
Expand All @@ -119,7 +119,7 @@
'size' => 'normal',
'color' => 'ff0000',
'label' => 'A',
'location' => $branch['Address']['address']
'location' => $branch['ContactAddress']['address']
)
)
),
Expand Down
12 changes: 6 additions & 6 deletions Core/Contact/View/Contacts/vcf/view.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
echo $this->Vcf->attr('cellPhone', $contact['Contact']['mobile']);
echo $this->Vcf->attr('image', $this->Html->url('/img/content/contact/contact/'.$branch['Branch']['image'], true));
echo $this->Vcf->address(
$contact['Branch']['Address']['name'],
$contact['Branch']['ContactAddress']['name'],
array(
'country' => $contact['Branch']['Address']['Country']['name'],
'province' => $branch['Address']['province'],
'postal' => $branch['Address']['postal'],
'city' => $branch['Address']['city'],
'street' => $branch['Address']['street']
'country' => $contact['Branch']['ContactAddress']['Country']['name'],
'province' => $branch['ContactAddress']['province'],
'postal' => $branch['ContactAddress']['postal'],
'city' => $branch['ContactAddress']['city'],
'street' => $branch['ContactAddress']['street']
)
);
echo $this->Vcf->end();
Expand Down
34 changes: 17 additions & 17 deletions Core/Contact/View/Elements/address_form.ctp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
if(!isset($plugin) || !$plugin || $plugin == 'contact'){
$plugin = $this->plugin;
}
Expand All @@ -7,35 +7,35 @@
}

if(!isset($countries) || !$countries){
$countries = ClassRegistry::init('Contact.Address')->Country->find('list');
$countries = ClassRegistry::init('Contact.ContactAddress')->Country->find('list');
}

$addressSelect = (isset($addressSelect)) ?(bool)$addressSelect : false;
?>
<fieldset>
<h1><?php echo __('Address'); ?></h1><?php
echo $this->Form->hidden('Address.id');
echo $this->Form->hidden('ContactAddress.id');

$options = ClassRegistry::init('Contact.Address')->getAddressesByRelated(
$options = ClassRegistry::init('Contact.ContactAddress')->getAddressesByRelated(
array(
'Address.plugin' => $plugin,
'Address.model' => $model
'ContactAddress.plugin' => $plugin,
'ContactAddress.model' => $model
)
);

if($addressSelect){
echo $this->Form->input($model . '.address_id', array('options' => $options, 'label' => __('Use existing'), 'empty' => Configure::read('Website.empty_select')));
}

echo $this->Form->hidden('Address.plugin', array('value' => $plugin));
echo $this->Form->hidden('Address.model', array('value' => $model));
echo $this->Form->hidden('Address.foreign_key');

echo $this->Form->input('Address.name');
echo $this->Form->input('Address.street');
echo $this->Form->input('Address.city');
echo $this->Form->input('Address.province');
echo $this->Form->input('Address.postal');
echo $this->Form->input('Address.continent_id', array('empty' => Configure::read('Website.empty_select'), 'options' => Configure::read('Contact.continents')));
echo $this->Form->input('Address.country_id', array('empty' => Configure::read('Website.empty_select'), 'options' => $countries)); ?>
echo $this->Form->hidden('ContactAddress.plugin', array('value' => $plugin));
echo $this->Form->hidden('ContactAddress.model', array('value' => $model));
echo $this->Form->hidden('ContactAddress.foreign_key');

echo $this->Form->input('ContactAddress.name');
echo $this->Form->input('ContactAddress.street');
echo $this->Form->input('ContactAddress.city');
echo $this->Form->input('ContactAddress.province');
echo $this->Form->input('ContactAddress.postal');
echo $this->Form->input('ContactAddress.continent_id', array('empty' => Configure::read('Website.empty_select'), 'options' => Configure::read('Contact.continents')));
echo $this->Form->input('ContactAddress.country_id', array('empty' => Configure::read('Website.empty_select'), 'options' => $countries)); ?>
</fieldset>

0 comments on commit c63674a

Please sign in to comment.