Example #1
0
 /**
  * The handler for the own details.
  *
  * @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_changePassword($handler_id, $args, &$data)
 {
     $this->_request_data['name'] = "fi.kilonkipinat.account";
     $title = $this->_l10n_midcom->get('index');
     $_MIDCOM->set_pagetitle(":: {$title}");
     $this->_component_data['active_leaf'] = "change_password";
     $message = '';
     $person = new fi_kilonkipinat_account_person_dba($_MIDGARD['user']);
     if (isset($_POST) && isset($_POST['old_pass']) && $_POST['old_pass'] != '') {
         $old_pass = trim($_POST['old_pass']);
         $auth_user = midgard_user::auth($person->username, $old_pass, self::sitegroup_for_auth(), false);
         if (!$auth_user) {
             $message = '<h3>Virhe</h3>Väärä vanha salasana!!!';
         } elseif (isset($_POST['new_pass']) && isset($_POST['new_pass2']) && strlen(trim($_POST['new_pass'])) >= $this->_config->get('password_min_length')) {
             $new_pass = trim($_POST['new_pass']);
             $new_pass2 = trim($_POST['new_pass2']);
             if ($new_pass == $new_pass2) {
                 // Enforce crypt mode
                 $salt = chr(rand(64, 126)) . chr(rand(64, 126));
                 $crypt_password = crypt($new_pass, $salt);
                 $person->password = $crypt_password;
                 $person->update();
                 $message = '<h3>Salasana vaihdettu</h3>';
                 $_MIDCOM->auth->_auth_backend->create_login_session($person->username, $new_pass);
             } else {
                 $message = '<h3>Virhe</h3>Varmistussalasana ei täsmää';
             }
         } else {
             $message = '<h3>Virhe</h3>Uusi salasana liian lyhyt';
         }
     }
     $this->_request_data['person'] = $person;
     $this->_request_data['messages'] = $message;
     return true;
 }
Example #2
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;
 }
Example #3
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_manageRequest($handler_id, $args, &$data)
 {
     $_MIDCOM->auth->require_admin_user();
     $this->_request_data['name'] = "fi.kilonkipinat.accountregistration";
     $this->_update_breadcrumb_line($handler_id);
     $title = $this->_l10n_midcom->get('fi.kilonkipinat.accountregistration');
     $_MIDCOM->set_pagetitle(":: {$title}");
     $prefix = $this->_request_data['prefix'];
     $request = new fi_kilonkipinat_accountregistration_accountrequest_dba(trim($args[0]));
     if (!isset($request) || !isset($request->guid) || $request->guid == '' || $request->guid != $args[0]) {
         debug_push_class(__CLASS__, __FUNCTION__);
         debug_pop();
         $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, 'Failed to load request, cannot continue. Last Midgard error was: ' . midcom_application::get_error_string());
         // This will exit.
     }
     $this->_request_data['request'] = $request;
     if (isset($_POST) && isset($_POST['username'])) {
         if (isset($_POST['isduplicate']) && $_POST['isduplicate'] == '1') {
             $request->status = FI_KILONKIPINAT_ACCOUNTREGISTRATION_ACCOUNT_STATUS_INVALID;
             $request->update();
             $message['title'] = $this->_l10n_midcom->get("Poistettu");
             $message['content'] = $this->_l10n_midcom->get("Kyseinen hakemus on merkattu duplikaatiksi, ts poistettu.");
         } else {
             if (isset($_POST['merge_user_guid']) && $_POST['merge_user_guid'] != '') {
                 $person = new fi_kilonkipinat_account_person_dba(trim($_POST['merge_user_guid']));
             } else {
                 $qb = fi_kilonkipinat_account_person_dba::new_query_builder();
                 $qb->add_constraint('username', '=', trim($_POST['username']));
                 $results = $qb->execute();
                 if (count($results) > 0) {
                     $message['title'] = $this->_l10n_midcom->get("error");
                     $message['content'] = $this->_l10n_midcom->get("Kyseinen tyyppi on jo olemassa");
                 } else {
                     $person = new fi_kilonkipinat_account_person_dba();
                     $person->username = trim($_POST['username']);
                     $person->create();
                 }
             }
             if (isset($person)) {
                 $person->firstname = $request->firstname;
                 $person->lastname = $request->lastname;
                 $person->email = $request->email;
                 $password = fi_kilonkipinat_accountregistration_viewer::generatePassword($this->_config->get('password_length'));
                 // Enforce crypt mode
                 $salt = chr(rand(64, 126)) . chr(rand(64, 126));
                 $crypt_password = crypt($password, $salt);
                 $person->password = $crypt_password;
                 $person->update();
                 if (isset($_POST['add_to_groups']) && count($_POST['add_to_groups']) > 0) {
                     foreach ($_POST['add_to_groups'] as $group_guid) {
                         $group = new midcom_db_group($group_guid);
                         if (isset($group) && isset($group->guid) && $group->guid == $group_guid) {
                             $membership = new midcom_db_member();
                             $membership->uid = $person->id;
                             $membership->gid = $group->id;
                             $membership->create();
                         }
                     }
                 }
                 $person->set_privilege('midgard:owner', "user:{$person->guid}");
                 $request->status = FI_KILONKIPINAT_ACCOUNTREGISTRATION_ACCOUNT_STATUS_RESOLVED;
                 $request->personGuid = $person->guid;
                 $request->update();
                 $subject = 'Tunnuksesi kilonkipinat.fi-sivustolle';
                 $body = sprintf('Hei %s', $person->firstname);
                 $body .= "\n\n";
                 $body .= sprintf('käyttäjätunnus: %s', $person->username);
                 $body .= "\n\n";
                 $body .= sprintf('salasana: %s', $password);
                 $mail = new org_openpsa_mail();
                 $mail->from = $this->_config->get('mail_sender_title') . ' <' . $this->_config->get('mail_sender_address') . '>';
                 $mail->to = $person->firstname . ' ' . $person->lastname . ' <' . $person->email . '>';
                 $mail->body = $body;
                 $mail->subject = $subject;
                 $message = array();
                 if ($mail->send('mail')) {
                     $message['title'] = $this->_l10n_midcom->get("Onnistui");
                     $message['content'] = '';
                 } else {
                     $message['title'] = $this->_l10n_midcom->get("error");
                     $message['content'] = $this->_l10n_midcom->get("Oops, something went wrong.");
                 }
             }
         }
         $this->_request_data['message'] = $message;
     }
     return true;
 }
Example #4
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();
 }
Example #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.accountregistration";
     $this->_update_breadcrumb_line($handler_id);
     $title = $this->_l10n_midcom->get('fi.kilonkipinat.accountregistration');
     $_MIDCOM->set_pagetitle(":: {$title}");
     $prefix = $this->_request_data['prefix'];
     $this->_request_data['sort_order'] = $this->_config->get('sort_order');
     if (isset($_POST) && isset($_POST['action_type']) && ($_POST['action_type'] == 'reset_password' || $_POST['action_type'] == 'registration')) {
         $_MIDCOM->auth->request_sudo('fi.kilonkipinat.accountregistration');
         if ($_POST['action_type'] == 'reset_password') {
             if (trim($_POST['username']) == '') {
                 $error_msg = 'Täytä käyttäjätunnus-kenttä';
             } else {
                 $qb = fi_kilonkipinat_account_person_dba::new_query_builder();
                 $qb->add_constraint('username', '=', trim($_POST['username']));
                 $qb->set_limit(1);
                 $user = $qb->execute();
                 if (isset($user) && count($user) > 0) {
                     $reset_request = new fi_kilonkipinat_accountregistration_resetrequest_dba();
                     $reset_request->username = $user[0]->username;
                     $reset_request->person = $user[0]->id;
                     $reset_request->status = FI_KILONKIPINAT_ACCOUNTREGISTRATION_PASSWORDRESETREQUEST_STATUS_NEW;
                     $reset_request->create();
                     $reset_request_quid = $reset_request->guid;
                     $subject = sprintf('Salasanan vaihto palvelimella %s', $_SERVER['SERVER_NAME']);
                     $body = sprintf('Hei %s', $user[0]->firstname);
                     $body .= "\n\n";
                     $body .= sprintf($this->_l10n_midcom->get('Pyysit salasanasi resetointia palvelimella %s'), $_SERVER['SERVER_NAME']);
                     $body .= "\n\n";
                     $body .= sprintf($this->_l10n_midcom->get('Resetoidaksesi salasanasi käyttäjätunnukselle %s, klikkaa alla olevaa linkkiä'), $user[0]->username);
                     $body .= "\n\n";
                     $body .= 'http://' . $_SERVER['SERVER_NAME'] . $prefix . 'approve_reset/' . $reset_request_quid . '/';
                     $mail = new org_openpsa_mail();
                     $mail->from = $this->_config->get('mail_sender_title') . ' <' . $this->_config->get('mail_sender_address') . '>';
                     $mail->to = $user[0]->firstname . ' ' . $user[0]->lastname . ' <' . $user[0]->email . '>';
                     $mail->body = $body;
                     $mail->subject = $subject;
                     if ($mail->send('mail')) {
                         $success_msg = $this->_l10n_midcom->get("Salasanan resetointipyyntö vastaanotettu, katso sähköpostiasi.");
                     }
                 }
             }
         } elseif ($_POST['action_type'] == 'registration') {
             if ($_POST['firstname'] == '' || $_POST['lastname'] == '' || $_POST['email'] == '') {
                 $error_msg = 'Täytä kaikki pakolliset kentät';
             } else {
                 $accountrequest = new fi_kilonkipinat_accountregistration_accountrequest_dba();
                 $accountrequest->firstname = $_POST['firstname'];
                 $accountrequest->lastname = $_POST['lastname'];
                 $accountrequest->email = $_POST['email'];
                 $accountrequest->status = FI_KILONKIPINAT_ACCOUNTREGISTRATION_ACCOUNT_STATUS_NEW;
                 $accountrequest->create();
                 $accountrequest_quid = $accountrequest->guid;
                 $subject = sprintf('Käyttäjätunnuksen rekisteröinti palvelimelle %s', $_SERVER['SERVER_NAME']);
                 $body = sprintf('Hei %s', $accountrequest->firstname);
                 $body .= "\n\n";
                 $body .= sprintf($this->_l10n_midcom->get('Käyttäjätunnuksen rekisteröinti palvelimelle %s.'), $_SERVER['SERVER_NAME']);
                 $body .= "\n\n";
                 $body .= $this->_l10n_midcom->get('Varmistaaksesi sähköpostisi, klikkaa alla olevaa linkkiä');
                 $body .= "\n\n";
                 $body .= 'http://' . $_SERVER['SERVER_NAME'] . $prefix . 'validate_email/' . $accountrequest_quid . '/';
                 $mail = new org_openpsa_mail();
                 $mail->from = $this->_config->get('mail_sender_title') . ' <' . $this->_config->get('mail_sender_address') . '>';
                 $mail->to = $accountrequest->firstname . ' ' . $accountrequest->lastname . ' <' . $accountrequest->email . '>';
                 $mail->body = $body;
                 $mail->subject = $subject;
                 if ($mail->send('mail')) {
                     $success_msg = 'Käyttäjätunnuksen rekisteröinti vastaanotettu, katso sähköpostisi';
                 }
             }
         }
         $_MIDCOM->auth->drop_sudo('fi.kilonkipinat.accountregistration');
     }
     $message = array();
     if (isset($success_msg) && $success_msg != '') {
         $message['title'] = 'Onnistui';
         $message['content'] = $success_msg;
         $this->_request_data['message'] = $message;
     }
     if (isset($error_msg) && $error_msg != '') {
         $message['title'] = 'Virhe';
         $message['content'] = $error_msg;
         $this->_request_data['message'] = $message;
     }
     return true;
 }
Example #6
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;
 }
Example #7
0
<?php

if (isset($_GET) && isset($_GET['search_str']) && $_GET['search_str'] != '' && strlen(trim($_GET['search_str'])) > 2) {
    $search_str = trim($_GET['search_str']);
    $qb = fi_kilonkipinat_account_person_dba::new_query_builder();
    $qb->begin_group('OR');
    $qb->add_constraint('username', 'LIKE', '%' . $search_str . '%');
    $qb->add_constraint('firstname', 'LIKE', '%' . $search_str . '%');
    $qb->add_constraint('lastname', 'LIKE', '%' . $search_str . '%');
    $qb->end_group();
    $results = $qb->execute();
    if (count($results) > 0) {
        echo "<table id=\"fi_kilonkipinat_accountregistration_merge_search_results\">\n";
        echo "\t<tr>\n";
        echo "\t\t<th>Etunimi</th>";
        echo "\t\t<th>Sukunimi</th>";
        echo "\t\t<th>Käyttäjätunnus</th>";
        echo "\t\t<th>Sähköposti</th>";
        echo "\t\t<th>&nbsp;</th>";
        echo "\t</tr>\n";
        foreach ($results as $result) {
            echo "\t<tr id=\"user_" . $result->guid . "\">\n";
            echo "\t\t<td>" . $result->firstname . "</td>";
            echo "\t\t<td>" . $result->lastname . "</td>";
            echo "\t\t<td>" . $result->username . "</td>";
            echo "\t\t<td>" . $result->email . "</td>";
            echo "\t\t<td><a href=\"#\" onclick=\"chooseUser('" . $result->guid . "', '" . $result->username . "'); return false;\">Valitse</a></td>";
            echo "\t</tr>\n";
        }
        echo "</table>\n";
    }
Example #8
0
 public function loadPersons($person_guids)
 {
     $tmp_guids = explode('|', $person_guids);
     $guids = array();
     foreach ($tmp_guids as $guid) {
         $guids[] = trim(str_replace('|', '', $guid));
     }
     $persons_qb = fi_kilonkipinat_account_person_dba::new_query_builder();
     $persons_qb->add_constraint('email', '<>', '');
     $persons_qb->add_constraint('guid', 'IN', $guids);
     $persons = $persons_qb->execute();
     return $persons;
 }