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.º 2
0
	      } 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.º 3
0
                     }
                     $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);
                        $mail->set_message($mail_body);
                        $mail->send();
Ejemplo n.º 4
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.º 5
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() . " <" . $send_to . ">";
         } else {
             $translator = $environment->getTranslationObject();
             $formal_data_send_to[] = $user->getFullName() . " <" . $translator->getMessage('USER_EMAIL_HIDDEN') . ">";
         }
         // 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() . " <" . $admin->getEmail() . ">");
                 $formal_data[] = $formal_data_from;
             }
             if (!isset($formal_data_reply)) {
                 $formal_data_reply = array($translator->getMessage('REPLY_TO'), $admin->getFullname() . " <" . $admin->getEmail() . ">");
                 $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.º 6
0
 							$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);
 					}
 				}
 			}
 			
 		} else {
 			// room id existiert nicht
 			$params = array();
 			$params['environment'] = $environment;
 			$params['with_modifying_actions'] = true;
 			$errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params);
 			unset($params);
Ejemplo n.º 7
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);
 }
 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.º 9
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.º 10
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.º 11
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);
 }
Ejemplo n.º 12
0
 private function _deleteMembership($mail, $membership_info, $id_manager)
 {
     $return_array = array("error" => 0, "value" => '');
     $source = $membership_info->getSourceSystem();
     $manager = $this->_environment->getUserManager();
     $stine_room_id = $membership_info->getRoomId();
     $stine_user_id = $membership_info->getSourceItemId();
     $commsy_user_id = $id_manager->getCommSyId($source, $stine_user_id);
     $commsy_room_id = $id_manager->getCommSyId($source, $stine_room_id);
     if (!empty($commsy_user_id)) {
         $user_item = $manager->getItem($commsy_user_id);
         $user_email = $user_item->getEmail();
         $manager->setUserIdLimit($user_item->getUserId());
         $manager->setAuthSourceLimit($user_item->getAuthSource());
         $manager->setContextLimit($commsy_room_id);
         $manager->setDeleteLimit(true);
         $manager->select();
         $user_list = $manager->get();
         $commsy_user_id_delete = 0;
         $delete_user = $user_list->getFirst();
         if (!empty($delete_user)) {
             // Mail to deleted member
             $portal_user = $user_item->getRelatedCommSyUserItem();
             $portal_id = $portal_user->getContextId();
             $portal_manager = $this->_environment->getPortalManager();
             $portal_item = $portal_manager->getItem($portal_id);
             $translator = $this->_environment->getTranslationObject();
             $room_manager = $this->_environment->getRoomManager();
             $room_item = $room_manager->getItem($commsy_room_id);
             $language = $room_item->getLanguage();
             $translator->initFromContext($room_item);
             $contact_list = $room_item->getContactModeratorList();
             $contact = $contact_list->getFirst();
             $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $room_item->getTitle()));
             $mail->set_to($delete_user->getEmail());
             $mail->set_reply_to_name($contact->getFullname());
             $mail->set_reply_to_email($contact->getEmail());
             $link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
             global $c_single_entry_point;
             $link = str_replace('soap.php', $c_single_entry_point . '?cid=' . $room_item->getItemId(), $link);
             $mail->set_subject($translator->getMessage('MAIL_SUBJECT_USER_MEMBERSHIP_DELETE', $room_item->getTitle()));
             $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
             $body .= LF . LF;
             $body .= $translator->getEmailMessage('MAIL_BODY_HELLO', $delete_user->getFullname());
             $body .= LF . LF;
             $body .= $translator->getEmailMessage('MAIL_BODY_USER_ACCOUNT_DELETE', $delete_user->getUserID(), $room_item->getTitle());
             $body .= LF . LF;
             $body .= $translator->getEmailMessage('MAIL_BODY_CIAO', $contact->getFullname(), $room_item->getTitle());
             $body .= LF . LF;
             $body .= $link;
             $mail->set_message($body);
             $mail->send();
             // mail handling for room moderators
             $user_list = $room_item->getModeratorList();
             $user_item = $user_list->getFirst();
             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 = $translator->getSelectedLanguage();
             foreach ($email_addresses as $key => $value) {
                 $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($translator->getMessage('SYSTEM_MAIL_MESSAGE', $room_item->getTitle()));
                     $mail->set_reply_to_name($delete_user->getFullname());
                     $mail->set_reply_to_email($delete_user->getEmail());
                     $mail->set_subject($translator->getMessage('USER_QUIT_CONTEXT_MAIL_SUBJECT', $delete_user->getFullname(), $room_item->getTitle()));
                     $body = $translator->getMessage('MAIL_AUTO', $translator->getDateInLang(getCurrentDateTimeInMySQL()), $translator->getTimeInLang(getCurrentDateTimeInMySQL()));
                     $body .= LF . LF;
                     $temp_language = $portal_user->getLanguage();
                     if ($temp_language == 'browser') {
                         $temp_language = $this->_environment->getSelectedLanguage();
                     }
                     $body .= $translator->getMessage('USER_QUIT_PROJECT_MAIL_BODY', $delete_user->getFullname(), $delete_user->getUserId(), $delete_user->getEmail(), $room_item->getTitle());
                     unset($temp_language);
                     $body .= LF . LF;
                     $body .= $translator->getMessage('MAIL_COMMENT_BY', 'IMS', $translator->getMessage('MAIL_COMMENT_IMS', $source));
                     $body .= LF . LF;
                     $body .= $translator->getMessage('MAIL_SEND_TO', $recipients);
                     $body .= LF;
                     $body .= $link;
                     $mail->set_message($body);
                     $mail->send();
                 }
             }
             $translator->setSelectedLanguage($save_language);
             //Delete User
             $commsy_user_id_delete = $delete_user->getItemId();
             $delete_user->delete();
             $return_array = array("error" => 0, "value" => 'User "' . $stine_user_id . '" is now un-enrolled from room "' . $stine_room_id . '". (CommSy-Id of unenrolled user: '******')');
             $this->_log('IMS', 'deleteMembership', 'User "' . $stine_user_id . '" is now un-enrolled from room "' . $stine_room_id . '". (CommSy-Id of unenrolled user: '******')');
         } else {
             $info_text = 'User:  '******' is not enrolled in group ' . $stine_room_id . '!';
             $return_array = array("error" => 1, "value" => $info_text);
         }
     } else {
         $info_text = 'Trying to unenroll an unknown person:  ' . $stine_user_id . ' !';
         $return_array = array("error" => 1, "value" => $info_text);
     }
     return $return_array;
 }
Ejemplo n.º 13
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.º 14
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.º 15
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.º 16
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.º 17
0
      }
      $translator->setSelectedLanguage($language);

      include_once('classes/cs_mail.php');
      $mail = new cs_mail();
      $mail->set_to($task_creator->getEmail());
      $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_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE',$current_portal->getTitle()));
      $mail->set_reply_to_name($current_user->getFullname());
      $mail->set_reply_to_email($current_user->getEmail());
      $mail->set_subject('RE: '.$translator->getMessage('MOVE_ROOM_MAIL_SUBJECT',$current_portal->getTitle()));
      $body = $translator->getMessage('MAIL_AUTO',$translator->getDateInLang(getCurrentDateTimeInMySQL()),$translator->getTimeInLang(getCurrentDateTimeInMySQL()));
      $body .= LF.LF;
      $body .= $translator->getMessage('MOVE_ROOM_MAIL_BODY_AGREE',$item->getTitle(),$current_portal->getTitle());
      $body .= LF.LF;
      $body .= $translator->getMessage('MOVE_ROOM_MAIL_BODY_TO_ROOM',$item->getTitle()).LF;
      $body .= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?cid='.$item->getItemID();
      $mail->set_message($body);
      $mail->send();

      // move wiki
      if ( $item->existWiki() ) {
         $wiki_manager = $environment->getWikiManager();
         $wiki_manager->moveWiki($item,$old_portal_id);
      }
Ejemplo n.º 18
0
             $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
             $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() != $_POST['code']
              and isset($_POST['code'])
   			and $agb_acceptance
            ) {
      $account_mode = 'member';
      $error = 'code';
   }
   if ($account_mode == 'to_room'){
Ejemplo n.º 19
0
         $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) {
            $add_message = $translator->getMessage('RUBRIC_EMAIL_ADDED_BODY_PROJECT_GROUP_S',$context_title,$name_array[0]);
         } elseif ($counter > 1) {
Ejemplo n.º 20
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.º 21
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.º 22
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.º 23
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;
 }