Beispiel #1
0
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_list($handler_id, array &$data)
 {
     if ($handler_id == 'mycontacts_xml') {
         $schemadb_person = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_person'));
         $datamanager = new midcom_helper_datamanager2_datamanager($schemadb_person);
         $xml = '<contacts></contacts>';
         $simplexml = simplexml_load_string($xml);
         foreach ($data['mycontacts'] as $person) {
             $contact = $simplexml->addChild('contact');
             $contact->addAttribute('guid', $person->guid);
             $datamanager->autoset_storage($person);
             $person_data = $datamanager->get_content_xml();
             foreach ($person_data as $key => $value) {
                 $contact->addChild($key, $value);
             }
             $mc = midcom_db_member::new_collector('uid', $person->id);
             $memberships = $mc->get_values('gid');
             $qb = org_openpsa_contacts_group_dba::new_query_builder();
             $qb->add_constraint('gid', 'IN', $memberships);
             $qb->add_constraint('orgOpenpsaObtype', '>', org_openpsa_contacts_list_dba::MYCONTACTS);
             $organisations = $qb->execute();
             foreach ($organisations as $organisation) {
                 $contact->addChild('company', str_replace('&', '&amp;', ${$organisation}->get_label()));
             }
         }
         echo $simplexml->asXml();
     } else {
         midcom_show_style("show-mycontacts-header");
         foreach ($data['mycontacts'] as $person) {
             $data['person'] = $person;
             midcom_show_style("show-mycontacts-item");
         }
         midcom_show_style("show-mycontacts-footer");
     }
 }
Beispiel #2
0
 public function list_members()
 {
     $mc = midcom_db_member::new_collector('gid', $this->id);
     $mc->add_order('uid.lastname');
     $mc->add_order('uid.firstname');
     return $mc->get_values('uid');
 }
Beispiel #3
0
 function _send_notifications($method = 'updated')
 {
     $message = $this->_construct_message($method);
     $subscriptions = array();
     $tmp_subscriptions = $this->list_parameters('fi.kilonkipinat.todos:subscribe');
     if (!empty($subscriptions)) {
         //Go through each subscription
         foreach ($tmp_subscriptions as $user_guid => $subscription_time) {
             $subscriptions[$user_guid] = true;
         }
     }
     if ($this->person != 0 && $this->person != '') {
         $person = new fi_kilonkipinat_account_person_dba($this->person);
         if ($this->person == $person->id) {
             $subscriptions[$person->guid] = true;
         }
     }
     if ($this->supervisor != 0 && $this->supervisor != '') {
         $person = new fi_kilonkipinat_account_person_dba($this->supervisor);
         if ($this->supervisor == $person->id) {
             $subscriptions[$person->guid] = true;
         }
     }
     if ($this->grp != 0 && $this->grp != '') {
         $grp = new midcom_db_group($this->grp);
         if ($this->grp == $grp->id) {
             $mc = midcom_db_member::new_collector('sitegroup', $_MIDGARD['sitegroup']);
             $mc->add_constraint('gid', '=', $this->grp);
             $mc->add_value_property('uid');
             $mc->execute();
             $tmp_keys = $mc->list_keys();
             foreach ($tmp_keys as $guid => $tmp_key) {
                 $person = new fi_kilonkipinat_account_person_dba($mc->get_subkey($guid, 'uid'));
                 if ($person->id != '' && $person->id != 0 && $person->guid != '') {
                     $subscriptions[$person->guid] = true;
                 }
             }
         }
     }
     if (isset($subscriptions[$_MIDCOM->auth->user->guid])) {
         $subscriptions[$_MIDCOM->auth->user->guid] = false;
     }
     if (count($subscriptions) > 0) {
         foreach ($subscriptions as $user_guid => $status) {
             if ($status) {
                 // Send notice
                 org_openpsa_notifications::notify('fi.kilonkipinat.todos:subscribe', $user_guid, $message);
             }
         }
     }
 }
Beispiel #4
0
 /**
  * Function for listing groups tasks contacts are members of
  *
  * @param org_openpsa_projects_task_dba &$task The task we're working with
  * @param string $mode By which property should groups be listed
  */
 static function task_groups(&$task, $mode = 'id')
 {
     //TODO: Localize something for the empty choice ?
     $ret = array(0 => '');
     $seen = array();
     if (!midcom::get('componentloader')->load_graceful('org.openpsa.contacts')) {
         //PONDER: Maybe we should raise a fatal error ??
         return $ret;
     }
     //Make sure the currently selected customer (if any) is listed
     if ($task->customer && !isset($ret[$task->customer])) {
         //Make sure we can read the current customer for the name
         midcom::get('auth')->request_sudo();
         $company = new org_openpsa_contacts_group_dba($task->customer);
         midcom::get('auth')->drop_sudo();
         $seen[$company->id] = true;
         self::task_groups_put($ret, $mode, $company);
     }
     $task->get_members();
     if (!is_array($task->contacts) || count($task->contacts) == 0) {
         return $ret;
     }
     $mc = midcom_db_member::new_collector('metadata.deleted', false);
     $mc->add_constraint('uid', 'IN', array_keys($task->contacts));
     /* Skip magic groups */
     $mc->add_constraint('gid.name', 'NOT LIKE', '\\_\\_%');
     $memberships = $mc->get_values('gid');
     if (empty($memberships)) {
         return $ret;
     }
     foreach ($memberships as $gid) {
         if (isset($seen[$gid]) && $seen[$gid] == true) {
             continue;
         }
         try {
             $company = new org_openpsa_contacts_group_dba($gid);
         } catch (midcom_error $e) {
             continue;
         }
         $seen[$company->id] = true;
         self::task_groups_put($ret, $mode, $company);
     }
     reset($ret);
     asort($ret);
     return $ret;
 }
Beispiel #5
0
 /**
  * The handler for the index article.
  *
  * @param mixed $handler_id the array key from the request array
  * @param array $args the arguments given to the handler
  * @param Array &$data The local request data.
  * @return boolean Indicating success.
  */
 function _handler_index($handler_id, $args, &$data)
 {
     $this->_request_data['name'] = "fi.kilonkipinat.account";
     $this->_update_breadcrumb_line($handler_id);
     $title = $this->_l10n_midcom->get('index');
     $_MIDCOM->set_pagetitle(":: {$title}");
     $root_group_guid = $this->_config->get('root_group_to_show');
     $persons = array();
     if (isset($root_group_guid) && $root_group_guid != null && $root_group_guid != '') {
         $root_group = new midcom_db_group($root_group_guid);
         if ($root_group && $root_group->guid == $root_group_guid) {
             $mc_members = midcom_db_member::new_collector('gid', $root_group->id);
             $mc_members->add_value_property('uid');
             $mc_members->execute();
             $member_guids = $mc_members->list_keys();
             $member_ids = array();
             foreach ($member_guids as $guid => $array) {
                 $member_ids[] = $mc_members->get_subkey($guid, 'uid');
             }
             $qb_persons = fi_kilonkipinat_account_person_dba::new_query_builder();
             $qb_persons->add_constraint('id', 'IN', $member_ids);
             $qb_persons->add_order('lastname', 'ASC');
             $qb_persons->add_order('nickname', 'ASC');
             $qb_persons->add_order('firstname', 'ASC');
             $persons = $qb_persons->execute();
         }
     }
     $this->_request_data['requests'] = '';
     if ($_MIDCOM->auth->admin) {
         $regs_topic = midcom_helper_find_node_by_component('fi.kilonkipinat.accountregistration');
         $regs_prefix = '';
         if ($regs_topic) {
             $regs_prefix = $regs_topic['18'];
         }
         $mc = fi_kilonkipinat_accountregistration_accountrequest_dba::new_collector('status', FI_KILONKIPINAT_ACCOUNTREGISTRATION_ACCOUNT_STATUS_EMAILVALIDATED);
         //            $mc->add_constraint('status', '=', fi_kilonkipinat_accountregistration_interface::FI_KILONKIPINAT_ACCOUNTREGISTRATION_ACCOUNT_STATUS_EMAILVALIDATED);
         $requests_count = $mc->count();
         if ($requests_count > 0 && $regs_prefix != '') {
             $this->_request_data['requests'] = '<a href="' . $regs_prefix . 'list_pending/">' . $requests_count . ' tunnushakemusta</a>';
         }
     }
     $this->_request_data['persons'] = $persons;
     return true;
 }
Beispiel #6
0
 private function _get_members_array()
 {
     if ($this->_members_loaded) {
         return $this->members;
     }
     $members = array();
     $mc = midcom_db_member::new_collector('gid', $this->id);
     $uids = $mc->get_values('uid');
     foreach ($uids as $uid) {
         $members[$uid] = true;
     }
     $this->_members_loaded = true;
     return $members;
 }
Beispiel #7
0
 private function _populate_calendar_from_filter($user, $from, $to)
 {
     // New UI for showing resources
     foreach ($user->list_parameters('org.openpsa.calendar.filters') as $type => $value) {
         $selected = @unserialize($value);
         // Skip empty
         if (!$selected || empty($selected)) {
             continue;
         }
         // Include each type
         switch ($type) {
             case 'people':
                 foreach ($selected as $guid) {
                     $person = new midcom_db_person($guid);
                     if (isset($this->_shown_persons[$person->id]) && $this->_shown_persons[$person->id] === true) {
                         continue;
                     }
                     $this->_calendar->_resources[$person->guid] = $this->_populate_calendar_resource($person, $from, $to);
                     $this->_shown_persons[$person->id] = true;
                 }
                 break;
             case 'groups':
                 foreach ($selected as $guid) {
                     // Get the group
                     try {
                         $group = new midcom_db_group($guid);
                     } catch (midcom_error $e) {
                         $e->log();
                         continue;
                     }
                     // Get the members
                     $mc = midcom_db_member::new_collector('gid', $group->id);
                     $mc->add_order('metadata.score', 'DESC');
                     $user_ids = $mc->get_values('uid');
                     foreach ($user_ids as $user_id) {
                         if (isset($this->_shown_persons[$user_id]) && $this->_shown_persons[$user_id] === true) {
                             continue;
                         }
                         $person = new midcom_db_person($user_id);
                         $this->_calendar->_resources[$person->guid] = $this->_populate_calendar_resource($person, $from, $to);
                         $this->_shown_persons[$person->id] = true;
                     }
                 }
                 break;
         }
     }
 }
Beispiel #8
0
 function _on_execute()
 {
     debug_push_class(__CLASS__, __FUNCTION__);
     if (!$_MIDCOM->auth->request_sudo('fi.kilonkipinat.emailmappings')) {
         $msg = "Could not get sudo, aborting operation, see error log for details";
         $this->print_error($msg);
         debug_add($msg, MIDCOM_LOG_ERROR);
         debug_pop();
         return;
     }
     $email_group_guid = $this->_config->get('group_for_emails');
     if ($email_group_guid == null) {
         // Email group not set in global config, we try to search for topic
         //            $nap_topic = midcom_helper_find_node_by_component('fi.kilonkipinat.emailmappings');
         //            $topic = new midcom_db_topic($nap_topic[MIDCOM_NAV_GUID]);
         $qb = midcom_db_topic::new_query_builder();
         $qb->add_constraint('component', '=', 'fi.kilonkipinat.emailmappings');
         $qb->add_constraint('name', '<>', '');
         $qb->set_limit(1);
         $topics = $qb->execute();
         $topic = False;
         if (count($topics) > 0) {
             $topic = $topics[0];
         }
         if ($topic && $topic->guid && $topic->guid != '') {
             $real_config = new midcom_helper_configuration($topic, 'fi.kilonkipinat.emailmappings');
             $email_group_guid = $real_config->get('group_for_emails');
         } else {
             $msg = "Could not find topic for config, aborting operation, see error log for details";
             $this->print_error($msg);
             debug_add($msg, MIDCOM_LOG_ERROR);
             debug_pop();
             return;
         }
     }
     $emails = array();
     $usernames = array();
     $file_content = '';
     if ($email_group_guid != null) {
         $email_group = new midcom_db_group($email_group_guid);
         if ($email_group && $email_group->guid && $email_group->guid != '' && $email_group->guid == $email_group_guid) {
             $mc_members = midcom_db_member::new_collector('gid', $email_group->id);
             $mc_members->add_value_property('uid');
             $mc_members->execute();
             $member_keys = $mc_members->list_keys();
             $person_ids = array();
             foreach ($member_keys as $guid => $content) {
                 $person_id = $mc_members->get_subkey($guid, 'uid');
                 $person_ids[] = $person_id;
                 unset($person_id);
             }
             $mc_persons = fi_kilonkipinat_account_person_dba::new_collector('sitegroup', $_MIDGARD['sitegroup']);
             if (count($person_ids) > 0) {
                 $mc_persons->add_constraint('id', 'IN', $person_ids);
             }
             $mc_persons->add_constraint('username', '<>', '');
             $mc_persons->add_constraint('email', '<>', '');
             $mc_persons->add_constraint('email', 'LIKE', '%@%');
             $mc_persons->add_value_property('username');
             $mc_persons->add_value_property('email');
             $mc_persons->execute();
             $person_keys = $mc_persons->list_keys();
             foreach ($person_keys as $guid => $content) {
                 $person_username = $mc_persons->get_subkey($guid, 'username');
                 $person_email = $mc_persons->get_subkey($guid, 'email');
                 if (strstr($person_email, '@kilonkipinat.fi') || strstr($person_email, '@lists.kilonkipinat.fi')) {
                     debug_add('illegal content in email-address for person guid ' . $guid . ', continuing to next person', MIDCOM_LOG_ERROR);
                     continue;
                 }
                 if (isset($emails[$person_email]) || isset($usernames[$person_username])) {
                     continue;
                 }
                 $emails[$person_email] = $person_email;
                 $usernames[$person_username] = $person_username;
                 $file_content .= "\n" . $person_username . ': ' . $person_email;
             }
         } else {
             $msg = "Could not instantiate group for emailmapping, aborting operation, see error log for details";
             $this->print_error($msg);
             debug_add($msg, MIDCOM_LOG_ERROR);
             debug_pop();
             return;
         }
     } else {
         $msg = "Could not find group for emailmapping, aborting operation, see error log for details";
         $this->print_error($msg);
         debug_add($msg, MIDCOM_LOG_ERROR);
         debug_pop();
         return;
     }
     if ($file_content != '') {
         $file_content .= "\n\n";
         $filename = '/root/mailaliases/aliases_automatic';
         if (is_writable($filename)) {
             if (!file_put_contents($filename, $file_content)) {
                 $msg = "Tried to write aliases file, aborting operation, see error log for details";
                 $this->print_error($msg);
                 debug_add($msg, MIDCOM_LOG_ERROR);
                 debug_pop();
                 return;
             }
         } else {
             $msg = "Couldn't write to aliases file, aborting operation, see error log for details";
             $this->print_error($msg);
             debug_add($msg, MIDCOM_LOG_ERROR);
             debug_pop();
             return;
         }
     }
     $file2_content = '';
     $mc_mappings = fi_kilonkipinat_emailmappings_emailmapping_dba::new_collector('sitegroup', $_MIDGARD['sitegroup']);
     $mc_mappings->add_value_property('name');
     $mc_mappings->add_value_property('persons');
     if (count($usernames) != 0) {
         $mc_mappings->add_constraint('name', 'NOT IN', $usernames);
     }
     $mc_mappings->execute();
     $mapping_keys = $mc_mappings->list_keys();
     foreach ($mapping_keys as $guid => $content) {
         $key = $mc_mappings->get_subkey($guid, 'name');
         $person_guids = $mc_mappings->get_subkey($guid, 'persons');
         $tmp_guids = explode('|', $person_guids);
         $guids = array();
         foreach ($tmp_guids as $guid2) {
             $guids[] = trim(str_replace('|', '', $guid2));
         }
         $persons_mc = fi_kilonkipinat_account_person_dba::new_collector('sitegroup', $_MIDGARD['sitegroup']);
         $persons_mc->add_value_property('email');
         if (count($guids) > 0) {
             $persons_mc->add_constraint('guid', 'IN', $guids);
         }
         $persons_mc->add_constraint('email', '<>', '');
         $persons_mc->execute();
         $persons_tmp = $persons_mc->list_keys();
         $emails = '';
         foreach ($persons_tmp as $guid3 => $content2) {
             $email = $persons_mc->get_subkey($guid3, 'email');
             if ($emails != '') {
                 $emails .= ', ';
             }
             $emails .= $email;
         }
         if (strlen($emails) > 3 && strstr($emails, "@")) {
             $file2_content .= "\n" . $key . ': ' . $emails;
         }
     }
     if ($file2_content != '') {
         $file2_content .= "\n\n";
         $filename2 = '/root/mailaliases/aliases_mappings';
         if (is_writable($filename2)) {
             if (!file_put_contents($filename2, $file2_content)) {
                 $msg = "Tried to write aliases file 2, aborting operation, see error log for details";
                 $this->print_error($msg);
                 debug_add($msg, MIDCOM_LOG_ERROR);
                 debug_pop();
                 return;
             }
         } else {
             $msg = "Couldn't write to aliases file 2, aborting operation, see error log for details";
             $this->print_error($msg);
             debug_add($msg, MIDCOM_LOG_ERROR);
             debug_pop();
             return;
         }
     }
     $_MIDCOM->auth->drop_sudo();
     debug_pop();
 }
Beispiel #9
0
 private function _populate_schema_contacts_for_customer(&$customer)
 {
     $fields =& $this->_schemadb['default']->fields;
     // We know the customer company, present contact as a select widget
     $persons_array = array();
     $member_mc = midcom_db_member::new_collector('gid', $customer->id);
     $members = $member_mc->get_values('uid');
     foreach ($members as $member) {
         try {
             $person = org_openpsa_contacts_person_dba::get_cached($member);
             $persons_array[$person->id] = $person->rname;
         } catch (midcom_error $e) {
         }
     }
     asort($persons_array);
     $fields['customerContact']['widget'] = 'select';
     $fields['customerContact']['type_config']['options'] = $persons_array;
     // And display the organization too
     $organization_array = array();
     $organization_array[$customer->id] = $customer->official;
     $fields['customer']['widget'] = 'select';
     $fields['customer']['type_config']['options'] = $organization_array;
 }
Beispiel #10
0
 function isInMyGroups($grp_id)
 {
     $mc = midcom_db_member::new_collector('uid', $_MIDGARD['user']);
     $mc->add_constraint('gid', '=', $grp_id);
     if ($mc->count() > 0) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #11
0
 /**
  * Get querybuilder for JSON user list
  */
 public function get_qb($field = null, $direction = 'ASC')
 {
     $qb = midcom_db_person::new_collector('metadata.deleted', false);
     //@todo constraint username <> '' ?
     if ($this->_group) {
         $mc = midcom_db_member::new_collector('gid', $this->_group->id);
         $members = $mc->get_values('uid');
         if (empty($members)) {
             $qb->add_constraint('id', '=', 0);
         } else {
             $qb->add_constraint('id', 'IN', $members);
         }
     }
     if (!is_null($field)) {
         if ($field == 'username') {
             midcom_core_account::add_username_order($qb, $direction);
         } else {
             $qb->add_order($field, $direction);
         }
     }
     $qb->add_order('lastname');
     $qb->add_order('firstname');
     $qb->add_order('id');
     return $qb;
 }
Beispiel #12
0
 /**
  * The handler for the index article.
  *
  * @param mixed $handler_id the array key from the request array
  * @param array $args the arguments given to the handler
  * @param Array &$data The local request data.
  * @return boolean Indicating success.
  */
 function _handler_all($handler_id, $args, &$data)
 {
     $_MIDCOM->auth->require_valid_user();
     $this->_request_data['name'] = "fi.kilonkipinat.todos";
     $this->_component_data['active_leaf'] = "{$this->_topic->id}_LIST_ALL";
     $this->_update_breadcrumb_line($handler_id);
     $title = 'Nakit';
     $_MIDCOM->set_pagetitle(":: {$title}");
     $qb = new org_openpsa_qbpager('fi_kilonkipinat_todos_todoitem_dba', 'fi_kilonkipinat_todos_list_my');
     $data['qb'] = $qb;
     $data['filters'] = fi_kilonkipinat_todos_viewer::prepare_todoitem_qb($data, $this->_config);
     $data['qb']->begin_group('OR');
     $data['qb']->add_constraint('visibility', '=', FI_KILONKIPINAT_TODOS_TODOITEM_VISIBILITY_PUBLIC);
     $data['qb']->add_constraint('person', '=', $_MIDGARD['user']);
     $data['qb']->add_constraint('supervisor', '=', $_MIDGARD['user']);
     $data['qb']->end_group();
     $data['qb']->add_order('status');
     $data['qb']->add_order('deadline');
     if ($handler_id == 'list_all_count') {
         $data['qb']->results_per_page = $args[0];
     } elseif (isset($data['filters']['filter_limit'])) {
         $data['qb']->results_per_page = (int) $data['filters']['filter_limit'];
     } else {
         $data['qb']->results_per_page = $this->_config->get('index_entries');
     }
     $data['todoitems'] = $data['qb']->execute();
     $data['handler_id'] = $handler_id;
     $persons = array();
     $root_group = new midcom_db_group($this->_config->get('root_group_to_show'));
     $person_ids = array();
     $mc_groups = midcom_db_member::new_collector('sitegroup', $_MIDGARD['sitegroup']);
     $mc_groups->add_constraint('gid', '=', $root_group->id);
     $mc_groups->add_value_property('uid');
     $mc_groups->execute();
     $tmp_keys = $mc_groups->list_keys();
     foreach ($tmp_keys as $guid => $tmp_key) {
         $person_id = $mc_groups->get_subkey($guid, 'uid');
         $person_ids[$person_id] = $person_id;
     }
     $mc_persons = fi_kilonkipinat_account_person_dba::new_collector('sitegroup', $_MIDGARD['sitegroup']);
     $mc_persons->add_constraint('id', 'IN', $person_ids);
     $mc_persons->add_value_property('id');
     $mc_persons->add_value_property('nickname');
     $mc_persons->add_value_property('firstname');
     $mc_persons->add_value_property('lastname');
     $mc_persons->execute();
     $tmp_persons = $mc_persons->list_keys();
     foreach ($tmp_persons as $guid => $tmp_key) {
         $persons[] = array('id' => $mc_persons->get_subkey($guid, 'id'), 'nickname' => $mc_persons->get_subkey($guid, 'nickname'), 'firstname' => $mc_persons->get_subkey($guid, 'firstname'), 'lastname' => $mc_persons->get_subkey($guid, 'lastname'));
     }
     $data['persons'] = $persons;
     return true;
 }
Beispiel #13
0
        echo "</td>";
        echo "\t\t</tr>";
    }
    echo "</table>";
    echo '<a href="' . $prefix . 'list/my/">Näytä kaikki</a>';
} else {
    echo "<p>Ei nakkeja</p>";
}
?>
</div>
</div>

<div class="fi_kilonkipinat_website_toggler_container">
<?php 
$my_groups = array();
$mc_my_groups = midcom_db_member::new_collector('sitegroup', $_MIDGARD['sitegroup']);
$mc_my_groups->add_constraint('uid', '=', $_MIDGARD['user']);
$mc_my_groups->add_value_property('gid');
$mc_my_groups->execute();
$tmp_keys = $mc_my_groups->list_keys();
foreach ($tmp_keys as $guid => $tmp_key) {
    $group_id = $mc_my_groups->get_subkey($guid, 'gid');
    $my_groups[$group_id] = $group_id;
}
$qb_my_groups = fi_kilonkipinat_todos_todoitem_dba::new_query_builder();
$qb_my_groups->add_constraint('grp', 'IN', $my_groups);
$qb_my_groups->add_constraint('grp', '<>', 0);
$qb_my_groups->add_order('deadline', 'ASC');
$qb_my_groups->add_constraint('status', '<', FI_KILONKIPINAT_TODOS_TODOITEM_STATUS_RESOLVED);
$my_groups_count = $qb_my_groups->count();
$qb_my_groups->set_limit(5);
Beispiel #14
0
 /**
  * Calculates P for the given two persons being duplicates
  * @param array person1
  * @param array person2
  * @return array with overall P and matched checks
  */
 function p_duplicate_person($person1, $person2)
 {
     $ret['p'] = 0;
     //TODO: read weight values from configuration
     $ret['email_match'] = false;
     if (!empty($person1['email']) && $person1['email'] == $person2['email']) {
         $ret['email_match'] = true;
         $ret['p'] += 1;
     }
     $ret['handphone_match'] = false;
     if (!empty($person1['handphone']) && $person1['handphone'] == $person2['handphone']) {
         $ret['handphone_match'] = true;
         $ret['p'] += 1;
     }
     $ret['fname_lname_city_match'] = false;
     if (!empty($person1['firstname']) && !empty($person1['lastname']) && !empty($person1['city']) && $person1['firstname'] == $person2['firstname'] && $person1['lastname'] == $person2['lastname'] && $person1['city'] == $person2['city']) {
         $ret['fname_lname_city_match'] = true;
         $ret['p'] += 0.5;
     }
     $ret['fname_lname_street_match'] = false;
     if (!empty($person1['firstname']) && !empty($person1['lastname']) && !empty($person1['street']) && $person1['firstname'] == $person2['firstname'] && $person1['lastname'] == $person2['lastname'] && $person1['street'] == $person2['street']) {
         $ret['fname_lname_street_match'] = true;
         $ret['p'] += 0.9;
     }
     $ret['fname_hphone_match'] = false;
     if (!empty($person1['firstname']) && !empty($person1['homephone']) && $person1['firstname'] == $person2['firstname'] && $person1['homephone'] == $person2['homephone']) {
         $ret['fname_hphone_match'] = true;
         $ret['p'] += 0.7;
     }
     $ret['fname_lname_company_match'] = false;
     // We cannot do this check if person1 hasn't been created yet...
     if (empty($person1['guid'])) {
         return $ret;
     }
     // Get membership maps
     if (!isset($this->_membership_cache[$person1['guid']]) || !is_array($this->_membership_cache[$person1['guid']])) {
         $this->_membership_cache[$person1['guid']] = array();
         $mc = midcom_db_member::new_collector('uid', $person1['id']);
         $memberships = $mc->get_values('gid');
         foreach ($memberships as $member) {
             $this->_membership_cache[$person1['guid']][$member] = $member;
         }
     }
     $person1_memberships =& $this->_membership_cache[$person1['guid']];
     if (!isset($this->_membership_cache[$person2['guid']]) || !is_array($this->_membership_cache[$person2['guid']])) {
         $this->_membership_cache[$person2['guid']] = array();
         $mc = midcom_db_member::new_collector('uid', $person2['id']);
         $memberships = $mc->get_values('gid');
         foreach ($memberships as $member) {
             $this->_membership_cache[$person2['guid']][$member] = $member;
         }
     }
     $person2_memberships =& $this->_membership_cache[$person2['guid']];
     foreach ($person1_memberships as $gid) {
         if (isset($person2_memberships[$gid]) && !empty($person2_memberships[$gid])) {
             $ret['fname_lname_company_match'] = true;
             $ret['p'] += 0.5;
             break;
         }
     }
     // All checks done, return
     return $ret;
 }