Skip to Content.
Sympa Menu

comanage-dev - [comanage-dev] r479 - in registry/trunk/app: Controller View/Elements

Subject: COmanage Developers List

List archive

[comanage-dev] r479 - in registry/trunk/app: Controller View/Elements


Chronological Thread 
  • From:
  • To:
  • Subject: [comanage-dev] r479 - in registry/trunk/app: Controller View/Elements
  • Date: Tue, 5 Mar 2013 15:07:47 -0500
  • Authentication-results: sfpop-ironport03.merit.edu; dkim=neutral (message not signed) header.i=none

Author: marie
Date: 2013-03-05 15:07:47 -0500 (Tue, 05 Mar 2013)
New Revision: 479

Modified:
registry/trunk/app/Controller/AppController.php
registry/trunk/app/View/Elements/dropMenu.ctp
Log:
co558 finish refactoring of demographics menu

Modified: registry/trunk/app/Controller/AppController.php
===================================================================
--- registry/trunk/app/Controller/AppController.php 2013-03-05 00:46:32
UTC (rev 478)
+++ registry/trunk/app/Controller/AppController.php 2013-03-05 20:07:47
UTC (rev 479)
@@ -1102,7 +1102,7 @@
$menu['cos'][ $data['Co']['id'] ] = $data['Co']['name'];
} elseif($this->Session->check('Auth.User.cos')) {
// Show only COs that a user is a member of
- foreach($this->Session->read('Auth.User.cos') as $name => $data)
+ foreach($this->Session->read('Auth.User.cos') as $name => $data){
$menu['cos'][ $data['co_id'] ] = $data['co_name'];
}

@@ -1115,12 +1115,28 @@
}
}

- // Determine user's own NSF Demographics id
+ // Determine user's own NSF Demographics ids
+ $this->loadModel('CoNsfDemographic');
+
+ foreach($this->Session->read('Auth.User.cos') as $name => $data){
+ // Grab co person id
+ $demodata =
$this->CoNsfDemographic->findByCoPersonId($data['co_person_id']);

- $this->loadModel('CoPerson');
- $persondata = $this->CoPerson->findById($orgIDs[0]['co_id']);
- $menu['CoNsfDemographic']['id'] = $persondata['CoNsfDemographic']['id'];
-
+ if(!empty($demodata)) {
+ // Edit if it already exists for this CO
+ $menu['CoNsfDemographic'][] = array('id' =>
$demodata['CoNsfDemographic']['id'],
+ 'action' => 'edit',
+ 'co_id' => $data['co_id'],
+ 'co_name' => $data['co_name']
+ );
+ } else {
+ // Add if it does not exist for this CO
+ $menu['CoNsfDemographic'][] = array('action' => 'add',
+ 'co_id' => $data['co_id'],
+ 'co_name' =>
$data['co_name'],
+ 'co_person_id' =>
$data['co_person_id']);
+ }
+ }
$this->set('menuContent', $menu);
}


Modified: registry/trunk/app/View/Elements/dropMenu.ctp
===================================================================
--- registry/trunk/app/View/Elements/dropMenu.ctp 2013-03-05 00:46:32
UTC (rev 478)
+++ registry/trunk/app/View/Elements/dropMenu.ctp 2013-03-05 20:07:47
UTC (rev 479)
@@ -335,25 +335,29 @@
<span class="sf-sub-indicator"> ยป</span>
<ul>';

- foreach ($mycos as $co) {
+ foreach ($menuContent['CoNsfDemographic'] as $d) {
print "<li>";
$args = array(
'plugin' => null,
'controller' => 'co_nsf_demographics',
- 'co' => $co['co_id']
+ 'co' => $d['co_id']
);

- // Adjust the link to the NSF Demographics Controller
according to whether or
- // not data has been set.
- if(empty($menuContent['CoNsfDemographic']['id'])) {
- $args['action'] = 'add';
- $args['copersonid'] = $co['co_person_id'];
- } else {
- $args['action'] = 'edit';
- $args[] = $menuContent['CoNsfDemographic']['id'];
- }
+ // If the record already exists, the id is needed for edit
+ if(isset($d['id']))
+ $args[] = $d['id'];

- print $this->Html->link(_txt('me.for',
array($co['co_name'])), $args);
+ // Adjust the link to the NSF Demographics Controller
according to
+ // whether or not data has been set already.
+ $args['action'] = $d['action'];
+
+ // If the record does not exist, the person id is needed for
add
+ if(isset($d['co_person_id']))
+ $args['copersonid'] = $d['co_person_id'];
+
+ print $this->Html->link(_txt('me.for',
array($d['co_name'])),
+ $args
+ );
print "</li>";
}




  • [comanage-dev] r479 - in registry/trunk/app: Controller View/Elements, svnlog, 03/05/2013

Archive powered by MHonArc 2.6.16.

Top of Page