本文整理汇总了PHP中ilMail::_usePearMail方法的典型用法代码示例。如果您正苦于以下问题:PHP ilMail::_usePearMail方法的具体用法?PHP ilMail::_usePearMail怎么用?PHP ilMail::_usePearMail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilMail
的用法示例。
在下文中一共展示了ilMail::_usePearMail方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRoleMailboxAddress
/**
* Returns the mailbox address of a role.
*
* Example 1: Mailbox address for an ILIAS reserved role name
* ----------------------------------------------------------
* The il_crs_member_345 role of the course object "English Course 1" is
* returned as one of the following mailbox addresses:
*
* a) Course Member <#member@[English Course 1]>
* b) Course Member <#il_crs_member_345@[English Course 1]>
* c) Course Member <#il_crs_member_345>
*
* Address a) is returned, if the title of the object is unique, and
* if there is only one local role with the substring "member" defined for
* the object.
*
* Address b) is returned, if the title of the object is unique, but
* there is more than one local role with the substring "member" in its title.
*
* Address c) is returned, if the title of the course object is not unique.
*
*
* Example 2: Mailbox address for a manually defined role name
* -----------------------------------------------------------
* The "Admin" role of the category object "Courses" is
* returned as one of the following mailbox addresses:
*
* a) Course Administrator <#Admin@Courses>
* b) Course Administrator <#Admin>
* c) Course Adminstrator <#il_role_34211>
*
* Address a) is returned, if the title of the object is unique, and
* if there is only one local role with the substring "Admin" defined for
* the course object.
*
* Address b) is returned, if the title of the object is not unique, but
* the role title is unique.
*
* Address c) is returned, if neither the role title nor the title of the
* course object is unique.
*
*
* Example 3: Mailbox address for a manually defined role title that can
* contains special characters in the local-part of a
* mailbox address
* --------------------------------------------------------------------
* The "Author Courses" role of the category object "Courses" is
* returned as one of the following mailbox addresses:
*
* a) "#Author Courses"@Courses
* b) Author Courses <#il_role_34234>
*
* Address a) is returned, if the title of the role is unique.
*
* Address b) is returned, if neither the role title nor the title of the
* course object is unique, or if the role title contains a quote or a
* backslash.
*
*
* @param int a role id
* @param boolean is_localize whether mailbox addresses should be localized
* @return String mailbox address or null, if role does not exist.
* @todo refactor rolf
*/
function getRoleMailboxAddress($a_role_id, $is_localize = true)
{
global $log, $lng, $ilDB;
include_once "Services/Mail/classes/class.ilMail.php";
if (ilMail::_usePearMail()) {
// Retrieve the role title and the object title.
$query = "SELECT rdat.title role_title,odat.title object_title, " . " oref.ref_id object_ref " . "FROM object_data rdat " . "JOIN rbac_fa fa ON fa.rol_id = rdat.obj_id " . "JOIN tree rtree ON rtree.child = fa.parent " . "JOIN object_reference oref ON oref.ref_id = rtree.parent " . "JOIN object_data odat ON odat.obj_id = oref.obj_id " . "WHERE rdat.obj_id = " . $this->ilDB->quote($a_role_id, 'integer') . " " . "AND fa.assign = 'y' ";
$r = $ilDB->query($query);
if (!($row = $ilDB->fetchObject($r))) {
//$log->write('class.ilRbacReview->getMailboxAddress('.$a_role_id.'): error role does not exist');
return null;
// role does not exist
}
$object_title = $row->object_title;
$object_ref = $row->object_ref;
$role_title = $row->role_title;
// In a perfect world, we could use the object_title in the
// domain part of the mailbox address, and the role title
// with prefix '#' in the local part of the mailbox address.
$domain = $object_title;
$local_part = $role_title;
// Determine if the object title is unique
$q = "SELECT COUNT(DISTINCT dat.obj_id) count " . "FROM object_data dat " . "JOIN object_reference ref ON ref.obj_id = dat.obj_id " . "JOIN tree ON tree.child = ref.ref_id " . "WHERE title = " . $this->ilDB->quote($object_title, 'text') . " " . "AND tree.tree = 1 ";
$r = $this->ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
// If the object title is not unique, we get rid of the domain.
if ($row->count > 1) {
$domain = null;
}
// If the domain contains illegal characters, we get rid of it.
//if (domain != null && preg_match('/[\[\]\\]|[\x00-\x1f]/',$domain))
// Fix for Mantis Bug: 7429 sending mail fails because of brakets
// Fix for Mantis Bug: 9978 sending mail fails because of semicolon
if ($domain != null && preg_match('/[\\[\\]\\]|[\\x00-\\x1f]|[\\x28-\\x29]|[;]/', $domain)) {
$domain = null;
}
//.........这里部分代码省略.........
示例2: validatePear
/**
*
* @param <type> $a_recipients
*/
private function validatePear($a_recipients)
{
if (ilMail::_usePearMail()) {
$this->setUsePear(true);
$tmp_names = $this->explodeRecipients($a_recipients, true);
if (is_a($tmp_names, 'PEAR_Error')) {
$this->setUsePear(false);
}
} else {
$this->setUsePear(false);
}
}
示例3: mailMembersObject
function mailMembersObject()
{
global $rbacreview, $ilErr, $ilAccess, $ilObjDataCache, $ilias;
include_once './Services/AccessControl/classes/class.ilObjRole.php';
$this->lng->loadLanguageModule('mail');
if (!isset($_GET['returned_from_mail'])) {
ilUtil::sendInfo($this->lng->txt('mail_select_recipients'));
}
$is_admin = (bool) $ilAccess->checkAccess("write", "", $this->object->getRefId());
if (!$is_admin && $this->object->getMailToMembersType() != ilCourseConstants::MAIL_ALLOWED_ALL) {
$ilErr->raiseError($this->lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
}
$this->setSubTabs('members');
$this->tabs_gui->setTabActive('members');
$this->tabs_gui->setSubTabActive('mail_members');
$this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail_members.html', 'Services/Contact');
require_once 'Services/Mail/classes/class.ilMailFormCall.php';
$this->tpl->setVariable("MAILACTION", ilMailFormCall::getLinkTarget($this, 'membersGallery', array(), array('type' => 'role', 'sig' => $this->createMailSignature())));
$this->tpl->setVariable("SELECT_ACTION", 'ilias.php?baseClass=ilmailgui&view=my_courses&search_crs=' . $this->object->getId());
$this->tpl->setVariable("MAIL_SELECTED", $this->lng->txt('send_mail_selected'));
$this->tpl->setVariable("MAIL_MEMBERS", $this->lng->txt('send_mail_members'));
$this->tpl->setVariable("MAIL_TUTOR", $this->lng->txt('send_mail_tutors'));
$this->tpl->setVariable("MAIL_ADMIN", $this->lng->txt('send_mail_admins'));
$this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath('arrow_downright.svg'));
$this->tpl->setVariable("OK", $this->lng->txt('next'));
// Display roles with user friendly mailbox addresses
$role_ids = $rbacreview->getRolesOfRoleFolder($this->object->getRefId(), false);
// Sort by relevance
$sorted_role_ids = array();
$counter = 3;
foreach ($role_ids as $role_id) {
switch (substr(ilObject::_lookupTitle($role_id), 0, 8)) {
case 'il_crs_a':
$sorted_role_ids[2] = $role_id;
break;
case 'il_crs_t':
$sorted_role_ids[1] = $role_id;
break;
case 'il_crs_m':
$sorted_role_ids[0] = $role_id;
break;
default:
$sorted_role_ids[$counter++] = $role_id;
break;
}
}
ksort($sorted_role_ids, SORT_NUMERIC);
foreach ((array) $sorted_role_ids as $role_id) {
$this->tpl->setCurrentBlock("mailbox_row");
$role_addr = $rbacreview->getRoleMailboxAddress($role_id);
// check if role title is unique. if not force use pear mail for roles
$ids_for_role_title = ilObject::_getIdsForTitle(ilObject::_lookupTitle($role_id), 'role');
if (count($ids_for_role_title) >= 2) {
$ilias->setSetting('pear_mail_enable', 1);
}
$this->tpl->setVariable("CHECK_MAILBOX", ilUtil::formCheckbox(1, 'roles[]', htmlspecialchars($role_addr)));
if (ilMail::_usePearMail() && substr($role_addr, 0, 4) != '#il_') {
// if pear mail is enabled, mailbox addresses are already localized in the language of the user
$this->tpl->setVariable("MAILBOX", $role_addr);
} else {
// if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
$this->tpl->setVariable("MAILBOX", ilObjRole::_getTranslation($ilObjDataCache->lookupTitle($role_id)) . " (" . $role_addr . ")");
}
$this->tpl->parseCurrentBlock();
}
}
示例4: mailMembersObject
public function mailMembersObject()
{
global $rbacreview, $ilObjDataCache;
include_once 'Services/AccessControl/classes/class.ilObjRole.php';
$this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail_members.html', 'Services/Contact');
$this->__setSubTabs('members');
include_once "./Services/Link/classes/class.ilLink.php";
$link_to_seminar = ilLink::_getLink($this->object->getRefId());
include_once 'Services/Mail/classes/class.ilMail.php';
require_once 'Services/Mail/classes/class.ilMailFormCall.php';
$this->tpl->setVariable("MAILACTION", ilMailFormCall::getLinkTarget($this, 'mailMembers', array(), array('type' => 'role')));
$this->tpl->setVariable('ADDITIONAL_MESSAGE_TEXT', $link_to_seminar);
$this->tpl->setVariable('IMG_ARROW', ilUtil::getImagePath('arrow_downright.png'));
$this->tpl->setVariable('OK', $this->lng->txt('ok'));
$role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
$role_ids = $rbacreview->getRolesOfRoleFolder($role_folder['ref_id'], false);
foreach ($role_ids as $role_id) {
$this->tpl->setCurrentBlock('mailbox_row');
$role_addr = $rbacreview->getRoleMailboxAddress($role_id);
$this->tpl->setVariable('CHECK_MAILBOX', ilUtil::formCheckbox(1, 'roles[]', htmlspecialchars($role_addr)));
if (ilMail::_usePearMail()) {
// if pear mail is enabled, mailbox addresses are already localized in the language of the user
$this->tpl->setVariable('MAILBOX', $role_addr);
} else {
// if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
$this->tpl->setVariable('MAILBOX', ilObjRole::_getTranslation($ilObjDataCache->lookupTitle($role_id)) . ' (' . $role_addr . ')');
}
$this->tpl->parseCurrentBlock();
}
}
示例5: mailMembersObject
/**
* Form for mail to group members
*/
function mailMembersObject()
{
global $rbacreview, $ilObjDataCache, $ilias;
include_once './Services/AccessControl/classes/class.ilObjRole.php';
$this->lng->loadLanguageModule('mail');
if (!isset($_GET['returned_from_mail'])) {
ilUtil::sendInfo($this->lng->txt('mail_select_recipients'));
}
$this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail_members.html', 'Services/Contact');
$this->setSubTabs('members');
$this->tabs_gui->setTabActive('members');
require_once 'Services/Mail/classes/class.ilMailFormCall.php';
$this->tpl->setVariable("MAILACTION", ilMailFormCall::getLinkTarget($this, 'mailMembers', array(), array('type' => 'role', 'sig' => $this->createMailSignature())));
$this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath('arrow_downright.png'));
$this->tpl->setVariable("TXT_MARKED_ENTRIES", $this->lng->txt('marked_entries'));
$this->tpl->setVariable("OK", $this->lng->txt('next'));
// Get role mailbox addresses
$role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
$role_ids = $rbacreview->getRolesOfRoleFolder($role_folder['ref_id'], false);
$role_addrs = array();
// Sort by relevance
$sorted_role_ids = array();
$counter = 2;
foreach ($role_ids as $role_id) {
switch (substr(ilObject::_lookupTitle($role_id), 0, 8)) {
case 'il_grp_a':
$sorted_role_ids[1] = $role_id;
break;
case 'il_grp_m':
$sorted_role_ids[0] = $role_id;
break;
default:
$sorted_role_ids[$counter++] = $role_id;
break;
}
}
ksort($sorted_role_ids, SORT_NUMERIC);
foreach ((array) $sorted_role_ids as $role_id) {
$this->tpl->setCurrentBlock("mailbox_row");
$role_addr = $rbacreview->getRoleMailboxAddress($role_id);
// check if role title is unique. if not force use pear mail for roles
$ids_for_role_title = ilObject::_getIdsForTitle(ilObject::_lookupTitle($role_id), 'role');
if (count($ids_for_role_title) >= 2) {
$ilias->setSetting('pear_mail_enable', 1);
}
$this->tpl->setVariable("CHECK_MAILBOX", ilUtil::formCheckbox(1, 'roles[]', htmlspecialchars($role_addr)));
if (ilMail::_usePearMail()) {
// if pear mail is enabled, mailbox addresses are already localized in the language of the user
$this->tpl->setVariable("MAILBOX", $role_addr);
} else {
// if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
$this->tpl->setVariable("MAILBOX", ilObjRole::_getTranslation($ilObjDataCache->lookupTitle($role_id)) . " (" . $role_addr . ")");
}
$this->tpl->parseCurrentBlock();
}
}