diff --git a/addressbook/inc/class.addressbook_favorite_portlet.inc.php b/addressbook/inc/class.addressbook_favorite_portlet.inc.php new file mode 100644 index 0000000000..09d7d7c392 --- /dev/null +++ b/addressbook/inc/class.addressbook_favorite_portlet.inc.php @@ -0,0 +1,107 @@ +context['template'] = 'addressbook.index.rows'; + $this->context['sel_options'] = array(); + foreach($ui->content_types as $tid => $data) + { + $this->context['sel_options']['tid'][$tid] = $data['name']; + } + error_log(array2string($this->nm_settings['col_filter'])); + $this->nm_settings += array( + 'get_rows' => 'addressbook.addressbook_ui.get_rows', + // Use a different template so it can be accessed from client side + 'template' => 'addressbook.index.rows', + 'default_cols' => 'type,n_fileas_n_given_n_family_n_family_n_given_org_name_n_family_n_given_n_fileas,'. + 'business_adr_one_countrycode_adr_one_postalcode,tel_work_tel_cell_tel_home,url_email_email_home', + ); + } + + public function exec($id = null, etemplate_new &$etemplate = null) + { + $ui = new addressbook_ui(); + $this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(EGW_ACL_READ,lang('All')); + $this->context['sel_options']['filter2'] = $ui->get_lists(EGW_ACL_READ,array('' => lang('none'))); + $this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']); + + parent::exec($id, $etemplate); + } + /** + * Here we need to handle any incoming data. Setup is done in the constructor, + * output is handled by parent. + * + * @param type $id + * @param etemplate_new $etemplate + */ + public static function process($values = array()) + { + parent::process($values); + $ui = new addressbook_ui(); + if (is_array($values) && !empty($values['nm']['action'])) + { + if (!count($values['nm']['selected']) && !$values['nm']['select_all']) + { + egw_framework::message(lang('You need to select some entries first')); + } + else + { + // Some processing to add values in for links and cats + $multi_action = $values['nm']['action']; + $success = $failed = $action_msg = null; + if ($ui->action($values['nm']['action'],$values['nm']['selected'],$values['nm']['select_all'], + $success,$failed,$action_msg,$values['do_email'] ? 'email' : 'index',$msg,$values['nm']['checkboxes'])) + { + $msg .= lang('%1 contact(s) %2',$success,$action_msg); + egw_json_response::get()->apply('egw.message',array($msg,'success')); + foreach($values['nm']['selected'] as &$id) + { + $id = 'addressbook::'.$id; + } + // Directly request an update - this will get addressbook tab too + egw_json_response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected'])); + } + elseif(is_null($msg)) + { + $msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); + egw_json_response::get()->apply('egw.message',array($msg,'error')); + } + elseif($msg) + { + $msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed); + egw_json_response::get()->apply('egw.message',array($msg,'error')); + } + unset($values['nm']['action']); + unset($values['nm']['select_all']); + } + } + } + } \ No newline at end of file diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 708e96ad1f..5ac1394327 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -349,7 +349,7 @@ class addressbook_ui extends addressbook_bo * @param string $org_view=null * @return array see nextmatch_widget::get_actions() */ - private function get_actions($tid_filter=null, $org_view=null) + public function get_actions($tid_filter=null, $org_view=null) { // we have no org view (view of one org has context menu like regular "add contacts" view, as it shows contacts if (!isset($this->org_views[(string) $org_view])) diff --git a/addressbook/templates/default/index.rows.xet b/addressbook/templates/default/index.rows.xet new file mode 100644 index 0000000000..7ee22b05a8 --- /dev/null +++ b/addressbook/templates/default/index.rows.xet @@ -0,0 +1,175 @@ + + + + + diff --git a/home/inc/class.home_favorite_portlet.inc.php b/home/inc/class.home_favorite_portlet.inc.php index e28baf8dd8..5a5e39d8e5 100644 --- a/home/inc/class.home_favorite_portlet.inc.php +++ b/home/inc/class.home_favorite_portlet.inc.php @@ -13,7 +13,7 @@ /** - * The home_favorite_portlet extends the list portlet to display the entries for a particular + * The home_favorite_portlet uses a nextmatch to display the entries for a particular * favorite, for a given app. */ class home_favorite_portlet extends home_portlet @@ -35,6 +35,8 @@ class home_favorite_portlet extends home_portlet protected $nm_settings = array( 'lettersearch' => false, 'favorites' => false, // Hide favorite control + 'actions' => array(), + 'placeholder_actions' => array() ); /** @@ -45,6 +47,9 @@ class home_favorite_portlet extends home_portlet * The implementing class is allowed to modify the context, if needed, but it is * better to use get_properties(). * + * We try to keep the constructor light as it gets called often, and only load + * things needed for display in exec. + * * @param context Array portlet settings such as size, as well as values for properties * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called) */ @@ -104,6 +109,8 @@ class home_favorite_portlet extends home_portlet unset($content['sel_options']); $etemplate->setElementAttribute('nm', 'template',$this->nm_settings['template']); + // Always load app's javascript, so most actions have a chance of working + egw_framework::validate_file('','app',$this->context['appname']); $etemplate->exec(get_called_class() .'::process',$content,$sel_options); } diff --git a/home/js/app.js b/home/js/app.js index cec88d7c7c..704eed9695 100644 --- a/home/js/app.js +++ b/home/js/app.js @@ -233,9 +233,9 @@ app.classes.home = AppJS.extend( } var portlet = et2_createWidget('portlet',attrs, this.portlet_container); + portlet.loadingFinished(); // Immediately add content ID so etemplate loads into the right place portlet.content.append('
'); - portlet.loadingFinished(); // Get actual attributes & settings, since they're not available client side yet var drop_data = [];