CommonITILObject::showUsersAssociated PHP Метод

showUsersAssociated() публичный Метод

show tooltip for user notification information
public showUsersAssociated ( $type, $canedit, array $options = [] ) : nothing
$type integer user type
$canedit boolean can edit ?
$options array array options for default values ($options of showForm)
Результат nothing display
    function showUsersAssociated($type, $canedit, array $options = array())
    {
        global $CFG_GLPI;
        $showuserlink = 0;
        if (User::canView()) {
            $showuserlink = 2;
        }
        $usericon = self::getActorIcon('user', $type);
        $user = new User();
        $linkuser = new $this->userlinkclass();
        $itemtype = $this->getType();
        $typename = self::getActorFieldNameType($type);
        $candelete = true;
        $mandatory = '';
        // For ticket templates : mandatories
        if ($itemtype == 'Ticket' && isset($options['_tickettemplate'])) {
            $mandatory = $options['_tickettemplate']->getMandatoryMark("_users_id_" . $typename);
            if ($options['_tickettemplate']->isMandatoryField("_users_id_" . $typename) && isset($this->users[$type]) && count($this->users[$type]) == 1) {
                $candelete = false;
            }
        }
        if (isset($this->users[$type]) && count($this->users[$type])) {
            foreach ($this->users[$type] as $d) {
                echo "<div class='actor_row'>";
                $k = $d['users_id'];
                echo "{$mandatory}{$usericon}&nbsp;";
                if ($k) {
                    $userdata = getUserName($k, 2);
                } else {
                    $email = $d['alternative_email'];
                    $userdata = "<a href='mailto:{$email}'>{$email}</a>";
                }
                if ($k) {
                    $param = array('display' => false);
                    if ($showuserlink) {
                        $param['link'] = $userdata["link"];
                    }
                    echo $userdata['name'] . "&nbsp;" . Html::showToolTip($userdata["comment"], $param);
                } else {
                    echo $userdata;
                }
                if ($CFG_GLPI['use_mailing']) {
                    $text = __('Email followup') . "&nbsp;" . Dropdown::getYesNo($d['use_notification']) . '<br>';
                    if ($d['use_notification']) {
                        $uemail = $d['alternative_email'];
                        if (empty($uemail) && $user->getFromDB($d['users_id'])) {
                            $uemail = $user->getDefaultEmail();
                        }
                        $text .= sprintf(__('%1$s: %2$s'), __('Email'), $uemail);
                        if (!NotificationMail::isUserAddressValid($uemail)) {
                            $text .= "&nbsp;<span class='red'>" . __('Invalid email address') . "</span>";
                        }
                    }
                    echo "&nbsp;";
                    if ($canedit || $d['users_id'] == Session::getLoginUserID()) {
                        $opt = array('img' => $CFG_GLPI['root_doc'] . '/pics/edit.png', 'popup' => $linkuser->getFormURL() . "?id=" . $d['id']);
                        Html::showToolTip($text, $opt);
                    }
                }
                if ($canedit && $candelete) {
                    echo "&nbsp;";
                    Html::showSimpleForm($linkuser->getFormURL(), 'delete', _x('button', 'Delete permanently'), array('id' => $d['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png");
                }
                echo "</div>";
            }
        }
    }
CommonITILObject