{
global $rbacsystem,
$lng, $ilUser,
$ilCtrl, $rbacreview;
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_search.html", "Services/Contact");
$this->tpl->setVariable("HEADER", $this->lng->txt("mail"));
$this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
$form->setTitle($this->lng->txt('search_recipients'));
$form->setId('search_rcp');
$form->setFormAction($ilCtrl->getFormAction($this, 'search'));
if (strlen(trim(
$_SESSION[
"mail_search_search"])) > 0)
{
}
$form->addItem($inp);
$chb =
new ilCheckboxInputGUI($this->lng->txt(
"mail_search_addressbook"),
'type_addressbook');
if (
$_SESSION[
'mail_search_type_addressbook'])
$inp->addSubItem($chb);
$inp->addSubItem($chb);
$form->addCommandButton('search', $this->lng->txt("search"));
$form->addCommandButton('cancel', $this->lng->txt("cancel"));
$this->tpl->setVariable('SEARCHFORM', $form->getHtml());
if (strlen(trim(
$_SESSION[
"mail_search_search"])) > 0)
{
}
{
$this->tpl->setVariable('CHECKED_TYPE_SYSTEM', "checked=\"checked\"");
}
else
{
if (
$_SESSION[
'mail_search_type_addressbook']) $this->tpl->setVariable(
'CHECKED_TYPE_ADDRESSBOOK',
"checked=\"checked\"");
if (
$_SESSION[
'mail_search_type_system'])$this->tpl->setVariable(
'CHECKED_TYPE_SYSTEM',
"checked=\"checked\"");
}
if (
$_SESSION[
'mail_search_type_addressbook'] && strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3)
{
if (count($entries))
{
$tbl_addr->setTitle($lng->txt('mail_addressbook'));
$tbl_addr->setRowTemplate('tpl.mail_search_addr_row.html', 'Services/Contact');
$counter = 0;
foreach ($entries as $entry)
{
ilUtil::formCheckbox(0,
'search_name_cc[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email'])) .
ilUtil::formCheckbox(0,
'search_name_bcc[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email']));
$result[$counter][
'login'] = $entry[
'login'];
$result[$counter][
'firstname'] = $entry[
'firstname'];
$result[$counter][
'lastname'] = $entry[
'lastname'];
{
$has_mail_addr = true;
$result[$counter][
'email'] = $entry[
'email'];
}
++$counter;
}
$tbl_addr->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
$tbl_addr->addColumn($this->lng->txt('login'), 'login', "15%");
$tbl_addr->addColumn($this->lng->txt('firstname'), 'firstname', "15%");
$tbl_addr->addColumn($this->lng->txt('lastname'), 'lastname', "15%");
if ($has_mail_addr)
{
{
if ($val[
'email'] ==
'')
$result[$key][
'email'] =
' ';
}
$tbl_addr->addColumn($this->lng->txt('email'), 'email', "15%");
}
$tbl_addr->setDefaultOrderField('login');
$tbl_addr->setPrefix('addr_');
$tbl_addr->enable('select_all');
$tbl_addr->setSelectAllCheckbox('search_name_to_addr');
$tbl_addr->setFormName('recipients');
$this->tpl->setVariable('TABLE_ADDR', $tbl_addr->getHTML());
}
}
if (
$_SESSION[
'mail_search_type_system'] && strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3)
{
include_once 'Services/Search/classes/class.ilQueryParser.php';
include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
include_once 'Services/Search/classes/class.ilSearchResult.php';
$query_parser->setMinWordLength(3);
$query_parser->parse();
$user_search->enableActiveCheck(true);
$user_search->setFields(array('login'));
$result_obj = $user_search->performSearch();
$all_results->mergeEntries($result_obj);
$user_search->setFields(array('firstname'));
$result_obj = $user_search->performSearch();
$all_results->mergeEntries($result_obj);
$user_search->setFields(array('lastname'));
$result_obj = $user_search->performSearch();
$all_results->mergeEntries($result_obj);
$all_results->setMaxHits(100000);
$all_results->preventOverwritingMaxhits(true);
include_once './Services/User/classes/class.ilUserFilter.php';
if (count($users))
{
$tbl_users->setTitle($lng->txt('system').': '.$lng->txt('persons'));
$tbl_users->setRowTemplate('tpl.mail_search_users_row.html','Services/Contact');
$counter = 0;
foreach ($users as
$user)
{
$result[$counter][
'login'] = $login;
{
$result[$counter][
'firstname'] = $name[
'firstname'];
$result[$counter][
'lastname'] = $name[
'lastname'];
}
else
{
$result[$counter][
'firstname'] =
'';
$result[$counter][
'lastname'] =
'';
}
{
$has_mail_usr = true;
}
++$counter;
}
$tbl_users->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
$tbl_users->addColumn($this->lng->txt('login'), 'login', '15%');
$tbl_users->addColumn($this->lng->txt('firstname'), 'firstname', '15%');
$tbl_users->addColumn($this->lng->txt('lastname'), 'lastname', '15%');
if ($has_mail_usr == true)
{
{
if ($val[
'email'] ==
'')
$result[$key][
'email'] =
' ';
}
$tbl_users->addColumn($this->lng->txt('email'), 'email', '15%');
}
$tbl_users->setDefaultOrderField('login');
$tbl_users->setPrefix('usr_');
$tbl_users->enable('select_all');
$tbl_users->setSelectAllCheckbox('search_name_to_usr');
$tbl_users->setFormName('recipients');
$this->tpl->setVariable('TABLE_USERS', $tbl_users->getHTML());
}
if (count($groups))
{
$tbl_grp->setTitle($lng->txt('system').': '.$lng->txt('groups'));
$tbl_grp->setRowTemplate('tpl.mail_search_groups_row.html','Services/Contact');
$counter = 0;
foreach ($groups as $grp)
{
$members = array();
$roles = $rbacreview->getAssignableChildRoles($grp['ref_id']);
foreach ($roles as $role)
{
if (substr($role['title'], 0, 14) == 'il_grp_member_' ||
substr($role['title'], 0, 13) == 'il_grp_admin_')
{
array_push($members, '#'.$role['title']);
}
}
$str_members = implode(',',$members);
$result[$counter][
'title'] = $grp[
'title'];
$result[$counter][
'description'] = $grp[
'description'];
++$counter;
}
$tbl_grp->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
$tbl_grp->addColumn($this->lng->txt('title'), 'title', '15%');
$tbl_grp->addColumn($this->lng->txt('description'), 'description', '15%');
$tbl_grp->setDefaultOrderField('title');
$tbl_grp->setPrefix('grp_');
$tbl_grp->enable('select_all');
$tbl_grp->setSelectAllCheckbox('search_name_to_grp');
$tbl_grp->setFormName('recipients');
$this->tpl->setVariable('TABLE_GRP', $tbl_grp->getHTML());
}
}
if (count($users) || count($groups) || count($entries))
{
$this->tpl->setVariable("ALT_ARROW", '');
$this->tpl->setVariable('BUTTON_ADOPT', $this->lng->txt('adopt'));
}
else if (strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3)
{
$this->lng->loadLanguageModule('search');
}
$this->tpl->show();
}