Skip to Content.
Sympa Menu

comanage-dev - [comanage-dev] r250 - in registry/trunk/app: Controller Model View/CoPeople

Subject: COmanage Developers List

List archive

[comanage-dev] r250 - in registry/trunk/app: Controller Model View/CoPeople


Chronological Thread 
  • From:
  • To:
  • Subject: [comanage-dev] r250 - in registry/trunk/app: Controller Model View/CoPeople
  • Date: Mon, 5 Mar 2012 20:23:30 -0500

Author: benno
Date: 2012-03-05 20:23:29 -0500 (Mon, 05 Mar 2012)
New Revision: 250

Modified:
registry/trunk/app/Controller/CoPeopleController.php
registry/trunk/app/Controller/CoPersonRolesController.php
registry/trunk/app/Model/Cou.php
registry/trunk/app/View/CoPeople/index.ctp
Log:
Additional fixes for CO-226 couadmin authz checks

Modified: registry/trunk/app/Controller/CoPeopleController.php
===================================================================
--- registry/trunk/app/Controller/CoPeopleController.php 2012-03-06
01:02:26 UTC (rev 249)
+++ registry/trunk/app/Controller/CoPeopleController.php 2012-03-06
01:23:29 UTC (rev 250)
@@ -333,9 +333,7 @@
// Determine which COUs a person can manage.

if($cmr['cmadmin'] || $cmr['coadmin'])
- $p['cous'] = $this->CoPerson->CoPersonRole->Cou->find("list",
-
array("conditions" =>
-
array("co_id" => $this->cur_co['Co']['id'])));
+ $p['cous'] =
$this->CoPerson->CoPersonRole->Cou->allCous($this->cur_co['Co']['id'],
'names');
elseif(!empty($cmr['couadmin']))
$p['cous'] = $cmr['couadmin'];
else

Modified: registry/trunk/app/Controller/CoPersonRolesController.php
===================================================================
--- registry/trunk/app/Controller/CoPersonRolesController.php 2012-03-06
01:02:26 UTC (rev 249)
+++ registry/trunk/app/Controller/CoPersonRolesController.php 2012-03-06
01:23:29 UTC (rev 250)
@@ -272,10 +272,11 @@
$p['view'] = ($cmr['cmadmin'] || $cmr['coadmin'] || $self);

// Determine which COUs a person can manage.
- if($cmr['cmadmin'] || $cmr['coadmin'])
- $p['cous'] = $this->CoPersonRole->Cou->find("list",
- array("conditions" =>
- array("co_id" =>
$this->cur_co['Co']['id'])));
+ if($cmr['cmadmin'] || $cmr['coadmin']) {
+ // Note that here we get id => name while in CoPeopleController we just
+ // get a list of names. This is to generate the pop-up on the edit
form.
+ $p['cous'] =
$this->CoPersonRole->Cou->allCous($this->cur_co['Co']['id']);
+ }
elseif(!empty($cmr['couadmin']))
$p['cous'] = $cmr['couadmin'];
else

Modified: registry/trunk/app/Model/Cou.php
===================================================================
--- registry/trunk/app/Model/Cou.php 2012-03-06 01:02:26 UTC (rev 249)
+++ registry/trunk/app/Model/Cou.php 2012-03-06 01:23:29 UTC (rev 250)
@@ -90,6 +90,37 @@
public $actsAs = array('Tree');

/**
+ * Obtain all COUs within a specified CO.
+ *
+ * @since COmanage Registry v0.4
+ * @param integer CO ID
+ * @param string Format, one of "names", "ids", or "hash" of id => name
+ * @return Array List or hash of member COUs, as specified by $format
+ */
+
+ public function allCous($coId, $format="hash") {
+ $args['conditions']['Cou.co_id'] = $coId;
+
+ $cous = $this->find("list", $args);
+
+ if($cous) {
+ switch($format) {
+ case 'names':
+ return(array_values($cous));
+ break;
+ case 'ids':
+ return(array_keys($cous));
+ break;
+ default:
+ return($cous);
+ break;
+ }
+ }
+
+ return(array());
+ }
+
+ /**
* Generates dropdown option list for html for a COU.
*
* @since COmanage Registry v0.3

Modified: registry/trunk/app/View/CoPeople/index.ctp
===================================================================
--- registry/trunk/app/View/CoPeople/index.ctp 2012-03-06 01:02:26 UTC (rev
249)
+++ registry/trunk/app/View/CoPeople/index.ctp 2012-03-06 01:23:29 UTC (rev
250)
@@ -48,10 +48,30 @@
<?php $i = 0; ?>
<?php foreach ($co_people as $p): ?>
<tr class="line<?php print ($i % 2)+1; ?>">
- <td><?php echo $this->Html->link(generateCn($p['Name']),
- array('controller' => 'co_people',
'action' => ($permissions['edit'] ? 'edit' : ($permissions['view'] ? 'view' :
'')), $p['CoPerson']['id'], 'co' => $cur_co['Co']['id'])); ?></td>
<td>
<?php
+ // Is this a person in a COU of the currently logged in person?
+ $myPerson = false;
+
+ // We look at COU here if set for the role
+ if($permissions['edit']
+ && (!isset($pr['cou_id'])
+ || $pr['cou_id'] == ''
+ || in_array($pr['Cou']['name'], $permissions['cous'])))
+ $myPerson = true;
+
+ print $this->Html->link(generateCn($p['Name']),
+ array(
+ 'controller' => 'co_people',
+ 'action' => ($permissions['edit']
+ ? 'edit'
+ : ($permissions['view'] ?
'view' : '')),
+ $p['CoPerson']['id'],
+ 'co' => $cur_co['Co']['id'])
+ );
+ ?></td>
+ <td>
+ <?php
global $status_t;

if(!empty($p['CoPerson']['status']) ) echo _txt('en.status', null,
$p['CoPerson']['status']);
@@ -59,17 +79,7 @@
</td>
<td>
<?php
- // Is this a person in a COU of the currently logged in person?
- $myPerson = false;
-
foreach ($p['CoPersonRole'] as $pr) {
- // We look at COU here if set for the role
- if($permissions['edit']
- && (!isset($pr['cou_id'])
- || $pr['cou_id'] == ''
- || in_array($pr['Cou']['name'], $permissions['cous'])))
- $myPerson = true;
-
if($myPerson) {
echo $this->Html->link(_txt('op.edit'),
array('controller' =>
'co_person_roles',
@@ -99,13 +109,13 @@
array('class' => 'comparebutton')) .
"\n";

if($myPerson) {
- // Edit actions are unavailable
+ // Edit actions are unavailable if not

if($permissions['edit'])
echo $this->Html->link(_txt('op.edit'),
array('controller' => 'co_people',
'action' => 'edit', $p['CoPerson']['id'], 'co' => $cur_co['Co']['id']),
array('class' => 'editbutton')) . "\n";
-
+
if($permissions['delete'])
echo '<button class="deletebutton" title="' .
_txt('op.delete') . '" onclick="javascript:js_confirm_delete(\'' .
_jtxt(Sanitize::html(generateCn($p['Name']))) . '\', \'' .
$this->Html->url(array('controller' => 'co_people', 'action' => 'delete',
$p['CoPerson']['id'], 'co' => $cur_co['Co']['id'])) . '\')";>' .
_txt('op.delete') . '</button>' . "\n";




  • [comanage-dev] r250 - in registry/trunk/app: Controller Model View/CoPeople, svnlog, 03/05/2012

Archive powered by MHonArc 2.6.16.

Top of Page