24require_once 
'./Services/User/classes/class.ilObjUser.php';
 
   25require_once 
'Services/Mail/classes/class.ilMailbox.php';
 
   26require_once 
'Services/Mail/classes/class.ilFormatMail.php';
 
   27include_once 
'Services/Table/classes/class.ilTable2GUI.php';
 
   28include_once 
'Services/Search/classes/class.ilQueryParser.php';
 
   29include_once 
'Services/Search/classes/class.ilObjectSearchFactory.php';
 
   30include_once 
'Services/Search/classes/class.ilSearchResult.php';
 
   69    public function __construct($wsp_access_handler = 
null, $wsp_node_id = 
null)
 
   73        $this->tpl               = 
$DIC[
'tpl'];
 
   74        $this->ctrl              = 
$DIC[
'ilCtrl'];
 
   75        $this->lng               = 
$DIC[
'lng'];
 
   76        $this->rbacreview        = 
$DIC[
'rbacreview'];
 
   77        $this->object_data_cache = 
$DIC[
'ilObjDataCache'];
 
   80        $this->wsp_access_handler = $wsp_access_handler;
 
   81        $this->wsp_node_id = $wsp_node_id;
 
   83        $this->ctrl->saveParameter($this, 
"mobj_id");
 
   84        $this->ctrl->saveParameter($this, 
"ref");
 
   91        $forward_class = $this->ctrl->getNextClass($this);
 
   92        switch ($forward_class) {
 
   94                if (!($cmd = $this->ctrl->getCmd())) {
 
  107        $recipients = array();
 
  108        $recipients = array_merge($recipients, (array) 
$_POST[
'search_name_to_addr']);
 
  109        $recipients = array_merge($recipients, (array) 
$_POST[
'search_name_to_usr']);
 
  110        $recipients = array_merge($recipients, (array) 
$_POST[
'search_name_to_grp']);
 
  112        $recipients = array_unique($recipients);
 
  114        $_SESSION[
"mail_search_results_to"] = $recipients;
 
  118        if (
$_GET[
"ref"] != 
"wsp") {
 
  124        $this->ctrl->returnToParent($this);
 
  129        $mail_data = $this->umail->getSavedData();
 
  131        $this->umail->savePostData(
 
  132            $mail_data[
"user_id"],
 
  133            $mail_data[
"attachments"],
 
  134            $mail_data[
"rcp_to"],
 
  135            $mail_data[
"rcp_cc"],
 
  136            $mail_data[
"rcp_bcc"],
 
  137            $mail_data[
"m_type"],
 
  138            $mail_data[
"m_email"],
 
  139            $mail_data[
"m_subject"],
 
  140            $mail_data[
"m_message"],
 
  141            $mail_data[
"use_placeholders"],
 
  142            $mail_data[
'tpl_ctx_id'],
 
  143            $mail_data[
'tpl_ctx_params']
 
  149        $this->ctrl->returnToParent($this);
 
  156        if (strlen(trim(
$_SESSION[
"mail_search_search"])) == 0) {
 
  158        } elseif (strlen(trim(
$_SESSION[
"mail_search_search"])) < 3) {
 
  159            $this->lng->loadLanguageModule(
'search');
 
  170        if (
$_GET[
"ref"] != 
"wsp") {
 
  172            $title = $this->lng->txt(
'search_recipients');
 
  174            $this->lng->loadLanguageModule(
"wsp");
 
  175            $title = $this->lng->txt(
"wsp_share_search_users");
 
  179        include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
  182        $form->setId(
'search_rcp');
 
  183        $form->setFormAction($this->ctrl->getFormAction($this, 
'search'));
 
  185        $inp = 
new ilTextInputGUI($this->lng->txt(
"search_for"), 
'search');
 
  187        $dsDataLink = $this->ctrl->getLinkTarget($this, 
'lookupRecipientAsync', 
'', 
true, 
false);
 
  188        $inp->setDataSource($dsDataLink);
 
  191            isset(
$_SESSION[
"mail_search_search"]) &&
 
  192            is_string(
$_SESSION[
"mail_search_search"]) &&
 
  193            strlen(trim(
$_SESSION[
"mail_search_search"])) > 0
 
  197        $form->addItem($inp);
 
  199        $form->addCommandButton(
'search', $this->lng->txt(
"search"));
 
  200        $form->addCommandButton(
'cancel', $this->lng->txt(
"cancel"));
 
  207        include_once 
'Services/JSON/classes/class.ilJsonUtil.php';
 
  208        include_once 
'Services/Mail/classes/class.ilMailForm.php';
 
  209        include_once 
'Services/Utilities/classes/class.ilStr.php';
 
  212        if (isset(
$_GET[
"term"]) && is_string(
$_GET[
"term"])) {
 
  213            $search = 
$_GET[
"term"];
 
  215        if (isset(
$_POST[
"term"]) && is_string(
$_POST[
"term"])) {
 
  219        $search = trim($search);
 
  229        $quoted = str_replace(
'%', 
'\%', $quoted);
 
  230        $quoted = str_replace(
'_', 
'\_', $quoted);
 
  232        $search_recipients = (
$_GET[
"ref"] != 
"wsp");
 
  246        $this->tpl->addBlockFile(
"ADM_CONTENT", 
"adm_content", 
"tpl.mail_search.html", 
"Services/Contact");
 
  247        $this->tpl->setVariable(
"ACTION", $this->ctrl->getFormAction($this));
 
  248        $this->tpl->setTitle($this->lng->txt(
"mail"));
 
  249        $this->tpl->setVariable(
'SEARCHFORM', 
$form->getHtml());
 
  253            !isset(
$_SESSION[
"mail_search_search"]) ||
 
  254            !is_string(
$_SESSION[
"mail_search_search"]) ||
 
  255            strlen(trim(
$_SESSION[
"mail_search_search"])) < 3
 
  257            if (
$_GET[
"ref"] != 
"wsp") {
 
  263        require_once 
'Services/Contact/BuddySystem/classes/class.ilBuddyList.php';
 
  265        if (count($relations)) {
 
  270            $query_parser->setMinWordLength(3);
 
  271            $query_parser->parse();
 
  274            $user_search->enableActiveCheck(
true);
 
  275            $user_search->setFields(array(
'login'));
 
  276            $result_obj = $user_search->performSearch();
 
  277            $contacts_search_result->mergeEntries($result_obj);
 
  279            $user_search->setFields(array(
'firstname'));
 
  280            $result_obj = $user_search->performSearch();
 
  281            $contacts_search_result->mergeEntries($result_obj);
 
  283            $user_search->setFields(array(
'lastname'));
 
  284            $result_obj = $user_search->performSearch();
 
  285            $contacts_search_result->mergeEntries($result_obj);
 
  287            $contacts_search_result->setMaxHits(100000);
 
  288            $contacts_search_result->preventOverwritingMaxhits(
true);
 
  289            $contacts_search_result->filter(ROOT_FOLDER_ID, 
true);
 
  292            include_once 
'Services/User/classes/class.ilUserFilter.php';
 
  294            $users = array_intersect(
$users, $relations->getKeys());
 
  297            $tbl_contacts->setTitle($this->lng->txt(
'mail_addressbook'));
 
  298            $tbl_contacts->setRowTemplate(
'tpl.mail_search_addr_row.html', 
'Services/Contact');
 
  300            $has_mail_addr = 
false;
 
  303            foreach (
$users as $user) {
 
  306                if (
$_GET[
'ref'] == 
'wsp') {
 
  317                    $has_mail_addr             = 
true;
 
  333            if (
$_GET[
'ref'] == 
'wsp') {
 
  334                $tbl_contacts->addColumn(
"", 
"", 
"1%", 
true);
 
  336                $tbl_contacts->addColumn($this->lng->txt(
'mail_to') . 
'/' . $this->lng->txt(
'cc') . 
'/' . $this->lng->txt(
'bc'), 
'check', 
'10%');
 
  338            $tbl_contacts->addColumn($this->lng->txt(
'login'), 
'login', 
'15%');
 
  339            $tbl_contacts->addColumn($this->lng->txt(
'firstname'), 
'firstname', 
'15%');
 
  340            $tbl_contacts->addColumn($this->lng->txt(
'lastname'), 
'lastname', 
'15%');
 
  341            if ($has_mail_addr) {
 
  343                    if ($val[
'email'] == 
'') {
 
  348                $tbl_contacts->addColumn($this->lng->txt(
'email'), 
'email', 
"15%");
 
  350            $tbl_contacts->setData(
$result);
 
  352            $tbl_contacts->setDefaultOrderField(
'login');
 
  353            $tbl_contacts->setPrefix(
'addr_');
 
  354            $tbl_contacts->enable(
'select_all');
 
  355            $tbl_contacts->setSelectAllCheckbox(
'search_name_to_addr');
 
  356            $tbl_contacts->setFormName(
'recipients');
 
  358            $this->tpl->setVariable(
'TABLE_ADDR', $tbl_contacts->getHTML());
 
  365        $query_parser->setMinWordLength(3);
 
  366        $query_parser->parse();
 
  369        $user_search->enableActiveCheck(
true);
 
  370        $user_search->setFields(array(
'login'));
 
  371        $result_obj = $user_search->performSearch();
 
  372        $all_results->mergeEntries($result_obj);
 
  374        $user_search->setFields(array(
'firstname'));
 
  375        $result_obj = $user_search->performSearch();
 
  376        $all_results->mergeEntries($result_obj);
 
  378        $user_search->setFields(array(
'lastname'));
 
  379        $result_obj = $user_search->performSearch();
 
  380        $all_results->mergeEntries($result_obj);
 
  382        $all_results->setMaxHits(100000);
 
  383        $all_results->preventOverwritingMaxhits(
true);
 
  384        $all_results->filter(ROOT_FOLDER_ID, 
true);
 
  387        include_once 
'Services/User/classes/class.ilUserFilter.php';
 
  391            $tbl_users->setTitle($this->lng->txt(
'system') . 
': ' . $this->lng->txt(
'persons'));
 
  392            $tbl_users->setRowTemplate(
'tpl.mail_search_users_row.html', 
'Services/Contact');
 
  396            foreach (
$users as $user) {
 
  399                if (
$_GET[
"ref"] != 
"wsp") {
 
  418                    $has_mail_usr              = 
true;
 
  425            if (
$_GET[
"ref"] != 
"wsp") {
 
  426                $tbl_users->addColumn($this->lng->txt(
'mail_to') . 
'/' . $this->lng->txt(
'cc') . 
'/' . $this->lng->txt(
'bc'), 
'check', 
'10%');
 
  428                $tbl_users->addColumn(
"", 
"", 
"1%");
 
  430            $tbl_users->addColumn($this->lng->txt(
'login'), 
'login', 
'15%');
 
  431            $tbl_users->addColumn($this->lng->txt(
'firstname'), 
'firstname', 
'15%');
 
  432            $tbl_users->addColumn($this->lng->txt(
'lastname'), 
'lastname', 
'15%');
 
  433            if ($has_mail_usr == 
true) {
 
  435                    if ($val[
'email'] == 
'') {
 
  440                $tbl_users->addColumn($this->lng->txt(
'email'), 
'email', 
'15%');
 
  444            $tbl_users->setDefaultOrderField(
'login');
 
  445            $tbl_users->setPrefix(
'usr_');
 
  446            $tbl_users->enable(
'select_all');
 
  447            $tbl_users->setSelectAllCheckbox(
'search_name_to_usr');
 
  448            $tbl_users->setFormName(
'recipients');
 
  450            $this->tpl->setVariable(
'TABLE_USERS', $tbl_users->getHTML());
 
  453        include_once 
'Services/Search/classes/class.ilQueryParser.php';
 
  454        include_once 
'Services/Search/classes/class.ilObjectSearchFactory.php';
 
  455        include_once 
'Services/Search/classes/class.ilSearchResult.php';
 
  456        include_once 
'Services/Membership/classes/class.ilParticipants.php';
 
  462        $query_parser->setMinWordLength(3);
 
  463        $query_parser->parse();
 
  466        $search->setFilter(array(
'grp'));
 
  467        $result = $search->performSearch();
 
  468        $group_results->mergeEntries(
$result);
 
  469        $group_results->setMaxHits(PHP_INT_MAX);
 
  470        $group_results->preventOverwritingMaxhits(
true);
 
  471        $group_results->setRequiredPermission(
'read');
 
  472        $group_results->filter(ROOT_FOLDER_ID, 
true);
 
  474        $visible_groups = array();
 
  475        if ($group_results->getResults()) {
 
  477            $tbl_grp->setTitle($this->lng->txt(
'system') . 
': ' . $this->lng->txt(
'groups'));
 
  478            $tbl_grp->setRowTemplate(
'tpl.mail_search_groups_row.html', 
'Services/Contact');
 
  483            $this->object_data_cache->preloadReferenceCache(array_keys($group_results->getResults()));
 
  485            $groups = $group_results->getResults();
 
  486            foreach ($groups as $grp) {
 
  491                if (
$_GET[
"ref"] != 
"wsp") {
 
  493                    $roles   = $this->rbacreview->getAssignableChildRoles($grp[
'ref_id']);
 
  494                    foreach ($roles as $role) {
 
  495                        if (substr($role[
'title'], 0, 14) == 
'il_grp_member_' ||
 
  496                            substr($role[
'title'], 0, 13) == 
'il_grp_admin_' 
  499                            array_push($members, 
'#' . $role[
'title']);
 
  502                    $str_members = implode(
',', $members);
 
  511                $result[
$counter][
'title']       = $this->object_data_cache->lookupTitle($grp[
'obj_id']);
 
  512                $result[
$counter][
'description'] = $this->object_data_cache->lookupDescription($grp[
'obj_id']);
 
  515                $visible_groups[] = $grp;
 
  518            if ($visible_groups) {
 
  521                if (
$_GET[
"ref"] != 
"wsp") {
 
  522                    $tbl_grp->addColumn($this->lng->txt(
'mail_to') . 
'/' . $this->lng->txt(
'cc') . 
'/' . $this->lng->txt(
'bc'), 
'check', 
'10%');
 
  524                    $tbl_grp->addColumn(
"", 
"", 
"1%");
 
  526                $tbl_grp->addColumn($this->lng->txt(
'title'), 
'title', 
'15%');
 
  527                $tbl_grp->addColumn($this->lng->txt(
'description'), 
'description', 
'15%');
 
  529                $tbl_grp->setDefaultOrderField(
'title');
 
  530                $tbl_grp->setPrefix(
'grp_');
 
  531                $tbl_grp->enable(
'select_all');
 
  532                $tbl_grp->setSelectAllCheckbox(
'search_name_to_grp');
 
  533                $tbl_grp->setFormName(
'recipients');
 
  535                $this->tpl->setVariable(
'TABLE_GRP', $tbl_grp->getHTML());
 
  539        if (count(
$users) || count($visible_groups) || count($relations)) {
 
  541            $this->tpl->setVariable(
"ALT_ARROW", 
'');
 
  543            if (
$_GET[
"ref"] != 
"wsp") {
 
  544                $this->tpl->setVariable(
'BUTTON_ADOPT', $this->lng->txt(
'adopt'));
 
  546                $this->tpl->setVariable(
'BUTTON_ADOPT', $this->lng->txt(
'wsp_share_with_users'));
 
  549            $this->lng->loadLanguageModule(
'search');
 
  553        if (
$_GET[
"ref"] != 
"wsp") {
 
  560        if (!is_array($a_obj_ids)) {
 
  561            $a_obj_ids = array($a_obj_ids);
 
  564        $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
 
  566        foreach ($a_obj_ids as $object_id) {
 
  567            if (!in_array($object_id, $existing)) {
 
  568                $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
 
An exception for terminatinating execution or to throw for unit testing.
static getInstanceByGlobalUser()
addPermission($a_obj_ids)
__construct($wsp_access_handler=null, $wsp_node_id=null)
static _lookupPref($a_usr_id, $a_keyword)
static _lookupEmail($a_user_id)
Lookup email.
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
static _getObjectSearchInstance($query_parser)
get reference of ilFulltext/LikeObjectSearch.
static _getUserSearchInstance($query_parser)
get reference of ilLikeUserSearch
static hasParticipantListAccess($a_obj_id, $a_usr_id=null)
Check if (current) user has access to the participant list.
This class represents a text property in a property form.
static getInstance()
Singelton get instance.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
if(isset($_POST['submit'])) $form