From d0d105b937592cc4bddf54b886e2f79be6c9a71e Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 18 May 2011 14:22:31 +0000 Subject: [PATCH] Disable delete using checkboxes too --- .../class.importexport_definitions_bo.inc.php | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/importexport/inc/class.importexport_definitions_bo.inc.php b/importexport/inc/class.importexport_definitions_bo.inc.php index 3dc934586f..50e910ce2c 100644 --- a/importexport/inc/class.importexport_definitions_bo.inc.php +++ b/importexport/inc/class.importexport_definitions_bo.inc.php @@ -43,11 +43,14 @@ class importexport_definitions_bo { public function get_rows(&$query, &$rows, &$readonlys) { $total = $this->so_sql->get_rows($query, $rows, $readonlys); + $ro_count = 0; foreach($rows as $row) { $readonlys["edit[{$row['definition_id']}]"] = $readonlys["delete[{$row['definition_id']}]"] = ($row['owner'] != $GLOBALS['egw_info']['user']['account_id']) && !$GLOBALS['egw_info']['user']['apps']['admin']; + if($readonlys["edit[{$row['definition_id']}]"]) $ro_count++; } + $readonlys['delete_selected'] = $ro_count == count($rows); return $total; } @@ -60,8 +63,13 @@ class importexport_definitions_bo { return $this->definitions; } public function read($definition_id) { - $definition = new importexport_definition( $definition_id['name'] ); - return $definition->get_record_array(); + if(is_numeric($definition_id)) { + $this->so_sql->read($definition_id); + $definition = new importexport_definition($this->so_sql->data['name']); + } else { + $definition = new importexport_definition( $definition_id['name'] ); + } + return $definition->get_record_array(); } /** * deletes a defintion @@ -69,10 +77,18 @@ class importexport_definitions_bo { * @param array $keys */ public function delete($keys) { - $this->so_sql->delete(array('definition_id' => $keys)); - // clear private cache - foreach ($keys as $key) { - unset($this->definitions[array_search($key,$this->definitions)]); + foreach ($keys as $index => $key) { + // Check for ownership + $definition = $this->read($key); + if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) { + // clear private cache + unset($this->definitions[array_search($key,$this->definitions)]); + } else { + unset($keys[$index]); + } + } + if(count($keys) > 0) { + $this->so_sql->delete(array('definition_id' => $keys)); } }