public function save($form_data, $additional = array())
 {
     $mail = new cs_mail();
     $mail->set_from_email($this->_environment->getCurrentUser()->getEmail());
     $mail->set_from_name($this->_environment->getCurrentUser()->getFullName());
     $roomId = null;
     if (isset($additional['roomId']) && !empty($additional['roomId'])) {
         $roomId = $additional['roomId'];
     }
     if (!empty($form_data['reciever'])) {
         $recipients = implode(', ', $form_data['reciever']);
         $mail->set_to($recipients);
     } else {
         $list = $this->getRecieverList($roomId);
         if (count($list) == 1) {
             $mail->set_to($list[0]['value']);
         } else {
             //no reciever checked
             $this->_popup_controller->setErrorReturn(112, 'no reciever checked');
         }
     }
     $context_item = $this->_environment->getCurrentContextItem();
     $mail->set_message($form_data['mailcontent']);
     $mail->set_subject($form_data['subject']);
     $success = $mail->send();
     if ($success) {
         $this->_popup_controller->setSuccessfullDataReturn('mail send successfully');
     } else {
         //TODO: Error handling
         pr($mail);
     }
 }
Ejemplo n.º 2
0
                     if ( $moderator->getPublishMaterialWantMail() == 'yes' ) {
                        $mailSendTo .= $moderator->getFullName().LF;
                     }
                     $moderator = $modList->getNext();
                  }

                  // Send mails // Warum werden die einzeln verschickt ???
                  $moderator = $modList->getFirst();
                  $translator = $environment->getTranslationObject();
                  while ( $moderator ) {
                     if ( $moderator->getPublishMaterialWantMail() == 'yes' ) {
                        include_once('classes/cs_mail.php');
                        $mail = new cs_mail();
                        $sender = $material_item->getModificatorItem();
                        $mail->set_from_name($sender->getFullName());
                        $mail->set_from_email($sender->getEMail());
                        $mail->set_reply_to_name($sender->getFullName());
                        $mail->set_reply_to_email($sender->getEMail());
                        $mail->set_to($moderator->getEMail());
                        $language = $moderator->getLanguage();
                        $translator->setSelectedLanguage($language);
                        $mail_subject = $translator->getMessage('ADMIN_MAIL_MATERIAL_SHOULD_BE_WORLDPUBLIC_SUBJECT',$context_item->getTitle());
                        $mail_body = $translator->getMessage('MAIL_AUTO',$translator->getDateInLang(getCurrentDateTimeInMySQL()),$translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                        $mail_body.= "\n\n";
                        $mail_body.= $translator->getMessage('ADMIN_MAIL_MATERIAL_SHOULD_BE_WORLDPUBLIC_BODY',$material_item->getTitle(),$context_item->getTitle(),$sender->getFullName());
                        $mail_body.= "\n\n";
                        $mail_body.= $translator->getMessage('MAIL_SEND_TO',$mailSendTo);
                        $mail_body.= "\n";
                        $url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?cid='.$environment->getCurrentContextID().'&mod=material_admin&fct=index&iid='.$material_item->getItemID().'&selstatus=1';
                        $mail_body.= $url;
                        $mail->set_subject($mail_subject);
Ejemplo n.º 3
0
 							$body .= LF.LF;
 						}
 						$body .= $translator->getMessage('MAIL_SEND_TO',$recipients);
 						$body .= LF;
 						if ($check_message == 'YES') {
 							$body .= $translator->getMessage('MAIL_USER_FREE_LINK').LF;
 							$body .= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?cid='.$current_item_id.'&mod=account&fct=index'.'&selstatus=1';
 						} else {
 							$body .= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?cid='.$current_item_id;
 						}
 						$mail = new cs_mail();
 						$mail->set_to(implode(',',$email_array));
 						$server_item = $environment->getServerItem();
 						$default_sender_address = $server_item->getDefaultSenderAddress();
 						if (!empty($default_sender_address)) {
 							$mail->set_from_email($default_sender_address);
 						} else {
 							$mail->set_from_email('@');
 						}
 						$current_context = $environment->getCurrentContextItem();
 						$mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE',$current_context->getTitle()));
 						$mail->set_from_name($room_item->getTitle());
 						$mail->set_reply_to_name($user_item->getFullname());
 						$mail->set_reply_to_email($user_item->getEmail());
 						$mail->set_subject($subject);
 						$mail->set_message($body);
 						$mail->send();
 						$translator->setSelectedLanguage($old_lang);
 					}
 				}
 			}
Ejemplo n.º 4
0
            while ($task_item) {
               if ($task_item->getStatus() == 'REQUEST' and ($task_item->getTitle() == 'TASK_USER_REQUEST' or $task_item->getTitle() == 'TASK_PROJECT_MEMBER_REQUEST')) {
                  $task_item->setStatus('CLOSED');
                  $task_item->save();
                  $task_title = $task_item->getTitle(); // needed for email
               }
               $task_item = $task_list->getNext();
            }
         }
      }

      if (empty($error_number)) {
         // send mail to user
         $mail = new cs_mail();
         $mail->set_to($user->getEmail());
         $mail->set_from_email($current_user->getEmail());
         $mail->set_from_name($current_user->getFullname());
         $mail->set_subject($subject);
         $mail->set_message($body);
         $mail->send();

         // back to index pages
         $history = $session->getValue('history');
         redirect($history[0]['context'],$history[0]['module'],$history[0]['function'],$history[0]['parameter']);
      } else {
         $error_string .= $translator->getMessage('COMMON_ERROR_SAVE_TASK').'<br />';
      }
   } else {
      $error_string .= $translator->getMessage('USER_ERROR_SAVE').'<br />';
   }
   $params = array();
 public function save($form_data, $additional = array())
 {
     if ($this->_popup_controller->checkFormData()) {
         $groupManager = $this->_environment->getGroupManager();
         $currentContext = $this->_environment->getCurrentContextItem();
         $translator = $this->_environment->getTranslationObject();
         $recipients = array();
         $recipientsBCC = array();
         $mail = array();
         $nameArray = array();
         foreach ($form_data["groups"] as $groupId) {
             $groupItem = $groupManager->getItem($groupId);
             $userList = $groupItem->getMemberItemList();
             $nameArray[] = $groupItem->getTitle();
             $userItem = $userList->getFirst();
             while ($userItem) {
                 if ($userItem->isUser()) {
                     if ($userItem->isEmailVisible()) {
                         $recipients[] = $userItem->getFullName() . " <" . $userItem->getEmail() . ">";
                     } else {
                         $recipientsBCC[] = $userItem->getFullName() . " <" . $userItem->getEmail() . ">";
                     }
                 }
                 $userItem = $userList->getNext();
             }
         }
         $recipients = array_unique($recipients);
         $recipientsBCC = array_unique($recipientsBCC);
         $serverItem = $this->_environment->getServerItem();
         $defaultSenderAddress = $serverItem->getDefaultSenderAddress();
         $currentUser = $this->_environment->getCurrentUser();
         $mail["from_name"] = $currentUser->getFullName();
         $mail["from_email"] = $currentUser->getEmail();
         $mail["reply_to_name"] = $currentUser->getFullName();
         $mail["reply_to_email"] = $currentUser->getEmail();
         $mail["to"] = implode(",", $recipients);
         $mail["subject"] = $form_data["subject"];
         $mail["message"] = $form_data["mailcontent"];
         $email = new cs_mail();
         $email->set_from_name($mail["from_name"]);
         $email->set_from_email($mail["from_email"]);
         $email->set_reply_to_name($mail["reply_to_name"]);
         $email->set_reply_to_email($mail["reply_to_email"]);
         $email->set_to($mail["to"]);
         $email->set_subject($mail["subject"]);
         if ($form_data["copytosender"] === "true") {
             $email->set_cc_to($currentUser->getEmail());
         }
         if (!empty($recipientsBCC)) {
             $email->set_bcc_to(implode(",", $recipientsBCC));
         }
         $addMessage = "";
         $context_title = str_ireplace('&amp;', '&', $currentContext->getTitle());
         if (sizeof($form_data["groups"]) == 1) {
             $addMessage = $translator->getMessage("RUBRIC_EMAIL_ADDED_BODY_PROJECT_GROUP_S", $context_title, $nameArray[0]);
         } else {
             $addMessage = $translator->getMessage("RUBRIC_EMAIL_ADDED_BODY_PROJECT_GROUP_PL", $context_title, implode("," . LF, $nameArray));
         }
         if (!empty($addMessage)) {
             $addMessage = LF . LF . "---" . LF . $addMessage;
         }
         $email->set_message($mail["message"] . $addMessage);
         if ($email->send()) {
             $this->_popup_controller->setSuccessfullDataReturn(array());
         } else {
             $this->_popup_controller->setErrorReturn("113", "error processing mails", $email->getErrorArray());
         }
     }
 }
Ejemplo n.º 6
0
 public function sendMailDeleteInfoToModeration()
 {
     $translator = $this->_environment->getTranslationObject();
     $default_language = 'de';
     $toggle_archive = false;
     if ($this->_environment->isArchiveMode()) {
         $toggle_archive = true;
         $this->_environment->toggleArchiveMode();
     }
     $server_item = $this->_environment->getServerItem();
     $default_sender_address = $server_item->getDefaultSenderAddress();
     if (empty($default_sender_address)) {
         $default_sender_address = '@';
     }
     $current_portal = $this->getContextItem();
     $current_user = $this->_environment->getCurrentUserItem();
     $fullname = $current_user->getFullname();
     if (empty($fullname)) {
         $mod_list = $current_portal->getContactModeratorList();
         if (empty($mod_list) or $mod_list->isNotEmpty()) {
             $mod_list = $current_portal->getContactModeratorList();
         }
         if (!empty($mod_list) and $mod_list->isNotEmpty()) {
             $current_user = $mod_list->getFirst();
         }
         unset($mod_list);
     }
     if ($toggle_archive) {
         $this->_environment->toggleArchiveMode();
     }
     unset($toggle_archive);
     $moderator_list = $this->getModeratorList();
     // get moderators
     $receiver_array = array();
     $moderator_name_array = array();
     if ($moderator_list->isNotEmpty()) {
         $mod_item = $moderator_list->getFirst();
         while ($mod_item) {
             if ($mod_item->getOpenRoomWantMail() == 'yes') {
                 $language = $this->getLanguage();
                 if ($language == 'user') {
                     $language = $mod_item->getLanguage();
                     if ($language == 'browser') {
                         $language = $default_language;
                     }
                 }
                 $receiver_array[$language][] = $mod_item->getEmail();
                 $moderator_name_array[] = $mod_item->getFullname();
             }
             $mod_item = $moderator_list->getNext();
         }
     }
     // now email information
     foreach ($receiver_array as $key => $value) {
         $save_language = $translator->getSelectedLanguage();
         $translator->setSelectedLanguage($key);
         $subject = '';
         $subject .= $translator->getMessage('PROJECT_MAIL_SUBJECT_DELETE_INFO', str_ireplace('&amp;', '&', $this->getTitle()), $current_portal->getDaysSendMailBeforeDeletingRooms());
         $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
         $body .= LF . LF;
         if ($this->isCommunityRoom()) {
             $body .= $translator->getMessage('COMMUNITY_MAIL_BODY_DELETE_INFO', $this->getTitle(), $current_portal->getDaysSendMailBeforeDeletingRooms(), $current_portal->getDaysUnusedBeforeDeletingRooms() - $current_portal->getDaysSendMailBeforeDeletingRooms());
         } else {
             $body .= $translator->getMessage('PROJECT_MAIL_BODY_DELETE_INFO', $this->getTitle(), $current_portal->getDaysSendMailBeforeDeletingRooms(), $current_portal->getDaysUnusedBeforeDeletingRooms() - $current_portal->getDaysSendMailBeforeDeletingRooms());
         }
         $room_change_action = $translator->getMessage('PROJECT_MAIL_BODY_ACTION_DELETE_INFO');
         $body .= LF . LF;
         $body .= $translator->getMessage('PROJECT_MAIL_BODY_INFORMATION', str_ireplace('&amp;', '&', $this->getTitle()), $current_user->getFullname(), $room_change_action);
         $url_to_portal = '';
         if (!empty($current_portal)) {
             $url_to_portal = $current_portal->getURL();
         }
         $c_commsy_cron_path = $this->_environment->getConfiguration('c_commsy_cron_path');
         if (isset($c_commsy_cron_path)) {
             $url = $c_commsy_cron_path . 'commsy.php?cid=';
         } elseif (!empty($url_to_portal)) {
             $c_commsy_domain = $this->_environment->getConfiguration('c_commsy_domain');
             if (stristr($c_commsy_domain, 'https://')) {
                 $url = 'https://';
             } else {
                 $url = 'http://';
             }
             $url .= $url_to_portal;
             $file = 'commsy.php';
             $c_single_entry_point = $this->_environment->getConfiguration('c_single_entry_point');
             if (!empty($c_single_entry_point)) {
                 $file = $c_single_entry_point;
             }
             $url .= '/' . $file . '?cid=';
         } else {
             $file = $_SERVER['PHP_SELF'];
             $file = str_replace('cron', 'commsy', $file);
             $url = 'http://' . $_SERVER['HTTP_HOST'] . $file . '?cid=';
         }
         $url .= $this->getItemID();
         $body .= LF . $url;
         if ($this->isProjectRoom()) {
             $community_name_array = array();
             $community_list = $this->getCommunityList();
             if ($community_list->isNotEmpty()) {
                 $community_item = $community_list->getFirst();
                 while ($community_item) {
                     $community_name_array[] = $community_item->getTitle();
                     unset($community_item);
                     $community_item = $community_list->getNext();
                 }
             }
             unset($community_list);
             if (!empty($community_name_array)) {
                 $body .= LF . LF;
                 $body .= $translator->getMessage('PROJECT_MAIL_BODY_COMMUNITIY_ROOMS') . LF;
                 $body .= implode(LF, $community_name_array);
             }
         }
         $body .= LF . LF;
         $body .= $translator->getMessage('MAIL_SEND_TO', implode(LF, $moderator_name_array));
         $body .= LF . LF;
         if ($this->isCommunityRoom()) {
             $body .= $translator->getMessage('MAIL_SEND_WHY_COMMUNITY', $this->getTitle());
         } else {
             $body .= $translator->getMessage('MAIL_SEND_WHY_PROJECT', $this->getTitle());
         }
         // send email
         include_once 'classes/cs_mail.php';
         $mail = new cs_mail();
         $mail->set_to(implode(',', $value));
         $mail->set_from_email($default_sender_address);
         if (isset($current_portal)) {
             $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $current_portal->getTitle()));
         } else {
             $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $room_item->getTitle()));
         }
         $mail->set_reply_to_name($current_user->getFullname());
         $mail->set_reply_to_email($current_user->getEmail());
         $mail->set_subject($subject);
         $mail->set_message($body);
         $retour = $mail->send();
         unset($mail);
         $translator->setSelectedLanguage($save_language);
         unset($save_language);
     }
     return $retour;
 }
Ejemplo n.º 7
0
	      	$body .= LF.LF;
	      	$body .= $translator->getEmailMessage('MAIL_BODY_CIAO',$current_user->getFullname(),$context_item->getTitle());
	      } else {
	      	include_once('functions/error_functions.php');trigger_error('lost change status',E_USER_ERROR);
	      }
	      $url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?cid='.$environment->getCurrentContextID();
	      $body .= LF.LF.$url;
	      $_POST['content'] = $body;
      }

      if ( !empty($command) AND isOption($command,$translator->getMessage('MAIL_SEND_BUTTON')) ) {
         $correct = $form->check();
         if ( $correct ) {
            include_once('classes/cs_mail.php');
            $mail = new cs_mail();
            $mail->set_from_email($_POST['senderAddress']);
            $mail->set_from_name($_POST['senderName']);
            $mail->set_reply_to_email($_POST['senderAddress']);
            $mail->set_reply_to_name($_POST['senderName']);
            $mail->set_subject($_POST['subject']);
            $mail->set_message($_POST['content']);
            if ( is_array($_POST['receivers']) ) {
               $receivers = implode(",",$_POST['receivers']);
            } else {
               $receivers = $_POST['receivers'];
            }
            $mail->set_to($receivers);
            $mail->send();

            $mail_obj->goBackLink();
         }
Ejemplo n.º 8
0
function write_email_to_user($user_item, $room, $password_generated = false, $temp_account_password = ''){
   global $environment;
   $room_manager = $environment->getRoomManager();
   $room_item = $room_manager->getItem($room);

   // get contact moderator (TBD) now first moderator
   $user_list = $room_item->getModeratorList();
   $contact_moderator = $user_list->getFirst();

   // change context
   $translator = $environment->getTranslationObject();
   $translator->setEmailTextArray($room_item->getEmailTextArray());
   if ($room_item->isProjectRoom()) {
      $translator->setContext('project');
   } else {
      $translator->setContext('community');
   }
   $save_language = $translator->getSelectedLanguage();
   $translator->setSelectedLanguage($room_item->getLanguage());

   // Datenschutz
   if($environment->getCurrentPortalItem()->getHideAccountname()){
   	$userid = 'XXX '.$translator->getMessage('COMMON_DATASECURITY');
   } else {
   	$userid = $user->getUserID();
   }
   
   // email texts
   $subject = $translator->getMessage('MAIL_SUBJECT_USER_STATUS_USER',$room_item->getTitle());
   $body  = $translator->getMessage('MAIL_AUTO',$translator->getDateInLang(getCurrentDateTimeInMySQL()),$translator->getTimeInLang(getCurrentDateTimeInMySQL()));
   $body .= LF.LF;
   $body .= $translator->getEmailMessage('MAIL_BODY_HELLO',$user_item->getFullname());
   $body .= LF.LF;
   $body .= $translator->getEmailMessage('MAIL_BODY_USER_STATUS_USER',$userid,$room_item->getTitle());
   $body .= LF.LF;
   if($password_generated){
      $body .= $translator->getMessage('CONFIGURATION_AUTOACCOUNTS_PASSWORD_GENERATED',$temp_account_password);
      $body .= LF.LF;
   }
   $body .= $translator->getEmailMessage('MAIL_BODY_CIAO',$contact_moderator->getFullname(),$room_item->getTitle());
   $body .= LF.LF;
   $body .= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?cid='.$environment->getCurrentContextID();

   // send mail to user
   include_once('classes/cs_mail.php');
   $mail = new cs_mail();
   $mail->set_to($user_item->getEmail());
   $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE',$room_item->getTitle()));
   $server_item = $environment->getServerItem();
   $default_sender_address = $server_item->getDefaultSenderAddress();
   if (!empty($default_sender_address)) {
      $mail->set_from_email($default_sender_address);
   } else {
      $mail->set_from_email('@');
   }
   $mail->set_reply_to_email($contact_moderator->getEmail());
   $mail->set_reply_to_name($contact_moderator->getFullname());
   $mail->set_subject($subject);
   $mail->set_message($body);
   $mail->send();
}
Ejemplo n.º 9
0
 public function _cronCheckPasswordExpiredSoon()
 {
     require_once 'functions/curl_functions.php';
     // Datenschutz
     $time_start = getmicrotime();
     $cron_array = array();
     $cron_array['title'] = 'Password expire soon';
     $cron_array['description'] = 'check if a password is expired soon';
     $user_manager = $this->_environment->getUserManager();
     $translator = $this->_environment->getTranslationObject();
     $portal_list = $this->getPortalList();
     // send mail to user if password expires soon
     // if password is expired set new random password
     if ($portal_list->isNotEmpty()) {
         $portal_item = $portal_list->getFirst();
         while ($portal_item) {
             if ($portal_item->isPasswordExpirationActive()) {
                 if ($user_manager->getCountUserPasswordExpiredSoonByContextID($portal_item->getItemID(), $portal_item) > 0) {
                     $expired_user_array = $user_manager->getUserPasswordExpiredSoonByContextID($portal_item->getItemID(), $portal_item);
                     require_once 'classes/cs_mail.php';
                     foreach ($expired_user_array as $user) {
                         $auth_manager = $this->_environment->getAuthSourceManager();
                         $auth_item = $auth_manager->getItem($user->getAuthSource());
                         if ($auth_item->getSourceType() == 'MYSQL') {
                             //                            if (!$user->isPasswordExpiredEmailSend()){
                             $mail = new cs_mail();
                             $mod_contact_list = $portal_item->getContactModeratorList();
                             $mod_user_first = $mod_contact_list->getFirst();
                             $mail->set_from_email($mod_user_first->getEmail());
                             $mail->set_from_name($mod_user_first->getFullname());
                             if ($user->getPasswordExpireDate() > getCurrentDateTimeInMySQL()) {
                                 $start_date = new DateTime(getCurrentDateTimeInMySQL());
                                 $since_start = $start_date->diff(new DateTime($user->getPasswordExpireDate()));
                                 $days = $since_start->days;
                                 if ($days == 0) {
                                     $days = 1;
                                 }
                             }
                             $subject = $translator->getMessage('EMAIL_PASSWORD_EXPIRATION_SOON_SUBJECT', $portal_item->getTitle(), $days);
                             $to = $user->getEmail();
                             $to_name = $user->getFullname();
                             if (!empty($to_name)) {
                                 $to = $to_name . " <" . $to . ">";
                             }
                             // link
                             $url_to_portal = '';
                             if (!empty($portal_item)) {
                                 $url_to_portal = $portal_item->getURL();
                             }
                             $c_commsy_cron_path = $this->_environment->getConfiguration('c_commsy_cron_path');
                             if (isset($c_commsy_cron_path)) {
                                 $link = $c_commsy_cron_path;
                             } elseif (!empty($url_to_portal)) {
                                 $c_commsy_domain = $this->_environment->getConfiguration('c_commsy_domain');
                                 if (stristr($c_commsy_domain, 'https://')) {
                                     $link = 'https://';
                                 } else {
                                     $link = 'http://';
                                 }
                                 $link .= $url_to_portal;
                                 $file = 'commsy.php';
                                 $c_single_entry_point = $this->_environment->getConfiguration('c_single_entry_point');
                                 if (!empty($c_single_entry_point)) {
                                     $file = $c_single_entry_point;
                                 }
                                 $link .= '/' . $file;
                             } else {
                                 $file = $_SERVER['PHP_SELF'];
                                 $file = str_replace('cron', 'commsy', $file);
                                 $link = 'http://' . $_SERVER['HTTP_HOST'] . $file;
                             }
                             $link .= '?cid=' . $portal_item->getItemID() . '&mod=home&fct=index';
                             // link
                             //content
                             $email_text_array = $portal_item->getEmailTextArray();
                             $translator->setEmailTextArray($portal_item->getEmailTextArray());
                             $body = $translator->getEmailMessage('MAIL_BODY_HELLO', $user->getFullName());
                             $body .= "\n\n";
                             $body .= $translator->getEmailMessage('EMAIL_BODY_PASSWORD_EXPIRATION_SOON', $days, $link);
                             $body .= "\n\n";
                             $body .= $translator->getEmailMessage('MAIL_BODY_CIAO', $mod_user_first->getFullName(), $portal_item->getTitle());
                             $body .= "\n\n";
                             $body .= $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                             $context_item = $this->_environment->getServerItem();
                             $translator->setEmailTextArray($context_item->getEmailTextArray());
                             $mail->set_subject($subject);
                             $mail->set_message($body);
                             $mail->set_to($to);
                             if ($mail->send()) {
                                 $cron_array['success'] = true;
                                 $cron_array['success_text'] = 'send mail to ' . $to;
                             } else {
                                 $cron_array['success'] = false;
                                 $cron_array['success_text'] = 'failed send mail to ' . $to;
                             }
                         }
                     }
                     $time_end = getmicrotime();
                     $time = round($time_end - $time_start, 0);
                     $cron_array['time'] = $time;
                 } else {
                     $cron_array['success'] = true;
                     $cron_array['success_text'] = 'nothing to do';
                 }
             } else {
                 $cron_array['success'] = true;
                 $cron_array['success_text'] = 'nothing to do';
             }
             unset($portal_item);
             $portal_item = $portal_list->getNext();
         }
     }
     return $cron_array;
 }
Ejemplo n.º 10
0
 function _cronTemporaryLoginAs()
 {
     $time_start = getmicrotime();
     $cron_array = array();
     $cron_array['title'] = 'Temporary login as expired';
     $cron_array['description'] = 'check if a temporary login is expired';
     $success = false;
     $translator = $this->_environment->getTranslationObject();
     $user_manager = $this->_environment->getUserManager();
     $user_list = $user_manager->getUserTempLoginExpired();
     require_once 'classes/cs_mail.php';
     if (!empty($user_list)) {
         foreach ($user_list as $user) {
             if ($user->getTimestampForLoginAs() <= getCurrentDateTimeInMySQL()) {
                 $success = true;
                 // unset login as timestamp
                 $user->unsetDaysForLoginAs();
                 $user->save();
                 // send mail
                 $mail = new cs_mail();
                 $subject = $translator->getMessage('EMAIL_LOGIN_EXPIRATION_SUBJECT', $this->getTitle());
                 $to = $user->getEmail();
                 $to_name = $user->getFullname();
                 if (!empty($to_name)) {
                     $to = $to_name . " <" . $to . ">";
                 }
                 $mod_contact_list = $this->getContactModeratorList();
                 $mod_user_first = $mod_contact_list->getFirst();
                 $mail->set_from_email($mod_user_first->getEmail());
                 $mail->set_from_name($mod_user_first->getFullname());
                 // $mail->set_cc_to($mod_user_first->getEmail());
                 $mail->set_cc_to($this->_environment->getRootUserItem()->getEmail());
                 // $current_context = $this->_environment->getCurrentContextItem();
                 $mod_list = $mod_contact_list;
                 if (!$mod_list->isEmpty()) {
                     $moderator_item = $mod_list->getFirst();
                     while ($moderator_item) {
                         $email = $moderator_item->getEmail();
                         if (!empty($email)) {
                             $mail->set_cc_to($email);
                             // $cc_array[] = $email;
                         }
                         unset($email);
                         $moderator_item = $mod_list->getNext();
                     }
                 }
                 // link
                 $url_to_portal = '';
                 if (!empty($this)) {
                     $url_to_portal = $this->getURL();
                 }
                 $c_commsy_cron_path = $this->_environment->getConfiguration('c_commsy_cron_path');
                 if (isset($c_commsy_cron_path)) {
                     $link = $c_commsy_cron_path;
                 } elseif (!empty($url_to_portal)) {
                     $c_commsy_domain = $this->_environment->getConfiguration('c_commsy_domain');
                     if (stristr($c_commsy_domain, 'https://')) {
                         $link = 'https://';
                     } else {
                         $link = 'http://';
                     }
                     $link .= $url_to_portal;
                     $file = 'commsy.php';
                     $c_single_entry_point = $this->_environment->getConfiguration('c_single_entry_point');
                     if (!empty($c_single_entry_point)) {
                         $file = $c_single_entry_point;
                     }
                     $link .= '/' . $file;
                 } else {
                     $file = $_SERVER['PHP_SELF'];
                     $file = str_replace('cron', 'commsy', $file);
                     $link = 'http://' . $_SERVER['HTTP_HOST'] . $file;
                 }
                 $link .= '?cid=' . $this->getItemID() . '&mod=home&fct=index';
                 // link
                 //content
                 $email_text_array = $this->getEmailTextArray();
                 $translator->setEmailTextArray($this->getEmailTextArray());
                 $body = '';
                 $body .= $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                 $body .= "\n\n";
                 $body .= $translator->getEmailMessage('MAIL_BODY_HELLO', $user->getFullName());
                 $body .= "\n\n";
                 $body .= $translator->getEmailMessage('EMAIL_LOGIN_EXPIRATION_BODY');
                 $body .= "\n\n";
                 $body .= $translator->getEmailMessage('MAIL_BODY_CIAO', $mod_user_first->getFullName(), $this->getTitle());
                 $body .= "\n\n";
                 $body .= $link;
                 $mail->set_subject($subject);
                 $mail->set_message($body);
                 $mail->set_to($to);
                 #$mail->setSendAsHTML();
                 if ($mail->send()) {
                     $cron_array['success'] = true;
                     $cron_array['success_text'] = 'send mail to ' . $to;
                 } else {
                     $cron_array['success'] = false;
                     $cron_array['success_text'] = 'failed send mail to ' . $to;
                 }
             }
         }
     }
     if ($success) {
         $cron_array['success'] = true;
         $cron_array['success_text'] = 'mails send';
     } else {
         $cron_array['success'] = true;
         $cron_array['success_text'] = 'nothing to do';
     }
     $time_end = getmicrotime();
     $time = round($time_end - $time_start, 0);
     $cron_array['time'] = $time;
     unset($user_manager);
     unset($user_list);
     return $cron_array;
 }
Ejemplo n.º 11
0
 $form->loadValues();
 if ($form->check()) {
    include_once('classes/cs_mail.php');
    $mail = new cs_mail();
    $receivers = '';
    if (!empty($_POST['receivers'])) {
       $receivers = implode(',',$_POST['receivers']);
    } elseif (!empty($_POST['receiver_email'])) {
       $receivers = $_POST['receiver_email'];
    } else {
       include_once('functions/error_functions.php');
       trigger_error('no reveiver selected',E_USER_ERROR);
    }
    $mail->set_to($receivers);
    $mail->set_from_name($_POST['sender_name']);
    $mail->set_from_email($_POST['sender_email']);
    $mail->set_subject($_POST['subject']);
    $mail->set_message($_POST['content']);
    $success = $mail->send();
    if ($success) {
       // redirect
       $history = $session->getValue('history');
       if (empty($history[1])) {
          redirect($environment->getCurrentContextID(),'home','index','');
       } else {
          redirect($history[1]['context'],$history[1]['module'],$history[1]['function'],$history[1]['parameter']);
       }
    } else {
       // error sending email
    }
 }
Ejemplo n.º 12
0
 public function IMS($session_id, $ims_xml)
 {
     global $c_ims_log_package;
     if (isset($c_ims_log_package) and $c_ims_log_package) {
         $this->_logXMLPackage($ims_xml);
     }
     $this->_ims_xml = $ims_xml;
     $session_id = $this->_encode_input($session_id);
     $return_array = array();
     $properties = array();
     if (true) {
         $this->_environment->setSessionID($session_id);
         $session_item = $this->_environment->getSessionItem();
         $current_user_id = $session_item->getValue('user_id');
         $user_manager = $this->_environment->getUserManager();
         if ($current_user_id == 'root') {
             $current_user = $this->_environment->getCurrentUserItem();
         } else {
             $current_server_id = $session_item->getValue('commsy_id');
             $auth_source_id = $session_item->getValue('auth_source');
             $user_manager->setContextLimit($current_server_id);
             $user_manager->setUserIdLimit($current_user_id);
             $user_manager->setAuthSourceLimit($auth_source_id);
             $user_manager->select();
             $current_user_list = $user_manager->get();
             $current_user = $current_user_list->getFirst();
         }
         if (!empty($current_user)) {
             $this->_environment->setCurrentUserItem($current_user);
             if ($current_user->isRoot() or $current_server_id == $this->_environment->getServerID() and $current_user->getUserID() == 'IMS_USER') {
                 $ims_xml = $this->_encode_input($ims_xml);
                 //check session
                 if (true) {
                     $id_manager = $this->_environment->getExternalIdManager();
                     //Prepare an notification email
                     include_once 'classes/cs_mail.php';
                     $mail = new cs_mail();
                     $server_item = $this->_environment->getServerItem();
                     $default_sender_address = $server_item->getDefaultSenderAddress();
                     if (!empty($default_sender_address)) {
                         $mail->set_from_email($default_sender_address);
                     } else {
                         $mail->set_from_email('@');
                     }
                     $mail->set_from_name($server_item->getTitle());
                     //Split Message in functional parts
                     //Properties
                     $properties = '';
                     $properties_array = array();
                     preg_match('~<properties.+?</properties>~isu', $ims_xml, $properties);
                     if (isset($properties[0])) {
                         $properties = $properties[0];
                         preg_match('~<targets>.+?</targets>~isu', $ims_xml, $targets);
                         if (isset($targets[0])) {
                             $targets = $targets[0];
                             $server_item = $this->_environment->getServerItem();
                             $portal_list = $server_item->getPortalList();
                             if ($portal_list->isNotEmpty()) {
                                 $portal_item = $portal_list->getFirst();
                                 $name_array = array();
                                 while ($portal_item) {
                                     if ($targets = '*' or strstr($portal_item->getTitle(), $targets)) {
                                         $name_array[] = $portal_item->getItemID();
                                     }
                                     $portal_item = $portal_list->getNext();
                                 }
                                 if (!empty($name_array)) {
                                     foreach ($name_array as $portal_target) {
                                         $properties_array[] = preg_replace('~<targets>.+?</targets>~isu', '<targets>' . $portal_target . '</targets>', $properties);
                                     }
                                 }
                             }
                             unset($portal_list);
                             unset($server_item);
                         } else {
                             $return_array[] = array('error' => '1', 'value' => 'IMS ERROR: no targets in properties defined');
                         }
                     } else {
                         include_once 'functions/error_functions.php';
                         trigger_error('no properties in XML package found', E_USER_WARNING);
                     }
                     if (!empty($properties_array)) {
                         //PERSON
                         $check_result = $this->_checkAndBackupPathfile('person');
                         $path_array_person = $check_result['path_array'];
                         $return_array = array_merge($check_result['error_array'], $return_array);
                         preg_match_all('~<person.+?</person>~isu', $ims_xml, $person_results);
                         $person_results = $person_results[0];
                         $person_values = array();
                         foreach ($person_results as $person) {
                             foreach ($properties_array as $properties_item) {
                                 $person_xml = simplexml_load_string(utf8_encode('<dummytag>' . $properties_item . ' ' . $person . '</dummytag>'));
                                 $temp_array = array();
                                 foreach ($path_array_person as $variable => $path) {
                                     $value = $this->_getValueFromXMLPath($path, $person_xml);
                                     $temp_array[$variable] = $value;
                                 }
                                 if (!empty($temp_array['OP'])) {
                                     $person_values['op' . $temp_array['OP']][$temp_array['USERID']] = $temp_array;
                                 } else {
                                     $return_array[] = array('error' => '1', 'value' => 'IMS ERROR: recstatus for person (' . $temp_array['USERID'] . ') is not set');
                                 }
                             }
                         }
                         //GROUP
                         $check_result = $this->_checkAndBackupPathfile('group');
                         $path_array_group = $check_result['path_array'];
                         $return_array = array_merge($check_result['error_array'], $return_array);
                         preg_match_all('~<group.+?</group>~isu', $ims_xml, $group_results);
                         $group_results = $group_results[0];
                         $group_values = array();
                         foreach ($group_results as $group) {
                             foreach ($properties_array as $properties_item) {
                                 $group_xml = simplexml_load_string('<dummytag>' . $properties_item . ' ' . $group . '</dummytag>');
                                 $temp_array = array();
                                 foreach ($path_array_group as $variable => $path) {
                                     $value = $this->_getValueFromXMLPath($path, $group_xml);
                                     $temp_array[$variable] = $value;
                                 }
                                 if (!empty($temp_array['OP'])) {
                                     $group_values['op' . $temp_array['OP']][$temp_array['GROUPID']] = $temp_array;
                                 } else {
                                     if (!empty($temp_array)) {
                                         $temp_array_for_message = serialize();
                                     } else {
                                         $temp_array_for_message = 'NO DATA FOUND';
                                     }
                                     $return_array[] = array('error' => '1', 'value' => 'IMS ERROR: recstatus for group (' . $temp_array['GROUPID'] . ') is not set. Data array for group: ' . $temp_array_for_message);
                                 }
                             }
                         }
                         //MEMBERSHIP
                         $check_result = $this->_checkAndBackupPathfile('membership');
                         $path_array_membership = $check_result['path_array'];
                         $return_array = array_merge($check_result['error_array'], $return_array);
                         preg_match_all('~<membership.+?</membership>~isu', $ims_xml, $membership_results);
                         $membership_results = $membership_results[0];
                         $membership_values = array();
                         foreach ($membership_results as $membership) {
                             foreach ($properties_array as $properties_item) {
                                 $membership_xml = simplexml_load_string('<dummytag>' . $properties_item . ' ' . $membership . '</dummytag>');
                                 $temp_array = array();
                                 foreach ($path_array_membership as $variable => $path) {
                                     $value = $this->_getValueFromXMLPath($path, $membership_xml);
                                     $temp_array[$variable] = $value;
                                 }
                                 if (!empty($temp_array['OP'])) {
                                     if (!array_key_exists($temp_array['USERID'] . '_' . $temp_array['ROLETYPE'] . '_' . $temp_array['GROUPID'], $temp_array)) {
                                         $membership_values['op' . $temp_array['OP']][$temp_array['USERID'] . '_' . $temp_array['ROLETYPE'] . '_' . $temp_array['GROUPID']] = $temp_array;
                                     } else {
                                         $membership_values['op' . $temp_array['OP']][] = $temp_array;
                                     }
                                 } else {
                                     $return_array[] = array('error' => '1', 'value' => 'IMS ERROR: recstatus for membership (' . $temp_array['USERID'] . '_' . $temp_array['ROLETYPE'] . '_' . $temp_array['GROUPID'] . ') is not set');
                                 }
                             }
                         }
                         // Order of actions is important!
                         // 1-Create person(s)
                         // 2-Create group(s)
                         // 3-Create membership(s)
                         // 4-Edit person(s)
                         // 5-Edit group(s)
                         // 6-Delete membership(s)
                         // 7-Delete group(s)
                         // 8-Delete person(s)
                         //Create Persons
                         if (!empty($person_values['op1'])) {
                             foreach ($person_values['op1'] as $person) {
                                 //every room needs an creator... if $person is marked as such, it is a copy of an existing
                                 // person, not a new one. It will be created while creating the room, so skip it here
                                 if (!isset($person['room_creator'])) {
                                     $return_array[] = $this->_handleUserPackage($person, $mail, $id_manager);
                                 }
                             }
                         }
                         //Create groups
                         if (!empty($group_values['op1'])) {
                             foreach ($group_values['op1'] as $room) {
                                 $return_array[] = $this->_handleRoomPackage($room, $mail, $id_manager, $person_values, $membership_values);
                             }
                         }
                         //Edit Persons
                         if (!empty($person_values['op2'])) {
                             foreach ($person_values['op2'] as $person) {
                                 $return_array[] = $this->_handleUserPackage($person, $mail, $id_manager);
                             }
                         }
                         //Edit groups
                         if (!empty($group_values['op2'])) {
                             foreach ($group_values['op2'] as $room) {
                                 $return_array[] = $this->_handleRoomPackage($room, $mail, $id_manager, $person_values, $membership_values);
                             }
                         }
                         //Create memberships
                         if (!empty($membership_values['op1'])) {
                             foreach ($membership_values['op1'] as $membership) {
                                 //every room needs an initial member (= creator)... if $membership
                                 //as such, this membership has allready been processed while creating a room
                                 if (!isset($membership['room_creator'])) {
                                     $return_array[] = $this->_handleMembershipPackage($membership, $mail, $id_manager);
                                 } else {
                                     $return_array[] = array('error' => 0, 'value' => 'User "' . $membership['USERID'] . '" is now enrolled in room "' . $membership['GROUPID'] . '"');
                                 }
                             }
                         }
                         //Delete memberships
                         if (!empty($membership_values['op3'])) {
                             foreach ($membership_values['op3'] as $membership) {
                                 $return_array[] = $this->_handleMembershipPackage($membership, $mail, $id_manager);
                             }
                         }
                         //Delete groups
                         if (!empty($group_values['op3'])) {
                             foreach ($group_values['op3'] as $room) {
                                 $return_array[] = $this->_handleRoomPackage($room, $mail, $id_manager, $person_values, $membership_values);
                             }
                         }
                         //Delete Persons
                         if (!empty($person_values['op3'])) {
                             foreach ($person_values['op3'] as $person) {
                                 $return_array[] = $this->_handleUserPackage($person, $mail, $id_manager);
                             }
                         }
                         $this->_log('IMS', 'IMS', 'SID=' . $session_id . ',IMS_XML=NOT_LOGGED');
                     } else {
                         $return_array[] = array('error' => '1', 'value' => 'IMS ERROR: targets defined in IMS paket are not available in CommSy');
                     }
                 } else {
                     $return_array[] = array('error' => '1', 'value' => 'IMS ERROR: Session id (' . $session_id . ') is not valid');
                 }
             } else {
                 $return_array[] = array('error' => '1', 'value' => 'IMS ERROR: Logged in user is not allowed to send IMS messages to CommSy!');
             }
         } else {
             $return_array[] = array('error' => '1', 'value' => 'IMS ERROR: can not identify current user');
         }
     } else {
         $return_array[] = array('error' => '1', 'value' => 'IMS ERROR: Session id (' . $session_id . ') is not valid');
     }
     return $this->_encode_output($this->_create_ims_return_string($return_array));
 }
Ejemplo n.º 13
0
 function _sendPrivateRoomNewsletter()
 {
     if (!$this->_send_newsletter) {
         include_once 'functions/misc_functions.php';
         $time_start = getmicrotime();
         $retour = array();
         $retour['title'] = 'privateroom newsletter';
         $retour['description'] = 'send activity newsletter to private room user';
         $retour['success'] = false;
         $retour['success_text'] = 'cron failed';
         // get user in room
         $user = $this->getOwnerUserItem();
         if (isset($user) and $this->isPrivateRoomNewsletterActive() and $this->isPrivateroom()) {
             $url_to_portal = '';
             $portal_item = $this->getContextItem();
             if (!empty($portal_item)) {
                 $url_to_portal = $portal_item->getURL();
             }
             global $c_commsy_cron_path;
             if (isset($c_commsy_cron_path)) {
                 $curl_text = $c_commsy_cron_path . 'commsy.php?cid=';
             } elseif (!empty($url_to_portal)) {
                 $c_commsy_domain = $this->_environment->getConfiguration('c_commsy_domain');
                 if (stristr($c_commsy_domain, 'https://')) {
                     $curl_text = 'https://';
                 } else {
                     $curl_text = 'http://';
                 }
                 $curl_text .= $url_to_portal;
                 $file = 'commsy.php';
                 $c_single_entry_point = $this->_environment->getConfiguration('c_single_entry_point');
                 if (!empty($c_single_entry_point)) {
                     $file = $c_single_entry_point;
                 }
                 $curl_text .= '/' . $file . '?cid=';
             } else {
                 $file = $_SERVER['PHP_SELF'];
                 $file = str_replace('cron_new', 'commsy', $file);
                 $file = str_replace('cron', 'commsy', $file);
                 $curl_text = 'http://' . $_SERVER['HTTP_HOST'] . $file . '?cid=';
             }
             $mail_array = array();
             $mail_array[] = $user->getEmail();
             // get activity informations for room and send mail
             if (!empty($mail_array)) {
                 // email
                 $id = $user->getItemID();
                 $portal = $this->getContextItem();
                 $room_manager = $this->_environment->getRoomManager();
                 $list = $this->getCustomizedRoomList();
                 if (!isset($list)) {
                     $list = $room_manager->_getRelatedContextListForUser($user->getUserID(), $user->getAuthSource(), $portal->getItemID(), true, true);
                 }
                 $list2 = new cs_list();
                 if (!$list->isEmpty()) {
                     $item = $list->getFirst();
                     while ($item) {
                         if ($item->isPrivateRoom() or !$item->isShownInPrivateRoomHomeByItemID($id) or !$item->isOpen() or $item->getItemID() < 0) {
                             // do nothing
                         } else {
                             $list2->add($item);
                         }
                         unset($item);
                         $item = $list->getNext();
                     }
                     unset($item);
                     unset($list);
                 }
                 $translator = $this->_environment->getTranslationObject();
                 $translator->setRubricTranslationArray($this->getRubricTranslationArray());
                 $mail_sequence = $this->getPrivateRoomNewsletterActivity();
                 $body = '';
                 $item = $list2->getFirst();
                 while ($item) {
                     $conf = $item->getHomeConf();
                     if (!empty($conf)) {
                         $rubrics = explode(',', $conf);
                     } else {
                         $rubrics = array();
                     }
                     $count = count($rubrics);
                     $check_managers = array();
                     $check_rubrics = array();
                     foreach ($rubrics as $rubric) {
                         list($rubric_name, $rubric_status) = explode('_', $rubric);
                         if ($rubric_status != 'none') {
                             $check_managers[] = $rubric_name;
                             if ($rubric_name == 'discussion') {
                                 $check_managers[] = 'discarticle';
                             }
                             if ($rubric_name == 'material') {
                                 $check_managers[] = 'section';
                             }
                         }
                     }
                     $title = '<a href="' . $curl_text . $item->getItemID() . '&amp;mod=home&amp;fct=index">' . $item->getTitle() . '</a>';
                     $body_title = BR . BR . $title . '' . LF;
                     $total_count = 0;
                     if ($mail_sequence == 'daily') {
                         $count_total = $item->getPageImpressionsForNewsletter(1);
                         $active = $item->getActiveMembersForNewsletter(1);
                     } else {
                         $count_total = $item->getPageImpressionsForNewsletter(7);
                         $active = $item->getActiveMembersForNewsletter(7);
                     }
                     if ($count_total == 1) {
                         $body_title .= '(' . $count_total . '&nbsp;' . $translator->getMessage('ACTIVITY_PAGE_IMPRESSIONS_SINGULAR') . '; ';
                     } else {
                         $body_title .= '(' . $count_total . '&nbsp;' . $translator->getMessage('ACTIVITY_PAGE_IMPRESSIONS') . '; ';
                     }
                     $body_title .= $translator->getMessage('ACTIVITY_ACTIVE_MEMBERS') . ': ';
                     $body_title .= $active . '):' . BRLF;
                     $body2 = '';
                     $annotation_manager = $this->_environment->getManager('annotation');
                     $annotation_manager->setContextLimit($item->getItemID());
                     if ($mail_sequence == 'daily') {
                         $annotation_manager->setAgeLimit(1);
                     } else {
                         $annotation_manager->setAgeLimit(7);
                     }
                     $annotation_manager->showNoNotActivatedEntries();
                     $annotation_manager->select();
                     $annotation_list = $annotation_manager->get();
                     for ($i = 0; $i < $count; $i++) {
                         $rubric_array = explode('_', $rubrics[$i]);
                         if ($rubric_array[1] != 'none') {
                             $rubric_manager = $this->_environment->getManager($rubric_array[0]);
                             $rubric_manager->reset();
                             $rubric_manager->setContextLimit($item->getItemID());
                             if ($mail_sequence == 'daily') {
                                 $rubric_manager->setAgeLimit(1);
                             } else {
                                 $rubric_manager->setAgeLimit(7);
                             }
                             if ($rubric_manager instanceof cs_dates_manager) {
                                 $rubric_manager->setDateModeLimit(2);
                             }
                             if ($rubric_manager instanceof cs_user_manager) {
                                 $rubric_manager->setUserLimit();
                             }
                             $rubric_manager->showNoNotActivatedEntries();
                             $rubric_manager->select();
                             $rubric_list = $rubric_manager->get();
                             // returns a cs_list of announcement_items
                             $ids = $rubric_manager->getIDs();
                             $rubric_item = $rubric_list->getFirst();
                             $user_manager = $this->_environment->getUserManager();
                             $user_manager->resetLimits();
                             $user_manager->setUserIDLimit($user->getUserID());
                             $user_manager->setAuthSourceLimit($user->getAuthSource());
                             $user_manager->setContextLimit($item->getItemID());
                             $user_manager->select();
                             $user_list = $user_manager->get();
                             if (isset($user_list) and $user_list->isNotEmpty() and $user_list->getCount() == 1) {
                                 $ref_user = $user_list->getFirst();
                                 if (isset($ref_user) and $ref_user->getItemID() > 0) {
                                     $temp_body = '';
                                     $count_entries = 0;
                                     while ($rubric_item) {
                                         $noticed_manager = $this->_environment->getNoticedManager();
                                         $noticed = $noticed_manager->getLatestNoticedForUserByID($rubric_item->getItemID(), $ref_user->getItemID());
                                         if (empty($noticed)) {
                                             $info_text = ' <span class="changed">[' . $translator->getMessage('COMMON_NEW') . ']</span>';
                                         } elseif ($noticed['read_date'] < $rubric_item->getModificationDate()) {
                                             $info_text = ' <span class="changed">[' . $translator->getMessage('COMMON_CHANGED') . ']</span>';
                                         } else {
                                             $info_text = '';
                                         }
                                         $annotation_item = $annotation_list->getFirst();
                                         $annotation_count = 0;
                                         while ($annotation_item) {
                                             $annotation_noticed = $noticed_manager->getLatestNoticedForUserByID($annotation_item->getItemID(), $ref_user->getItemID());
                                             if (empty($annotation_noticed)) {
                                                 $linked_item = $annotation_item->getLinkedItem();
                                                 if ($linked_item->getItemID() == $rubric_item->getItemID()) {
                                                     $annotation_count++;
                                                 }
                                             }
                                             $annotation_item = $annotation_list->getNext();
                                         }
                                         if ($annotation_count == 1) {
                                             $info_text .= ' <span class="changed">[' . $translator->getMessage('COMMON_NEW_ANNOTATION') . ']</span>';
                                         } else {
                                             if ($annotation_count > 1) {
                                                 $info_text .= ' <span class="changed">[' . $translator->getMessage('COMMON_NEW_ANNOTATIONS') . ']</span>';
                                             }
                                         }
                                         if (!empty($info_text)) {
                                             $count_entries++;
                                             $params = array();
                                             $params['iid'] = $rubric_item->getItemID();
                                             $title = '';
                                             if ($rubric_item->isA(CS_USER_TYPE)) {
                                                 $title .= $this->_environment->getTextConverter()->text_as_html_short($rubric_item->getFullname());
                                             } else {
                                                 $title .= $this->_environment->getTextConverter()->text_as_html_short($rubric_item->getTitle());
                                             }
                                             if ($rubric_item->isA(CS_LABEL_TYPE)) {
                                                 $mod = $rubric_item->getLabelType();
                                             } else {
                                                 $mod = $rubric_item->getType();
                                             }
                                             $title .= $info_text;
                                             $ahref_curl = '<a href="' . $curl_text . $item->getItemID() . '&amp;mod=' . $mod . '&amp;fct=detail&amp;iid=' . $params['iid'] . '">' . $title . '</a>';
                                             $temp_body .= BR . '&nbsp;&nbsp;- ' . $ahref_curl;
                                         }
                                         $rubric_item = $rubric_list->getNext();
                                     }
                                 }
                             }
                             $tempMessage = '';
                             switch (mb_strtoupper($rubric_array[0], 'UTF-8')) {
                                 case 'ANNOUNCEMENT':
                                     $tempMessage = $translator->getMessage('ANNOUNCEMENT_INDEX');
                                     break;
                                 case 'DATE':
                                     $tempMessage = $translator->getMessage('DATES_INDEX');
                                     break;
                                 case 'DISCUSSION':
                                     $tempMessage = $translator->getMessage('DISCUSSION_INDEX');
                                     break;
                                 case 'GROUP':
                                     $tempMessage = $translator->getMessage('GROUP_INDEX');
                                     break;
                                 case 'INSTITUTION':
                                     $tempMessage = $translator->getMessage('INSTITUTION_INDEX');
                                     break;
                                 case 'MATERIAL':
                                     $tempMessage = $translator->getMessage('MATERIAL_INDEX');
                                     break;
                                 case 'MYROOM':
                                     $tempMessage = $translator->getMessage('MYROOM_INDEX');
                                     break;
                                 case 'PROJECT':
                                     $tempMessage = $translator->getMessage('PROJECT_INDEX');
                                     break;
                                 case 'TODO':
                                     $tempMessage = $translator->getMessage('TODO_INDEX');
                                     break;
                                 case 'TOPIC':
                                     $tempMessage = $translator->getMessage('TOPIC_INDEX');
                                     break;
                                 case 'USER':
                                     $tempMessage = $translator->getMessage('USER_INDEX');
                                     break;
                                 case 'ENTRY':
                                     $tempMessage = $translator->getMessage('ENTRY_INDEX');
                                     break;
                                 default:
                                     $tempMessage = $translator->getMessage('COMMON_MESSAGETAG_ERROR' . ' cs_privateroom_item(456) ');
                                     break;
                             }
                             if ($count_entries == 1) {
                                 $ahref_curl = '<a href="' . $curl_text . $item->getItemID() . '&amp;mod=' . $rubric_array[0] . '&amp;fct=index">' . $tempMessage . '</a>';
                                 $body2 .= '&nbsp;&nbsp;' . $ahref_curl;
                                 $body2 .= ' <span style="font-size:8pt;">(' . $count_entries . ' ' . $translator->getMessage('NEWSLETTER_NEW_SINGLE_ENTRY') . ')</span>';
                             } elseif ($count_entries > 1) {
                                 $ahref_curl = '<a href="' . $curl_text . $item->getItemID() . '&amp;mod=' . $rubric_array[0] . '&amp;fct=index">' . $tempMessage . '</a>';
                                 $body2 .= '&nbsp;&nbsp;' . $ahref_curl;
                                 $body2 .= ' <span style="font-size:8pt;">(' . $count_entries . ' ' . $translator->getMessage('NEWSLETTER_NEW_ENTRIES') . ')</span>';
                             }
                             if (!empty($body2) and !empty($temp_body)) {
                                 $body2 .= $temp_body . BRLF . LF;
                             }
                         }
                         $j = $i + 1;
                     }
                     $item = $list2->getNext();
                     if (!empty($body2)) {
                         $body .= $body_title;
                         $body2 .= BRLF;
                         $body .= $body2;
                     } else {
                         $body .= $body_title;
                         $body2 .= '&nbsp;&nbsp;' . $translator->getMessage('COMMON_NO_NEW_ENTRIES') . BRLF;
                         $body .= $body2;
                     }
                 }
                 if (empty($body)) {
                     $translator->getMessage('COMMON_NO_NEW_ENTRIES') . LF;
                 }
                 $body .= LF;
                 $portal = $this->getContextItem();
                 $portal_title = '';
                 if (isset($portal)) {
                     $portal_title = $portal->getTitle();
                 }
                 if ($mail_sequence == 'daily') {
                     $body = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_HEADER_DAILY', $portal_title) . LF . LF . $body;
                 } else {
                     $body = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_HEADER_WEEKLY', $portal_title) . LF . LF . $body;
                 }
                 $body .= BRLF . BR . '-----------------------------' . BRLF . LF . $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_FOOTER');
                 $from = $translator->getMessage('SYSTEM_MAIL_MESSAGE', $portal_title);
                 $to = implode($mail_array, ',');
                 if ($mail_sequence == 'daily') {
                     $subject = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_DAILY') . ': ' . $portal_title;
                 } else {
                     $subject = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_WEEKLY') . ': ' . $portal_title;
                 }
                 // send email
                 include_once 'classes/cs_mail.php';
                 $mail = new cs_mail();
                 $mail->set_to($to);
                 $mail->set_from_name($from);
                 $server_item = $this->_environment->getServerItem();
                 $default_sender_address = $server_item->getDefaultSenderAddress();
                 if (!empty($default_sender_address)) {
                     $mail->set_from_email($default_sender_address);
                 } else {
                     $mail->set_from_email('@');
                 }
                 $mail->set_subject($subject);
                 $mail->set_message($body);
                 $mail->setSendAsHTML();
                 if ($mail->send()) {
                     $retour['success'] = true;
                     $retour['success_text'] = 'send newsletter to ' . $to;
                     $this->_send_newsletter = true;
                 }
                 unset($mail);
                 unset($body);
                 unset($subject);
                 unset($default_sender_address);
                 unset($from);
                 unset($to);
                 unset($user_list);
                 unset($ref_user);
                 unset($translator);
                 unset($room_manager);
                 unset($list);
                 unset($list2);
                 unset($portal);
                 unset($user_manager);
                 unset($file);
                 unset($curl_text);
                 unset($mail_array);
                 unset($rubric_manager);
                 unset($noticed_manager);
                 unset($rubric_list);
                 unset($rubric_item);
             } else {
                 $retour['success'] = true;
                 $retour['success_text'] = 'no user in room want the newsletter';
             }
         }
         $time_end = getmicrotime();
         $time = round($time_end - $time_start, 0);
         $retour['time'] = $time;
         return $retour;
     }
 }
Ejemplo n.º 14
0
function cron_workflow($logFile, $portal)
{
    global $c_workflow;
    global $environment;
    global $cs_special_language_tags;
    if ($c_workflow) {
        fwrite($logFile, 'Workflow is active' . LF);
        $material_manager = $environment->getMaterialManager();
        $item_array = $material_manager->getResubmissionItemIDsByDate(date('Y'), date('m'), date('d'));
        foreach ($item_array as $item) {
            $temp_material = $material_manager->getItem($item['item_id']);
            $item_id_current_version = $material_manager->getLatestVersionID($item['item_id']);
            if (isset($temp_material) && !$temp_material->isDeleted() && $item['version_id'] == $item_id_current_version) {
                //$temp_material = $material_manager->getItem($item['item_id']);
                $room_manager = $environment->getRoomManager();
                $temp_room = $room_manager->getItem($temp_material->getContextID());
                // check if context of room is current portal
                if ($temp_room->getContextID() != $portal->getItemID()) {
                    continue;
                }
                if ($temp_material->getWorkflowResubmission() and $temp_room->withWorkflowResubmission()) {
                    $email_receiver_array = array();
                    if ($temp_material->getWorkflowResubmissionWho() == 'creator') {
                        $email_receiver_array[] = $temp_material->getCreator();
                    } else {
                        $temp_list = $temp_material->getModifierList();
                        $email_receiver_array = $temp_list->to_array();
                    }
                    $to = '';
                    $first = true;
                    foreach ($email_receiver_array as $email_receiver) {
                        if ($first) {
                            $to .= $email_receiver->getEmail();
                            $first = false;
                        } else {
                            $to .= ',' . $email_receiver->getEmail();
                        }
                    }
                    $additional_receiver = $temp_material->getWorkflowResubmissionWhoAdditional();
                    if (!empty($additional_receiver)) {
                        $to .= ',' . $additional_receiver;
                    }
                    include_once 'classes/cs_mail.php';
                    $translator = $environment->getTranslationObject();
                    $mail = new cs_mail();
                    $mail->set_to($to);
                    $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $portal->getTitle()));
                    $server_item = $environment->getServerItem();
                    $default_sender_address = $server_item->getDefaultSenderAddress();
                    if (!empty($default_sender_address)) {
                        $mail->set_from_email($default_sender_address);
                    } else {
                        $mail->set_from_email('@');
                    }
                    $mail->set_subject($translator->getMessage('COMMON_WORKFLOW_EMAIL_SUBJECT_RESUBMISSION', $portal->getTitle()));
                    $url_to_portal = '';
                    if (!empty($portal)) {
                        $url_to_portal = $portal->getURL();
                    }
                    global $c_commsy_cron_path;
                    if (isset($c_commsy_cron_path)) {
                        $curl_text = $c_commsy_cron_path . 'commsy.php?cid=';
                    } elseif (!empty($url_to_portal)) {
                        $c_commsy_domain = $environment->getConfiguration('c_commsy_domain');
                        if (stristr($c_commsy_domain, 'https://')) {
                            $curl_text = 'https://';
                        } else {
                            $curl_text = 'http://';
                        }
                        $curl_text .= $url_to_portal;
                        $file = 'commsy.php';
                        $c_single_entry_point = $environment->getConfiguration('c_single_entry_point');
                        if (!empty($c_single_entry_point)) {
                            $file = $c_single_entry_point;
                        }
                        $curl_text .= '/' . $file . '?cid=';
                    } else {
                        $commsy_file = $_SERVER['PHP_SELF'];
                        $commsy_file = str_replace('cron_new', 'commsy', $commsy_file);
                        $commsy_file = str_replace('cron', 'commsy', $commsy_file);
                        $curl_text = 'http://' . $_SERVER['HTTP_HOST'] . $commsy_file . '?cid=';
                    }
                    $link = '<a href="' . $curl_text . $temp_room->getItemID() . '&amp;mod=material&amp;fct=detail&amp;iid=' . $temp_material->getItemID() . '">' . $temp_material->getTitle() . '</a>';
                    if (isset($cs_special_language_tags) and !empty($cs_special_language_tags)) {
                        $mail->set_message($translator->getMessage($cs_special_language_tags . '_WORKFLOW_EMAIL_BODY_RESUBMISSION', $temp_room->getTitle(), $temp_material->getTitle(), $link));
                    } else {
                        $mail->set_message($translator->getMessage('COMMON_WORKFLOW_EMAIL_BODY_RESUBMISSION', $temp_room->getTitle(), $temp_material->getTitle(), $link));
                    }
                    $mail->setSendAsHTML();
                    if ($mail->send()) {
                        fwrite($logFile, 'workflow resubmission e-mail send for item: ' . $item['item_id']);
                    }
                    // change the status of the material
                    $material_manager->setWorkflowStatus($temp_material->getItemID(), $temp_material->getWorkflowResubmissionTrafficLight(), $temp_material->getVersionID());
                    unset($mail);
                    unset($translator);
                    unset($server_item);
                }
                unset($temp_material);
                unset($temp_room);
                unset($room_manager);
            }
        }
        $item_array = $material_manager->getValidityItemIDsByDate(date('Y'), date('m'), date('d'));
        foreach ($item_array as $item) {
            $temp_material = $material_manager->getItem($item['item_id']);
            $item_id_current_version = $material_manager->getLatestVersionID($item['item_id']);
            if (isset($temp_material) && !$temp_material->isDeleted() && $item['version_id'] == $item_id_current_version) {
                //$temp_material = $material_manager->getItem($item['item_id']);
                $room_manager = $environment->getRoomManager();
                $temp_room = $room_manager->getItem($temp_material->getContextID());
                // check if context of room is current portal
                if ($temp_room->getContextID() != $portal->getItemID()) {
                    continue;
                }
                if ($temp_material->getWorkflowValidity() and $temp_room->withWorkflowValidity()) {
                    $email_receiver_array = array();
                    if ($temp_material->getWorkflowValidityWho() == 'creator') {
                        $email_receiver_array[] = $temp_material->getCreator();
                    } else {
                        $temp_list = $temp_material->getModifierList();
                        $email_receiver_array = $temp_list->to_array();
                    }
                    $to = '';
                    $first = true;
                    foreach ($email_receiver_array as $email_receiver) {
                        if ($first) {
                            $to .= $email_receiver->getEmail();
                            $first = false;
                        } else {
                            $to .= ',' . $email_receiver->getEmail();
                        }
                    }
                    $additional_receiver = $temp_material->getWorkflowValidityWhoAdditional();
                    if (!empty($additional_receiver)) {
                        $to .= ',' . $additional_receiver;
                    }
                    include_once 'classes/cs_mail.php';
                    $translator = $environment->getTranslationObject();
                    $mail = new cs_mail();
                    $mail->set_to($to);
                    $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $portal->getTitle()));
                    $server_item = $environment->getServerItem();
                    $default_sender_address = $server_item->getDefaultSenderAddress();
                    if (!empty($default_sender_address)) {
                        $mail->set_from_email($default_sender_address);
                    } else {
                        $mail->set_from_email('@');
                    }
                    $mail->set_subject($translator->getMessage('COMMON_WORKFLOW_EMAIL_SUBJECT_VALIDITY', $portal->getTitle()));
                    $url_to_portal = '';
                    if (!empty($portal)) {
                        $url_to_portal = $portal->getURL();
                    }
                    global $c_commsy_cron_path;
                    if (isset($c_commsy_cron_path)) {
                        $curl_text = $c_commsy_cron_path . 'commsy.php?cid=';
                    } elseif (!empty($url_to_portal)) {
                        $c_commsy_domain = $environment->getConfiguration('c_commsy_domain');
                        if (stristr($c_commsy_domain, 'https://')) {
                            $curl_text = 'https://';
                        } else {
                            $curl_text = 'http://';
                        }
                        $curl_text .= $url_to_portal;
                        $file = 'commsy.php';
                        $c_single_entry_point = $environment->getConfiguration('c_single_entry_point');
                        if (!empty($c_single_entry_point)) {
                            $file = $c_single_entry_point;
                        }
                        $curl_text .= '/' . $file . '?cid=';
                    } else {
                        $commsy_file = $_SERVER['PHP_SELF'];
                        $commsy_file = str_replace('cron_new', 'commsy', $commsy_file);
                        $commsy_file = str_replace('cron', 'commsy', $commsy_file);
                        $curl_text = 'http://' . $_SERVER['HTTP_HOST'] . $commsy_file . '?cid=';
                    }
                    $link = '<a href="' . $curl_text . $temp_room->getItemID() . '&amp;mod=material&amp;fct=detail&amp;iid=' . $temp_material->getItemID() . '">' . $temp_material->getTitle() . '</a>';
                    if (isset($cs_special_language_tags) and !empty($cs_special_language_tags)) {
                        $mail->set_message($translator->getMessage($cs_special_language_tags . '_WORKFLOW_EMAIL_BODY_RESUBMISSION', $temp_room->getTitle(), $temp_material->getTitle(), $link));
                    } else {
                        $mail->set_message($translator->getMessage('COMMON_WORKFLOW_EMAIL_BODY_VALIDITY', $temp_room->getTitle(), $temp_material->getTitle(), $link));
                    }
                    $mail->setSendAsHTML();
                    if ($mail->send()) {
                        fwrite($logFile, 'workflow validity e-mail send for item: ' . $item['item_id']);
                    }
                    // change the status of the material
                    $material_manager->setWorkflowStatus($temp_material->getItemID(), $temp_material->getWorkflowValidityTrafficLight(), $temp_material->getVersionID());
                    unset($mail);
                    unset($translator);
                    unset($server_item);
                }
                unset($temp_material);
                unset($temp_room);
                unset($room_manager);
            }
        }
        unset($item_array);
        unset($material_manager);
    } else {
        fwrite($logFile, 'Workflow is NOT active' . LF);
    }
}
Ejemplo n.º 15
0
 function SendDeleteEntryMailToModerators()
 {
     /*
        When an entry was deleted in the personal repository of a user, an email was send to the moderators of the context
        the user was accessing before opening the repository. To prevent this behaviour, this functions checks if the item is
        inside a repository. If so, no email is send.
     */
     $self_context_item = $this->getContextItem();
     if (!$self_context_item->isPrivateRoom()) {
         $translator = $this->_environment->getTranslationObject();
         $default_language = 'de';
         $server_item = $this->_environment->getServerItem();
         $default_sender_address = $server_item->getDefaultSenderAddress();
         if (empty($default_sender_address)) {
             $default_sender_address = '@';
         }
         $current_context = $this->_environment->getCurrentContextItem();
         $moderator_list = $current_context->getModeratorList();
         $mod_item = $moderator_list->getFirst();
         while ($mod_item) {
             if ($mod_item->getDeleteEntryWantMail() == 'yes') {
                 $language = $current_context->getLanguage();
                 if ($language == 'user') {
                     $language = $mod_item->getLanguage();
                     if ($language == 'browser') {
                         $language = $default_language;
                     }
                 }
                 $receiver_array[$language][] = $mod_item->getEmail();
                 $moderator_name_array[] = $mod_item->getFullname();
             }
             $mod_item = $moderator_list->getNext();
         }
         $context_item = $this->_environment->getCurrentContextItem();
         // now email information
         foreach ($receiver_array as $key => $value) {
             $current_portal = $this->_environment->getCurrentPortalItem();
             $current_user = $this->_environment->getCurrentUserItem();
             $fullname = $current_user->getFullname();
             $save_language = $translator->getSelectedLanguage();
             $translator->setSelectedLanguage($key);
             $subject = '';
             $subject .= $translator->getMessage('COMMON_DELETED_ENTRY', $context_item->getTitle());
             $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
             $body .= LF . LF;
             $body .= $translator->getMessage('COMMON_DELETED_ENTRY_DESC', $this->getTitle(), $context_item->getTitle(), $fullname, $translator->getMessage('COMMON_' . strtoupper($this->getType())));
             $body .= LF . LF;
             $url_to_portal = '';
             if (!empty($current_portal)) {
                 $url_to_portal = $current_portal->getURL();
             }
             $c_commsy_cron_path = $this->_environment->getConfiguration('c_commsy_cron_path');
             if (isset($c_commsy_cron_path)) {
                 $url = $c_commsy_cron_path . 'commsy.php?cid=';
             } elseif (!empty($url_to_portal)) {
                 $c_commsy_domain = $this->_environment->getConfiguration('c_commsy_domain');
                 if (stristr($c_commsy_domain, 'https://')) {
                     $url = 'https://';
                 } else {
                     $url = 'http://';
                 }
                 $url .= $url_to_portal;
                 $file = 'commsy.php';
                 $c_single_entry_point = $this->_environment->getConfiguration('c_single_entry_point');
                 if (!empty($c_single_entry_point)) {
                     $file = $c_single_entry_point;
                 }
                 $url .= '/' . $file . '?cid=';
             } else {
                 $file = $_SERVER['PHP_SELF'];
                 $file = str_replace('cron', 'commsy', $file);
                 $url = 'http://' . $_SERVER['HTTP_HOST'] . $file . '?cid=';
             }
             $url .= $context_item->getItemID();
             $body .= $translator->getMessage('COMMON_LINK_WORKSPACE') . ' ' . $url;
             $body .= LF . LF;
             $body .= $translator->getMessage('MAIL_SEND_TO', implode(LF, $moderator_name_array));
             $body .= LF . LF;
             // send email
             include_once 'classes/cs_mail.php';
             $mail = new cs_mail();
             $mail->set_to(implode(',', $value));
             $mail->set_from_email($default_sender_address);
             if (isset($current_portal)) {
                 $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $current_portal->getTitle()));
             } else {
                 $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $room_item->getTitle()));
             }
             $mail->set_reply_to_name($current_user->getFullname());
             $mail->set_reply_to_email($current_user->getEmail());
             $mail->set_subject($subject);
             $mail->set_message($body);
             $retour = $mail->send();
             unset($mail);
             $translator->setSelectedLanguage($save_language);
             unset($save_language);
         }
     }
 }
Ejemplo n.º 16
0
         $recipients_display_bcc = array_unique($recipients_display_bcc);

         $server_item = $environment->getServerItem();
         $default_sender_address = $server_item->getDefaultSenderAddress();
         $current_user = $environment->getCurrentUser();
         $mail['from_name'] = $current_user->getFullName();
         $mail['from_email'] = $current_user->getEmail();
         $mail['reply_to_name'] = $current_user->getFullName();
         $mail['reply_to_email'] = $current_user->getEmail();
         $mail['to'] = implode(",",$recipients);
         $mail['subject'] = $_POST['subject'];
         $mail['message'] = $_POST['mailcontent'];

         $email = new cs_mail();
         $email->set_from_name($mail['from_name']);
         $email->set_from_email($mail['from_email']);
         $email->set_reply_to_name($mail['reply_to_name']);
         $email->set_reply_to_email($mail['reply_to_email']);
         $email->set_to($mail['to']);
         $email->set_subject($mail['subject']);
         if ($translator->getMessage('COMMON_YES') == $_POST['copytosender']) {
            $email->set_cc_to($current_user->getEmail());
         }
         if ( !empty($recipients_bcc) ) {
            $email->set_bcc_to(implode(",",$recipients_bcc));
         }

         $add_message = '';
         $current_context = $environment->getCurrentContextItem();
         $context_title = str_ireplace('&amp;', '&', $current_context->getTitle());
         if ($counter == 1) {
Ejemplo n.º 17
0
 function execute()
 {
     $success = false;
     $form = $this->_class_factory->getClass(ACCOUNT_FORGET_FORM, array('environment' => $this->_environment));
     // Load form data from postvars
     if (!empty($this->_post_vars)) {
         $form->setFormPost($this->_post_vars);
     }
     $form->prepareForm();
     $form->loadValues();
     // cancel
     if (!empty($this->_command) and (isOption($this->_command, $this->_translator->getMessage('COMMON_CANCEL_BUTTON')) or isOption($this->_command, $this->_translator->getMessage('COMMON_FORWARD_BUTTON')))) {
         $this->_redirect_back();
     }
     // get accounts
     if (!empty($this->_command) and isOption($this->_command, $this->_translator->getMessage('ACCOUNT_SEND_BUTTON'))) {
         $correct = $form->check();
         if ($correct) {
             $user_manager = $this->_environment->getUserManager();
             $user_manager->resetLimits();
             $user_manager->setContextLimit($this->_environment->getCurrentPortalID());
             /*
              * email must match(not only be like) database entry to avoid finding to much identifications
              */
             //$user_manager->setSearchLimit($this->_post_vars['email']);
             $user_manager->setEmailLimit($this->_post_vars['email']);
             $user_manager->select();
             $user_list = $user_manager->get();
             $account_text = '';
             $user_fullname = ' ';
             $portal_item = $this->_environment->getCurrentPortalItem();
             $user_item = $user_list->getFirst();
             $show_auth_source = false;
             while ($user_item) {
                 if (isset($auth_source_id) and $auth_source_id != $user_item->getAuthSource()) {
                     $show_auth_source = true;
                     break;
                 } else {
                     $auth_source_id = $user_item->getAuthSource();
                 }
                 $user_item = $user_list->getNext();
             }
             $first = true;
             $user_item = $user_list->getFirst();
             while ($user_item) {
                 if ($first) {
                     $first = false;
                 } else {
                     $account_text .= LF;
                 }
                 $account_text .= $user_item->getUserID();
                 if ($show_auth_source) {
                     $auth_souce_item = $portal_item->getAuthSource($user_item->getAuthSource());
                     $account_text .= ' (' . $auth_souce_item->getTitle() . ')';
                 }
                 $user_fullname = $user_item->getFullname();
                 $user_item = $user_list->getNext();
             }
             $user_email = $this->_post_vars['email'];
             // send email
             $context_item = $this->_environment->getCurrentPortalItem();
             $mod_text = '';
             $mod_list = $context_item->getContactModeratorList();
             if (!$mod_list->isEmpty()) {
                 $mod_item = $mod_list->getFirst();
                 $contact_moderator = $mod_item;
                 while ($mod_item) {
                     if (!empty($mod_text)) {
                         $mod_text .= ',' . LF;
                     }
                     $mod_text .= $mod_item->getFullname();
                     $mod_text .= ' (' . $mod_item->getEmail() . ')';
                     $mod_item = $mod_list->getNext();
                 }
             }
             $translator = $this->_environment->getTranslationObject();
             include_once 'classes/cs_mail.php';
             $mail = new cs_mail();
             $mail->set_to($user_email);
             $server_item = $this->_environment->getServerItem();
             $default_sender_address = $server_item->getDefaultSenderAddress();
             if (!empty($default_sender_address)) {
                 $mail->set_from_email($default_sender_address);
             } else {
                 $mail->set_from_email('@');
             }
             if (isset($contact_moderator)) {
                 $mail->set_reply_to_email($contact_moderator->getEmail());
                 $mail->set_reply_to_name($contact_moderator->getFullname());
             }
             $mail->set_from_name($this->_translator->getMessage('SYSTEM_MAIL_MESSAGE', $context_item->getTitle()));
             $mail->set_subject($translator->getMessage('USER_ACCOUNT_FORGET_MAIL_SUBJECT', $context_item->getTitle()));
             $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
             $body .= LF . LF;
             $body .= $translator->getEmailMessage('MAIL_BODY_HELLO', $user_fullname);
             $body .= LF . LF;
             $body .= $this->_translator->getMessage('USER_ACCOUNT_FORGET_MAIL_BODY', $context_item->getTitle(), $account_text);
             $body .= LF . LF;
             if (empty($contact_moderator)) {
                 $body .= $translator->getMessage('SYSTEM_MAIL_REPLY_INFO') . LF;
                 $body .= $mod_text;
                 $body .= LF . LF;
             } else {
                 $body .= $translator->getEmailMessage('MAIL_BODY_CIAO', $contact_moderator->getFullname(), $context_item->getTitle());
                 $body .= LF . LF;
             }
             $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $this->_environment->getCurrentContextID();
             $mail->set_message($body);
             if ($mail->send()) {
                 // show little status page that mail was sent successful
                 $form->showMailSent($user_email);
             } else {
                 // show little status page that mail was not sent successful
                 $form->showMailFailure();
             }
         }
     }
     return $this->_show_form($form);
 }
Ejemplo n.º 18
0
 function execute()
 {
     $success = false;
     $class_params = array();
     $class_params['environment'] = $this->_environment;
     $form = $class_factory->getClass(BECOME_MEMBER_FORM, $class_params);
     unset($class_params);
     // Load form data from postvars
     if (!empty($this->_post_vars)) {
         $form->setFormPost($this->_post_vars);
     }
     $form->prepareForm();
     $form->loadValues();
     $user_manager = $this->_environment->getUserManager();
     $current_user = $this->_environment->getCurrentUserItem();
     $user_manager->setUserIDLimit($current_user->getUserID());
     $user_manager->setAuthSourceLimit($current_user->getAuthSource());
     $user_manager->select();
     $user_list = $user_manager->get();
     $room_user = NULL;
     if ($user_list->isNotEmpty()) {
         $room_user = $user_list->getFirst();
     }
     // cancel
     if (!empty($this->_command) and (isOption($this->_command, $this->_translator->getMessage('COMMON_CANCEL_BUTTON')) or isOption($this->_command, $this->_translator->getMessage('COMMON_FORWARD_BUTTON')))) {
         $this->_redirect_back();
     } elseif (!empty($this->_command) and isOption($this->_command, $this->_translator->getMessage('USER_BECOME_MEMBER_BUTTON')) and !isset($room_user)) {
         $correct = $form->check();
         if ($correct) {
             // build new user_item
             $current_user = $this->_environment->getCurrentUserItem();
             $private_room_user_item = $current_user->getRelatedPrivateRoomUserItem();
             if (isset($private_room_user_item)) {
                 $user_item = $private_room_user_item->cloneData();
                 $picture = $private_room_user_item->getPicture();
             } else {
                 $user_item = $current_user;
                 $picture = '';
             }
             //check room_settings
             $current_context = $this->_environment->getCurrentContextItem();
             if (!$current_context->checkNewMembersNever() and !$current_context->checkNewMembersWithCode()) {
                 $user_item->request();
                 $check_message = 'YES';
                 // for mail body
             } else {
                 $user_item->makeUser();
                 // for mail body
                 $check_message = 'NO';
             }
             $user_item->setContextID($current_context->getItemID());
             if (!empty($picture)) {
                 $value_array = explode('_', $picture);
                 $value_array[0] = 'cid' . $user_item->getContextID();
                 $new_picture_name = implode('_', $value_array);
                 $disc_manager = $this->_environment->getDiscManager();
                 $disc_manager->copyImageFromRoomToRoom($picture, $user_item->getContextID());
                 $user_item->setPicture($new_picture_name);
             }
             $portal_user = $user_item->getRelatedPortalUserItem();
             $conf = $portal_user->getConfigurationHideMailByDefault();
             if (!empty($conf)) {
                 // use default user config
                 if ($conf) {
                     // hide
                     $user_item->setDefaultMailNotVisible();
                 } else {
                     $user_item->setDefaultMailVisible();
                 }
             } else {
                 // default portal config
                 if ($conf) {
                     $user_item->setDefaultMailNotVisible();
                 } else {
                     $user_item->setDefaultMailVisible();
                 }
             }
             $user_item->save();
             $user_item->setCreatorID2ItemID();
             // save task
             if (!$current_context->checkNewMembersNever() and !$current_context->checkNewMembersWithCode()) {
                 $task_manager = $this->_environment->getTaskManager();
                 $task_item = $task_manager->getNewItem();
                 $task_item->setCreatorItem($user_item);
                 $task_item->setContextID($current_context->getItemID());
                 $task_item->setTitle('TASK_USER_REQUEST');
                 $task_item->setStatus('REQUEST');
                 $task_item->setItem($user_item);
                 $task_item->save();
             }
             // send email to moderators if necessary
             $user_list = $current_context->getModeratorList();
             $email_addresses = array();
             $moderator_item = $user_list->getFirst();
             $recipients = '';
             $language = $current_context->getLanguage();
             while ($moderator_item) {
                 $want_mail = $moderator_item->getAccountWantMail();
                 if (!empty($want_mail) and $want_mail == 'yes') {
                     if ($language == 'user' and $moderator_item->getLanguage() != 'browser') {
                         $email_addresses[$moderator_item->getLanguage()][] = $moderator_item->getEmail();
                     } elseif ($language == 'user' and $user_item->getLanguage() == 'browser') {
                         $email_addresses[$this->_environment->getSelectedLanguage()][] = $moderator_item->getEmail();
                     } else {
                         $email_addresses[$language][] = $moderator_item->getEmail();
                     }
                     $recipients .= $moderator_item->getFullname() . LF;
                 }
                 $moderator_item = $user_list->getNext();
             }
             $save_language = $this->_translator->getSelectedLanguage();
             foreach ($email_addresses as $key => $value) {
                 $this->_translator->setSelectedLanguage($key);
                 if (count($value) > 0) {
                     $subject = $this->_translator->getMessage('USER_JOIN_CONTEXT_MAIL_SUBJECT', $user_item->getFullname(), $current_context->getTitle());
                     $body = $this->_translator->getMessage('MAIL_AUTO', $this->_translator->getDateInLang(getCurrentDateTimeInMySQL()), $this->_translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                     $body .= LF . LF;
                     $temp_language = $user_item->getLanguage();
                     if ($temp_language == 'browser') {
                         $temp_language = $this->_environment->getSelectedLanguage();
                     }
                     $tempMessage = '';
                     switch (mb_strtoupper($temp_language, 'UTF-8')) {
                         case 'DE':
                             $tempMessage = $this->_translator->getMessage('DE');
                             break;
                         case 'EN':
                             $tempMessage = $this->_translator->getMessage('EN');
                             break;
                         case 'RU':
                             $tempMessage = $this->_translator->getMessage('RU');
                             break;
                         default:
                             // $tempMessage = $this->_translator->getMessage('COMMON_MESSAGETAG_ERROR'.' cs_become_member_page(168) ');
                             break;
                     }
                     $body .= $this->_translator->getMessage('USER_GET_MAIL_BODY', $user_item->getFullname(), $user_item->getUserID(), $user_item->getEmail(), $tempMessage);
                     $body .= LF . LF;
                     $tempMessage = "";
                     switch ($check_message) {
                         case 'YES':
                             $tempMessage = $this->_translator->getMessage('USER_GET_MAIL_STATUS_YES');
                             break;
                         case 'NO':
                             $tempMessage = $this->_translator->getMessage('USER_GET_MAIL_STATUS_NO');
                             break;
                         default:
                             break;
                     }
                     $body .= $tempMessage;
                     $body .= LF . LF;
                     if (!empty($this->_post_vars['description'])) {
                         $body .= $this->_translator->getMessage('MAIL_COMMENT_BY', $user_item->getFullname(), $this->_post_vars['description']);
                         $body .= LF . LF;
                     }
                     $body .= $this->_translator->getMessage('MAIL_SEND_TO', $recipients);
                     $body .= LF;
                     if (!$user_item->isUser()) {
                         $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $current_context->getItemID() . '&mod=account&fct=index' . '&selstatus=1';
                     } else {
                         $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $current_context->getItemID();
                     }
                     include_once 'classes/cs_mail.php';
                     $mail = new cs_mail();
                     $mail->set_to(implode(',', $value));
                     $server_item = $this->_environment->getServerItem();
                     $default_sender_address = $server_item->getDefaultSenderAddress();
                     if (!empty($default_sender_address)) {
                         $mail->set_from_email($default_sender_address);
                     } else {
                         $mail->set_from_email('@');
                     }
                     $current_context = $this->_environment->getCurrentContextItem();
                     $mail->set_from_name($this->_translator->getMessage('SYSTEM_MAIL_MESSAGE', $current_context->getTitle()));
                     $mail->set_reply_to_name($user_item->getFullname());
                     $mail->set_reply_to_email($user_item->getEmail());
                     $mail->set_subject($subject);
                     $mail->set_message($body);
                     $mail->send();
                 }
             }
             $this->_translator->setSelectedLanguage($save_language);
             // send email to user when account is free automatically
             if ($user_item->isUser()) {
                 $mod_text = '';
                 $mod_list = $current_context->getContactModeratorList();
                 if (!$mod_list->isEmpty()) {
                     $mod_item = $mod_list->getFirst();
                     $contact_moderator = $mod_item;
                     while ($mod_item) {
                         if (!empty($mod_text)) {
                             $mod_text .= ',' . LF;
                         }
                         $mod_text .= $mod_item->getFullname();
                         $mod_text .= ' (' . $mod_item->getEmail() . ')';
                         $mod_item = $mod_list->getNext();
                     }
                 }
                 // email texts
                 $subject = $this->_translator->getMessage('MAIL_SUBJECT_USER_STATUS_USER', $current_context->getTitle());
                 $body = $this->_translator->getMessage('MAIL_AUTO', $this->_translator->getDateInLang(getCurrentDateTimeInMySQL()), $this->_translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                 $body .= LF . LF;
                 $body .= $this->_translator->getEmailMessage('MAIL_BODY_HELLO', $user_item->getFullname());
                 $body .= LF . LF;
                 $body .= $this->_translator->getEmailMessage('MAIL_BODY_USER_STATUS_USER', $user_item->getUserID(), $current_context->getTitle());
                 $body .= LF . LF;
                 if (empty($contact_moderator)) {
                     $body .= $this->_translator->getMessage('SYSTEM_MAIL_REPLY_INFO') . LF;
                     $body .= $mod_text;
                     $body .= LF . LF;
                 } else {
                     $body .= $this->_translator->getEmailMessage('MAIL_BODY_CIAO', $contact_moderator->getFullname(), $current_context->getTitle());
                     $body .= LF . LF;
                 }
                 $body .= LF . LF;
                 $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $current_context->getItemID();
                 // send mail to user
                 include_once 'classes/cs_mail.php';
                 $mail = new cs_mail();
                 $mail->set_to($user_item->getEmail());
                 $mail->set_from_name($this->_translator->getMessage('SYSTEM_MAIL_MESSAGE', $current_context->getTitle()));
                 $server_item = $this->_environment->getServerItem();
                 $default_sender_address = $server_item->getDefaultSenderAddress();
                 if (!empty($default_sender_address)) {
                     $mail->set_from_email($default_sender_address);
                 } else {
                     $mail->set_from_email('@');
                 }
                 if (!empty($contact_moderator)) {
                     $mail->set_reply_to_email($contact_moderator->getEmail());
                     $mail->set_reply_to_name($contact_moderator->getFullname());
                 }
                 $mail->set_subject($subject);
                 $mail->set_message($body);
                 $mail->send();
                 // redirect back
                 $this->_redirect_back();
             } else {
                 $form->showAccountNotOpen($user_item);
             }
         }
     }
     if (isset($room_user)) {
         $form->showAccountNotOpen($room_user);
     }
     return $this->_show_form($form);
 }
 public function save($form_data, $additional = array())
 {
     switch ($additional['action']) {
         case 'context_join':
             //---
             $room_manager = $this->_environment->getRoomManager();
             $room_item = $room_manager->getItem($form_data['iid']);
             $current_item_id = $form_data['iid'];
             if (empty($room_item)) {
                 $grouproom_flag = true;
                 $room_item = $room_manager->getItem($additional['context_id']);
                 $current_item_id = $additional['context_id'];
                 // label item holen und addmember ausführen wenn kein member
                 $label_manager = $this->_environment->getLabelManager();
                 $label_item = $label_manager->getItem($form_data['iid']);
             }
             $translator = $this->_environment->getTranslationObject();
             $portal_item = $this->_environment->getCurrentPortalItem();
             $agb_flag = false;
             if ($portal_item->withAGBDatasecurity()) {
                 if ($room_item->getAGBStatus() == 1) {
                     if ($form_data['agb']) {
                         $agb_flag = true;
                     } else {
                         $agb_flag = false;
                     }
                 } else {
                     $agb_flag = true;
                 }
             } else {
                 $agb_flag = true;
             }
             #pr($agb_flag);
             // build new user_item
             if ((!$room_item->checkNewMembersWithCode() or $room_item->getCheckNewMemberCode() == $form_data['code'] or $room_item->getCheckNewMemberCode() and !empty($form_data['description_user'])) and $agb_flag) {
                 $current_user = $this->_environment->getCurrentUserItem();
                 $private_room_user_item = $current_user->getRelatedPrivateRoomUserItem();
                 if (isset($private_room_user_item)) {
                     $user_item = $private_room_user_item->cloneData();
                     $picture = $private_room_user_item->getPicture();
                 } else {
                     $user_item = $current_user->cloneData();
                     $picture = $current_user->getPicture();
                 }
                 $user_item->setContextID($current_item_id);
                 if (!empty($picture)) {
                     $value_array = explode('_', $picture);
                     $value_array[0] = 'cid' . $user_item->getContextID();
                     $new_picture_name = implode('_', $value_array);
                     $disc_manager = $this->_environment->getDiscManager();
                     $disc_manager->copyImageFromRoomToRoom($picture, $user_item->getContextID());
                     $user_item->setPicture($new_picture_name);
                 }
                 if (isset($form_data['description_user'])) {
                     $user_item->setUserComment($form_data['description_user']);
                 }
                 //check room_settings
                 if (!$room_item->checkNewMembersNever() and !$room_item->checkNewMembersWithCode() or $room_item->checkNewMembersWithCode() and $room_item->getCheckNewMemberCode() != $form_data['code']) {
                     $user_item->request();
                     $check_message = 'YES';
                     // for mail body
                     $account_mode = 'info';
                 } else {
                     $user_item->makeUser();
                     // for mail body
                     $check_message = 'NO';
                     $account_mode = 'to_room';
                     // save link to the group ALL
                     $group_manager = $this->_environment->getLabelManager();
                     $group_manager->setExactNameLimit('ALL');
                     $group_manager->setContextLimit($current_item_id);
                     $group_manager->select();
                     $group_list = $group_manager->get();
                     if ($group_list->getCount() == 1) {
                         $group = $group_list->getFirst();
                         $group->setTitle('ALL');
                         $user_item->setGroupByID($group->getItemID());
                     }
                     if (isset($label_item) and !empty($label_item)) {
                         if (!$label_item->isMember($current_user)) {
                             $label_item->addMember($current_user);
                         }
                     }
                 }
                 if ($portal_item->withAGBDatasecurity()) {
                     if ($room_item->getAGBStatus()) {
                         if ($form_data['agb']) {
                             $user_item->setAGBAcceptance();
                         }
                     }
                 }
                 // test if user id already exists (reload page)
                 $user_id = $user_item->getUserID();
                 $user_test_item = $room_item->getUserByUserID($user_id, $user_item->getAuthSource());
                 if (!isset($user_test_item) and mb_strtoupper($user_id, 'UTF-8') != 'GUEST' and mb_strtoupper($user_id, 'UTF-8') != 'ROOT') {
                     $user_item->save();
                     $user_item->setCreatorID2ItemID();
                     // save task
                     if (!$room_item->checkNewMembersNever() and !$room_item->checkNewMembersWithCode()) {
                         $task_manager = $this->_environment->getTaskManager();
                         $task_item = $task_manager->getNewItem();
                         $current_user = $this->_environment->getCurrentUserItem();
                         $task_item->setCreatorItem($current_user);
                         $task_item->setContextID($room_item->getItemID());
                         $task_item->setTitle('TASK_USER_REQUEST');
                         $task_item->setStatus('REQUEST');
                         $task_item->setItem($user_item);
                         $task_item->save();
                     }
                     // send email to moderators if necessary
                     $user_manager = $this->_environment->getUserManager();
                     $user_manager->resetLimits();
                     $user_manager->setModeratorLimit();
                     $user_manager->setContextLimit($current_item_id);
                     $user_manager->select();
                     $user_list = $user_manager->get();
                     $email_addresses = array();
                     $moderator_item = $user_list->getFirst();
                     $recipients = '';
                     while ($moderator_item) {
                         $want_mail = $moderator_item->getAccountWantMail();
                         if (!empty($want_mail) and $want_mail == 'yes') {
                             $email_addresses[] = $moderator_item->getEmail();
                             $recipients .= $moderator_item->getFullname() . "\n";
                         }
                         $moderator_item = $user_list->getNext();
                     }
                     // language
                     $language = $room_item->getLanguage();
                     if ($language == 'user') {
                         $language = $user_item->getLanguage();
                         if ($language == 'browser') {
                             $language = $this->_environment->getSelectedLanguage();
                         }
                     }
                     if (count($email_addresses) > 0) {
                         $save_language = $translator->getSelectedLanguage();
                         $translator->setSelectedLanguage($language);
                         $subject = $translator->getMessage('USER_JOIN_CONTEXT_MAIL_SUBJECT', $user_item->getFullname(), $room_item->getTitle());
                         $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                         $body .= LF . LF;
                         // Datenschutz
                         if ($this->_environment->getCurrentPortalItem()->getHideAccountname()) {
                             $userid = 'XXX ' . $translator->getMessage('COMMON_DATASECURITY');
                         } else {
                             $userid = $user_item->getUserID();
                         }
                         $body .= $translator->getMessage('USER_JOIN_CONTEXT_MAIL_BODY', $user_item->getFullname(), $userid, $user_item->getEmail(), $room_item->getTitle());
                         $body .= LF . LF;
                         $tempMessage = "";
                         switch (cs_strtoupper($check_message)) {
                             case 'YES':
                                 $body .= $translator->getMessage('USER_GET_MAIL_STATUS_YES');
                                 break;
                             case 'NO':
                                 $body .= $translator->getMessage('USER_GET_MAIL_STATUS_NO');
                                 break;
                             default:
                                 $body .= $translator->getMessage('COMMON_MESSAGETAG_ERROR') . " context_detail(244) ";
                                 break;
                         }
                         $body .= LF . LF;
                         if (!empty($form_data['description_user'])) {
                             $body .= $translator->getMessage('MAIL_COMMENT_BY', $user_item->getFullname(), $form_data['description_user']);
                             $body .= LF . LF;
                         }
                         $body .= $translator->getMessage('MAIL_SEND_TO', $recipients);
                         $body .= LF;
                         if (cs_strtoupper($check_message) == 'YES') {
                             $body .= $translator->getMessage('MAIL_USER_FREE_LINK') . LF;
                             $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $current_item_id . '&mod=account&fct=index' . '&selstatus=1';
                         } else {
                             $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $current_item_id;
                         }
                         $mail = new cs_mail();
                         $mail->set_to(implode(',', $email_addresses));
                         $server_item = $this->_environment->getServerItem();
                         $default_sender_address = $server_item->getDefaultSenderAddress();
                         if (!empty($default_sender_address)) {
                             $mail->set_from_email($default_sender_address);
                         } else {
                             $mail->set_from_email('@');
                         }
                         $current_context = $this->_environment->getCurrentContextItem();
                         $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $current_context->getTitle()));
                         $mail->set_reply_to_name($user_item->getFullname());
                         $mail->set_reply_to_email($user_item->getEmail());
                         $mail->set_subject($subject);
                         $mail->set_message($body);
                         $mail->send();
                         $translator->setSelectedLanguage($save_language);
                     }
                     // send email to user when account is free automatically (PROJECT ROOM)
                     if ($user_item->isUser()) {
                         // get contact moderator (TBD) now first moderator
                         $user_list = $room_item->getModeratorList();
                         $contact_moderator = $user_list->getFirst();
                         // change context to project room
                         $translator->setEmailTextArray($room_item->getEmailTextArray());
                         $translator->setContext('project');
                         $save_language = $translator->getSelectedLanguage();
                         // language
                         $language = $room_item->getLanguage();
                         if ($language == 'user') {
                             $language = $user_item->getLanguage();
                             if ($language == 'browser') {
                                 $language = $this->_environment->getSelectedLanguage();
                             }
                         }
                         // Datenschutz
                         if ($this->_environment->getCurrentPortalItem()->getHideAccountname()) {
                             $userid = 'XXX ' . $translator->getMessage('COMMON_DATASECURITY');
                         } else {
                             $userid = $user_item->getUserID();
                         }
                         $translator->setSelectedLanguage($language);
                         // email texts
                         $subject = $translator->getMessage('MAIL_SUBJECT_USER_STATUS_USER', $room_item->getTitle());
                         $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                         $body .= LF . LF;
                         $body .= $translator->getEmailMessage('MAIL_BODY_HELLO', $user_item->getFullname());
                         $body .= LF . LF;
                         $body .= $translator->getEmailMessage('MAIL_BODY_USER_STATUS_USER', $userid, $room_item->getTitle());
                         $body .= LF . LF;
                         $body .= $translator->getEmailMessage('MAIL_BODY_CIAO', $contact_moderator->getFullname(), $room_item->getTitle());
                         $body .= LF . LF;
                         $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $this->_environment->getCurrentContextID();
                         // send mail to user
                         $mail = new cs_mail();
                         $mail->set_to($user_item->getEmail());
                         $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $room_item->getTitle()));
                         $server_item = $this->_environment->getServerItem();
                         $default_sender_address = $server_item->getDefaultSenderAddress();
                         if (!empty($default_sender_address)) {
                             $mail->set_from_email($default_sender_address);
                         } else {
                             $mail->set_from_email('@');
                         }
                         $mail->set_reply_to_email($contact_moderator->getEmail());
                         $mail->set_reply_to_name($contact_moderator->getFullname());
                         $mail->set_subject($subject);
                         $mail->set_message($body);
                         $mail->send();
                     }
                 }
             } elseif ($room_item->checkNewMembersWithCode() and $room_item->getCheckNewMemberCode() != $form_data['code']) {
                 $account_mode = 'member';
                 $error = 'code';
                 $this->_popup_controller->setErrorReturn(111, 'wrong_code', array());
             } elseif (!$agb_flag and $portal_item->withAGBDatasecurity() and $room_item->getAGBStatus() == 1) {
                 $this->_popup_controller->setErrorReturn(115, 'agb_not_accepted', array());
             }
             if ($account_mode == 'to_room') {
                 // 		        $this->_popup_controller->setSuccessfullItemIDReturn($form_data['iid']);
                 // 		      	$this->_popup_controller->setSuccessfullItemIDReturn($this->_environment->getCurrentContextID());
                 $data['cid'] = $this->_environment->getCurrentContextID();
                 if ($label_item) {
                     $data['item_id'] = $label_item->getItemID();
                     $data['mod'] = 'group';
                 } else {
                     $data['item_id'] = $room_item->getItemID();
                     $data['mod'] = 'project';
                 }
                 $this->_popup_controller->setSuccessfullDataReturn($data);
             } else {
                 $data['cid'] = $this->_environment->getCurrentContextID();
                 if ($label_item) {
                     $data['item_id'] = $label_item->getItemID();
                     $data['mod'] = 'group';
                 } else {
                     $data['item_id'] = $room_item->getItemID();
                     $data['mod'] = 'project';
                 }
                 $this->_popup_controller->setSuccessfullDataReturn($data);
                 // 		        $this->_popup_controller->setSuccessfullItemIDReturn($this->_environment->getCurrentContextID());
             }
             //---
             // set return
             break;
     }
 }
Ejemplo n.º 20
0
 function _sendMailToModeration2($room_item, $room_change)
 {
     $translator = $this->_environment->getTranslationObject();
     $default_language = 'de';
     $server_item = $this->_environment->getServerItem();
     // maybe in archive mode
     $toggle_archive = false;
     if ($this->_environment->isArchiveMode()) {
         $toggle_archive = true;
         $this->_environment->toggleArchiveMode();
     }
     $default_sender_address = $server_item->getDefaultSenderAddress();
     if (empty($default_sender_address)) {
         $default_sender_address = '@';
     }
     $current_portal = $this->_environment->getCurrentPortalItem();
     if (empty($current_portal) or !$current_portal->isPortal()) {
         $current_portal = $this->getContextItem();
     }
     $current_user = $this->_environment->getCurrentUserItem();
     $fullname = $current_user->getFullname();
     if (empty($fullname)) {
         $current_user = $this->_environment->getRootUserItem();
         $email = $current_user->getEmail();
         if (empty($email) and !empty($default_sender_address) and $default_sender_address != '@') {
             $current_user->setEmail($default_sender_address);
         }
     }
     if ($toggle_archive) {
         $this->_environment->toggleArchiveMode();
     }
     unset($toggle_archive);
     $moderator_list = $room_item->getModeratorList();
     // get moderators
     $receiver_array = array();
     $moderator_name_array = array();
     if ($moderator_list->isNotEmpty()) {
         $mod_item = $moderator_list->getFirst();
         while ($mod_item) {
             if ($mod_item->getOpenRoomWantMail() == 'yes') {
                 $language = $room_item->getLanguage();
                 if ($language == 'user') {
                     $language = $mod_item->getLanguage();
                     if ($language == 'browser') {
                         $language = $default_language;
                     }
                 }
                 $receiver_array[$language][] = $mod_item->getEmail();
                 $moderator_name_array[] = $mod_item->getFullname();
             }
             $mod_item = $moderator_list->getNext();
         }
     }
     // now email information
     foreach ($receiver_array as $key => $value) {
         $subject = '';
         if ($room_item->isPortal()) {
             $subject .= $room_item->getTitle() . ': ';
         }
         $save_language = $translator->getSelectedLanguage();
         $translator->setSelectedLanguage($key);
         $title = str_ireplace('&amp;', '&', $this->getTitle());
         if ($room_change == 'open') {
             $subject = $translator->getMessage('PROJECT_MAIL_SUBJECT_OPEN', $title);
         } elseif ($room_change == 'reopen') {
             $subject = $translator->getMessage('PROJECT_MAIL_SUBJECT_REOPEN', $title);
         } elseif ($room_change == 'delete') {
             $subject = $translator->getMessage('PROJECT_MAIL_SUBJECT_DELETE', $title);
         } elseif ($room_change == 'undelete') {
             $subject = $translator->getMessage('PROJECT_MAIL_SUBJECT_UNDELETE', $title);
         } elseif ($room_change == 'archive') {
             $subject = $translator->getMessage('PROJECT_MAIL_SUBJECT_ARCHIVE', $title);
         } elseif ($room_change == 'link') {
             $subject = $translator->getMessage('PROJECT_MAIL_SUBJECT_LINK', $title);
         } elseif ($room_change == 'lock') {
             $subject = $translator->getMessage('PROJECT_MAIL_SUBJECT_LOCK', $title);
         } elseif ($room_change == 'unlock') {
             $subject = $translator->getMessage('PROJECT_MAIL_SUBJECT_UNLOCK', $title);
         }
         $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
         $body .= LF . LF;
         if ($room_change == 'open') {
             $body .= $translator->getMessage('COMMUNITY_MAIL_BODY_OPEN');
             $room_change_action = $translator->getMessage('PROJECT_MAIL_BODY_ACTION_OPEN');
         } elseif ($room_change == 'reopen') {
             $body .= $translator->getMessage('COMMUNITY_MAIL_BODY_REOPEN');
             $room_change_action = $translator->getMessage('PROJECT_MAIL_BODY_ACTION_REOPEN');
         } elseif ($room_change == 'delete') {
             $body .= $translator->getMessage('COMMUNITY_MAIL_BODY_DELETE');
             $room_change_action = $translator->getMessage('PROJECT_MAIL_BODY_ACTION_DELETE');
         } elseif ($room_change == 'undelete') {
             $body .= $translator->getMessage('COMMUNITY_MAIL_BODY_UNDELETE');
             $room_change_action = $translator->getMessage('PROJECT_MAIL_BODY_ACTION_UNDELETE');
         } elseif ($room_change == 'archive') {
             $body .= $translator->getMessage('COMMUNITY_MAIL_BODY_ARCHIVE');
             $room_change_action = $translator->getMessage('PROJECT_MAIL_BODY_ACTION_ARCHIVE');
         } elseif ($room_change == 'lock') {
             $body .= $translator->getMessage('COMMUNITY_MAIL_BODY_LOCK');
             $room_change_action = $translator->getMessage('PROJECT_MAIL_BODY_ACTION_LOCK');
         } elseif ($room_change == 'unlock') {
             $body .= $translator->getMessage('COMMUNITY_MAIL_BODY_UNLOCK');
             $room_change_action = $translator->getMessage('PROJECT_MAIL_BODY_ACTION_UNLOCK');
         }
         $body .= LF . LF;
         $body .= $translator->getMessage('PROJECT_MAIL_BODY_INFORMATION', str_ireplace('&amp;', '&', $this->getTitle()), $current_user->getFullname(), $room_change_action);
         if ($room_change != 'delete') {
             $url_to_portal = '';
             if (!empty($current_portal)) {
                 $url_to_portal = $current_portal->getURL();
             }
             if (!empty($url_to_portal)) {
                 $c_commsy_domain = $this->_environment->getConfiguration('c_commsy_domain');
                 if (stristr($c_commsy_domain, 'https://')) {
                     $url = 'https://';
                 } else {
                     $url = 'http://';
                 }
                 $url .= $url_to_portal;
                 $file = 'commsy.php';
                 $c_single_entry_point = $this->_environment->getConfiguration('c_single_entry_point');
                 if (!empty($c_single_entry_point)) {
                     $file = $c_single_entry_point;
                 }
                 $url .= '/' . $file . '?cid=';
             } else {
                 $file = $_SERVER['PHP_SELF'];
                 $file = str_replace('cron', 'commsy', $file);
                 $url = 'http://' . $_SERVER['HTTP_HOST'] . $file . '?cid=';
             }
             $url .= $this->getContextID();
             $url .= '&room_id=' . $this->getItemID();
             $body .= LF . $url;
             #$body .= LF.'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?cid='.$this->getContextID().'&room_id='.$this->getItemID();
         }
         $body .= LF . LF;
         $body .= $translator->getMessage('MAIL_SEND_TO', implode(LF, $moderator_name_array));
         $body .= LF . LF;
         if ($room_item->isPortal()) {
             $body .= $translator->getMessage('MAIL_SEND_WHY_PORTAL', $room_item->getTitle());
         } elseif ($room_item->isCommunityRoom()) {
             $body .= $translator->getMessage('MAIL_SEND_WHY_COMMUNITY', $room_item->getTitle());
         } else {
             $body .= $translator->getMessage('MAIL_SEND_WHY_PROJECT', $room_item->getTitle());
         }
         // send email
         include_once 'classes/cs_mail.php';
         $mail = new cs_mail();
         $mail->set_to(implode(',', $value));
         $mail->set_from_email($default_sender_address);
         if (isset($current_portal)) {
             $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $current_portal->getTitle()));
         } else {
             $server_item = $this->_environment->getServerItem();
             $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $server_item->getTitle()));
             unset($server_item);
         }
         $mail->set_reply_to_name($current_user->getFullname());
         $mail->set_reply_to_email($current_user->getEmail());
         $mail->set_subject($subject);
         $mail->set_message($body);
         $mail->send();
         $translator->setSelectedLanguage($save_language);
         unset($save_language);
         unset($mail);
     }
     unset($current_portal);
     unset($current_user);
 }
Ejemplo n.º 21
0
 public function actionSendMail()
 {
     $user_manager = $this->_environment->getUserManager();
     $translator = $this->_environment->getTranslationObject();
     $ids = $this->_data["ids"];
     $sendMail = $this->_data["sendMail"];
     $modCC = $this->_data["modCC"];
     $modBCC = $this->_data["modBCC"];
     $authCC = $this->_data["authCC"];
     $authBCC = $this->_data["authBCC"];
     $subject = $this->_data["subject"];
     $action = $this->_data["action"];
     $admin = $this->_environment->getCurrentUser();
     $response_array = array();
     include_once "classes/cs_mail.php";
     foreach ($ids as $id) {
         $user = $user_manager->getItem($id);
         $sendTo = $user->getEmail();
         $description = $this->_data["description"];
         $formal_data_send_to = array();
         if ($user->isEmailVisible()) {
             $formal_data_send_to[] = $user->getFullName() . " &lt;" . $sendTo . "&gt;";
         } else {
             $formal_data_send_to[] = $user->getFullName() . " &lt;" . $translator->getMessage("USER_EMAIL_HIDDEN") . "&gt;";
         }
         // prepare mail
         $mail = new cs_mail();
         $mail->set_from_email($admin->getEmail());
         $mail->set_from_name($admin->getFullname());
         $mail->set_reply_to_email($admin->getEmail());
         $mail->set_reply_to_name($admin->getFullname());
         if (!isset($formal_data_from)) {
             $formal_data_from = array($translator->getMessage("MAIL_FROM"), $admin->getFullname() . " &lt;" . $admin->getEmail() . "&gt;");
             $formal_data[] = $form_data_from;
         }
         if (!isset($formal_data_reply)) {
             $form_data_reply = array($translator->getMessage("REPLY_TO"), $admin->getFullname() . " &lt;" . $admin->getEmail() . "&gt;");
             $formal_data[] = $form_data_reply;
         }
         // subject and body
         $room = $this->_environment->getCurrentContextItem();
         $url_to_room = LF . LF;
         $url_to_room .= "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"] . "?cid=" . $this->_environment->getCurrentContextID();
         if ($action !== "email") {
             $description = str_replace("%1", $user->getFullname(), $description);
             $description = str_replace("%2", $user->getUserID(), $description);
             $description = str_replace("%3", $room->getTitle(), $description);
         }
         if (isset($subject) && !empty($subject)) {
             $mail->set_subject($subject);
             if (!isset($formal_data_subject)) {
                 $formal_data_subject = array($translator->getMessage("MAIL_SUBJECT"), $subject);
             }
         }
         if (isset($description) && !empty($description)) {
             $mail->set_message($description);
             if (!isset($formal_data_message)) {
                 $formal_data_message = array($translator->getMessage("COMMON_MAIL_CONTENT") . ":", $description);
             }
         }
         // reciever
         if (isset($sendMail) && $sendMail == "true" || $action == "mail") {
             $mail->set_to($sendTo);
         }
         // Datenschutz
         if ($this->_environment->getCurrentPortalItem()->getHideAccountname()) {
             $mail_user = $mail;
             $user_description = str_replace('XXX ' . $translator->getMessage('COMMON_DATASECURITY_NAME', $user->getFullname()), $user->getUserID(), $description);
             $mail_user->set_message($user_description);
             $mail_success = $mail_user->send();
             // 					$mail->set_to($admin->getEmail());
             $mail->set_message($description);
         }
         // cc / bcc
         $cc_array = array();
         $bcc_array = array();
         if (isset($authCC) && $authCC == "true") {
             $cc_array[] = $admin->getEmail();
         }
         if (isset($authBCC) && authBCC == "true") {
             $bcc_array[] = $admin->getEmail();
         }
         if (isset($modCC) && $modCC == "true") {
             $current_context = $this->_environment->getCurrentContextItem();
             $mod_list = $current_context->getModeratorList();
             if (!$mod_list->isEmpty()) {
                 $moderator_item = $mod_list->getFirst();
                 while ($moderator_item) {
                     $email = $moderator_item->getEmail();
                     if (!empty($email)) {
                         $cc_array[] = $email;
                     }
                     unset($email);
                     $moderator_item = $mod_list->getNext();
                 }
             }
         }
         if (isset($modBCC) && $modBCC == "true") {
             $current_context = $this->_environment->getCurrentContextItem();
             $mod_list = $current_context->getModeratorList();
             if (!$mod_list->isEmpty()) {
                 $moderator_item = $mod_list->getFirst();
                 while ($moderator_item) {
                     $email = $moderator_item->getEmail();
                     if (!empty($email)) {
                         $bcc_array[] = $email;
                     }
                     unset($email);
                     $moderator_item = $mod_list->getNext();
                 }
             }
         }
         // make unique
         if (!empty($cc_array)) {
             $cc_array = array_unique($cc_array);
         }
         if (!empty($bcc_array)) {
             $bcc_array = array_unique($bcc_array);
         }
         // build strings
         $cc_string = implode(",", $cc_array);
         $bcc_string = implode(",", $bcc_array);
         if (!empty($cc_string)) {
             $mail->set_cc_to($cc_string);
         }
         if (!empty($bcc_string)) {
             $mail->set_bcc_to($bcc_string);
         }
         if ($this->_environment->getCurrentPortalItem()->getHideAccountname()) {
             if (!empty($cc_string) or !empty($bcc_string)) {
                 $mail->set_to('');
                 $mail_success = $mail->send();
             }
         } else {
             $mail_success = $mail->send();
         }
         unset($cc_string);
         unset($bcc_string);
         // send mail
         $response_array[] = array($mail_success, $mail_error_array = $mail->getErrorArray());
     }
     // setup successfull reponse array - but it can also contains errors
     $this->setSuccessfullDataReturn($response_array);
     echo $this->_return;
 }
Ejemplo n.º 22
0
 function execute()
 {
     $success = false;
     $class_params = array();
     $class_params['environment'] = $this->_environment;
     $form = $this->_class_factory->getClass(PASSWORD_FORGET_FORM, $class_params);
     unset($class_params);
     // Load form data from postvars
     if (!empty($this->_post_vars)) {
         $form->setFormPost($this->_post_vars);
     }
     $form->prepareForm();
     $form->loadValues();
     // cancel
     if (!empty($this->_command) and (isOption($this->_command, $this->_translator->getMessage('COMMON_CANCEL_BUTTON')) or isOption($this->_command, $this->_translator->getMessage('COMMON_FORWARD_BUTTON')))) {
         $this->_redirect_back();
     }
     // Save item
     if (!empty($this->_command) and isOption($this->_command, $this->_translator->getMessage('PASSWORD_GENERATE_BUTTON'))) {
         $correct = $form->check();
         if ($correct) {
             // save special session
             $user_manager = $this->_environment->getUserManager();
             $user_manager->setContextLimit($this->_environment->getCurrentPortalID());
             $user_manager->setUserIDLimit($this->_post_vars['user_id']);
             if (!empty($this->_post_vars['auth_source'])) {
                 $user_manager->setAuthSourceLimit($this->_post_vars['auth_source']);
             }
             $user_manager->select();
             $user_list = $user_manager->get();
             $user_item = $user_list->getFirst();
             $success = true;
             while ($user_item) {
                 // auth source
                 $auth_source_manager = $this->_environment->getAuthSourceManager();
                 $auth_source_item = $auth_source_manager->getItem($user_item->getAuthSource());
                 if ($auth_source_item->allowAddAccount()) {
                     include_once 'classes/cs_session_item.php';
                     $new_special_session_item = new cs_session_item();
                     $new_special_session_item->createSessionID($this->_post_vars['user_id']);
                     $new_special_session_item->setValue('auth_source', $user_item->getAuthSource());
                     if ($this->_post_vars['user_id'] == 'root') {
                         $new_special_session_item->setValue('commsy_id', $this->_environment->getServerID());
                     } else {
                         $new_special_session_item->setValue('commsy_id', $this->_environment->getCurrentPortalID());
                     }
                     if (isset($_SERVER["SERVER_ADDR"]) and !empty($_SERVER["SERVER_ADDR"])) {
                         $new_special_session_item->setValue('password_forget_ip', $_SERVER["SERVER_ADDR"]);
                     } else {
                         $new_special_session_item->setValue('password_forget_ip', $_SERVER["HTTP_HOST"]);
                     }
                     include_once 'functions/date_functions.php';
                     $new_special_session_item->setValue('password_forget_time', getCurrentDateTimeInMySQL());
                     $new_special_session_item->setValue('javascript', -1);
                     $new_special_session_item->setValue('cookie', 0);
                     $session_manager = $this->_environment->getSessionManager();
                     $session_manager->save($new_special_session_item);
                 }
                 $user_email = '';
                 $user_fullname = '';
                 $user_id = '';
                 $portal = $this->_environment->getCurrentPortalItem();
                 $user_fullname = $user_item->getFullName();
                 $user_email = $user_item->getEMail();
                 $user_id = $user_item->getUserID();
                 $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $this->_environment->getCurrentPortalID();
                 if ($auth_source_item->allowAddAccount()) {
                     $url .= '&SID=' . $new_special_session_item->getSessionID();
                 }
                 // send email
                 $context_item = $this->_environment->getCurrentPortalItem();
                 $mod_text = '';
                 $mod_list = $context_item->getModeratorList();
                 if (!$mod_list->isEmpty()) {
                     $mod_item = $mod_list->getFirst();
                     $contact_moderator = $mod_item;
                     while ($mod_item) {
                         if (!empty($mod_text)) {
                             $mod_text .= ',' . LF;
                         }
                         $mod_text .= $mod_item->getFullname();
                         $mod_text .= ' (' . $mod_item->getEmail() . ')';
                         $mod_item = $mod_list->getNext();
                     }
                 }
                 $translator = $this->_environment->getTranslationObject();
                 include_once 'classes/cs_mail.php';
                 $mail = new cs_mail();
                 $mail->set_to($user_email);
                 $server_item = $this->_environment->getServerItem();
                 $default_sender_address = $server_item->getDefaultSenderAddress();
                 if (!empty($default_sender_address)) {
                     $mail->set_from_email($default_sender_address);
                 } else {
                     $mail->set_from_email('@');
                 }
                 if (!empty($contact_moderator)) {
                     $mail->set_reply_to_email($contact_moderator->getEmail());
                     $mail->set_reply_to_name($contact_moderator->getFullname());
                 }
                 $mail->set_from_name($this->_translator->getMessage('SYSTEM_MAIL_MESSAGE', $context_item->getTitle()));
                 $mail->set_subject($translator->getMessage('USER_PASSWORD_MAIL_SUBJECT', $context_item->getTitle()));
                 $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                 $body .= LF . LF;
                 $body .= $translator->getEmailMessage('MAIL_BODY_HELLO', $user_fullname);
                 $body .= LF . LF;
                 if ($auth_source_item->allowAddAccount()) {
                     $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY', $user_id, $context_item->getTitle(), $url, '15');
                 } else {
                     $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY_SORRY', $user_id, $context_item->getTitle());
                     $body .= LF . LF;
                     $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY_SORRY2', $auth_source_item->getTitle());
                     $link = $auth_source_item->getPasswordChangeLink();
                     $contact_mail = $auth_source_item->getContactEMail();
                     if (!empty($link)) {
                         $body .= LF . LF;
                         $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY_SORRY2_LINK', $link);
                     }
                     if (!empty($contact_mail)) {
                         $body .= LF . LF;
                         $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY_SORRY2_MAIL', $auth_source_item->getTitle(), $contact_mail);
                     }
                     $body .= LF . LF;
                     $body .= $translator->getMessage('USER_PASSWORD_MAIL_BODY_SORRY3');
                 }
                 $body .= LF . LF;
                 if (empty($contact_moderator)) {
                     $body .= $translator->getMessage('SYSTEM_MAIL_REPLY_INFO') . LF;
                     $body .= $mod_text;
                     $body .= LF . LF;
                 } else {
                     $body .= $translator->getEmailMessage('MAIL_BODY_CIAO', $contact_moderator->getFullname(), $context_item->getTitle());
                     $body .= LF . LF;
                 }
                 $mail->set_message($body);
                 $success = $success and $mail->send();
                 $user_item = $user_list->getNext();
             }
             if ($success) {
                 // show little status page that mail was sent successful
                 $form->showMailSent($user_email);
             } else {
                 // show little status page that mail was not sent successful
                 $form->showMailFailure();
             }
         }
     }
     return $this->_show_form($form);
 }
Ejemplo n.º 23
0
 function execute()
 {
     $success = false;
     $class_params = array();
     $class_params['environment'] = $this->_environment;
     $form = $this->_class_factory->getClass(HOME_MEMBER2_FORM, $class_params);
     unset($class_params);
     // Load form data from postvars
     if (!empty($this->_post_vars)) {
         $form->setFormPost($this->_post_vars);
     }
     if (!empty($this->_get_vars)) {
         $form->setFormGet($this->_get_vars);
     }
     $form->prepareForm();
     $form->loadValues();
     // cancel
     if (!empty($this->_command) and isOption($this->_command, $this->_translator->getMessage('COMMON_CANCEL_BUTTON'))) {
         $this->_redirect_back();
     }
     // Save item
     if (!empty($this->_command) and isOption($this->_command, $this->_translator->getMessage('ACCOUNT_GET_BUTTON'))) {
         $correct = $form->check();
         if ($correct) {
             if (isset($this->_post_vars['auth_source']) and !empty($this->_post_vars['auth_source'])) {
                 $auth_source = $this->_post_vars['auth_source'];
             } else {
                 include_once 'functions/error_functions.php';
                 trigger_error('lost auth source', E_USER_ERROR);
             }
             $portal_item = $this->_environment->getCurrentPortalItem();
             $auth_source_item = $portal_item->getAuthSource($auth_source);
             $redirect_to_login = true;
             // CAS
             if ($auth_source_item->getSourceType() == 'CAS') {
                 $redirect_to_login = false;
             } elseif ($auth_source_item->getSourceType() == 'Typo3') {
                 $redirect_to_login = false;
             } elseif ($auth_source_item->getSourceType() == 'Joomla') {
                 $redirect_to_login = false;
             } elseif ($auth_source_item->getSourceType() == 'MYSQL') {
                 $redirect_to_login = false;
             } elseif ($auth_source_item->getSourceType() == 'LDAP') {
                 $redirect_to_login = false;
             } elseif ($auth_source_item->isCommSyDefault()) {
                 $redirect_to_login = false;
             }
             if ($redirect_to_login) {
                 // if someting is wrong
                 $params = $this->_environment->getCurrentParameterArray();
                 unset($params['cs_modus']);
                 redirect($this->_environment->getCurrentContextID(), 'home', 'index', $params);
                 exit;
             }
             // Create new item
             $authentication = $this->_environment->getAuthenticationObject();
             $new_account = $authentication->getNewItem();
             $new_account->setUserID($this->_post_vars['user_id']);
             $new_account->setFirstname($this->_post_vars['firstname']);
             $new_account->setLastname($this->_post_vars['lastname']);
             $new_account->setLanguage($this->_post_vars['language']);
             $new_account->setEmail($this->_post_vars['email']);
             $new_account->setPortalID($this->_environment->getCurrentPortalID());
             $new_account->setAuthSourceID($auth_source);
             $save_only_user = true;
             $authentication->save($new_account, $save_only_user);
             $portal_user = $authentication->getUserItem();
             $error = $authentication->getErrorMessage();
             if (empty($error)) {
                 $success = true;
                 $portal_item = $this->_environment->getCurrentPortalItem();
                 if ($this->_environment->getCurrentContextItem()->withAGB() and $this->_environment->getCurrentContextItem()->withAGBDatasecurity()) {
                     if ($this->_post_vars['terms_of_use']) {
                         $portal_user->setAGBAcceptance();
                     }
                 }
                 if ($portal_item->getConfigurationHideMailByDefault()) {
                     // hide
                     $portal_user->setDefaultMailNotVisible();
                 } else {
                     $portal_user->setDefaultMailVisible();
                 }
                 #if ( $portal_item->checkNewMembersAlways()
                 #     or $portal_item->checkNewMembersSometimes()
                 #   ) {
                 #   // portal: generate and save task
                 #   $task_manager = $environment->getTaskManager();
                 #   $task_item = $task_manager->getNewItem();
                 #   $task_item->setContextID($portal_item->getItemID());
                 #   $task_item->getCreatorItem($portal_user);
                 #   $task_item->setTitle('TASK_USER_REQUEST');
                 #   $task_item->setStatus('REQUEST');
                 #   $task_item->setItem($portal_user);
                 #   $task_item->save();
                 #}
                 // portal: send mail to moderators in different languages
                 $user_list = $portal_item->getModeratorList();
                 $email_addresses = array();
                 $user_item = $user_list->getFirst();
                 $recipients = '';
                 $language = $portal_item->getLanguage();
                 while ($user_item) {
                     $want_mail = $user_item->getAccountWantMail();
                     if (!empty($want_mail) and $want_mail == 'yes') {
                         if ($language == 'user' and $user_item->getLanguage() != 'browser') {
                             $email_addresses[$user_item->getLanguage()][] = $user_item->getEmail();
                         } elseif ($language == 'user' and $user_item->getLanguage() == 'browser') {
                             $email_addresses[$this->_environment->getSelectedLanguage()][] = $user_item->getEmail();
                         } else {
                             $email_addresses[$language][] = $user_item->getEmail();
                         }
                         $recipients .= $user_item->getFullname() . LF;
                     }
                     $user_item = $user_list->getNext();
                 }
                 $save_language = $this->_translator->getSelectedLanguage();
                 foreach ($email_addresses as $key => $value) {
                     $this->_translator->setSelectedLanguage($key);
                     if (count($value) > 0) {
                         include_once 'classes/cs_mail.php';
                         $mail = new cs_mail();
                         $mail->set_to(implode(',', $value));
                         $server_item = $this->_environment->getServerItem();
                         $default_sender_address = $server_item->getDefaultSenderAddress();
                         if (!empty($default_sender_address)) {
                             $mail->set_from_email($default_sender_address);
                         } else {
                             $mail->set_from_email('@');
                         }
                         $mail->set_from_name($this->_translator->getMessage('SYSTEM_MAIL_MESSAGE', $portal_item->getTitle()));
                         $mail->set_reply_to_name($portal_user->getFullname());
                         $mail->set_reply_to_email($portal_user->getEmail());
                         $mail->set_subject($this->_translator->getMessage('USER_GET_MAIL_SUBJECT', $portal_user->getFullname()));
                         $body = $this->_translator->getMessage('MAIL_AUTO', $this->_translator->getDateInLang(getCurrentDateTimeInMySQL()), $this->_translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                         $body .= LF . LF;
                         $temp_language = $portal_user->getLanguage();
                         if ($temp_language == 'browser') {
                             $temp_language = $this->_environment->getSelectedLanguage();
                         }
                         $body .= $this->_translator->getMessage('USER_GET_MAIL_BODY', $portal_user->getFullname(), $portal_user->getUserID(), $portal_user->getEmail(), $this->_translator->getLanguageLabelTranslated($temp_language));
                         unset($temp_language);
                         $body .= LF . LF;
                         #                    if ( !$portal_item->checkNewMembersNever()
                         #                         or $portal_item->checkNewMembersSometimes()
                         #                       ) {
                         #                       $check_message = 'YES';
                         #                    } else {
                         $check_message = 'NO';
                         #                    }
                         switch ($check_message) {
                             case 'YES':
                                 $body .= $this->_translator->getMessage('USER_GET_MAIL_STATUS_YES');
                                 break;
                             case 'NO':
                                 $body .= $this->_translator->getMessage('USER_GET_MAIL_STATUS_NO');
                                 break;
                             default:
                                 break;
                         }
                         $body .= LF . LF;
                         if (!empty($_POST['explanation'])) {
                             $body .= $this->_translator->getMessage('MAIL_COMMENT_BY', $portal_user->getFullname(), '');
                             $body .= LF . LF;
                         }
                         $body .= $this->_translator->getMessage('MAIL_SEND_TO', $recipients);
                         $body .= LF;
                         $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $portal_item->getItemID() . '&mod=account&fct=index' . '&selstatus=1';
                         $mail->set_message($body);
                         $mail->send();
                     }
                 }
                 $this->_translator->setSelectedLanguage($save_language);
                 // activate user
                 #$login = false;
                 #if ($portal_item->checkNewMembersNever()) {
                 $portal_user->makeUser();
                 $portal_user->save();
                 $current_user = $portal_user;
                 $this->_environment->setCurrentUserItem($current_user);
                 #$this->setCurrentUser($this->_environment->getCurrentUserItem());
                 #$login = true;
                 #}
                 // send email to user
                 if ($current_user->isUser()) {
                     if (!$this->_environment->inPortal()) {
                         // change translation context
                         $this->_translator->setContext('portal');
                         $current_portal = $this->_environment->getCurrentPortalItem();
                         $this->_translator->setEmailTextArray($current_portal->getEmailTextArray());
                         $this->_translator->setSelectedLanguage($current_portal->getLanguage());
                     }
                     $mod_text = '';
                     $mod_list = $portal_item->getContactModeratorList();
                     if (!$mod_list->isEmpty()) {
                         $mod_item = $mod_list->getFirst();
                         $contact_moderator = $mod_item;
                         while ($mod_item) {
                             if (!empty($mod_text)) {
                                 $mod_text .= ',' . LF;
                             }
                             $mod_text .= $mod_item->getFullname();
                             $mod_text .= ' (' . $mod_item->getEmail() . ')';
                             $mod_item = $mod_list->getNext();
                         }
                     }
                     $language = getSelectedLanguage();
                     $this->_translator->setSelectedLanguage($language);
                     include_once 'classes/cs_mail.php';
                     $mail = new cs_mail();
                     $mail->set_to($current_user->getEmail());
                     $mail->set_from_name($this->_translator->getMessage('SYSTEM_MAIL_MESSAGE', $portal_item->getTitle()));
                     $server_item = $this->_environment->getServerItem();
                     $default_sender_address = $server_item->getDefaultSenderAddress();
                     if (!empty($default_sender_address)) {
                         $mail->set_from_email($default_sender_address);
                     } else {
                         $user_manager = $this->_environment->getUserManager();
                         $root_user = $user_manager->getRootUser();
                         $root_mail_address = $root_user->getEmail();
                         if (!empty($root_mail_address)) {
                             $mail->set_from_email($root_mail_address);
                         } else {
                             $mail->set_from_email('@');
                         }
                     }
                     if (!empty($contact_moderator)) {
                         $mail->set_reply_to_email($contact_moderator->getEmail());
                         $mail->set_reply_to_name($contact_moderator->getFullname());
                     }
                     $mail->set_subject($this->_translator->getMessage('MAIL_SUBJECT_USER_ACCOUNT_FREE', $portal_item->getTitle()));
                     $body = $this->_translator->getMessage('MAIL_AUTO', $this->_translator->getDateInLang(getCurrentDateTimeInMySQL()), $this->_translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                     $body .= LF . LF;
                     $body .= $this->_translator->getEmailMessage('MAIL_BODY_HELLO', $current_user->getFullname());
                     $body .= LF . LF;
                     $body .= $this->_translator->getEmailMessage('MAIL_BODY_USER_STATUS_USER', $portal_user->getUserID(), $portal_item->getTitle());
                     $body .= LF . LF;
                     if (empty($contact_moderator)) {
                         $body .= $this->_translator->getMessage('SYSTEM_MAIL_REPLY_INFO') . LF;
                         $body .= $mod_text;
                         $body .= LF . LF;
                     } else {
                         $body .= $this->_translator->getEmailMessage('MAIL_BODY_CIAO', $contact_moderator->getFullname(), $portal_item->getTitle());
                         $body .= LF . LF;
                     }
                     $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $this->_environment->getCurrentContextID();
                     $mail->set_message($body);
                     $mail->send();
                     if (!$this->_environment->inPortal()) {
                         // change translation context back
                         $current_context = $this->_environment->getCurrentContextItem();
                         if ($current_context->isProjectRoom()) {
                             $this->_translator->setContext('project');
                         } else {
                             $this->_translator->setContext('community');
                         }
                         $this->_translator->setEmailTextArray($current_context->getEmailTextArray());
                         $this->_translator->setSelectedLanguage($current_context->getLanguage());
                     }
                 }
                 // login in user
                 #if ($login) {
                 $session = $this->_environment->getSessionItem();
                 #if ($session->issetValue('last_step')) {
                 #$last_step = $session->getValue('last_step');
                 #$session->unsetValue('last_step');
                 #}
                 $cookie = $session->getValue('cookie');
                 include_once 'classes/cs_session_item.php';
                 global $session;
                 // for PHP5 and TBD !!!!!!!!!!
                 $session = new cs_session_item();
                 $session->createSessionID($_POST['user_id']);
                 if ($cookie == '1') {
                     $session->setValue('cookie', 2);
                 } else {
                     $session->setValue('cookie', 0);
                 }
                 // save portal id in session to be sure, that user didn't
                 // switch between portals
                 $session->setValue('commsy_id', $this->_environment->getCurrentPortalID());
                 // auth_source
                 if (empty($auth_source)) {
                     $auth_source = $authentication->getAuthSourceItemID();
                 }
                 $session->setValue('auth_source', $auth_source);
                 $this->_environment->setSessionItem($session);
             }
         }
     }
     if (!$success) {
         return $this->_show_form($form);
     } else {
         $this->_redirect_back();
     }
 }
Ejemplo n.º 24
0
   if (count($email_addresses) > 0) {
      $save_language = $translator->getSelectedLanguage();
      $translator->setSelectedLanguage($language);
      $subject = $translator->getMessage('USER_ASK_MAIL_SUBJECT',$user_item->getFullname(),$room_item->getTitle());
      $body  = '';
      if (!empty($_POST['description_user'])) {
          $body .= $_POST['description_user'];
          $body .= LF.LF;
        $body .= '---'.LF;
      }
      $body .= $translator->getMessage('MAIL_SEND_TO',$recipients);
      $body .= LF;
      $mail = new cs_mail();
      $mail->set_to(implode(',',$email_addresses));
      $mail->set_from_email($user_item->getEmail());
      $mail->set_from_name($user_item->getFullname());
      $mail->set_reply_to_name($user_item->getFullname());
      $mail->set_reply_to_email($user_item->getEmail());
      $mail->set_subject($subject);
      $mail->set_message($body);
      $mail->send();
      $translator->setSelectedLanguage($save_language);
   }

   if ( $environment->getCurrentModule() == CS_PROJECT_TYPE ) {
      redirect($environment->getCurrentContextID(), CS_PROJECT_TYPE, 'detail', $params);
   } elseif ( $environment->getCurrentModule() == CS_MYROOM_TYPE ) {
      redirect($environment->getCurrentContextID(), CS_MYROOM_TYPE, 'detail', $params);
   }
}
Ejemplo n.º 25
0
 function performAction($environment, $action_array, $post_array)
 {
     global $formal_data;
     global $mail_success;
     global $mail_error_array;
     // Get the translator object
     $translator = $environment->getTranslationObject();
     // perform action
     $user_manager = $environment->getUserManager();
     $admin = $user_manager->getItem($action_array['user_item_id']);
     if (!isset($admin)) {
         $admin = $environment->getCurrentUserItem();
     }
     if (isset($post_array['copy']) and !empty($post_array['copy']) and !in_array($action_array['user_item_id'], $action_array['selected_ids']) and count($action_array['selected_ids']) > 1) {
         $action_array['selected_ids'][] = $action_array['user_item_id'];
     }
     foreach ($action_array['selected_ids'] as $user_item_id) {
         $user = $user_manager->getItem($user_item_id);
         if (isset($user)) {
             $last_status = $user->getStatus();
         }
         if ($action_array['action'] == 'USER_ACCOUNT_DELETE') {
             if ($environment->inPortal() or $environment->inServer()) {
                 $authentication = $environment->getAuthenticationObject();
                 $authentication->delete($user_item_id);
                 unset($authentication);
             } else {
                 ################################
                 # FLAG: group room
                 ################################
                 if ($environment->inGroupRoom()) {
                     $current_context = $environment->getCurrentContextItem();
                     $group_item = $current_context->getLinkedGroupItem();
                     if (isset($group_item) and !empty($group_item)) {
                         $project_room_item = $current_context->getLinkedProjectItem();
                         if (isset($project_room_item) and !empty($project_room_item)) {
                             $project_room_user_item = $project_room_item->getUserByUserID($user->getUserID(), $user->getAuthSource());
                             $group_item->removeMember($project_room_user_item);
                             unset($project_room_user_item);
                         }
                         unset($project_room_item);
                     }
                     unset($group_item);
                     unset($current_context);
                 }
                 ################################
                 # FLAG: group room
                 ################################
                 $hash_manager = $environment->getHashManager();
                 $hash_manager->deleteHashesForUser($user->getItemID());
                 $user->delete();
             }
             $send_to = $user->getEmail();
         } elseif ($action_array['action'] == 'USER_ACCOUNT_LOCK') {
             $hash_manager = $environment->getHashManager();
             $hash_manager->deleteHashesForUser($user->getItemID());
             $user->reject();
             $user->save();
             ################################
             # FLAG: group room
             ################################
             if ($environment->inGroupRoom()) {
                 $current_context = $environment->getCurrentContextItem();
                 $group_item = $current_context->getLinkedGroupItem();
                 if (isset($group_item) and !empty($group_item)) {
                     $project_room_item = $current_context->getLinkedProjectItem();
                     if (isset($project_room_item) and !empty($project_room_item)) {
                         $project_room_user_item = $project_room_item->getUserByUserID($user->getUserID(), $user->getAuthSource());
                         $group_item->removeMember($project_room_user_item);
                         unset($group_item);
                         unset($project_room_user_item);
                     }
                     unset($project_room_item);
                 }
                 unset($current_context);
             }
             ################################
             # FLAG: group room
             ################################
             $send_to = $user->getEmail();
         } elseif ($action_array['action'] == 'USER_ACCOUNT_FREE') {
             // link to group 'ALL' in project rooms
             if ($environment->inProjectRoom()) {
                 $group_list = $user->getGroupList();
                 if ($group_list->isEmpty()) {
                     $group_manager = $environment->getLabelManager();
                     $group_manager->setExactNameLimit('ALL');
                     $group_manager->setContextLimit($environment->getCurrentContextID());
                     $group_manager->select();
                     $group_list = $group_manager->get();
                     if ($group_list->getCount() == 1) {
                         $group = $group_list->getFirst();
                         $group->setTitle('ALL');
                         // needed, but not good (TBD)
                     }
                     // save link to the group ALL
                     if (isset($group)) {
                         $user->setGroupByID($group->getItemID());
                         $group->setModificatorItem($user);
                         $group->save();
                         unset($group);
                     }
                     unset($group_list);
                     unset($group_manager);
                 }
             }
             // don't change users with status user or Moderator
             if (!$user->isUser() and !$user->isModerator()) {
                 $user->makeUser();
                 $user->save();
                 ################################
                 # FLAG: group room
                 ################################
                 if ($environment->inGroupRoom()) {
                     $current_context = $environment->getCurrentContextItem();
                     $group_item = $current_context->getLinkedGroupItem();
                     if (isset($group_item) and !empty($group_item)) {
                         $project_room_item = $current_context->getLinkedProjectItem();
                         if (isset($project_room_item) and !empty($project_room_item)) {
                             $project_room_user_item = $project_room_item->getUserByUserID($user->getUserID(), $user->getAuthSource());
                             $group_item->addMember($project_room_user_item);
                             unset($group_item);
                             unset($project_room_user_item);
                         }
                         unset($project_room_item);
                     }
                     unset($group_item);
                     unset($current_context);
                 }
                 ################################
                 # FLAG: group room
                 ################################
             }
             $send_to = $user->getEmail();
         } elseif ($action_array['action'] == 'USER_STATUS_USER') {
             // link to group 'ALL' in project rooms
             if ($environment->inProjectRoom()) {
                 $group_list = $user->getGroupList();
                 if ($group_list->isEmpty()) {
                     $group_manager = $environment->getLabelManager();
                     $group_manager->setExactNameLimit('ALL');
                     $group_manager->setContextLimit($environment->getCurrentContextID());
                     $group_manager->select();
                     $group_list = $group_manager->get();
                     if ($group_list->getCount() == 1) {
                         $group = $group_list->getFirst();
                         $group->setTitle('ALL');
                         // needed, but not good (TBD)
                     }
                     // save link to the group ALL
                     if (isset($group)) {
                         $user->setGroupByID($group->getItemID());
                         $group->setModificatorItem($user);
                         $group->save();
                         unset($group);
                     }
                     unset($group_list);
                     unset($group_manager);
                 }
             }
             $user->makeUser();
             $user->save();
             $send_to = $user->getEmail();
             ################################
             # FLAG: group room
             ################################
             if ($environment->inGroupRoom()) {
                 $current_context = $environment->getCurrentContextItem();
                 $group_item = $current_context->getLinkedGroupItem();
                 if (isset($group_item) and !empty($group_item)) {
                     $project_room_item = $current_context->getLinkedProjectItem();
                     if (isset($project_room_item) and !empty($project_room_item)) {
                         $project_room_user_item = $project_room_item->getUserByUserID($user->getUserID(), $user->getAuthSource());
                         $group_item->addMember($project_room_user_item);
                         unset($project_room_user_item);
                         unset($group_item);
                     }
                     unset($project_room_item);
                 }
                 unset($current_context);
                 unset($group_item);
             }
             ################################
             # FLAG: group room
             ################################
         } elseif ($action_array['action'] == 'USER_STATUS_MODERATOR') {
             // link to group 'ALL' in project rooms
             if ($environment->inProjectRoom()) {
                 $group_list = $user->getGroupList();
                 if ($group_list->isEmpty()) {
                     $group_manager = $environment->getLabelManager();
                     $group_manager->setExactNameLimit('ALL');
                     $group_manager->setContextLimit($environment->getCurrentContextID());
                     $group_manager->select();
                     $group_list = $group_manager->get();
                     if ($group_list->getCount() == 1) {
                         $group = $group_list->getFirst();
                         $group->setTitle('ALL');
                         // needed, but not good (TBD)
                     }
                     unset($group_list);
                     // save link to the group ALL
                     if (isset($group)) {
                         $user->setGroupByID($group->getItemID());
                         $group->setModificatorItem($user);
                         $group->save();
                         unset($group);
                     }
                     unset($group_manager);
                 }
             }
             $user->makeModerator();
             $user->save();
             $send_to = $user->getEmail();
             ################################
             # FLAG: group room
             ################################
             if ($environment->inGroupRoom()) {
                 $current_context = $environment->getCurrentContextItem();
                 $group_item = $current_context->getLinkedGroupItem();
                 if (isset($group_item) and !empty($group_item)) {
                     $project_room_item = $current_context->getLinkedProjectItem();
                     if (isset($project_room_item) and !empty($project_room_item)) {
                         $project_room_user_item = $project_room_item->getUserByUserID($user->getUserID(), $user->getAuthSource());
                         $group_item->addMember($project_room_user_item);
                         unset($project_room_user_item);
                         unset($group_item);
                     }
                     unset($project_room_item);
                 }
                 unset($current_context);
                 unset($group_item);
             }
             ################################
             # FLAG: group room
             ################################
         } elseif ($action_array['action'] == 'USER_MAKE_CONTACT_PERSON') {
             $user->makeContactPerson();
             $user->save();
             $send_to = $user->getEmail();
         } elseif ($action_array['action'] == 'USER_UNMAKE_CONTACT_PERSON') {
             $user->makeNoContactPerson();
             $user->save();
             $send_to = $user->getEmail();
         } elseif ($action_array['action'] == 'USER_EMAIL_SEND') {
             $send_to = $user->getEmail();
         } elseif ($action_array['action'] == 'USER_EMAIL_ACCOUNT_PASSWORD') {
             $send_to = $user->getEmail();
         } elseif ($action_array['action'] == 'USER_EMAIL_ACCOUNT_MERGE') {
             $send_to = $user->getEmail();
         }
         if ($user->isEmailVisible()) {
             $formal_data_send_to[] = $user->getFullName() . " &lt;" . $send_to . "&gt;";
         } else {
             $translator = $environment->getTranslationObject();
             $formal_data_send_to[] = $user->getFullName() . " &lt;" . $translator->getMessage('USER_EMAIL_HIDDEN') . "&gt;";
         }
         // change task status
         if ($action_array['action'] == 'USER_ACCOUNT_DELETE' or $action_array['action'] == 'USER_ACCOUNT_LOCK' or $action_array['action'] == 'USER_ACCOUNT_FREE' or $action_array['action'] == 'USER_STATUS_USER' or $action_array['action'] == 'USER_STATUS_MODERATOR') {
             $task_manager = $environment->getTaskManager();
             $task_list = $task_manager->getTaskListForItem($user);
             if ($task_list->getCount() > 0) {
                 $task_item = $task_list->getFirst();
                 while ($task_item) {
                     if ($task_item->getStatus() == 'REQUEST' and ($task_item->getTitle() == 'TASK_USER_REQUEST' or $task_item->getTitle() == 'TASK_PROJECT_ROOM_REQUEST')) {
                         $task_item->setStatus('CLOSED');
                         $task_item->save();
                     }
                     $task_item = $task_list->getNext();
                 }
             }
             unset($task_list);
             unset($task_item);
             unset($task_manager);
         }
         // if commsy user is rejected, reject all accounts in projectrooms and community rooms
         if ($user->isRejected() and $environment->inPortal()) {
             $user_list = $user->getRelatedUserList();
             $user_item = $user_list->getFirst();
             while ($user_item) {
                 $user_item->reject();
                 $user_item->save();
                 $user_item = $user_list->getNext();
             }
             unset($user_list);
             unset($user_item);
         }
         // if commsy user is re-opend, re-open own room user
         if ($environment->inPortal() and isset($last_status) and (empty($last_status) or $last_status == 0)) {
             $user_own_room = $user->getRelatedPrivateRoomUserItem();
             if (isset($user_own_room)) {
                 $user_own_room->makeModerator();
                 $user_own_room->makeContactPerson();
                 $user_own_room->save();
             }
         }
         // send email
         if (isset($post_array['with_mail']) and $post_array['with_mail'] == '1') {
             include_once 'classes/cs_mail.php';
             $mail = new cs_mail();
             $mail->set_from_email($admin->getEmail());
             $mail->set_from_name($admin->getFullname());
             $mail->set_reply_to_email($admin->getEmail());
             $mail->set_reply_to_name($admin->getFullname());
             if (!isset($formal_data_from)) {
                 $formal_data_from = array($translator->getMessage('MAIL_FROM'), $admin->getFullname() . " &lt;" . $admin->getEmail() . "&gt;");
                 $formal_data[] = $formal_data_from;
             }
             if (!isset($formal_data_reply)) {
                 $formal_data_reply = array($translator->getMessage('REPLY_TO'), $admin->getFullname() . " &lt;" . $admin->getEmail() . "&gt;");
                 $formal_data[] = $formal_data_reply;
             }
             // subject and body
             // language
             $translator = $environment->getTranslationObject();
             $room = $environment->getCurrentContextItem();
             $url_to_room = LF . LF;
             $url_to_room .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $environment->getCurrentContextID();
             $subject = $_POST['subject'];
             $content = $_POST['content'];
             $content = str_replace('%1', $user->getFullname(), $content);
             // now prepare for each action separately
             if ($action_array['action'] == 'USER_ACCOUNT_DELETE' or $action_array['action'] == 'USER_ACCOUNT_LOCK' or $action_array['action'] == 'USER_ACCOUNT_FREE' or $action_array['action'] == 'USER_STATUS_USER' or $action_array['action'] == 'USER_STATUS_MODERATOR' or $action_array['action'] == 'USER_UNMAKE_CONTACT_PERSON' or $action_array['action'] == 'USER_MAKE_CONTACT_PERSON') {
                 if ($this->_environment->getCurrentPortalItem()->getHideAccountname()) {
                     $userid = $user->getFullName();
                 } else {
                     $userid = $user->getUserID();
                 }
                 $content = str_replace('%2', $userid, $content);
                 $content = str_replace('%3', $room->getTitle(), $content);
             } elseif ($action_array['action'] == 'USER_EMAIL_ACCOUNT_PASSWORD') {
                 $content = str_replace('%2', $room->getTitle(), $content);
                 $content = str_replace('%3', $userid, $content);
             } elseif ($action_array['action'] == 'USER_EMAIL_ACCOUNT_MERGE') {
                 $account_text = '';
                 $user_manager->resetLimits();
                 $user_manager->setContextLimit($environment->getCurrentContextID());
                 $user_manager->setUserLimit();
                 $user_manager->setSearchLimit($user->getEmail());
                 $user_manager->select();
                 $user_list = $user_manager->get();
                 if (!$user_list->isEmpty()) {
                     if ($user_list->getCount() > 1) {
                         $first = true;
                         $user_item = $user_list->getFirst();
                         while ($user_item) {
                             if ($first) {
                                 $first = false;
                             } else {
                                 $account_text .= LF;
                             }
                             $account_text .= $user_item->getUserID();
                             $user_item = $user_list->getNext();
                         }
                     } else {
                         include_once 'functions/error_functions.php';
                         trigger_error('that is impossible, list must be greater than one', E_USER_WARNING);
                     }
                 } else {
                     include_once 'functions/error_functions.php';
                     trigger_error('that is impossible, list must be greater than one', E_USER_WARNING);
                 }
                 $content = str_replace('%2', $user->getEmail(), $content);
                 $content = str_replace('%3', $room->getTitle(), $content);
                 $content = str_replace('%4', $account_text, $content);
             }
             unset($translator);
             unset($room);
             $translator = $environment->getTranslationObject();
             if (isset($subject) and !empty($subject)) {
                 $mail->set_subject($subject);
                 if (!isset($formal_data_subject)) {
                     $formal_data_subject = array($translator->getMessage('MAIL_SUBJECT'), $subject);
                 }
             }
             if (isset($content) and !empty($content)) {
                 $mail->set_message($content);
                 if (!isset($formal_data_message)) {
                     $formal_data_message = array($translator->getMessage('COMMON_MAIL_CONTENT') . ":", $content);
                 }
             }
             $mail->set_to($send_to);
             #// cc / bcc
             $cc_string = '';
             $bcc_string = '';
             $cc_array = array();
             $bcc_array = array();
             if (isset($post_array['cc']) and $post_array['cc'] == 'cc') {
                 $cc_array[] = $admin->getEmail();
             }
             if (isset($post_array['bcc']) and $post_array['bcc'] == 'bcc') {
                 $bcc_array[] = $admin->getEmail();
             }
             if (isset($post_array['cc_moderator']) and $post_array['cc_moderator'] == 'cc_moderator') {
                 $current_context = $environment->getCurrentContextItem();
                 $mod_list = $current_context->getModeratorList();
                 if (!$mod_list->isEmpty()) {
                     $moderator_item = $mod_list->getFirst();
                     while ($moderator_item) {
                         $email = $moderator_item->getEmail();
                         if (!empty($email)) {
                             $cc_array[] = $email;
                         }
                         unset($email);
                         $moderator_item = $mod_list->getNext();
                     }
                 }
                 unset($current_context);
             }
             if (isset($post_array['bcc_moderator']) and $post_array['bcc_moderator'] == 'bcc_moderator') {
                 $current_context = $environment->getCurrentContextItem();
                 $mod_list = $current_context->getModeratorList();
                 if (!$mod_list->isEmpty()) {
                     $moderator_item = $mod_list->getFirst();
                     while ($moderator_item) {
                         $email = $moderator_item->getEmail();
                         if (!empty($email)) {
                             $bcc_array[] = $email;
                         }
                         unset($email);
                         $moderator_item = $mod_list->getNext();
                     }
                 }
                 unset($current_context);
             }
             if (isset($post_array['copy']) and !empty($post_array['copy']) and !in_array($action_array['user_item_id'], $action_array['selected_ids']) and count($action_array['selected_ids']) == 1) {
                 $cc_array[] = $admin->getEmail();
             }
             if (!empty($cc_array)) {
                 $cc_array = array_unique($cc_array);
             }
             if (!empty($bcc_array)) {
                 $bcc_array = array_unique($bcc_array);
             }
             $cc_string = implode(",", $cc_array);
             $bcc_string = implode(",", $bcc_array);
             unset($cc_array);
             unset($bcc_array);
             if (!empty($cc_string)) {
                 $mail->set_cc_to($cc_string);
             }
             if (!empty($bcc_string)) {
                 $mail->set_bcc_to($bcc_string);
             }
             unset($cc_string);
             unset($bcc_string);
             $mail_success = $mail->send();
             $mail_error_array = $mail->getErrorArray();
             unset($mail);
         }
         unset($user);
     }
     if (isset($formal_data_send_to)) {
         $formal_data[] = array($translator->getMessage('MAIL_TO'), implode(",", $formal_data_send_to));
     }
     if (isset($formal_data_subject)) {
         $formal_data[] = $formal_data_subject;
     }
     if (isset($formal_data_message)) {
         $formal_data[] = $formal_data_message;
     }
     unset($user_manager);
     unset($admin);
     redirect($environment->getCurrentContextID(), $environment->getCurrentModule(), 'index');
 }
Ejemplo n.º 26
0
 public function sendContactMail($session_id, $context_id, $message)
 {
     $xml = "";
     if ($this->_isSessionValid($session_id)) {
         $context_id = $this->_encode_input($context_id);
         $this->_environment->setCurrentContextID($context_id);
         $contextItem = $this->_environment->getCurrentContextItem();
         $errorArray = array();
         // get the contact moderator list and prepare mail data
         $moderatorList = $contextItem->getContactModeratorList();
         $emailAddresses = array();
         $recipients = "";
         $moderatorItem = $moderatorList->getFirst();
         while ($moderatorItem) {
             $emailAddresses[] = $moderatorItem->getEmail();
             $recipients .= $moderatorItem->getFullname() . LF;
             $moderatorItem = $moderatorList->getnext();
         }
         // get user item
         $this->_environment->setSessionID($session_id);
         $session = $this->_environment->getSessionItem();
         $userId = $session->getValue('user_id');
         $authSourceId = $session->getValue('auth_source');
         $userManager = $this->_environment->getUserManager();
         $userItem = $userManager->getItemByUserIDAuthSourceID($userId, $authSourceId);
         // determe language
         $language = $contextItem->getLanguage();
         if ($language == "user") {
             $langguage = $userItem->getLanguage();
             if ($language == "browser") {
                 $langauge = $this->_environment->getSelectedLanguage();
             }
         }
         $emailAddresses = array_filter($emailAddresses, function ($element) {
             return trim($element) !== "";
         });
         // setup and send mails
         if ($emailAddresses) {
             $translator = $this->_environment->getTranslationObject();
             $oldLanguage = $translator->getSelectedLanguage();
             $subject = $translator->getMessage("USER_ASK_MAIL_SUBJECT", $userItem->getFullname(), $contextItem->getTitle());
             $body = "";
             $body .= $this->_encode_input($message);
             $body .= LF . LF;
             $body .= "---" . LF;
             $body .= $translator->getMessage("MAIL_SEND_TO", $recipients);
             $body .= LF;
             include_once 'classes/cs_mail.php';
             $mail = new cs_mail();
             $mail->set_to(implode(',', $emailAddresses));
             $mail->set_from_email($userItem->getEmail());
             $mail->set_from_name($userItem->getFullname());
             $mail->set_reply_to_name($userItem->getFullname());
             $mail->set_reply_to_email($userItem->getEmail());
             $mail->set_subject($subject);
             $mail->set_message($body);
             if (!$mail->send()) {
                 $errorArray["send"] = '';
             }
             $translator->getSelectedLanguage($oldLanguage);
         } else {
             $errorArray["missing"] = "Es wurden keine E-Mailadressen hinterlegt.";
         }
         if (sizeof($errorArray) > 0) {
             $xml = "<errors>\n";
             foreach ($errorArray as $code => $description) {
                 $xml .= "<" . $code . "><![CDATA[" . $description . "]]></" . $code . ">\n";
             }
             $xml .= "</errors>";
         } else {
             $xml = "<success></success>";
         }
         $xml = $this->_encode_output($xml);
     } else {
         return new SoapFault('ERROR', 'Session (' . $session_id . ') not valid!');
     }
     return $xml;
 }
Ejemplo n.º 27
0
 public function actionDetail()
 {
     $session = $this->_environment->getSessionItem();
     $environment = $this->_environment;
     $translator = $this->_environment->getTranslationObject();
     // try to set the item
     $this->setItem();
     #			if($this->_item->isA(CS_LABEL_TYPE) && $this->_item->getLabelType() === CS_GROUP_TYPE && $this->_item->isGroupRoomActivated()) {
     #				$this->_show_content_without_window = true;
     #			}
     $this->setupInformation();
     // TODO: include_once('include/inc_delete_entry.php');
     $label_manager = $this->_environment->getGroupManager();
     $account_mode = 'none';
     if (!empty($_GET['account'])) {
         $account_mode = $_GET['account'];
     }
     // use agb datasecurity
     $portal_item = $this->_environment->getCurrentPortalItem();
     $agb_checked = $_GET['agb'];
     // true or false
     if ($portal_item->getAGBStatus() == 2 and $portal_item->withAGBDatasecurity()) {
         if ($agb_checked == "true") {
             $check_agb_ds = true;
         } else {
             $check_agb_ds = false;
         }
     } else {
         $check_agb_ds = true;
     }
     $option = 'none';
     if (isset($_POST['option'])) {
         $option = $_POST['option'];
     }
     if (isOption($option, CS_OPTION_JOIN)) {
     }
     $type = $this->_item->getItemType();
     // check for correct type
     if ($type !== CS_GROUP_TYPE) {
         throw new cs_detail_item_type_exception('wrong item type', 0);
     } else {
         // used to signal which "craetor infos" of annotations are expanded...
         $creatorInfoStatus = array();
         if (!empty($_GET['creator_info_max'])) {
             $creatorInfoStatus = explode('-', $_GET['creator_info_max']);
         }
         // initialize
         $current_user = $this->_environment->getCurrentUser();
         // check for deleted
         if ($this->_item->isDeleted()) {
             throw new cs_detail_item_type_exception('item deleted', 1);
         } elseif (!$this->_item->maySee($current_user)) {
             // TODO: implement error handling
             /*
             * $params = array();
                   $params['environment'] = $environment;
                   $params['with_modifying_actions'] = true;
                   $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params);
                   unset($params);
                   $errorbox->setText($translator->getMessage('LOGIN_NOT_ALLOWED'));
                   $page->add($errorbox);
             */
         } else {
             // enter or leave group
             if (!empty($_GET['group_option'])) {
                 if ($_GET['group_option'] === '1') {
                     $room_item = $this->_item->getGroupRoomItem();
                     if (isset($room_item) and !empty($room_item)) {
                         $session = $environment->getSessionItem();
                         $params['iid'] = $this->_item->getItemID();
                         // build new user_item
                         if ((!$room_item->checkNewMembersWithCode() or $room_item->getCheckNewMemberCode() == $_GET['code']) and $check_agb_ds) {
                             $current_user = $environment->getCurrentUserItem();
                             $user_item = $current_user->cloneData();
                             $picture = $current_user->getPicture();
                             $user_item->setContextID($room_item->getItemID());
                             if (!empty($picture)) {
                                 $value_array = explode('_', $picture);
                                 $value_array[0] = 'cid' . $user_item->getContextID();
                                 $new_picture_name = implode('_', $value_array);
                                 $disc_manager = $environment->getDiscManager();
                                 $disc_manager->copyImageFromRoomToRoom($picture, $user_item->getContextID());
                                 $user_item->setPicture($new_picture_name);
                             }
                             if (isset($_POST['description_user'])) {
                                 $user_item->setUserComment($_POST['description_user']);
                             }
                             //check room_settings
                             if (!$room_item->checkNewMembersNever() and !$room_item->checkNewMembersWithCode()) {
                                 $user_item->request();
                                 $check_message = 'YES';
                                 // for mail body
                                 $account_mode = 'info';
                             } else {
                                 $user_item->makeUser();
                                 // for mail body
                                 $check_message = 'NO';
                                 $account_mode = 'to_room';
                             }
                             if ($portal_item->getAGBStatus() == 2 and $portal_item->withAGBDatasecurity()) {
                                 if ($agb_checked) {
                                     $user_item->setAGBAcceptance();
                                 }
                             }
                             // test if user id allready exist (reload page)
                             $user_id = $user_item->getUserID();
                             $user_test_item = $room_item->getUserByUserID($user_id, $user_item->getAuthSource());
                             if (!isset($user_test_item) and mb_strtoupper($user_id, 'UTF-8') != 'GUEST' and mb_strtoupper($user_id, 'UTF-8') != 'ROOT') {
                                 $user_item->save();
                                 $user_item->setCreatorID2ItemID();
                                 // save task
                                 if (!$room_item->checkNewMembersNever() and !$room_item->checkNewMembersWithCode()) {
                                     $task_manager = $environment->getTaskManager();
                                     $task_item = $task_manager->getNewItem();
                                     $current_user = $environment->getCurrentUserItem();
                                     $task_item->setCreatorItem($current_user);
                                     $task_item->setContextID($room_item->getItemID());
                                     $task_item->setTitle('TASK_USER_REQUEST');
                                     $task_item->setStatus('REQUEST');
                                     $task_item->setItem($user_item);
                                     $task_item->save();
                                 }
                                 // send email to moderators if necessary
                                 $user_list = $room_item->getModeratorList();
                                 $email_addresses = array();
                                 $moderator_item = $user_list->getFirst();
                                 $recipients = '';
                                 while ($moderator_item) {
                                     $want_mail = $moderator_item->getAccountWantMail();
                                     if (!empty($want_mail) and $want_mail == 'yes') {
                                         $email_addresses[] = $moderator_item->getEmail();
                                         $recipients .= $moderator_item->getFullname() . LF;
                                     }
                                     $moderator_item = $user_list->getNext();
                                 }
                                 // language
                                 $language = $room_item->getLanguage();
                                 if ($language == 'user') {
                                     $language = $user_item->getLanguage();
                                     if ($language == 'browser') {
                                         $language = $environment->getSelectedLanguage();
                                     }
                                 }
                                 if (count($email_addresses) > 0) {
                                     $save_language = $translator->getSelectedLanguage();
                                     $translator->setSelectedLanguage($language);
                                     $subject = $translator->getMessage('USER_JOIN_CONTEXT_MAIL_SUBJECT', $user_item->getFullname(), $room_item->getTitle());
                                     $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                                     $body .= LF . LF;
                                     // Datenschutz
                                     if ($this->_environment->getCurrentPortalItem()->getHideAccountname()) {
                                         $userid = 'XXX (aus Datenschutzgründen verborgen)';
                                     } else {
                                         $userid = $user_item->getUserID();
                                     }
                                     $body .= $translator->getMessage('GROUPROOM_USER_JOIN_CONTEXT_MAIL_BODY', $user_item->getFullname(), $userid, $user_item->getEmail(), $room_item->getTitle());
                                     $body .= LF . LF;
                                     switch ($check_message) {
                                         case 'YES':
                                             $body .= $translator->getMessage('USER_GET_MAIL_STATUS_YES');
                                             break;
                                         case 'NO':
                                             $body .= $translator->getMessage('USER_GET_MAIL_STATUS_NO');
                                             break;
                                         default:
                                             break;
                                     }
                                     $body .= LF . LF;
                                     if (!empty($_POST['description_user'])) {
                                         $body .= $translator->getMessage('MAIL_COMMENT_BY', $user_item->getFullname(), $_POST['description_user']);
                                         $body .= LF . LF;
                                     }
                                     $body .= $translator->getMessage('MAIL_SEND_TO', $recipients);
                                     if (!$room_item->checkNewMembersNever()) {
                                         $body .= LF;
                                         $body .= $translator->getMessage('MAIL_USER_FREE_LINK') . LF;
                                         $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $room_item->getItemID() . '&mod=account&fct=index&selstatus=1';
                                     } else {
                                         $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $room_item->getItemID();
                                     }
                                     include_once 'classes/cs_mail.php';
                                     $mail = new cs_mail();
                                     $mail->set_to(implode(',', $email_addresses));
                                     $server_item = $environment->getServerItem();
                                     $default_sender_address = $server_item->getDefaultSenderAddress();
                                     if (!empty($default_sender_address)) {
                                         $mail->set_from_email($default_sender_address);
                                     } else {
                                         $mail->set_from_email('@');
                                     }
                                     $current_context = $environment->getCurrentContextItem();
                                     $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $current_context->getTitle()));
                                     $mail->set_reply_to_name($user_item->getFullname());
                                     $mail->set_reply_to_email($user_item->getEmail());
                                     $mail->set_subject($subject);
                                     $mail->set_message($body);
                                     $mail->send();
                                     $translator->setSelectedLanguage($save_language);
                                 }
                                 // send email to user when account is free automatically
                                 // and make member of the group in the group room
                                 if ($user_item->isUser()) {
                                     // make member
                                     $this->_item->addMember($current_user);
                                     // get contact moderator (TBD) now first contect moderator
                                     $user_list = $room_item->getContactModeratorList();
                                     $contact_moderator = $user_list->getFirst();
                                     // change context to group room
                                     $translator->setEmailTextArray($room_item->getEmailTextArray());
                                     $translator->setContext(CS_GROUPROOM_TYPE);
                                     $save_language = $translator->getSelectedLanguage();
                                     // language
                                     $language = $room_item->getLanguage();
                                     if ($language == 'user') {
                                         $language = $user_item->getLanguage();
                                         if ($language == 'browser') {
                                             $language = $environment->getSelectedLanguage();
                                         }
                                     }
                                     $translator->setSelectedLanguage($language);
                                     // email texts
                                     $subject = $translator->getMessage('MAIL_SUBJECT_USER_STATUS_USER', $room_item->getTitle());
                                     $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                                     $body .= LF . LF;
                                     $body .= $translator->getEmailMessage('MAIL_BODY_HELLO', $user_item->getFullname());
                                     $body .= LF . LF;
                                     // Datenschutz
                                     if ($this->_environment->getCurrentPortalItem()->getHideAccountname()) {
                                         $userid = ' ';
                                     } else {
                                         $userid = $user_item->getUserID();
                                     }
                                     $body .= $translator->getEmailMessage('MAIL_BODY_USER_STATUS_USER', $userid, $room_item->getTitle());
                                     $body .= LF . LF;
                                     $body .= $translator->getEmailMessage('MAIL_BODY_CIAO', $contact_moderator->getFullname(), $room_item->getTitle());
                                     $body .= LF . LF;
                                     $body .= 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $environment->getCurrentContextID();
                                     // send mail to user
                                     include_once 'classes/cs_mail.php';
                                     $mail = new cs_mail();
                                     $mail->set_to($user_item->getEmail());
                                     $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $room_item->getTitle()));
                                     $server_item = $environment->getServerItem();
                                     $default_sender_address = $server_item->getDefaultSenderAddress();
                                     if (!empty($default_sender_address)) {
                                         $mail->set_from_email($default_sender_address);
                                     } else {
                                         $mail->set_from_email('@');
                                     }
                                     $mail->set_reply_to_email($contact_moderator->getEmail());
                                     $mail->set_reply_to_name($contact_moderator->getFullname());
                                     $mail->set_subject($subject);
                                     $mail->set_message($body);
                                     $mail->send();
                                 }
                             }
                         } elseif ($room_item->checkNewMembersWithCode() and $room_item->getCheckNewMemberCode() != $_GET['code']) {
                             $account_mode = 'member';
                             $error = 'code';
                         }
                         if ($account_mode == 'to_room') {
                             redirect($room_item->getItemID(), 'home', 'index', '');
                         } else {
                             $params['account'] = $account_mode;
                             if (isset($error) and !empty($error)) {
                                 $params['error'] = $error;
                             }
                             redirect($environment->getCurrentContextID(), $environment->getCurrentModule(), 'detail', $params);
                         }
                     } else {
                         $this->_item->addMember($current_user);
                         if ($this->_environment->getCurrentContextItem()->WikiEnableDiscussionNotificationGroups() === '1') {
                             $wiki_manager = $this->_environment->getWikiManager();
                             $wiki_manager->updateNotification();
                         }
                     }
                 } elseif ($_GET['group_option'] === '2') {
                     $this->_item->removeMember($current_user);
                     if ($this->_environment->getCurrentContextItem()->WikiEnableDiscussionNotificationGroups() === '1') {
                         $wiki_manager = $this->_environment->getWikiManager();
                         $wiki_manager->updateNotification();
                     }
                     if ($this->_item->isGroupRoomActivated()) {
                         $grouproom_item = $this->_item->getGroupRoomItem();
                         if (isset($grouproom_item) && !empty($grouproom_item)) {
                             $group_room_user_item = $grouproom_item->getUserByUserID($current_user->getUserID(), $current_user->getAuthSource());
                             $group_room_user_item->reject();
                             $group_room_user_item->save();
                         }
                     }
                 }
             } else {
                 if ($this->_item->isGroupRoomActivated()) {
                     $grouproom_item = $this->_item->getGroupRoomItem();
                     if (isset($grouproom_item) && !empty($grouproom_item)) {
                         if ($grouproom_item->checkNewMembersWithCode()) {
                             $this->assign("join", "code", true);
                         }
                         if ($grouproom_item->getAGBStatus() != 2) {
                             $this->assign("join", "agb", true);
                         }
                     }
                 }
             }
             // mark as read and noticed
             $this->markRead();
             $this->markNoticed();
             /*
             * // Create view
                   $context_item = $environment->getCurrentContextItem();
                   $params = array();
                   $params['environment'] = $environment;
                   $params['with_modifying_actions'] = $context_item->isOpen();
                   $params['creator_info_status'] = $creatorInfoStatus;
                   $detail_view = $class_factory->getClass(GROUP_DETAIL_VIEW,$params);
                   unset($params);
                   $detail_view->setItem($group_item);
             
                   #######################################
                   # FLAG: group room
                   #######################################
                   $detail_view->setAccountMode($account_mode);
                   #######################################
                   # FLAG: group room
                   #######################################
             */
             /*
             *
             
             
             
                   // Set up rubric connections and browsing
                   if ( $context_item->withRubric(CS_USER_TYPE) ) {
                      $ids = $group_item->getLinkedItemIDArray(CS_USER_TYPE);
                      $session->setValue('cid'.$environment->getCurrentContextID().'_user_index_ids', $ids);
                   }
                   $rubric_connections = array();
                   if ( $context_item->withRubric(CS_TOPIC_TYPE) ) {
                      $ids = $group_item->getLinkedItemIDArray(CS_TOPIC_TYPE);
                      $session->setValue('cid'.$environment->getCurrentContextID().'_topics_index_ids', $ids);
                      $rubric_connections = array(CS_TOPIC_TYPE);
                   }
                   $current_room_modules = $context_item->getHomeConf();
                   if ( !empty($current_room_modules) ){
                      $room_modules = explode(',',$current_room_modules);
                   } else {
                      $room_modules =  $default_room_modules;
                   }
                   $first = '';
                   foreach ( $room_modules as $module ) {
                      $link_name = explode('_', $module);
                      if ( $link_name[1] != 'none' ) {
                         switch ($link_name[0]) {
                            case CS_ANNOUNCEMENT_TYPE:
                               $ids = $group_item->getLinkedItemIDArray(CS_ANNOUNCEMENT_TYPE);
                               $session->setValue('cid'.$environment->getCurrentContextID().'_announcement_index_ids', $ids);
                               $rubric_connections[] = CS_ANNOUNCEMENT_TYPE;
                               break;
                            case 'todo':
                               $context = $environment->getCurrentContextItem();
                               if ($context->withRubric(CS_TODO_TYPE)){
                                  $ids = $group_item->getLinkedItemIDArray(CS_TODO_TYPE);
                                  $session->setValue('cid'.$environment->getCurrentContextID().'_todo_index_ids', $ids);
                                  $rubric_connections[] = CS_TODO_TYPE;
                               }
                               break;
                            case CS_DATE_TYPE:
                               $ids = $group_item->getLinkedItemIDArray(CS_DATE_TYPE);
                               $session->setValue('cid'.$environment->getCurrentContextID().'_dates_index_ids', $ids);
                               $rubric_connections[] = CS_DATE_TYPE;
                               break;
                            case 'material':
                               $ids = $group_item->getLinkedItemIDArray(CS_MATERIAL_TYPE);
                               $session->setValue('cid'.$environment->getCurrentContextID().'_material_index_ids', $ids);
                               $rubric_connections[] = CS_MATERIAL_TYPE;
                               break;
                            case 'discussion':
                               $ids = $group_item->getLinkedItemIDArray(CS_DISCUSSION_TYPE);
                               $session->setValue('cid'.$environment->getCurrentContextID().'_discussion_index_ids', $ids);
                               $rubric_connections[] = CS_DISCUSSION_TYPE;
                               break;
                         }
                      }
                   }
                   $detail_view->setRubricConnections($rubric_connections);
             
                   // highlight search words in detail views
                   $session_item = $environment->getSessionItem();
                   if ( $session->issetValue('cid'.$environment->getCurrentContextID().'_campus_search_parameter_array') ) {
                      $search_array = $session->getValue('cid'.$environment->getCurrentContextID().'_campus_search_parameter_array');
                      if ( !empty($search_array['search']) ) {
                         $detail_view->setSearchText($search_array['search']);
                      }
                      unset($search_array);
                   }
             
                   // Add view to page ... and done
                   $page->add($detail_view);
             */
             $this->assign('detail', 'content', $this->getDetailContent());
         }
     }
 }
Ejemplo n.º 28
0
 function exportItemToWiki_soap($current_item_id, $rubric)
 {
     global $c_commsy_path_file;
     global $c_pmwiki_path_file;
     global $c_pmwiki_absolute_path_file;
     global $c_pmwiki_path_url;
     global $c_commsy_domain;
     global $c_commsy_url_path;
     $translator = $this->_environment->getTranslationObject();
     $client = $this->getSoapClient();
     $client->createDir('uploads/Main', $this->_environment->getSessionID());
     $author = '';
     $description = '';
     if ($rubric == CS_MATERIAL_TYPE) {
         // Material Item
         $material_manager = $this->_environment->getMaterialManager();
         $material_version_list = $material_manager->getVersionList($current_item_id);
         $item = $material_version_list->getFirst();
         // Informationen
         $author = $item->getAuthor();
         if (empty($author)) {
             $author = $item->getModificatorItem()->getFullName();
             $description = $item->getDescription();
         }
         $informations = '!' . $item->getTitle() . '%0a%0a';
         $informations .= '(:table border=0 style="margin-left:0px;":)%0a';
         $informations .= '(:cell:)\'\'\'AutorInnen:\'\'\' %0a(:cell:)' . $author . ' %0a';
         // Kurzfassung fuer Wiki vorbereiten
         if (!preg_match('~<!-- KFC TEXT -->[\\S|\\s]*<!-- KFC TEXT -->~u', $description)) {
             $text_converter = $this->_environment->getTextConverter();
             $description = $text_converter->text_for_wiki_export($description);
             //$description = _text_php2html_long($description);
         }
     } elseif ($rubric == CS_DISCUSSION_TYPE) {
         // Discussion Item
         $discussion_manager = $this->_environment->getDiscussionManager();
         $item = $discussion_manager->getItem($current_item_id);
         $informations = '!' . $item->getTitle() . '%0a%0a';
     }
     if ($rubric == CS_MATERIAL_TYPE or $rubric == CS_DISCUSSION_TYPE) {
         global $class_factory;
         $params = array();
         $params['environment'] = $this->_environment;
         $wiki_view = $class_factory->getClass(WIKI_VIEW, $params);
         $wiki_view->setItem($item);
         $description = $wiki_view->formatForWiki($description);
         $description = $this->encodeUmlaute($description);
         $description = $this->encodeUrl($description);
         if ($rubric == CS_MATERIAL_TYPE) {
             $html_wiki_file = 'Main.CommSyMaterial' . $current_item_id . '.html';
         } elseif ($rubric == CS_DISCUSSION_TYPE) {
             $html_wiki_file = 'Main.CommSy' . $translator->getMessage('COMMON_DISCUSSION') . $current_item_id . '.html';
         }
         $old_dir = getcwd();
         $description = '<br />' . "\n" . $description;
         $client->uploadFile($html_wiki_file, base64_encode($description), 'uploads/Main', $this->_environment->getSessionID());
         $c_pmwiki_path_url_upload = preg_replace('~http://[^/]*~u', '', $c_pmwiki_path_url);
         $returnwiki = '(:includeupload /' . $c_pmwiki_path_url_upload . '/wikis/' . $this->_environment->getCurrentPortalID() . '/' . $this->_environment->getCurrentContextID() . '/uploads/Main/' . $html_wiki_file . ':)';
         if ($rubric == CS_MATERIAL_TYPE) {
             $informations .= '(:cellnr:)\'\'\'Kurzfassung:\'\'\' %0a(:cell:)' . $returnwiki . ' %0a';
         }
         // Dateien
         $file_list = $item->getFileList();
         if (!$file_list->isEmpty()) {
             $file_array = $file_list->to_array();
             $file_link_array = array();
             foreach ($file_array as $file) {
                 $new_filename = $this->encodeUrl($file->getDiskFileNameWithoutFolder());
                 $new_filename = preg_replace('~cid([0-9]*)_~u', '', $new_filename);
                 $new_filename = $new_filename . '.' . $file->getExtension();
                 $temp_file = file_get_contents($c_commsy_path_file . '/' . $file->getDiskFileName());
                 $client->uploadFile($new_filename, base64_encode($temp_file), 'uploads/Main', $this->_environment->getSessionID());
                 $new_link = $this->encodeUrlToHtml($file->getFileName());
                 $file_link_array[] = '[[' . $c_pmwiki_path_url . '/wikis/' . $this->_environment->getCurrentPortalID() . '/' . $this->_environment->getCurrentContextID() . '/uploads/Main/' . $new_filename . '|' . $new_link . ']]';
             }
             $file_links = implode('\\\\%0a', $file_link_array);
             $informations .= '(:cellnr:)\'\'\'Dateien:\'\'\' %0a(:cell:)' . $file_links . ' %0a';
         }
         if ($rubric == CS_MATERIAL_TYPE) {
             // Abschnitte
             $sub_item_list = $item->getSectionList();
         } elseif ($rubric == CS_DISCUSSION_TYPE) {
             $discussionarticles_manager = $this->_environment->getDiscussionArticlesManager();
             $discussionarticles_manager->setDiscussionLimit($item->getItemID(), array());
             $discussion_type = $item->getDiscussionType();
             if ($discussion_type == 'threaded') {
                 $discussionarticles_manager->setSortPosition();
             }
             if (isset($_GET['status']) and $_GET['status'] == 'all_articles') {
                 $discussionarticles_manager->setDeleteLimit(false);
             }
             $discussionarticles_manager->select();
             $sub_item_list = $discussionarticles_manager->get();
         }
         $sub_item_descriptions = '';
         if (!$sub_item_list->isEmpty()) {
             $size = $sub_item_list->getCount();
             $index_start = 1;
             if ($rubric == CS_DISCUSSION_TYPE and $size > 0) {
                 $size = $size - 1;
                 $index_start = 0;
             }
             $sub_item_link_array = array();
             $sub_item_description_array = array();
             for ($index = $index_start; $index <= $size; $index++) {
                 $sub_item = $sub_item_list->get($index);
                 if ($rubric == CS_DISCUSSION_TYPE) {
                     $sub_item_link_array[] = '(:cellnr width=50%:)' . ($index + 1) . '. [[#' . $sub_item->getSubject() . '|' . $sub_item->getSubject() . ']] %0a(:cell width=30%:)' . $sub_item->getCreatorItem()->getFullName() . ' %0a(:cell:)' . getDateTimeInLang($sub_item->getModificationDate()) . '%0a';
                 } else {
                     $sub_item_link_array[] = '[[#' . $sub_item->getTitle() . '|' . $sub_item->getTitle() . ']]';
                 }
                 // Abschnitt fuer Wiki vorbereiten
                 $description = $sub_item->getDescription();
                 if (!preg_match('~<!-- KFC TEXT -->[\\S|\\s]*<!-- KFC TEXT -->~u', $description)) {
                     $text_converter = $this->_environment->getTextConverter();
                     $description = $text_converter->text_for_wiki_export($description);
                     //$description = _text_php2html_long($sub_item->getDescription());
                 }
                 $params = array();
                 $params['environment'] = $this->_environment;
                 $params['with_modifying_actions'] = true;
                 $wiki_view = $this->_class_factory->getClass(WIKI_VIEW, $params);
                 unset($params);
                 $wiki_view->setItem($sub_item);
                 $description = $wiki_view->formatForWiki($description);
                 $description = $this->encodeUmlaute($description);
                 $description = $this->encodeUrl($description);
                 if ($rubric == CS_MATERIAL_TYPE) {
                     $html_wiki_file = 'Main.CommSyMaterial' . $current_item_id . '.sub_item.' . $sub_item->getItemID() . '.html';
                 } elseif ($rubric == CS_DISCUSSION_TYPE) {
                     $html_wiki_file = 'Main.CommSy' . $translator->getMessage('COMMON_DISCUSSION') . $current_item_id . '.sub_item.' . $sub_item->getItemID() . '.html';
                 }
                 $html_wiki_file = $this->encodeUmlaute($html_wiki_file);
                 $html_wiki_file = $this->encodeUrl($html_wiki_file);
                 $description = '<br />' . "\n" . $description;
                 $client->uploadFile($html_wiki_file, base64_encode($description), 'uploads/Main', $this->_environment->getSessionID());
                 $c_pmwiki_path_url_upload = preg_replace('~http://[^/]*~u', '', $c_pmwiki_path_url);
                 $returnwiki = '(:includeupload /' . $c_pmwiki_path_url_upload . '/wikis/' . $this->_environment->getCurrentPortalID() . '/' . $this->_environment->getCurrentContextID() . '/uploads/Main/' . $html_wiki_file . ':)';
                 $description_sub_item_link = str_replace(' ', '', $sub_item->getTitle());
                 // Dateien (Abschnitte)
                 $files = '%0a%0a';
                 $file_list = $sub_item->getFileList();
                 if (!$file_list->isEmpty()) {
                     $file_array = $file_list->to_array();
                     $file_link_array = array();
                     foreach ($file_array as $file) {
                         $new_filename = $this->encodeUrl($file->getDiskFileNameWithoutFolder());
                         $new_filename = preg_replace('~cid([0-9]*)_~u', '', $new_filename);
                         $new_filename = $new_filename . '.' . $file->getExtension();
                         $temp_file = file_get_contents($c_commsy_path_file . '/' . $file->getDiskFileName());
                         $client->uploadFile($new_filename, base64_encode($temp_file), 'uploads/Main', $this->_environment->getSessionID());
                         $new_link = $this->encodeUrlToHtml($file->getFileName());
                         $file_link_array[] = '[[' . $c_pmwiki_path_url . '/wikis/' . $this->_environment->getCurrentPortalID() . '/' . $this->_environment->getCurrentContextID() . '/uploads/Main/' . $new_filename . '|' . $new_link . ']]';
                     }
                     $file_links = implode('\\\\%0a', $file_link_array);
                     $files .= '(:table border=0 style="margin-left:0px;":)%0a';
                     $files .= '(:cell:)\'\'\'Dateien:\'\'\' %0a(:cell:)' . $file_links . ' %0a';
                     $files .= '(:tableend:) %0a';
                 }
                 $sub_item_description_array[] = '%0a----%0a%0a====%0a%0a!!' . $sub_item->getTitle() . '%0a[[#' . $description_sub_item_link . ']]%0a' . $returnwiki . $files;
             }
             if ($rubric == CS_MATERIAL_TYPE) {
                 $sub_item_links = implode('\\\\%0a', $sub_item_link_array);
                 $informations .= '(:cellnr:)\'\'\'' . $translator->getMessage('MATERIAL_SECTIONS') . ':\'\'\' %0a(:cell:)' . $sub_item_links . ' %0a';
             } elseif ($rubric == CS_DISCUSSION_TYPE) {
                 $sub_item_links = implode('', $sub_item_link_array);
                 $informations .= '(:cellnr:)%0a(:cell:)%0a';
                 $informations .= '(:table border=0 style="margin-left:0px;":)%0a';
                 $informations .= $sub_item_links;
                 $informations .= '(:tableend:) %0a';
             }
             $informations .= '(:tableend:) %0a';
             $sub_item_descriptions = implode('\\\\%0a', $sub_item_description_array);
         }
         $buzzword_text = '';
         $buzzword_list = $item->getBuzzwordList();
         $buzzword = $buzzword_list->getFirst();
         $buzzword_file_text = '';
         $commentbox_text = '';
         while ($buzzword) {
             if (!empty($buzzword_text)) {
                 $buzzword_text .= ', ';
             }
             if (!empty($buzzword_file_text)) {
                 $buzzword_file_text .= ',';
             }
             $buzzword_title = cs_ucfirst(str_replace('.', '', str_replace(' ', '', $buzzword->getTitle())));
             $buzzword_text .= '[[!' . $buzzword_title . ']]';
             $exists_file = $client->getPageExists('Category.' . $buzzword_title, $this->_environment->getSessionID());
             if (!$exists_file) {
                 $file_buzzword_contents = file_get_contents($c_commsy_path_file . '/etc/pmwiki/Category.Keyword');
                 $file_buzzword_contents = str_replace('CS_KEYWORD', $buzzword_title, $file_buzzword_contents);
                 $client->createPage('Category.' . $buzzword_title, $file_buzzword_contents, $this->_environment->getSessionID());
             }
             $buzzword_file_text .= 'Category.' . $buzzword_title;
             $buzzword = $buzzword_list->getNext();
         }
         if (!empty($buzzword_text)) {
             $buzzword_text = '%0a\\\\%0a' . $translator->getMessage('COMMON_BUZZWORDS') . ': ' . $buzzword_text;
         }
         if ($item->getItemType() == CS_MATERIAL_TYPE) {
             $wiki_file = 'Main.CommSyMaterial' . $current_item_id . '-Comments';
         } elseif ($item->getItemType() == CS_DISCUSSION_TYPE) {
             $wiki_file = 'Main.CommSy' . $translator->getMessage('COMMON_DISCUSSION') . $current_item_id . '-Comments';
         }
         $exists_file = $client->getPageExists($wiki_file, $this->_environment->getSessionID());
         if (!$exists_file) {
             $commentbox_text = '%0a%0a----%0a\\\\%0a' . '(:include Site.FoxCommentBox:)';
         }
         // Link zurueck ins CommSy
         global $c_single_entry_point;
         $link = '[[' . $c_commsy_domain . $c_commsy_url_path . '/' . $c_single_entry_point . '?cid=' . $this->_environment->getCurrentContextID() . '&mod=' . $rubric . '&fct=detail&iid=' . $current_item_id . '|"' . $item->getTitle() . '" im CommSy]]';
         $old_dir = getcwd();
         // Kurzfassung fuer Wiki vorbereiten
         if ($rubric == CS_MATERIAL_TYPE) {
             $file_contents = file_get_contents($c_commsy_path_file . '/etc/pmwiki/Main.Material');
         } elseif ($rubric == CS_DISCUSSION_TYPE) {
             $file_contents = file_get_contents($c_commsy_path_file . '/etc/pmwiki/Main.' . $translator->getMessage('COMMON_DISCUSSION'));
         }
         $file_contents_array = explode("\n", $file_contents);
         for ($index = 0; $index < sizeof($file_contents_array); $index++) {
             if (stripos($file_contents_array[$index], 'name=') !== false) {
                 if ($rubric == CS_MATERIAL_TYPE) {
                     $file_contents_array[$index] = 'name=Main.CommSyMaterial' . $current_item_id;
                 } elseif ($rubric == CS_DISCUSSION_TYPE) {
                     $file_contents_array[$index] = 'name=Main.CommSy' . $translator->getMessage('COMMON_DISCUSSION') . $current_item_id;
                 }
             }
             if (stripos($file_contents_array[$index], 'text=') !== false) {
                 if ($rubric == CS_MATERIAL_TYPE) {
                     $title_text = '(:title CommSy-Material "' . $item->getTitle() . '":)';
                 } elseif ($rubric == CS_DISCUSSION_TYPE) {
                     $title_text = '(:title CommSy-' . $translator->getMessage('COMMON_DISCUSSION') . ' "' . $item->getTitle() . '":)';
                 }
                 $file_contents_array[$index] = 'text=' . $informations . $sub_item_descriptions . '%0a%0a----%0a\\\\%0a' . $buzzword_text . '%0a\\\\%0a' . $link . $commentbox_text . '%0a%0a' . $title_text;
             }
             if (stripos($file_contents_array[$index], 'targets=') !== false and !empty($buzzword_file_text)) {
                 $file_contents_array[$index] = 'targets=' . $buzzword_file_text;
             }
         }
         $file_contents = implode("\n", $file_contents_array);
         if (!strstr($file_contents, 'targets=') and !empty($buzzword_file_text)) {
             $file_contents .= '"\\n"' . 'targets=' . $buzzword_file_text;
         }
         if ($rubric == CS_MATERIAL_TYPE) {
             $file_contents = $file_contents . "\n" . 'title=CommSy-Material "' . $item->getTitle() . '"';
             $client->createPage('Main.CommSyMaterial' . $current_item_id, $file_contents, $this->_environment->getSessionID());
         } elseif ($rubric == CS_DISCUSSION_TYPE) {
             $file_contents = $file_contents . 'title=CommSy-' . $translator->getMessage('COMMON_DISCUSSION') . ' "' . $item->getTitle() . '"';
             $client->createPage('Main.CommSy' . $translator->getMessage('COMMON_DISCUSSION') . '' . $current_item_id, $file_contents, $this->_environment->getSessionID());
         }
         $item->setExportToWiki('1');
         $item->save();
         $link_modifier_item_manager = $this->_environment->getLinkModifierItemManager();
         $modifiers = $link_modifier_item_manager->getModifiersOfItem($item->getItemID());
         $user_manager = $this->_environment->getUserManager();
         $user_manager->reset();
         $user_manager->setContextLimit($this->_environment->getCurrentContextID());
         $user_manager->setIDArrayLimit($modifiers);
         $user_manager->select();
         $user_list = $user_manager->get();
         if ($user_list->getCount() >= 1) {
             $user_item = $user_list->getFirst();
             include_once 'classes/cs_mail.php';
             $translator = $this->_environment->getTranslationObject();
             while ($user_item) {
                 $mail = new cs_mail();
                 $mail->set_to($user_item->getEmail());
                 $room = $this->_environment->getCurrentContextItem();
                 $room_title = '';
                 if (isset($room)) {
                     $room_title = $room->getTitle();
                 }
                 $from = $translator->getMessage('SYSTEM_MAIL_MESSAGE', $room_title);
                 $mail->set_from_name($from);
                 $server_item = $this->_environment->getServerItem();
                 $default_sender_address = $server_item->getDefaultSenderAddress();
                 if (!empty($default_sender_address)) {
                     $mail->set_from_email($default_sender_address);
                 } else {
                     $mail->set_from_email('@');
                 }
                 $subject = $translator->getMessage('MATERIAL_EXPORT_WIKI_MAIL_SUBJECT') . ': ' . $room_title;
                 $mail->set_subject($subject);
                 $body = $translator->getMessage('MATERIAL_EXPORT_WIKI_MAIL_BODY', $room_title, $this->_environment->getCurrentUserItem()->getFullname(), $item->getTitle(), $item->getExportToWikiLink());
                 $mail->set_message($body);
                 $mail->setSendAsHTML();
                 $mail->send();
                 $user_item = $user_list->getNext();
             }
         }
     }
     $this->updateExportLists($rubric);
 }
Ejemplo n.º 29
0
 public function save($form_data, $additional = array())
 {
     $environment = $this->_environment;
     $text_converter = $this->_environment->getTextConverter();
     if ($additional["contextId"]) {
         $itemManager = $this->_environment->getItemManager();
         $type = $itemManager->getItemType($additional["contextId"]);
         $manager = $this->_environment->getManager($type);
         $current_context = $manager->getItem($additional["contextId"]);
         if ($type === CS_PRIVATEROOM_TYPE) {
             $this->_environment->changeContextToPrivateRoom($current_context->getItemID());
         }
     }
     $current_user = $this->_environment->getCurrentUserItem();
     $current_context = $this->_environment->getCurrentContextItem();
     $current_iid = $form_data['iid'];
     if (isset($form_data['editType'])) {
         $this->_edit_type = $form_data['editType'];
     }
     $translator = $this->_environment->getTranslationObject();
     if ($current_iid === 'NEW') {
         $item = null;
     } else {
         $manager = $this->_environment->getMaterialManager();
         if (isset($additional['version_id']) and $additional['part'] != 'version') {
             $item = $manager->getItemByVersion($current_iid, $additional['version_id']);
         } else {
             $item = $manager->getItem($current_iid);
         }
     }
     $this->_popup_controller->performChecks($item, $form_data, $additional);
     // TODO: check rights */
     /****************************/
     if ($current_iid != 'NEW' and !isset($item)) {
     } elseif (!($current_iid == 'NEW' and $current_user->isUser() or $current_iid != 'NEW' and isset($item) and $item->mayEdit($current_user))) {
         /****************************/
     } elseif ($this->_edit_type != 'normal') {
         $this->cleanup_session($current_iid);
         // Set modificator and modification date
         $current_user = $environment->getCurrentUserItem();
         $item->setModificatorItem($current_user);
         if ($this->_edit_type == 'buzzwords') {
             $new_buzzword = '';
             $buzzwords = array();
             $buzzword_manager = $this->_environment->getLabelManager();
             $buzzword_manager->resetLimits();
             $buzzword_manager->setContextLimit($environment->getCurrentContextID());
             $buzzword_manager->setTypeLimit('buzzword');
             $buzzword_manager->select();
             $buzzword_list = $buzzword_manager->get();
             $buzzword_ids = $buzzword_manager->getIDArray();
             if (isset($form_data['buzzwords'])) {
                 foreach ($form_data['buzzwords'] as $buzzword) {
                     if (!in_array($buzzword, $buzzword_ids)) {
                         $new_buzzword = $buzzword;
                     } else {
                         $buzzwords[] = $buzzword;
                     }
                 }
             }
             // buzzwords
             $item->setBuzzwordListByID($buzzwords);
         }
         if ($this->_edit_type == 'tags') {
             // buzzwords
             $item->setTagListByID($form_data['tags']);
         }
         $item->save();
         // save session
         $session = $this->_environment->getSessionItem();
         $this->_environment->getSessionManager()->save($session);
         // Add modifier to all users who ever edited this item
         $manager = $environment->getLinkModifierItemManager();
         $manager->markEdited($item->getItemID());
         // set return
         $this->_popup_controller->setSuccessfullItemIDReturn($item->getItemID(), CS_MATERIAL_TYPE);
     } else {
         //Acces granted
         $this->cleanup_session($current_iid);
         $check_passed = $this->_popup_controller->checkFormData('general');
         if ($check_passed === true && $form_data['bib_kind'] !== 'none') {
             $check_passed = $this->_popup_controller->checkFormData($form_data['bib_kind']);
         }
         // save item
         if ($check_passed === true) {
             $session = $this->_environment->getSessionItem();
             $item_is_new = false;
             // Create new item
             if (!isset($item)) {
                 $manager = $environment->getMaterialManager();
                 $item = $manager->getNewItem();
                 $item->setContextID($current_context->getItemID());
                 $item->setCreatorItem($current_user);
                 $item->setCreationDate(getCurrentDateTimeInMySQL());
                 $item_is_new = true;
             }
             // Create new version button pressed
             if ($additional['part'] == 'version') {
                 $new_version_id = $item->getVersionID() + 1;
                 $new_version = true;
                 $item = $item->cloneCopy($new_version);
                 $item->setVersionID($new_version_id);
                 $infoBox_forAutoNewVersion = '';
             }
             // Set modificator and modification date
             $item->setModificatorItem($current_user);
             // Set attributes
             if (isset($form_data['title'])) {
                 $item->setTitle($form_data['title']);
             }
             if (isset($form_data['description'])) {
                 $item->setDescription($this->_popup_controller->getUtils()->cleanCKEditor($form_data['description']));
             }
             // already attached files
             $file_ids = array();
             foreach ($form_data as $key => $value) {
                 if (mb_substr($key, 0, 5) === 'file_') {
                     $file_ids[] = $value;
                 }
             }
             // this will handle already attached files as well as adding new files
             $this->_popup_controller->getUtils()->setFilesForItem($item, $file_ids, $form_data["files"]);
             if (isset($form_data["external_viewer"])) {
                 $item->setPrivateEditing('0');
             } else {
                 if (isset($form_data['private_editing'])) {
                     $item->setPrivateEditing('0');
                 } else {
                     $item->setPrivateEditing('1');
                 }
             }
             if (isset($form_data['rights_tab'])) {
                 if (isset($form_data['public'])) {
                     $item->setPublic($form_data['public']);
                 }
                 if (isset($form_data['public'])) {
                     if ($item->isPublic() != $form_data['public']) {
                         $item->setPublic($form_data['public']);
                     }
                 } else {
                     if (isset($form_data['private_editing'])) {
                         $item->setPrivateEditing('0');
                     } else {
                         $item->setPrivateEditing('1');
                     }
                 }
                 if (isset($form_data['hide'])) {
                     // variables for datetime-format of end and beginning
                     $dt_hiding_time = '00:00:00';
                     $dt_hiding_date = '9999-00-00';
                     $dt_hiding_datetime = '';
                     $converted_activating_time_start = convertTimeFromInput($form_data['activating_time']);
                     if ($converted_activating_time_start['conforms'] == TRUE) {
                         $dt_hiding_time = $converted_activating_time_start['datetime'];
                     }
                     $converted_activate_day_start = convertDateFromInput($form_data['activating_date'], $environment->getSelectedLanguage());
                     if ($converted_activate_day_start['conforms'] == TRUE) {
                         $dt_hiding_date = $converted_activate_day_start['datetime'];
                     }
                     $dt_hiding_datetime = $dt_hiding_date . ' ' . $dt_hiding_time;
                     $item->setModificationDate($dt_hiding_datetime);
                 } else {
                     if ($item->isNotActivated()) {
                         $item->setModificationDate(getCurrentDateTimeInMySQL());
                     }
                 }
             }
             // set bibliographic
             $this->setBibliographic($form_data, $item);
             /** Start Dokumentenverwaltung **/
             if (isset($form_data['document_editor']) and $item->getDocumentEditor() != $form_data['document_editor']) {
                 $item->setDocumentEditor($form_data['document_editor']);
             }
             if (isset($form_data['document_maintainer']) and $item->getDocumentMaintainer() != $form_data['document_maintainer']) {
                 $item->setDocumentMaintainer($form_data['document_maintainer']);
             }
             if (isset($form_data['document_release_number']) and $item->getDocumentReleaseNumber() != $form_data['document_release_number']) {
                 $item->setDocumentReleaseNumber($form_data['document_release_number']);
             }
             if (isset($form_data['document_release_date']) and $item->getDocumentReleaseDate() != $form_data['document_release_date']) {
                 $item->setDocumentReleaseDate($form_data['document_release_date']);
             }
             /** Ende Dokumentenverwaltung **/
             if (isset($form_data['foto_copyright']) and $item->getDocumentReleaseDate() != $form_data['foto_copyright']) {
                 $item->setFotoCopyright($form_data['foto_copyright']);
             }
             if (isset($form_data['foto_reason']) and $item->getDocumentReleaseDate() != $form_data['foto_reason']) {
                 $item->setFotoReason($form_data['foto_reason']);
             }
             if (isset($form_data['foto_date']) and $item->getDocumentReleaseDate() != $form_data['foto_date']) {
                 $item->setFotoDate($form_data['foto_date']);
             }
             if (isset($form_data['external_viewer']) and isset($form_data['external_viewer_accounts'])) {
                 $user_ids = explode(" ", $form_data['external_viewer_accounts']);
                 $item->setExternalViewerAccounts($user_ids);
             } else {
                 $item->unsetExternalViewerAccounts();
             }
             // workflow
             if (isset($form_data['workflow_traffic_light']) and $item->getWorkflowTrafficLight() != $form_data['workflow_traffic_light']) {
                 $item->setWorkflowTrafficLight($form_data['workflow_traffic_light']);
             }
             if (isset($form_data['workflow_resubmission']) and $item->getWorkflowResubmission() != $form_data['workflow_resubmission']) {
                 $item->setWorkflowResubmission($form_data['workflow_resubmission']);
             } else {
                 if (!isset($form_data['workflow_resubmission'])) {
                     $item->setWorkflowResubmission(0);
                 }
             }
             if (isset($form_data['workflow_resubmission_date']) and $item->getWorkflowResubmissionDate() != $form_data['workflow_resubmission_date']) {
                 $dt_workflow_resubmission_time = '00:00:00';
                 $dt_workflow_resubmission_date = $form_data['workflow_resubmission_date'];
                 $dt_workflow_resubmission_datetime = '';
                 $converted_day_start = convertDateFromInput($form_data['workflow_resubmission_date'], $environment->getSelectedLanguage());
                 if ($converted_day_start['conforms'] == TRUE) {
                     $dt_workflow_resubmission_datetime = $converted_day_start['datetime'] . ' ';
                     $dt_workflow_resubmission_datetime .= $dt_workflow_resubmission_time;
                 }
                 $item->setWorkflowResubmissionDate($dt_workflow_resubmission_datetime);
             } else {
                 $item->setWorkflowResubmissionDate('');
             }
             if (isset($form_data['workflow_resubmission_who']) and $item->getWorkflowResubmissionWho() != $form_data['workflow_resubmission_who']) {
                 $item->setWorkflowResubmissionWho($form_data['workflow_resubmission_who']);
             }
             if (isset($form_data['workflow_resubmission_who_additional']) and !empty($form_data['workflow_resubmission_who_additional'])) {
                 $item->setWorkflowResubmissionWhoAdditional($form_data['workflow_resubmission_who_additional']);
             }
             if (isset($form_data['workflow_resubmission_traffic_light']) and $item->getWorkflowResubmissionTrafficLight() != $form_data['workflow_resubmission_traffic_light']) {
                 $item->setWorkflowResubmissionTrafficLight($form_data['workflow_resubmission_traffic_light']);
             }
             if (isset($form_data['workflow_validity']) and $item->getWorkflowValidity() != $form_data['workflow_validity']) {
                 $item->setWorkflowValidity($form_data['workflow_validity']);
             } else {
                 if (!isset($form_data['workflow_validity'])) {
                     $item->setWorkflowValidity(0);
                 }
             }
             if (isset($form_data['workflow_validity_date']) and $item->getWorkflowValidityDate() != $form_data['workflow_validity_date']) {
                 $dt_workflow_validity_time = '00:00:00';
                 $dt_workflow_validity_date = $form_data['workflow_validity_date'];
                 $dt_workflow_validity_datetime = '';
                 $converted_day_start = convertDateFromInput($form_data['workflow_validity_date'], $environment->getSelectedLanguage());
                 if ($converted_day_start['conforms'] == TRUE) {
                     $dt_workflow_validity_datetime = $converted_day_start['datetime'] . ' ';
                     $dt_workflow_validity_datetime .= $dt_workflow_resubmission_time;
                 }
                 $item->setWorkflowValidityDate($dt_workflow_validity_datetime);
             } else {
                 $item->setWorkflowValidityDate('');
             }
             if (isset($form_data['workflow_validity_who']) and $item->getWorkflowValidityWho() != $form_data['workflow_validity_who']) {
                 $item->setWorkflowValidityWho($form_data['workflow_validity_who']);
             }
             if (isset($form_data['workflow_validity_who_additional']) and !empty($form_data['workflow_validity_who_additional'])) {
                 $item->setWorkflowValidityWhoAdditional($form_data['workflow_validity_who_additional']);
             }
             if (isset($form_data['workflow_validity_traffic_light']) and $item->getWorkflowValidityTrafficLight() != $form_data['workflow_validity_traffic_light']) {
                 $item->setWorkflowValidityTrafficLight($form_data['workflow_validity_traffic_light']);
             }
             if ($current_context->isCommunityRoom() and $current_context->isOpenForGuests()) {
                 $old_world_public = $item->getWorldPublic();
                 if (isset($form_data['world_public']) and $old_world_public == 0 or !isset($form_data['world_public']) and $old_world_public == 2 and !$current_user->isModerator()) {
                     // Request for world public
                     $item->setWorldPublic(1);
                     $createATask = 'TASK_REQUEST_MATERIAL_WORLDPUBLIC';
                 } elseif (isset($form_data['world_public']) and $old_world_public == 1) {
                     $item->setWorldPublic(0);
                     $createATask = 'TASK_CANCEL_MATERIAL_WORLDPUBLIC';
                 } elseif (isset($form_data['world_public']) and $old_world_public == 2) {
                     $item->setWorldPublic(0);
                     $createATask = '';
                 } else {
                     $createATask = '';
                 }
             } else {
                 $createATask = '';
             }
             // buzzwords
             // save buzzwords
             $this->saveBuzzwords($environment, $item, $form_data['buzzwords']);
             // tags
             if (isset($form_data['tags_tab'])) {
                 $item->setTagListByID($form_data['tags']);
             }
             // Save item
             $item->save();
             // workflow - unset read markers
             $item_manager = $environment->getItemManager();
             $item_manager->markItemAsWorkflowNotReadForAllUsers($item->getItemID());
             $item_manager->markItemAsWorkflowRead($item->getItemID(), $current_user->getItemID());
             // send notifications if world public status is requested
             if ($item->getWorldPublic() == 1 and isset($current_context) and $current_context->isCommunityRoom()) {
                 // Get receiving moderators
                 $modList = $current_context->getModeratorList();
                 $moderator = $modList->getFirst();
                 $mailSendTo = '';
                 while ($moderator) {
                     if ($moderator->getPublishMaterialWantMail() == 'yes') {
                         $mailSendTo .= $moderator->getFullName() . LF;
                     }
                     $moderator = $modList->getNext();
                 }
                 // Send mails // Warum werden die einzeln verschickt ???
                 $moderator = $modList->getFirst();
                 $translator = $environment->getTranslationObject();
                 while ($moderator) {
                     if ($moderator->getPublishMaterialWantMail() == 'yes') {
                         include_once 'classes/cs_mail.php';
                         $mail = new cs_mail();
                         $sender = $item->getModificatorItem();
                         $mail->set_from_name($sender->getFullName());
                         $mail->set_from_email($sender->getEMail());
                         $mail->set_reply_to_name($sender->getFullName());
                         $mail->set_reply_to_email($sender->getEMail());
                         $mail->set_to($moderator->getEMail());
                         $language = $moderator->getLanguage();
                         $translator->setSelectedLanguage($language);
                         $mail_subject = $translator->getMessage('ADMIN_MAIL_MATERIAL_SHOULD_BE_WORLDPUBLIC_SUBJECT', $current_context->getTitle());
                         $mail_body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                         $mail_body .= "\n\n";
                         $mail_body .= $translator->getMessage('ADMIN_MAIL_MATERIAL_SHOULD_BE_WORLDPUBLIC_BODY', $item->getTitle(), $current_context->getTitle(), $sender->getFullName());
                         $mail_body .= "\n\n";
                         $mail_body .= $translator->getMessage('MAIL_SEND_TO', $mailSendTo);
                         $mail_body .= "\n";
                         $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $environment->getCurrentContextID() . '&mod=material_admin&fct=index&iid=' . $item->getItemID() . '&selstatus=1';
                         $mail_body .= $url;
                         $mail->set_subject($mail_subject);
                         $mail->set_message($mail_body);
                         $mail->send();
                     }
                     $moderator = $modList->getNext();
                 }
             }
             // Create tasks for world public status
             if ($createATask == 'TASK_REQUEST_MATERIAL_WORLDPUBLIC') {
                 $task_manager = $environment->getTaskManager();
                 $task_item = $task_manager->getNewItem();
                 $task_item->setTitle('TASK_REQUEST_MATERIAL_WORLDPUBLIC');
                 $task_item->setStatus('REQUEST');
                 $user = $environment->getCurrentUserItem();
                 $task_item->getCreatorItem($user);
                 $task_item->setItem($item);
                 $task_item->save();
             } elseif ($createATask == 'TASK_CANCEL_MATERIAL_WORLDPUBLIC') {
                 $task_manager = $environment->getTaskManager();
                 // Close any open requests
                 $task_list = $task_manager->getTaskListForItem($item);
                 if (!$task_list->isEmpty()) {
                     $task_item = $task_list->getFirst();
                     while ($task_item) {
                         if ($task_item->getStatus() == 'REQUEST' and $task_item->getTitle() == 'TASK_REQUEST_MATERIAL_WORLDPUBLIC') {
                             $task_item->setStatus('CLOSED');
                             $task_item->save();
                         }
                         $task_item = $task_list->getNext();
                     }
                 }
                 // Create new task
                 $task_item = $task_manager->getNewItem();
                 $task_item->setTitle('TASK_CANCEL_MATERIAL_WORLDPUBLIC');
                 $task_item->setStatus('CLOSED');
                 $user = $environment->getCurrentUserItem();
                 $task_item->getCreatorItem($user);
                 $task_item->setItem($item);
                 $task_item->save();
             }
             // this will update the right box list
             if ($item_is_new) {
                 if ($session->issetValue('cid' . $environment->getCurrentContextID() . '_' . CS_MATERIAL_TYPE . '_index_ids')) {
                     $id_array = array_reverse($session->getValue('cid' . $environment->getCurrentContextID() . '_' . CS_MATERIAL_TYPE . '_index_ids'));
                 } else {
                     $id_array = array();
                 }
                 $id_array[] = $item->getItemID();
                 $id_array = array_reverse($id_array);
                 $session->setValue('cid' . $environment->getCurrentContextID() . '_' . CS_MATERIAL_TYPE . '_index_ids', $id_array);
             }
             // save session
             $this->_environment->getSessionManager()->save($session);
             // Add modifier to all users who ever edited this item
             $manager = $environment->getLinkModifierItemManager();
             $manager->markEdited($item->getItemID());
             // set return
             $this->_popup_controller->setSuccessfullItemIDReturn($item->getItemID());
         }
     }
 }
Ejemplo n.º 30
0
 public function actionInviteParticipants()
 {
     $groupId = $this->_data["groupId"];
     $mailAddresses = $this->_data["participantMails"];
     $mailSubject = $this->_data["participantMailSubject"];
     $mailText = $this->_data["participantMailtext"];
     $withTokens = $this->_data["withTokens"];
     $surveyId = $this->_data["surveyId"];
     $currentContextItem = $this->_environment->getCurrentContextItem();
     // LimeSurvey RPC
     $this->initClient();
     if ($withTokens === true) {
         $members = array();
         // get all member of the selected group - if set
         if ($groupId !== "none") {
             $groupManager = $this->_environment->getGroupManager();
             $groupItem = $groupManager->getItem($groupId);
             if ($groupItem !== null) {
                 $memberList = $groupItem->getMemberItemList();
                 $member = $memberList->getFirst();
                 while ($member) {
                     $members[] = array("email" => $member->getEmail(), "firstname" => $member->getFirstName(), "lastname" => $member->getLastName());
                     $member = $memberList->getNext();
                 }
             }
         }
         // add additional participants, if given
         $additionalParticipants = array();
         foreach ($this->_data['formValues'] as $formKey => $formValue) {
             if (!empty($formValue) && preg_match('/^additional(FirstName|LastName|Mail)_(\\d+)/', $formKey, $matches) === 1) {
                 $key = '';
                 if ($matches[1] === "FirstName") {
                     $key = 'firstname';
                 } else {
                     if ($matches[1] === "LastName") {
                         $key = 'lastname';
                     } else {
                         $key = 'mail';
                     }
                 }
                 $additionalParticipants[$matches[2]][$key] = $formValue;
             }
         }
         if (!empty($additionalParticipants)) {
             $members = array_merge($members, $additionalParticipants);
         }
         // activate tokens
         // unfortunately survey properties does not reflect the correct usetokens setting
         $tokenStatus = $this->client->activate_tokens($this->sessionKey, $surveyId);
         // add participants
         $participantData = $this->client->add_participants($this->sessionKey, $surveyId, $members, true);
         // check for errors
         if (isset($participantData["status"])) {
             $this->closeClient();
             $this->setErrorReturn("903", $participantData["status"]);
             echo $this->_return;
             exit;
         }
         // remind participants
         $inviteData = $this->client->invite_participants($this->sessionKey, $surveyId);
     } else {
         // sanitize
         $textConverter = $this->_environment->getTextConverter();
         $mailAddresses = $textConverter->sanitizeHTML($mailAddresses);
         $mailSubject = $textConverter->sanitizeHTML($mailSubject);
         $mailText = $textConverter->sanitizeFullHTML($mailText);
         $survey = $this->getSurveyFromLimeSurvey($this->sessionKey, $surveyId);
         $surveyTitle = $survey["surveyls_title"];
         $portalItem = $this->_environment->getCurrentPortalItem();
         $rpcPathParsed = parse_url($portalItem->getLimeSurveyJsonRpcUrl());
         $surveyUrl = $rpcPathParsed['scheme'] . "://" . $rpcPathParsed['host'] . "/index.php/" . $surveyId;
         // extract the reciever
         $mailArray = array_unique(array_merge(explode(" ", $mailAddresses), explode("\n", $mailAddresses), explode(";", $mailAddresses), explode(",", $mailAddresses)));
         // replace placeholders in mail text
         $mailText = str_replace("{SURVEY_TITLE}", $surveyTitle, $mailText);
         $mailText = str_replace("{SURVEY_URL}", $surveyUrl, $mailText);
         $currentUserItem = $this->_environment->getCurrentUserItem();
         // send mails
         include_once "classes/cs_mail.php";
         $mail = new cs_mail();
         $mail->set_from_email($currentUserItem->getEmail());
         $mail->set_from_name($currentUserItem->getFullname());
         $mail->set_reply_to_email($currentUserItem->getEmail());
         $mail->set_reply_to_name($currentUserItem->getFullname());
         $mail->set_subject($mailSubject);
         $mail->set_message($mailText);
         foreach ($mailArray as $mailAddress) {
             $mail->set_to($mailAddress);
             $mail->send();
         }
     }
     // close
     $this->closeClient();
     $this->setSuccessfullDataReturn(array());
     echo $this->_return;
 }