Skip to content

Commit

Permalink
updating the contacts with lat / long on the addresses and making the…
Browse files Browse the repository at this point in the history
… phone number not required
  • Loading branch information
dogmatic69 committed Jun 18, 2012
1 parent 8d0a83f commit f46373b
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Core/Contact/Config/Schema/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function after($event = array()) {
'postal' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 10, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'country_id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'continent_id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 2),
'plugin' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 50, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'latitude' => array('type' => 'float', 'null' => true, 'default' => NULL, 'length' => '9,6'),
'longitude' => array('type' => 'float', 'null' => true, 'default' => NULL, 'length' => '9,6'),
'model' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 50, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'foreign_key' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'created' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
Expand All @@ -34,7 +35,7 @@ public function after($event = array()) {
'email' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 100, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'phone' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 20, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'fax' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 20, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'address_id' => array('type' => 'integer', 'null' => false, 'default' => '0'),
'address_id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'user_count' => array('type' => 'integer', 'null' => false, 'default' => NULL),
'active' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
'ordering' => array('type' => 'integer', 'null' => false, 'default' => NULL),
Expand Down
2 changes: 1 addition & 1 deletion Core/Contact/Config/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id":"4c94edcc-4ec0-4c4e-97de-78d86318cd70","name":"Contact","update_url":"infinitas-cms.org\/plugins\/version\/plugin:contact","version":"0.9","dependancies":[],"author":"Infinitas","website":"infinitas-cms.org","description":"Display your contact details and allow users to contact you","license":"MIT"}
{"id":"4c94edcc-4ec0-4c4e-97de-78d86318cd70","name":"Contact","update_url":"infinitas-cms.org\/plugins\/version\/plugin:contact","version":"0.9.1","dependancies":[],"author":"Infinitas","website":"infinitas-cms.org","description":"Display your contact details and allow users to contact you","license":"MIT"}
88 changes: 88 additions & 0 deletions Core/Contact/Config/releases/000091_Contact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/**
* Infinitas Releas
*
* Auto generated database update
*/

class R4fdf1936e2ac4687a9a93c866318cd70 extends CakeRelease {

/**
* Migration description
*
* @var string
* @access public
*/
public $description = 'Migration for Contact version 0.9.1';

/**
* Plugin name
*
* @var string
* @access public
*/
public $plugin = 'Contact';

/**
* Actions to be performed
*
* @var array $migration
* @access public
*/
public $migration = array(
'up' => array(
'create_field' => array(
'contact_addresses' => array(
'latitude' => array('type' => 'float', 'null' => true, 'default' => NULL, 'length' => '9,6', 'after' => 'continent_id'),
'longitude' => array('type' => 'float', 'null' => true, 'default' => NULL, 'length' => '9,6', 'after' => 'latitude'),
),
),
'drop_field' => array(
'contact_addresses' => array('plugin',),
),
'alter_field' => array(
'contact_branches' => array(
'address_id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
),
),
),
'down' => array(
'drop_field' => array(
'contact_addresses' => array('latitude', 'longitude',),
),
'create_field' => array(
'contact_addresses' => array(
'plugin' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 50, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
),
),
'alter_field' => array(
'contact_branches' => array(
'address_id' => array('type' => 'integer', 'null' => false, 'default' => '0'),
),
),
),
);


/**
* Before migration callback
*
* @param string $direction, up or down direction of migration process
* @return boolean Should process continue
* @access public
*/
public function before($direction) {
return true;
}

/**
* After migration callback
*
* @param string $direction, up or down direction of migration process
* @return boolean Should process continue
* @access public
*/
public function after($direction) {
return true;
}
}
2 changes: 2 additions & 0 deletions Core/Contact/Config/releases/map.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
$map = array(
1 => array(
'000009_Contact' => 'R4f56323e260c44679ec440726318cd70'),
2 => array(
'000091_Contact' => 'R4fdf1936e2ac4687a9a93c866318cd70'),
);
?>
9 changes: 3 additions & 6 deletions Core/Contact/Model/Branch.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,10 @@ public function __construct($id = false, $table = null, $ds = null) {
)
),
'phone' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => __('Please enter some text for the body')
),
'phone' => array(
'rule' => array('phone', '/\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$/'), //Configure::read('Website.phone_regex')),
'message' => __('The number does not seem to be valid')
'message' => __('The number does not seem to be valid'),
'allowEmpty' => true
)
),
'fax' => array(
Expand All @@ -87,7 +84,7 @@ public function __construct($id = false, $table = null, $ds = null) {
* of different branches.
*
* @param array $queryData the find data
*
*
* @return bool
*/
public function beforeFind($queryData){
Expand Down

0 comments on commit f46373b

Please sign in to comment.