ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilMailSearchCoursesGUI Class Reference
+ Collaboration diagram for ilMailSearchCoursesGUI:

Public Member Functions

 __construct ($wsp_access_handler=null, $wsp_node_id=null)
 executeCommand ()
 mail ()
 mailCourses ()
 mailMembers ()
 adoptMembers ()
 Take over course members to addressbook.
 cancel ()
 Cancel action.
 showMembers ()
 Show course members.
 share ()

Protected Member Functions

 addPermission ($a_obj_ids)

Protected Attributes

 $mailing_allowed

Private Attributes

 $tpl = null
 $ctrl = null
 $lng = null
 $umail = null
 $abook = null

Detailed Description

Author
Jens Conze
Version
Id:
class.ilMailSearchCoursesGUI.php 50300 2014-05-23 11:02:39Z mjansen

Definition at line 16 of file class.ilMailSearchCoursesGUI.php.

Constructor & Destructor Documentation

ilMailSearchCoursesGUI::__construct (   $wsp_access_handler = null,
  $wsp_node_id = null 
)

Definition at line 27 of file class.ilMailSearchCoursesGUI.php.

References $_SESSION, $ilCtrl, $ilUser, $lng, and $tpl.

{
global $tpl, $ilCtrl, $lng, $ilUser, $rbacsystem;
$this->tpl = $tpl;
$this->ctrl = $ilCtrl;
$this->lng = $lng;
// personal workspace
$this->wsp_access_handler = $wsp_access_handler;
$this->wsp_node_id = $wsp_node_id;
// check if current user may send mails
include_once "Services/Mail/classes/class.ilMail.php";
$mail = new ilMail($_SESSION["AccountId"]);
$this->mailing_allowed = $rbacsystem->checkAccess('internal_mail',$mail->getMailObjectReferenceId());
$this->ctrl->saveParameter($this, "mobj_id");
$this->ctrl->saveParameter($this, "ref");
$this->umail = new ilFormatMail($ilUser->getId());
$this->abook = new ilAddressbook($ilUser->getId());
}

Member Function Documentation

ilMailSearchCoursesGUI::addPermission (   $a_obj_ids)
protected

Definition at line 587 of file class.ilMailSearchCoursesGUI.php.

References ilUtil\sendSuccess().

Referenced by share().

{
if(!is_array($a_obj_ids))
{
$a_obj_ids = array($a_obj_ids);
}
$existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
$added = false;
foreach($a_obj_ids as $object_id)
{
if(!in_array($object_id, $existing))
{
$added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
}
}
if($added)
{
ilUtil::sendSuccess($this->lng->txt("wsp_share_success"), true);
}
$this->ctrl->redirectByClass("ilworkspaceaccessgui", "share");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMailSearchCoursesGUI::adoptMembers ( )

Take over course members to addressbook.

Definition at line 241 of file class.ilMailSearchCoursesGUI.php.

References $_GET, $_POST, $lng, ilObjUser\_lookupEmail(), ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ilObjUser\_lookupPref(), ilUtil\sendInfo(), and showMembers().

{
global $lng;
$ids = ((int)$_GET['search_members']) ? array((int)$_GET['search_members']) : $_POST['search_members'];
if ((int)$ids && !is_array($ids))
$ids = array((int)$ids);
if ($ids )
{
$members = array();
foreach ($ids as $member)
{
$login = ilObjUser::_lookupLogin($member);
if (!$this->abook->checkEntry($login))
{
$name = ilObjUser::_lookupName($member);
$email = '';
if(ilObjUser::_lookupPref((int)$member, 'public_email') == 'y')
{
$email = ilObjUser::_lookupEmail($member);
}
$this->abook->addEntry(
$login,
$name["firstname"],
$name["lastname"],
$email
);
}
}
ilUtil::sendInfo($lng->txt("mail_members_added_addressbook"));
}
else
{
ilUtil::sendInfo($lng->txt("mail_select_one_entry"));
}
$this->showMembers();
}

+ Here is the call graph for this function:

ilMailSearchCoursesGUI::cancel ( )

Cancel action.

Definition at line 286 of file class.ilMailSearchCoursesGUI.php.

References $_GET.

{
if ($_GET["view"] == "mycourses" &&
$_GET["ref"] == "mail")
{
$this->ctrl->returnToParent($this);
}
else
{
$this->showMyCourses();
}
}
ilMailSearchCoursesGUI::executeCommand ( )

Definition at line 51 of file class.ilMailSearchCoursesGUI.php.

References $cmd.

{
$forward_class = $this->ctrl->getNextClass($this);
switch($forward_class)
{
default:
if (!($cmd = $this->ctrl->getCmd()))
{
$cmd = "showMyCourses";
}
$this->$cmd();
break;
}
return true;
}
ilMailSearchCoursesGUI::mail ( )

Definition at line 68 of file class.ilMailSearchCoursesGUI.php.

References $_GET, $_POST, $ilUser, $lng, mailCourses(), mailMembers(), ilUtil\sendInfo(), and showMembers().

{
global $ilUser, $lng;
if ($_GET["view"] == "mycourses")
{
$ids = ((int)$_GET['search_crs']) ? array((int)$_GET['search_crs']) : $_POST['search_crs'];
if ($ids)
{
$this->mailCourses();
}
else
{
ilUtil::sendInfo($lng->txt("mail_select_course"));
$this->showMyCourses();
}
}
else if ($_GET["view"] == "crs_members")
{
$ids = ((int)$_GET['search_members']) ? array((int)$_GET['search_members']) : $_POST['search_members'];
if ($ids)
{
$this->mailMembers();
}
else
{
ilUtil::sendInfo($lng->txt("mail_select_one_entry"));
$this->showMembers();
}
}
else
{
$this->showMyCourses();
}
}

+ Here is the call graph for this function:

ilMailSearchCoursesGUI::mailCourses ( )

Definition at line 104 of file class.ilMailSearchCoursesGUI.php.

References $_GET, $_POST, $ilUser, $lng, $ref_id, ilObject\_getAllReferences(), and ilUtil\redirect().

Referenced by mail().

{
global $ilUser, $lng, $rbacreview;
$members = array();
if (!is_array($old_mail_data = $this->umail->getSavedData()))
{
$this->umail->savePostData(
$ilUser->getId(),
array(),
"",
"",
"",
"",
"",
"",
"",
""
);
}
require_once './Services/Object/classes/class.ilObject.php';
$ids = ((int)$_GET['search_crs']) ? array((int)$_GET['search_crs']) : $_POST['search_crs'];
foreach ($ids as $crs_id)
{
$ref_ids = ilObject::_getAllReferences($crs_id);
foreach ($ref_ids as $ref_id)
{
$roles = $rbacreview->getAssignableChildRoles($ref_id);
foreach ($roles as $role)
{
if (substr($role['title'], 0, 14) == 'il_crs_member_' ||
substr($role['title'], 0, 13) == 'il_crs_tutor_' ||
substr($role['title'], 0, 13) == 'il_crs_admin_')
{
if(isset($old_mail_data['rcp_to']) &&
trim($old_mail_data['rcp_to']) != '')
{
$rcpt = $rbacreview->getRoleMailboxAddress($role['obj_id']);
if(!$this->umail->doesRecipientStillExists($rcpt, $old_mail_data['rcp_to']))
// does not work if Pear is enabled and Mailbox Address contain special chars!!
// array_push($members, $rcpt);
// FIX for Mantis: 7523, 8061
array_push($members, '#'.$role['title']);
unset($rcpt);
}
else
{
// does not work if Pear is enabled and Mailbox Address contain special chars!!
// array_push($members, $rbacreview->getRoleMailboxAddress($role['obj_id']));
// FIX for Mantis: 7523, 8061
array_push($members, '#'.$role['title']);
}
}
}
}
}
if(count($members))
$mail_data = $this->umail->appendSearchResult($members, 'to');
else
$mail_data = $this->umail->getSavedData();
$this->umail->savePostData(
$mail_data["user_id"],
$mail_data["attachments"],
$mail_data["rcp_to"],
$mail_data["rcp_cc"],
$mail_data["rcp_bcc"],
$mail_data["m_type"],
$mail_data["m_email"],
$mail_data["m_subject"],
$mail_data["m_message"],
$mail_data["use_placeholders"]
);
#$this->ctrl->returnToParent($this);
ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMailSearchCoursesGUI::mailMembers ( )

Definition at line 190 of file class.ilMailSearchCoursesGUI.php.

References $_GET, $_POST, $ilUser, ilObjUser\_lookupLogin(), and ilUtil\redirect().

Referenced by mail().

{
global $ilUser;
$members = array();
if (!is_array($this->umail->getSavedData()))
{
$this->umail->savePostData(
$ilUser->getId(),
array(),
"",
"",
"",
"",
"",
"",
"",
""
);
}
$ids = ((int)$_GET['search_members']) ? array((int)$_GET['search_members']) : $_POST['search_members'];
foreach ($ids as $member)
{
$login = ilObjUser::_lookupLogin($member);
array_push($members, $login);
}
$mail_data = $this->umail->appendSearchResult($members,"to");
$this->umail->savePostData(
$mail_data["user_id"],
$mail_data["attachments"],
$mail_data["rcp_to"],
$mail_data["rcp_cc"],
$mail_data["rcp_bcc"],
$mail_data["m_type"],
$mail_data["m_email"],
$mail_data["m_subject"],
$mail_data["m_message"],
$mail_data["use_placeholders"]
);
#$this->ctrl->returnToParent($this);
ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMailSearchCoursesGUI::share ( )

Definition at line 551 of file class.ilMailSearchCoursesGUI.php.

References $_GET, $_REQUEST, $lng, addPermission(), ilUtil\sendInfo(), and showMembers().

{
global $lng;
if ($_GET["view"] == "mycourses")
{
$ids = $_REQUEST["search_crs"];
if (sizeof($ids))
{
$this->addPermission($ids);
}
else
{
ilUtil::sendInfo($lng->txt("mail_select_course"));
$this->showMyCourses();
}
}
else if ($_GET["view"] == "crs_members")
{
$ids = $_REQUEST["search_members"];
if (sizeof($ids))
{
$this->addPermission($ids);
}
else
{
ilUtil::sendInfo($lng->txt("mail_select_one_entry"));
$this->showMembers();
}
}
else
{
$this->showMyCourses();
}
}

+ Here is the call graph for this function:

ilMailSearchCoursesGUI::showMembers ( )

Show course members.

Definition at line 443 of file class.ilMailSearchCoursesGUI.php.

References $_GET, $_POST, $_SESSION, $ilUser, $lng, ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ilObjUser\_lookupPref(), ilUtil\_sortIds(), ilObjectFactory\getInstanceByObjId(), and ilUtil\sendInfo().

Referenced by adoptMembers(), mail(), and share().

{
global $lng, $ilUser, $ilObjDataCache;
include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
if ($_GET["search_crs"] != "")
{
$_POST["search_crs"] = explode(",", $_GET["search_crs"]);
$_GET["search_crs"] = "";
}
else if ($_SESSION["search_crs"] != "")
{
$_POST["search_crs"] = explode(",", $_SESSION["search_crs"]);
$_SESSION["search_crs"] = "";
}
if(is_array($_POST['search_crs']))
{
$_POST['search_crs'] = array_filter(array_map('intval', $_POST['search_crs']));
}
if (!is_array($_POST["search_crs"]) ||
count($_POST["search_crs"]) == 0)
{
ilUtil::sendInfo($lng->txt("mail_select_course"));
$this->showMyCourses();
}
else
{
foreach($_POST['search_crs'] as $crs_id)
{
if($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED)
{
unset($_POST['search_crs']);
ilUtil::sendInfo($lng->txt('mail_crs_list_members_not_available_for_at_least_one_crs'));
return $this->showMyCourses();
}
unset($oTmpCrs);
}
$this->tpl->setTitle($this->lng->txt("mail_addressbook"));
$this->ctrl->setParameter($this, "view", "crs_members");
if ($_GET["ref"] != "") $this->ctrl->setParameter($this, "ref", $_GET["ref"]);
if (is_array($_POST["search_crs"])) $this->ctrl->setParameter($this, "search_crs", implode(",", $_POST["search_crs"]));
$this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
$this->ctrl->clearParameters($this);
$lng->loadLanguageModule('crs');
include_once 'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
$context = $_GET["ref"] ? $_GET["ref"] : "mail";
$table = new ilMailSearchCoursesMembersTableGUI($this, 'crs', $context);
$table->setId('show_crs_mmbrs_tbl');
$tableData = array();
$searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
foreach($_POST["search_crs"] as $crs_id)
{
$members_obj = ilCourseParticipants::_getinstanceByObjId($crs_id);
$tmp_members = $members_obj->getParticipants();
$course_members = ilUtil::_sortIds($tmp_members, 'usr_data', 'lastname', 'usr_id');
foreach ($course_members as $member)
{
$tmp_usr = new ilObjUser($member);
if($tmp_usr->checkTimeLimit()== false || $tmp_usr->getActive() == false )
{
unset($tmp_usr);
continue;
}
unset($tmp_usr);
$name = ilObjUser::_lookupName($member);
$login = ilObjUser::_lookupLogin($member);
$fullname = "";
if(in_array(ilObjUser::_lookupPref($member, 'public_profile'), array("g", 'y')))
$fullname = $name['lastname'].', '.$name['firstname'];
$rowData = array(
'members_id' => $member,
'members_login' => $login,
'members_name' => $fullname,
'members_crs_grp' => $ilObjDataCache->lookupTitle($crs_id),
'members_in_addressbook' => $this->abook->checkEntryByLogin($login) ? $lng->txt("yes") : $lng->txt("no"),
'search_crs' => $crs_id
);
$tableData[] = $rowData;
}
}
$table->setData($tableData);
if (count($tableData))
{
$searchTpl->setVariable("TXT_MARKED_ENTRIES",$lng->txt("marked_entries"));
}
$searchTpl->setVariable('TABLE', $table->getHtml());
$this->tpl->setContent($searchTpl->get());
if($_GET["ref"] != "wsp")
{
$this->tpl->show();
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilMailSearchCoursesGUI::$abook = null
private

Definition at line 23 of file class.ilMailSearchCoursesGUI.php.

ilMailSearchCoursesGUI::$ctrl = null
private

Definition at line 19 of file class.ilMailSearchCoursesGUI.php.

ilMailSearchCoursesGUI::$lng = null
private
ilMailSearchCoursesGUI::$mailing_allowed
protected

Definition at line 25 of file class.ilMailSearchCoursesGUI.php.

ilMailSearchCoursesGUI::$tpl = null
private

Definition at line 18 of file class.ilMailSearchCoursesGUI.php.

Referenced by __construct().

ilMailSearchCoursesGUI::$umail = null
private

Definition at line 22 of file class.ilMailSearchCoursesGUI.php.


The documentation for this class was generated from the following file: