From b2b292603d4863b84444dff337894d9801cd1527 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 23 Nov 2010 17:56:56 +0000 Subject: [PATCH] - Fix incorrect result counts when using whole query - Add action to change completion - Give warning if trying to change the status of a done entry. Completion of 100% will change it right back. - Fix ACL when linking - only link to entries with EDIT permission - Hide group types if user has no access to them --- infolog/inc/class.infolog_ui.inc.php | 55 +++++++++++++++++++++++++++- infolog/js/index.js | 6 +++ infolog/setup/etemplates.inc.php | 4 +- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 0670437c6c..d501306aef 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -521,6 +521,10 @@ class infolog_ui { $values['multi_action'] = 'cat_' . $values['cat']; } + elseif ($values['multi_action'] == 'completion') + { + $values['multi_action'] = 'completion_' . $values['completion']; + } if ($this->action($values['multi_action'],$values['nm']['rows']['checked'],$values['use_all'], $success,$failed,$action_msg,false,$msg)) { @@ -736,6 +740,7 @@ class infolog_ui 'close' => lang('Close'), 'cat' => lang('Change category'), 'link' => lang('Add or delete links'), + 'completion' => lang('Change completion'), ) ); @@ -744,6 +749,17 @@ class infolog_ui foreach($this->bo->enums['type'] as $type => $label) { $types['type_'.$type] = $label; + } + if ($this->bo->group_owners) + { + // remove types owned by groups the user has no edit grant + foreach($this->bo->group_owners as $type => $group) + { + if (!($this->bo->grants[$group] & EGW_ACL_EDIT)) + { + unset($types['type_'.$type]); + } + } } $sel_options['multi_action'][lang('Change type:')] = $types; @@ -757,6 +773,7 @@ class infolog_ui $statis = array(); foreach($this->bo->status as $typ => $stati) { + if($typ == 'defaults') continue; $statis += $stati; } $statis = array_unique($statis); @@ -800,7 +817,15 @@ class infolog_ui { @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small $query['num_rows'] = -1; // all - $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's + $this->get_rows($query,$result,$readonlys); + $checked = array(); + foreach($result as $key => $info) + { + if(is_numeric($key)) + { + $checked[] = $info['info_id']; + } + } } } @@ -822,6 +847,10 @@ class infolog_ui $title = egw_link::title($app, $link_id); foreach($checked as $id) { + if(!$this->bo->check_access($id, EGW_ACL_EDIT)) { + $failed++; + continue; + } if($add_remove == 'add') { $action_msg = lang('linked to %1', $title); if(egw_link::link('infolog', $id, $app, $link_id)) @@ -846,7 +875,6 @@ class infolog_ui { if(!$entry = $this->bo->read($id)) { - $failed++; continue; } switch($action) @@ -868,7 +896,30 @@ class infolog_ui $success++; break; + case 'completion': + $action_msg = lang('changed completion to %1%', $settings); + $entry['info_percent'] = $settings; + // Done entries will get changed right back if we don't change the status too + if($entry['info_status'] == 'done') { + $entry['info_status'] = 'ongoing'; + } + if($this->bo->write($entry)) + { + $success++; + } + else + { + $failed++; + } + break; + case 'status': + if($settings != 'done' && $entry['info_status'] == 'done' && $entry['info_percent'] == 100) + { + $msg .= lang('Unable to change status from done because of completion. ') . "\n"; + $failed++; + break; + } if(in_array($settings, $this->bo->status[$entry['info_type']])) { $action_msg = lang('changed status to %1', lang($this->bo->status[$entry['info_type']][$settings])); $entry['info_status'] = $settings; diff --git a/infolog/js/index.js b/infolog/js/index.js index da379ba2d8..7d1d097aa4 100644 --- a/infolog/js/index.js +++ b/infolog/js/index.js @@ -22,6 +22,12 @@ function do_infolog_action(selbox) { popup.style.display = 'block'; } return; + case "completion": + var popup = document.getElementById(prefix+'[completion_popup]'); + if(popup) { + popup.style.display = 'block'; + } + return; } selbox.form.submit(); selbox.value = ""; diff --git a/infolog/setup/etemplates.inc.php b/infolog/setup/etemplates.inc.php index 95c6116ec6..cc0ce09df0 100644 --- a/infolog/setup/etemplates.inc.php +++ b/infolog/setup/etemplates.inc.php @@ -2,7 +2,7 @@ /** * eGroupWare - eTemplates for Application infolog * http://www.egroupware.org - * generated by soetemplate::dump4setup() 2010-11-22 15:43 + * generated by soetemplate::dump4setup() 2010-11-23 10:55 * * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @package infolog @@ -55,7 +55,7 @@ $templ_data[] = array('name' => 'infolog.export_csv_selectors','template' => '', $templ_data[] = array('name' => 'infolog.importexport_wizard_chooseowner','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:1:{s:2:"h2";s:14:",@no_owner_map";}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"name";s:3:"msg";s:7:"no_lang";s:1:"1";}}i:2;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"checkbox";s:5:"label";s:30:"Use field from CSV if possible";s:4:"name";s:14:"owner_from_csv";}}i:3;a:1:{s:1:"A";a:2:{s:4:"type";s:14:"select-account";s:4:"name";s:5:"owner";}}i:4;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}i:5;a:1:{s:1:"A";a:3:{s:4:"type";s:11:"select-bool";s:5:"label";s:26:"Change owner when updating";s:4:"name";s:12:"change_owner";}}}s:4:"rows";i:5;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1286389863',); -$templ_data[] = array('name' => 'infolog.index','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:7:{i:0;a:6:{s:1:"A";s:3:"90%";s:2:"h3";s:2:",1";s:2:"h2";s:6:",!@msg";s:2:"c6";s:7:"noPrint";s:2:"h4";s:7:",!@main";s:2:"h1";s:6:",!@css";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:4:"html";s:4:"span";s:3:"all";s:4:"name";s:3:"css";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:5:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";s:5:"align";s:6:"center";s:4:"name";s:3:"msg";s:7:"no_lang";s:1:"1";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:8:"template";s:4:"name";s:11:"header_left";}s:1:"B";a:2:{s:4:"type";s:8:"template";s:4:"name";s:12:"header_right";}}i:4;a:2:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:4:"main";s:4:"span";s:3:"all";s:4:"name";s:27:"infolog.index.rows-noheader";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:5;a:2:{s:1:"A";a:4:{s:4:"type";s:9:"nextmatch";s:4:"size";s:20:"infolog.index.rows,1";s:4:"span";s:3:"all";s:4:"name";s:2:"nm";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:6;a:2:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:5:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:4:"name";s:9:"add[note]";s:4:"help";s:15:"Add a new Entry";s:7:"onclick";s:245:"window.open(egw::link(\'/index.php\',\'menuaction=infolog.infolog_ui.edit&type=note&action=$cont[action]&action_id=$cont[action_id]&cat_id={$cont[nm][cat_id]}\'),\'_blank\',\'dependent=yes,width=750,height=600,scrollbars=yes,status=yes\'); return false;";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:4:"name";s:6:"cancel";s:4:"help";s:17:"Back to main list";}}s:1:"B";a:8:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"5";s:5:"align";s:5:"right";i:1;a:5:{s:4:"type";s:3:"box";s:4:"name";s:10:"link_popup";s:4:"size";s:1:"1";s:4:"span";s:20:",action_popup prompt";i:1;a:5:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:5:"label";s:4:"span";s:13:",promptheader";s:5:"label";s:17:"Add / Remove link";}i:2;a:3:{s:4:"type";s:10:"link-entry";s:4:"name";s:11:"action_link";s:4:"span";s:21:",action_popup-content";}i:3;a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:4:"name";s:16:"link_action[add]";}i:2;a:3:{s:4:"type";s:6:"button";s:4:"name";s:19:"link_action[delete]";s:5:"label";s:6:"Delete";}i:3;a:3:{s:4:"type";s:10:"buttononly";s:5:"label";s:6:"Cancel";s:7:"onclick";s:30:"hide_popup(this,\'link_popup\');";}}}}i:2;a:5:{s:4:"type";s:3:"box";s:4:"name";s:9:"cat_popup";s:4:"size";s:1:"1";s:4:"span";s:20:",action_popup prompt";i:1;a:5:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:5:"label";s:4:"span";s:13:",promptheader";s:5:"label";s:15:"Change category";}i:2;a:5:{s:4:"type";s:10:"select-cat";s:4:"span";s:21:",action_popup-content";s:4:"name";s:3:"cat";s:4:"size";s:14:"None,,,infolog";s:5:"label";s:19:"Select new category";}i:3;a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:5:"Apply";s:4:"name";s:10:"change_cat";}i:2;a:3:{s:4:"type";s:10:"buttononly";s:5:"label";s:6:"Cancel";s:7:"onclick";s:29:"hide_popup(this,\'cat_popup\');";}}}}i:3;a:5:{s:4:"type";s:8:"checkbox";s:4:"name";s:7:"use_all";s:5:"label";s:11:"whole query";s:8:"onchange";s:125:"if (this.checked==true && !confirm(\'Apply the action on the whole query, NOT only the shown entries!!!\')) this.checked=false;";s:4:"help";s:66:"Apply the action on the whole query, NOT only the shown entries!!!";}i:4;a:6:{s:4:"type";s:6:"select";s:8:"onchange";s:24:"do_infolog_action(this);";s:4:"size";s:19:"Select an action...";s:7:"no_lang";s:1:"1";s:4:"name";s:12:"multi_action";s:4:"help";s:16:"Select an action";}i:5;a:8:{s:4:"type";s:6:"button";s:4:"size";s:9:"arrow_ltr";s:5:"label";s:9:"Check all";s:4:"name";s:9:"check_all";s:4:"help";s:9:"Check all";s:7:"onclick";s:70:"toggle_all(this.form,form::name(\'nm[rows][checked][]\')); return false;";s:6:"needed";s:1:"1";s:4:"span";s:14:",checkAllArrow";}}}}s:4:"rows";i:6;s:4:"cols";i:2;s:4:"size";s:12:"100%,,0,,0,0";}}','size' => '100%,,0,,0,0','style' => '/** +$templ_data[] = array('name' => 'infolog.index','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:7:{i:0;a:6:{s:1:"A";s:3:"90%";s:2:"h3";s:2:",1";s:2:"h2";s:6:",!@msg";s:2:"c6";s:7:"noPrint";s:2:"h4";s:7:",!@main";s:2:"h1";s:6:",!@css";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:4:"html";s:4:"span";s:3:"all";s:4:"name";s:3:"css";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:5:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";s:5:"align";s:6:"center";s:4:"name";s:3:"msg";s:7:"no_lang";s:1:"1";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:8:"template";s:4:"name";s:11:"header_left";}s:1:"B";a:2:{s:4:"type";s:8:"template";s:4:"name";s:12:"header_right";}}i:4;a:2:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:4:"main";s:4:"span";s:3:"all";s:4:"name";s:27:"infolog.index.rows-noheader";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:5;a:2:{s:1:"A";a:4:{s:4:"type";s:9:"nextmatch";s:4:"size";s:20:"infolog.index.rows,1";s:4:"span";s:3:"all";s:4:"name";s:2:"nm";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:6;a:2:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:5:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:4:"name";s:9:"add[note]";s:4:"help";s:15:"Add a new Entry";s:7:"onclick";s:245:"window.open(egw::link(\'/index.php\',\'menuaction=infolog.infolog_ui.edit&type=note&action=$cont[action]&action_id=$cont[action_id]&cat_id={$cont[nm][cat_id]}\'),\'_blank\',\'dependent=yes,width=750,height=600,scrollbars=yes,status=yes\'); return false;";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:4:"name";s:6:"cancel";s:4:"help";s:17:"Back to main list";}}s:1:"B";a:9:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"6";s:5:"align";s:5:"right";i:1;a:5:{s:4:"type";s:3:"box";s:4:"name";s:10:"link_popup";s:4:"size";s:1:"1";s:4:"span";s:20:",action_popup prompt";i:1;a:5:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:5:"label";s:4:"span";s:13:",promptheader";s:5:"label";s:17:"Add / Remove link";}i:2;a:3:{s:4:"type";s:10:"link-entry";s:4:"name";s:11:"action_link";s:4:"span";s:21:",action_popup-content";}i:3;a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:4:"name";s:16:"link_action[add]";}i:2;a:3:{s:4:"type";s:6:"button";s:4:"name";s:19:"link_action[delete]";s:5:"label";s:6:"Delete";}i:3;a:3:{s:4:"type";s:10:"buttononly";s:5:"label";s:6:"Cancel";s:7:"onclick";s:30:"hide_popup(this,\'link_popup\');";}}}}i:2;a:5:{s:4:"type";s:3:"box";s:4:"name";s:9:"cat_popup";s:4:"size";s:1:"1";s:4:"span";s:20:",action_popup prompt";i:1;a:5:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:5:"label";s:4:"span";s:13:",promptheader";s:5:"label";s:15:"Change category";}i:2;a:5:{s:4:"type";s:10:"select-cat";s:4:"span";s:21:",action_popup-content";s:4:"name";s:3:"cat";s:4:"size";s:14:"None,,,infolog";s:5:"label";s:19:"Select new category";}i:3;a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:5:"Apply";s:4:"name";s:10:"change_cat";}i:2;a:3:{s:4:"type";s:10:"buttononly";s:5:"label";s:6:"Cancel";s:7:"onclick";s:29:"hide_popup(this,\'cat_popup\');";}}}}i:3;a:5:{s:4:"type";s:3:"box";s:4:"name";s:16:"completion_popup";s:4:"size";s:1:"1";s:4:"span";s:20:",action_popup prompt";i:1;a:5:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:5:"label";s:4:"span";s:13:",promptheader";s:5:"label";s:16:"Change completed";}i:2;a:4:{s:4:"type";s:14:"select-percent";s:4:"span";s:21:",action_popup-content";s:4:"name";s:10:"completion";s:5:"label";s:9:"Completed";}i:3;a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:5:"Apply";s:4:"name";s:17:"change_completion";}i:2;a:3:{s:4:"type";s:10:"buttononly";s:5:"label";s:6:"Cancel";s:7:"onclick";s:36:"hide_popup(this,\'completion_popup\');";}}}}i:4;a:5:{s:4:"type";s:8:"checkbox";s:4:"name";s:7:"use_all";s:5:"label";s:11:"whole query";s:8:"onchange";s:125:"if (this.checked==true && !confirm(\'Apply the action on the whole query, NOT only the shown entries!!!\')) this.checked=false;";s:4:"help";s:66:"Apply the action on the whole query, NOT only the shown entries!!!";}i:5;a:6:{s:4:"type";s:6:"select";s:8:"onchange";s:24:"do_infolog_action(this);";s:4:"size";s:19:"Select an action...";s:7:"no_lang";s:1:"1";s:4:"name";s:12:"multi_action";s:4:"help";s:16:"Select an action";}i:6;a:8:{s:4:"type";s:6:"button";s:4:"size";s:9:"arrow_ltr";s:5:"label";s:9:"Check all";s:4:"name";s:9:"check_all";s:4:"help";s:9:"Check all";s:7:"onclick";s:70:"toggle_all(this.form,form::name(\'nm[rows][checked][]\')); return false;";s:6:"needed";s:1:"1";s:4:"span";s:14:",checkAllArrow";}}}}s:4:"rows";i:6;s:4:"cols";i:2;s:4:"size";s:12:"100%,,0,,0,0";}}','size' => '100%,,0,,0,0','style' => '/** * Add / remove link or category popup used for actions on multiple entries */