Skip to Content.
Sympa Menu

comanage-dev - [comanage-dev] r260 - in registry/trunk/app: Controller Model

Subject: COmanage Developers List

List archive

[comanage-dev] r260 - in registry/trunk/app: Controller Model


Chronological Thread 
  • From:
  • To:
  • Subject: [comanage-dev] r260 - in registry/trunk/app: Controller Model
  • Date: Wed, 14 Mar 2012 03:47:22 -0400

Author: marie
Date: 2012-03-14 03:47:21 -0400 (Wed, 14 Mar 2012)
New Revision: 260

Modified:
registry/trunk/app/Controller/CoNsfDemographicsController.php
registry/trunk/app/Model/CoNsfDemographic.php
Log:
co-294 rest errors on add

Modified: registry/trunk/app/Controller/CoNsfDemographicsController.php
===================================================================
--- registry/trunk/app/Controller/CoNsfDemographicsController.php
2012-03-13 04:09:31 UTC (rev 259)
+++ registry/trunk/app/Controller/CoNsfDemographicsController.php
2012-03-14 07:47:21 UTC (rev 260)
@@ -53,7 +53,11 @@
if($this->action == 'edit')
{
// Pass previously selected options
- $options =
$this->CoNsfDemographic->extractOptions($this->data['CoNsfDemographic']);
+ if($this->restful)
+ $options =
$this->CoNsfDemographic->extractOptions($this->request['data']['CoNsfDemographics'][0]);
+ else
+ $options =
$this->CoNsfDemographic->extractOptions($this->data['CoNsfDemographic']);
+
if(isset($options['race']))
$this->set('race_options', $options['race']);
if(isset($options['disability']))
@@ -94,15 +98,20 @@
*/

function checkWriteDependencies($reqdata, $curdata = null) {
- // Look up id
- $cmr = $this->calculateCMRoles();
+ // Look up id to check validity
+ if($this->restful) {
+ $personid =
$this->request['data']['CoNsfDemographics'][0]['CoPersonId'];
+ } else {
+ $cmr = $this->calculateCMRoles();
+ $personid = $cmr['copersonid'];
+ }

- // Is this a valid co person id?
$args = array(
'conditions' => array(
- 'CoPerson.id' => $cmr['copersonid']
+ 'CoPerson.id' => $personid
)
);
+
$rowCount = $this->CoNsfDemographic->CoPerson->find('count', $args);

// If not valid, return error
@@ -119,7 +128,7 @@
// Does a row exist in the database for this id?
$args = array(
'conditions' => array(
- 'CoNsfDemographic.co_person_id' => $cmr['copersonid'],
+ 'CoNsfDemographic.co_person_id' => $personid,
'CoPerson.co_id' => $this->cur_co['Co']['id']
)
);
@@ -151,7 +160,11 @@
if(!empty($this->request->data))
{
// Data doesn't already exist so encode for writing
- $encoded =
$this->CoNsfDemographic->encodeOptions($this->request->data['CoNsfDemographic']);
+ if($this->restful)
+ $encoded =
$this->CoNsfDemographic->encodeOptions($this->request['data']['CoNsfDemographics'][0]);
+ else
+ $encoded =
$this->CoNsfDemographic->encodeOptions($this->request->data['CoNsfDemographic']);
+
if(isset($encoded['race']))
$this->request->data['CoNsfDemographic']['race'] =
$encoded['race'];
if(isset($encoded['disability']))

Modified: registry/trunk/app/Model/CoNsfDemographic.php
===================================================================
--- registry/trunk/app/Model/CoNsfDemographic.php 2012-03-13 04:09:31
UTC (rev 259)
+++ registry/trunk/app/Model/CoNsfDemographic.php 2012-03-14 07:47:21
UTC (rev 260)
@@ -91,9 +91,9 @@
public function encodeOptions($d) {
$encoded = array();

- if(is_array($d['race']))
+ if(isset($d['race']) && is_array($d['race']))
$encoded['race'] = implode($d['race']);
- if(is_array($d['disability']))
+ if(isset($d['disability']) && is_array($d['disability']))
$encoded['disability'] = implode($d['disability']);

return $encoded;
@@ -118,7 +118,7 @@
$disabilityOptions = $cm_texts[ $cm_lang ]['en.nsf.disab'];

// Extract selected values for race into array of single characters
- if($d['race'] != NULL)
+ if(isset($d['race']) && ($d['race'] != NULL))
{
$raceValues = str_split($d['race']);

@@ -136,7 +136,7 @@
}

// Extract values for disability into array of single characters
- if($d['disability'] != NULL)
+ if(isset($d['disability']) && ($d['disability'] != NULL))
{
$disValues = str_split($d['disability']);




  • [comanage-dev] r260 - in registry/trunk/app: Controller Model, svnlog, 03/14/2012

Archive powered by MHonArc 2.6.16.

Top of Page