Exemple #1
0
 /**
  * @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_edit($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     // Check if we get the group
     $this->_group = new org_openpsa_contacts_group_dba($args[0]);
     $this->_group->require_do('midgard:update');
     if ($this->_group->orgOpenpsaObtype < org_openpsa_contacts_group_dba::MYCONTACTS) {
         $this->_type = 'group';
     } else {
         $this->_type = 'organization';
     }
     $data['controller'] = $this->get_controller('simple', $this->_group);
     switch ($data['controller']->process_form()) {
         case 'save':
             $indexer = new org_openpsa_contacts_midcom_indexer($this->_topic);
             $indexer->index($data['controller']->datamanager);
             // *** FALL-THROUGH ***
         // *** FALL-THROUGH ***
         case 'cancel':
             $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
             return new midcom_response_relocate($prefix . "group/" . $this->_group->guid . "/");
     }
     $root_group = org_openpsa_contacts_interface::find_root_group();
     if ($this->_group->owner && $this->_group->owner != $root_group->id) {
         $data['parent_group'] = new org_openpsa_contacts_group_dba($this->_group->owner);
     } else {
         $data['parent_group'] = false;
     }
     $data['group'] =& $this->_group;
     org_openpsa_helpers::dm2_savecancel($this);
     $this->bind_view_to_object($this->_group);
     midcom::get('head')->set_pagetitle(sprintf($this->_l10n_midcom->get('edit %s'), $this->_group->official));
     org_openpsa_contacts_viewer::add_breadcrumb_path_for_group($this->_group, $this);
     $this->add_breadcrumb("", sprintf($this->_l10n_midcom->get('edit %s'), $this->_l10n->get($this->_type)));
 }
Exemple #2
0
 /**
  * This is what Datamanager calls to actually create a group
  */
 public function &dm2_create_callback(&$datamanager)
 {
     $this->_group = new org_openpsa_contacts_group_dba();
     if ($this->_type == 'organization' && $this->_parent_group) {
         $this->_group->owner = (int) $this->_parent_group->id;
     } else {
         $root_group = org_openpsa_contacts_interface::find_root_group();
         $this->_group->owner = (int) $root_group->id;
     }
     $this->_group->name = time();
     if (!$this->_group->create()) {
         debug_print_r('We operated on this object:', $this->_group);
         throw new midcom_error("Failed to create a new group. Error: " . midcom_connection::get_error_string());
     }
     return $this->_group;
 }
Exemple #3
0
 public function _on_creating()
 {
     $this->orgOpenpsaObtype = self::MYCONTACTS;
     if (!$this->owner) {
         $root_group = org_openpsa_contacts_interface::find_root_group('__org_openpsa_contacts_list');
         $this->owner = $root_group->id;
     }
     if (!$this->name) {
         $this->name = 'mycontacts_' . $this->person;
     }
     if (!$this->official) {
         $person = new org_openpsa_contacts_person_dba($this->person);
         $l10n = midcom::get('i18n')->get_l10n('org.openpsa.contacts');
         $this->official = sprintf($l10n->get('contacts of %s'), $person->name);
     }
     return true;
 }
Exemple #4
0
 public static function add_breadcrumb_path_for_group($group, &$handler)
 {
     if (!is_object($group)) {
         return;
     }
     $tmp = array();
     $root_group = org_openpsa_contacts_interface::find_root_group();
     $root_id = $root_group->id;
     $tmp[$group->guid] = $group->official;
     $parent = $group->get_parent();
     while ($parent && $parent->id != $root_id) {
         $group = $parent;
         $tmp[$group->guid] = $group->official;
         $parent = $group->get_parent();
     }
     $tmp = array_reverse($tmp, true);
     foreach ($tmp as $guid => $title) {
         $handler->add_breadcrumb('group/' . $guid . '/', $title);
     }
 }
Exemple #5
0
 /**
  * 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);
 }
Exemple #6
0
 /**
  * Renderer for organization address cards
  */
 public static function show_address_card(&$customer, $cards)
 {
     $cards_to_show = array();
     $multiple_addresses = false;
     $inherited_cards_only = true;
     $default_shown = false;
     $siteconfig = org_openpsa_core_siteconfig::get_instance();
     $contacts_url = $siteconfig->get_node_full_url('org.openpsa.contacts');
     foreach ($cards as $cardname) {
         if ($cardname == 'visiting') {
             if ($customer->street) {
                 $default_shown = true;
                 $cards_to_show[] = $cardname;
             }
             continue;
         }
         $property = $cardname . 'Street';
         if (sizeof($cards_to_show) == 0) {
             if ($property != 'street' && $customer->{$property}) {
                 $inherited_cards_only = false;
                 $cards_to_show[] = $cardname;
             } else {
                 if (!$default_shown && $customer->street) {
                     $default_shown = true;
                     $cards_to_show[] = $cardname;
                 }
             }
         } else {
             if ($customer->{$property} || $customer->street && (!$inherited_cards_only && !$default_shown)) {
                 $inherited_cards_only = false;
                 $multiple_addresses = true;
                 $cards_to_show[] = $cardname;
             }
         }
     }
     if (sizeof($cards_to_show) == 0) {
         return;
     }
     $root_group = org_openpsa_contacts_interface::find_root_group();
     $parent = $customer->get_parent();
     $parent_name = false;
     if ($parent->id != $root_group->id) {
         $parent_name = $parent->get_label();
     }
     foreach ($cards_to_show as $cardname) {
         echo '<div class="vcard">';
         if ($multiple_addresses || $cardname != 'visiting' && !$inherited_cards_only) {
             echo '<div style="text-align:center"><em>' . midcom::get('i18n')->get_string($cardname . ' address', 'org.openpsa.contacts') . "</em></div>\n";
         }
         echo "<strong>\n";
         if ($parent_name) {
             echo '<a href="' . $contacts_url . 'group/' . $parent->guid . '/">' . $parent_name . "</a><br />\n";
         }
         $label = $customer->get_label();
         if ($cardname != 'visiting') {
             $label_property = $cardname . '_label';
             $label = $customer->{$label_property};
         }
         echo $label . "\n";
         echo "</strong>\n";
         $property_street = 'street';
         $property_postcode = 'postcode';
         $property_city = 'city';
         if ($cardname != 'visiting') {
             $property_street = $cardname . 'Street';
             $property_postcode = $cardname . 'Postcode';
             $property_city = $cardname . 'City';
         }
         if ($customer->{$property_street}) {
             echo "<p>{$customer->{$property_street}}<br />\n";
             echo "{$customer->{$property_postcode}} {$customer->{$property_city}}</p>\n";
         } else {
             if ($customer->street) {
                 echo "<p>{$customer->street}<br />\n";
                 echo "{$customer->postcode} {$customer->city}</p>\n";
             }
         }
         echo "</div>\n";
     }
 }
Exemple #7
0
 private function _check_person_url(org_openpsa_contacts_person_dba $person)
 {
     $data = org_openpsa_contacts_interface::_get_data_from_url($person->homepage);
     // Use the data we got
     if (array_key_exists('georss_url', $data)) {
         // GeoRSS subscription is a good way to keep track of person's location
         $person->parameter('org.routamc.positioning:georss', 'georss_url', $data['georss_url']);
     } else {
         if (array_key_exists('icbm', $data)) {
             // Instead of using the ICBM position data directly we can subscribe to it so we get modifications too
             $person->parameter('org.routamc.positioning:html', 'icbm_url', $person->homepage);
         }
     }
     if (array_key_exists('rss_url', $data)) {
         // Instead of using the ICBM position data directly we can subscribe to it so we get modifications too
         $person->parameter('net.nemein.rss', 'url', $data['rss_url']);
     }
     if (array_key_exists('hcards', $data)) {
         // Process those hCard values that are interesting for us
         foreach ($data['hcards'] as $hcard) {
             foreach ($hcard as $key => $val) {
                 $person = $this->_update_from_hcard($person, $hcard);
             }
         }
         $person->update();
     }
     return true;
 }
Exemple #8
0
 private function _populate_toolbar()
 {
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'person/create/', 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->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'group/create/organization/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create organization'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_people-new.png', MIDCOM_TOOLBAR_ENABLED => org_openpsa_contacts_interface::find_root_group()->can_do('midgard:create')));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'group/create/group/', MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get('group')), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_people-new.png', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard:create', null, 'org_openpsa_contacts_group_dba')));
 }