/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_delete($handler_id, array $args, array &$data) { midcom::get('auth')->require_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface'); $this->_group = new midcom_db_group($args[0]); if (array_key_exists('org_openpsa_user_deleteok', $_POST)) { $delete_succeeded = $this->_group->delete(); $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); if ($delete_succeeded) { // Update the index $indexer = midcom::get('indexer'); $indexer->delete($this->_group->guid); return new midcom_response_relocate(''); } else { // Failure, give a message midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.user'), $this->_l10n->get("failed to delete group, reason") . ' ' . midcom_connection::get_error_string(), 'error'); return new midcom_response_relocate($prefix . 'group/' . $this->_group->guid . '/'); } } $data['view'] = midcom_helper_datamanager2_handler::get_view_controller($this, $this->_group); $data['group'] = $this->_group; org_openpsa_widgets_tree::add_head_elements(); $this->add_breadcrumb('groups/', $this->_l10n->get('groups')); $this->add_breadcrumb('', sprintf($this->_l10n_midcom->get('delete %s'), $this->_group->get_label())); $this->bind_view_to_object($this->_group); }
/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_view($handler_id, array $args, array &$data) { midcom::get('auth')->require_user_do('org.openpsa.user:access', null, 'org_openpsa_user_interface'); $this->_group = new midcom_db_group($args[0]); $data['group'] = $this->_group; $data['view'] = midcom_helper_datamanager2_handler::get_view_controller($this, $this->_group); org_openpsa_widgets_tree::add_head_elements(); org_openpsa_widgets_grid::add_head_elements(); $this->add_breadcrumb('groups/', $this->_l10n->get('groups')); $this->add_breadcrumb('', $this->_group->get_label()); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "group/edit/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get("edit"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:update'), MIDCOM_TOOLBAR_ACCESSKEY => 'e')); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "group/delete/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get("delete"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:delete'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "group/privileges/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("permissions"), MIDCOM_TOOLBAR_ICON => 'midgard.admin.asgard/permissions-16.png', MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:privileges'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "group/notifications/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("notification settings"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock-discussion.png', MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:update'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "create/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create person'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_person-new.png', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard:create', null, 'org_openpsa_contacts_person_dba'))); $this->bind_view_to_object($this->_group); }
/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_view($handler_id, array $args, array &$data) { midcom::get('auth')->require_valid_user(); $this->_person = new org_openpsa_contacts_person_dba($args[0]); $data['view'] = midcom_helper_datamanager2_handler::get_view_controller($this, $this->_person); $this->add_breadcrumb('', $this->_person->get_label()); $auth = midcom::get('auth'); if ($this->_person->id == midcom_connection::get_user() || $auth->can_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface')) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "edit/{$this->_person->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get("edit"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $this->_person->can_do('midgard:update'), MIDCOM_TOOLBAR_ACCESSKEY => 'e')); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "delete/{$this->_person->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get("delete"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $this->_person->can_do('midgard:delete'))); if (midcom_connection::is_user($this->_person)) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "privileges/{$this->_person->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("permissions"), MIDCOM_TOOLBAR_ICON => 'midgard.admin.asgard/permissions-16.png', MIDCOM_TOOLBAR_ENABLED => $this->_person->can_do('midgard:privileges'))); } $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "person/notifications/{$this->_person->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("notification settings"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock-discussion.png', MIDCOM_TOOLBAR_ENABLED => $this->_person->can_do('midgard:update'))); } $this->bind_view_to_object($this->_person); }
/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_delete($handler_id, array $args, array &$data) { $this->_person = new midcom_db_person($args[0]); if ($this->_person->id != midcom_connection::get_user()) { midcom::get('auth')->require_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface'); } if (array_key_exists('org_openpsa_user_deleteok', $_POST)) { $delete_succeeded = $this->_person->delete(); if ($delete_succeeded) { // Update the index $indexer = midcom::get('indexer'); $indexer->delete($this->_person->guid); return new midcom_response_relocate(''); } else { // Failure, give a message midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.user'), $this->_l10n->get("failed to delete person, reason") . ' ' . midcom_connection::get_error_string(), 'error'); return new midcom_response_relocate('view/' . $this->_person->guid . '/'); } } $data['view'] = midcom_helper_datamanager2_handler::get_view_controller($this, $this->_person); $data['person'] = $this->_person; $this->add_breadcrumb('', sprintf($this->_l10n_midcom->get('delete %s'), $this->_person->get_label())); $this->bind_view_to_object($this->_person); }
/** * Handler method for listing group members * * @param string $handler_id Name of the used handler * @param mixed $args Array containing the variable arguments passed to the handler * @param mixed &$data Data passed to the show method */ public function _handler_view($handler_id, array $args, array &$data) { midcom::get('auth')->require_valid_user(); // Get the requested group object $this->_group = new org_openpsa_contacts_group_dba($args[0]); $data['group'] = $this->_group; if ($this->_group->orgOpenpsaObtype < org_openpsa_contacts_group_dba::MYCONTACTS) { $this->_type = 'group'; $data['group_tree'] = $this->_master->get_group_tree(); $data['members_grid'] = new org_openpsa_widgets_grid('members_grid', 'json'); org_openpsa_widgets_tree::add_head_elements(); } else { $this->_type = 'organization'; $root_group = org_openpsa_contacts_interface::find_root_group(); if ($this->_group->owner != $root_group->id) { $data['parent_group'] = $this->_group->get_parent(); } else { $data['parent_group'] = false; } //pass billing-data if invoices is installed if (midcom::get('componentloader')->is_installed('org.openpsa.invoices')) { $qb_billing_data = org_openpsa_invoices_billing_data_dba::new_query_builder(); $qb_billing_data->add_constraint('linkGuid', '=', $this->_group->guid); $billing_data = $qb_billing_data->execute(); if (count($billing_data) > 0) { $this->_request_data['billing_data'] = $billing_data[0]; } } // This handler uses Ajax, include the handler javascripts midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . "/org.openpsa.helpers/ajaxutils.js"); org_openpsa_widgets_ui::enable_ui_tab(); } $data['view'] = midcom_helper_datamanager2_handler::get_view($this, $this->_group); // Add toolbar items $this->_populate_toolbar(); $this->bind_view_to_object($this->_group); midcom::get('head')->set_pagetitle($this->_group->official); org_openpsa_contacts_viewer::add_breadcrumb_path_for_group($this->_group, $this); }
/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_delete($handler_id, array $args, array &$data) { $this->_billing_data = new org_openpsa_invoices_billing_data_dba($args[0]); $this->_billing_data->require_do('midgard:delete'); $this->_linked_object = midcom::get('dbfactory')->get_object_by_guid($this->_billing_data->linkGuid); $this->_controller = midcom_helper_datamanager2_handler::get_delete_controller(); $this->_process_billing_form(); $data['datamanager'] = midcom_helper_datamanager2_handler::get_view_controller($this, $this->_billing_data); $this->_prepare_output('delete'); }
/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_delete($handler_id, array $args, array &$data) { midcom::get('auth')->require_valid_user(); $this->_document = $this->_load_document($args[0]); $this->_document->require_do('midgard:delete'); $data['controller'] = midcom_helper_datamanager2_handler::get_delete_controller(); switch ($data['controller']->process_form()) { case 'delete': if ($this->_document->delete()) { // Update the index $indexer = midcom::get('indexer'); $indexer->delete($this->_document->guid); // Redirect to the directory return new midcom_response_relocate(''); } else { // Failure, give a message midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.documents'), $this->_l10n->get("failed to delete document, reason ") . midcom_connection::get_error_string(), 'error'); } //Fall-through //Fall-through case 'cancel': return new midcom_response_relocate("document/" . $this->_document->guid . "/"); } $data['document_dm'] = $this->_datamanager; $data['document'] = $this->_document; org_openpsa_helpers::dm2_savecancel($this, 'delete'); $this->_update_breadcrumb_line('delete'); }
/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_delete($handler_id, array $args, array &$data) { // Check if we get the person $this->_person = new midcom_db_person($args[0]); $this->_person->require_do('midgard:update'); if ($this->_person->id != midcom_connection::get_user()) { midcom::get('auth')->require_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface'); } $this->_account = new midcom_core_account($this->_person); if (!$this->_account->get_username()) { // Account needs to be created first, relocate return new midcom_response_relocate("view/" . $this->_person->guid . "/"); } $data['controller'] = midcom_helper_datamanager2_handler::get_delete_controller(); switch ($data['controller']->process_form()) { case 'delete': if (!$this->_account->delete()) { throw new midcom_error("Failed to delete account for {$this->_person->guid}, last Midgard error was: " . midcom_connection::get_error_string()); } //Fall-through //Fall-through case 'cancel': return new midcom_response_relocate('view/' . $this->_person->guid . "/"); } $this->add_stylesheet(MIDCOM_STATIC_URL . "/midcom.helper.datamanager2/legacy.css"); midcom::get('head')->enable_jquery(); midcom::get('head')->set_pagetitle("{$this->_person->firstname} {$this->_person->lastname}"); $this->_prepare_request_data(); $this->_update_breadcrumb_line('delete account'); // Add toolbar items org_openpsa_helpers::dm2_savecancel($this, 'delete'); }
/** * Displays an object delete confirmation view. * * Note, that the object for non-index mode operation is automatically determined in the can_handle * phase. * * If create privileges apply, we relocate to the index creation object * * @param mixed $handler_id The ID of the handler. * @param array $args The argument list. * @param array &$data The local request data. */ public function _handler_delete($handler_id, array $args, array &$data) { $this->_mode = 'delete'; $this->_load_object($handler_id, $args, $data); $this->_object->require_do('midgard:delete'); $this->_load_schemadb(); $this->_load_datamanager(); $this->_controller = midcom_helper_datamanager2_handler::get_delete_controller(); switch ($this->_controller->process_form()) { case 'delete': // Deletion confirmed, try doing it. if (!$this->_object->delete()) { throw new midcom_error("Failed to delete object {$this->_object->guid}, last Midgard error was: " . midcom_connection::get_error_string()); } // Update the index $indexer = midcom::get('indexer'); $indexer->delete($this->_object->guid); // Show user interface message // midcom::get('uimessages')->add($this->_l10n->get('net.nehmer.blog'), sprintf($this->_l10n->get('object %s deleted'), $title)); // Delete ok, relocating to welcome. return new midcom_response_relocate(''); case 'cancel': return new midcom_response_relocate($this->_get_object_url()); } $this->_prepare_request_data(); // Call the per-component metadata methods $this->_populate_toolbar($handler_id); $this->_update_title($handler_id); $this->_update_breadcrumb($handler_id); // Let MidCOM know about the object midcom::get('metadata')->set_request_metadata($this->_object->metadata->revised, $this->_object->guid); $this->bind_view_to_object($this->_object, $this->_datamanager->schema->name); $this->_handler_callback($handler_id, $args, $data); }