function _getSecondFolder($second_folder) { $second_folder = (string) $second_folder; if (!empty($second_folder)) { $array = array(); $retour = ''; for ($i = 0; $i < strlen($second_folder); $i++) { if ($i > 0 and $i % 4 == 0) { $retour .= '/'; } $retour .= $second_folder[$i]; } $retour .= '_'; } else { include_once 'functions/date_functions.php'; $retour = md5(getCurrentDateTimeInMySQL()); } return $retour; }
$params = array(); $params['focus_element_onload'] = 'new_buzzword'; redirect($environment->getCurrentContextID(), 'buzzwords', 'edit', $params); } }elseif (!empty($command) and isOption($command, $translator->getMessage('BUZZWORDS_COMBINE_BUTTON'))){ if ( (isset($_POST['sel1']) and !empty($_POST['sel1'])) and (isset($_POST['sel2']) and !empty($_POST['sel2'])) and (isset($_POST['sel1']) and isset($_POST['sel2']) and $_POST['sel1'] !=$_POST['sel2']) ){ $link_manager = $environment->getLinkManager(); $link_manager->combineBuzzwords($_POST['sel1'],$_POST['sel2']); $buzzword_manager = $environment->getLabelManager(); $buzzword_item1 = $buzzword_manager->getItem($_POST['sel1']); $buzzword_item2 = $buzzword_manager->getItem($_POST['sel2']); $buzzword_item1->setName($buzzword_item1->getName().'/'.$buzzword_item2->getName()); $buzzword_item1->setModificationDate(getCurrentDateTimeInMySQL()); $buzzword_item1->save(); $buzzword_item2->delete(); $params = array(); $params['focus_element_onload'] = 'sel1'; redirect($environment->getCurrentContextID(), 'buzzwords', 'edit', $params); } } // Display form $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $form_view = $class_factory->getClass(FORM_VIEW,$params); unset($params);
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()); } } }
$values = $_POST; $form->setFormPost($values); } $form->prepareForm(); $form->loadValues(); if ( !empty($command) and isOption($command, $translator->getMessage('DATES_SELECTION_BUTTON')) ) { $date_manager = $environment->getDateManager(); foreach($date_array as $dates_data){ $dates_item = $date_manager->getNewItem(); $dates_item->setContextID($environment->getCurrentContextID()); $user = $environment->getCurrentUserItem(); $dates_item->setCreatorItem($user); $dates_item->setCreationDate(getCurrentDateTimeInMySQL()); if (isset($dates_data[$_POST['title']])){ $dates_item->setTitle($dates_data[$_POST['title']]); }else{ $dates_item->setTitle($translator->getMessage('COMMON_TITLE')); } if (isset($dates_data[$_POST['description']])){ $dates_item->setDescription($dates_data[$_POST['description']]); } if (isset($_POST['mode'])){ $dates_item->setDateMode('1'); }else{ $dates_item->setDateMode('0'); } $dates_item->setPublic('1'); if (isset($dates_data[$_POST['starttime']])){
$email_addresses[$environment->getSelectedLanguage()][] = $moderator_item->getEmail(); } elseif ($language == 'user' and $moderator_item->getLanguage() != 'browser') { $email_addresses[$moderator_item->getLanguage()][] = $moderator_item->getEmail(); } else { $email_addresses[$room_item->getLanguage()][] = $moderator_item->getEmail(); } $recipients .= $moderator_item->getFullname().LF; } $moderator_item = $user_list->getNext(); } foreach ($email_addresses as $language => $email_array) { if (count($email_array) > 0) { $old_lang = $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()),getTimeInLang(getCurrentDateTimeInMySQL())); $body .= LF.LF; if ( $room_item->isCommunityRoom() ) { $portal = $environment->getCurrentContextItem(); if($portal->getHideAccountname()){ // Hide useraccountname $user_id = $translator->getMessage('USER_ACCOUNT_NOT_VISIBLE'); $body .= $translator->getMessage('USER_JOIN_COMMUNITY_MAIL_BODY_BY_MODERATOR',$user_item->getFullname(),$user_id,$user_item->getEmail(),$room_item->getTitle(),$current_user->getFullname()); } else { $body .= $translator->getMessage('USER_JOIN_COMMUNITY_MAIL_BODY_BY_MODERATOR',$user_item->getFullname(),$user_item->getUserID(),$user_item->getEmail(),$room_item->getTitle(),$current_user->getFullname()); } } else { $portal = $environment->getCurrentContextItem(); if($portal->getHideAccountname()){ // Hide useraccountname $user_id = $translator->getMessage('USER_ACCOUNT_NOT_VISIBLE');
public function getCountUserPasswordExpiredByContextID($cid) { $retour = 0; $date = getCurrentDateTimeInMySQL(); $query = "SELECT count(DISTINCT " . $this->addDatabasePrefix("user") . ".item_id) as number FROM " . $this->addDatabasePrefix("user") . " WHERE " . $this->addDatabasePrefix("user") . ".expire_date IS NOT NULL AND " . $this->addDatabasePrefix("user") . ".context_id = '" . encode(AS_DB, $cid) . "' AND " . $this->addDatabasePrefix("user") . ".expire_date <= '" . encode(AS_DB, $date) . "'"; $query .= " and deletion_date IS NULL"; $result = $this->_db_connector->performQuery($query); if (!isset($result)) { include_once 'functions/error_functions.php'; trigger_error('Problems counting open accounts.', E_USER_WARNING); } else { foreach ($result as $rs) { $retour = $rs['number']; } unset($result); } return $retour; }
/** save session item -- TBD: needed any more? * this method saves a session item into the database table "session" * * @param object cs_session_item the session item */ function update($item) { // cookie management if (!$item->issetValue('cookie') or $item->getValue('cookie') == 2) { $this->_saveSessionIDInCookie($item->getSessionID(), $item->getToolName()); if ($item->getValue('cookie') == 2) { $item->setValue('cookie', 1); } } include_once 'functions/date_functions.php'; $current_date_time = getCurrentDateTimeInMySQL(); $session_data = serialize($item->_data); include_once 'functions/text_functions.php'; $query = "UPDATE session SET session_value='" . encode(AS_DB, $session_data) . "',\n created='" . $current_date_time . "'\n WHERE session_id='" . encode(AS_DB, $item->getSessionID()) . "';"; $this->_last_query = $query; $result = $this->_db_conntector->performQuery($query); if (!isset($result) or !$result) { include_once 'functions/error_functions.php'; trigger_error('Problems saving session values for: ' . $item->getSessionID() . '.', E_USER_WARNING); } unset($item); }
public function actionEdit() { $session = $this->_environment->getSessionItem(); $translator = $this->_environment->getTranslationObject(); // get the current user and room $current_user = $this->_environment->getCurrentUserItem(); $current_context = $this->_environment->getCurrentContextItem(); // get post data $this->getPostData(); // check access rights if ($current_context->isProjectRoom() && $current_context->isClosed()) { /* * $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); unset($params); $errorbox->setText($translator->getMessage('PROJECT_ROOM_IS_CLOSED', $context_item->getTitle())); $page->add($errorbox); */ } elseif ($this->_item_id !== "NEW" && !isset($this->_item)) { /* * $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); unset($params); $errorbox->setText($translator->getMessage('ITEM_DOES_NOT_EXIST', $current_iid)); $page->add($errorbox); */ } elseif (!($this->_item_id === "NEW" && $current_user->isUser() || $this->_item_id !== "NEW" && isset($this->_item) && $this->_item->mayEdit($current_user))) { /* * $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 { if ($this->_command !== null && (isOption($this->_command, CS_OPTION_SAVE) || isOption($this->_command, CS_OPTION_CHANGE) || isOption($this->_command, CS_OPTION_NEW))) { if ($this->checkFormData()) { if (!isset($step_item)) { $step_manager = $this->_environment->getStepManager(); $step_item = $step_manager->getNewItem(); $step_item->setContextID($this->_environment->getCurrentContextID()); $user = $this->_environment->getCurrentUserItem(); $step_item->setCreatorItem($user); $step_item->setCreationDAte(getCurrentDateTimeInMySQL()); $step_item->setTodoID($_POST["todo_id"]); } $todo_manager = $this->_environment->getTodoManager(); $todo_item = $todo_manager->getItem($_POST["todo_id"]); // set modificator and modification date $user = $this->_environment->getCurrentUserItem(); $step_item->setModificatorItem($user); $step_item->setModificationDate(getCurrentDateTimeInMySQL()); // set attributes if (isset($_POST["form_data"]["title"])) { $step_item->setTitle($_POST["form_data"]["title"]); } if (isset($_POST["form_data"]["ckeditor_step"])) { $step_item->setDescription($_POST["form_data"]["ckeditor_step"]); } if (isset($_POST["form_data"]["minutes"])) { $minutes = $_POST["form_data"]["minutes"]; $minutes = str_replace(",", ".", $minutes); if (isset($_POST["form_data"]["time_type"])) { $step_item->setTimeType($_POST["form_data"]["time_type"]); switch ($_POST["form_data"]["time_type"]) { case 2: $minutes = $minutes * 60; break; case 3: $minutes = $minutes * 60 * 8; break; } } $step_item->setMinutes($minutes); } // save $step_item->save(); $status = $todo_item->getStatus(); if ($status == $translator->getMessage("TODO_NOT_STARTED")) { $todo_item->setStatus(2); } $todo_item->setModificationDate(getCurrentDateTimeInMySQL()); $todo_item->save(); /* // Set links to connected rubrics if ( isset($_POST[CS_MATERIAL_TYPE]) ) { $step_item->setMaterialListByID($_POST[CS_MATERIAL_TYPE]); } else { $step_item->setMaterialListByID(array()); } $item_files_upload_to = $step_item; include_once('include/inc_fileupload_edit_page_save_item.php'); */ // redirect $this->cleanup_session($this->_item_id); redirect($this->_environment->getCurrentContextID(), "todo", "detail", array("iid" => $step_item->getTodoID()), "step" . $step_item->getItemID()); } else { // store description in session $sessionKey = 'cid' . $this->_environment->getCurrentContextID() . '_step_last_description'; $session->setValue($sessionKey, $_POST['form_data']['ckeditor_step']); redirect($this->_environment->getCurrentContextID(), "todo", "detail", array("iid" => $_POST["todo_id"], "step_exception" => "mandatory"), "step_new"); } } } }
/** delete a task * this method deletes a new task * * @param integer item_id item id of the task */ function delete($item_id) { $current_datetime = getCurrentDateTimeInMySQL(); $current_user = $this->_environment->getCurrentUserItem(); $user_id = $current_user->getItemID(); unset($current_user); $query = 'UPDATE ' . $this->addDatabasePrefix('tasks') . ' SET ' . 'deletion_date="' . $current_datetime . '",' . 'deleter_id="' . encode(AS_DB, $user_id) . '",' . 'status="CLOSED"' . ' WHERE item_id="' . encode(AS_DB, $item_id) . '"'; $result = $this->_db_connector->performQuery($query); if (!isset($result) or !$result) { include_once 'functions/error_functions.php'; trigger_error('Problems deleting tasks from query: "' . $query . '"', E_USER_WARNING); } else { parent::delete($item_id); } }
/** delete link , but it is just an update * this method deletes all links from an item, but only as an update to restore it later and for evaluation * * @param integer file_id id of the file item */ function deleteByFileID($file_id) { $query = 'UPDATE ' . $this->addDatabasePrefix($this->_db_table) . ' SET ' . 'deletion_date="' . getCurrentDateTimeInMySQL() . '",' . 'deleter_id="' . encode(AS_DB, $this->_current_user->getItemID()) . '"' . ' WHERE file_id="' . encode(AS_DB, $file_id) . '";'; $result = $this->_db_connector->performQuery($query); if (!isset($result) or !$result) { include_once 'functions/error_functions.php'; trigger_error('Problems deleting (updating) links of an item from query: "' . $query . '". - ' . __FILE__ . ' - ' . __LINE__, E_USER_WARNING); } }
/** update a room - internal, do not use -> use method save * this method updates a room * * @param object cs_context_item a commsy room */ public function _update($item) { if ($this->_update_with_changing_modification_information) { parent::_update($item); } $query = 'UPDATE ' . $this->addDatabasePrefix($this->_db_table) . ' SET '; if ($this->_update_with_changing_modification_information) { $query .= 'modification_date="' . getCurrentDateTimeInMySQL() . '",'; $modifier_id = $this->_current_user->getItemID(); if (!empty($modifier_id)) { $query .= 'modifier_id="' . encode(AS_DB, $modifier_id) . '",'; } } if ($item->isOpenForGuests()) { $open_for_guests = 1; } else { $open_for_guests = 0; } if ($item->isContinuous()) { $continuous = 1; } else { $continuous = -1; } if ($item->isTemplate()) { $template = 1; } else { $template = -1; } if ($item->getActivityPoints()) { $activity = $item->getActivityPoints(); } else { $activity = '0'; } if ($item->getPublic()) { $public = '1'; } else { $public = '0'; } if ($item->isTemplate()) { $title = $item->getTitlePure(); } else { $title = $item->getTitle(); } $query .= 'title="' . encode(AS_DB, $title) . '",' . "extras='" . encode(AS_DB, serialize($item->getExtraInformation())) . "'," . "status='" . encode(AS_DB, $item->getStatus()) . "'," . "activity='" . encode(AS_DB, $activity) . "'," . "public='" . encode(AS_DB, $public) . "'," . "continuous='" . $continuous . "'," . "template='" . $template . "'," . "is_open_for_guests='" . $open_for_guests . "'" . ' WHERE item_id="' . encode(AS_DB, $item->getItemID()) . '"'; $result = $this->_db_connector->performQuery($query); if (!isset($result) or !$result) { include_once 'functions/error_functions.php'; trigger_error('Problems updating ' . $this->_db_table . ' item from query: "' . $query . '"', E_USER_WARNING); } }
public function save($form_data, $additional = array()) { $current_context = $this->_environment->getCurrentContextItem(); $current_portal_item = $this->_environment->getCurrentPortalItem(); // check context if (false) { } else { if (false) { } else { $tab = $additional['part']; switch ($tab) { /**** ACCOUNT ****/ case 'account_merge': if ($this->_popup_controller->checkFormData('merge')) { $authentication = $this->_environment->getAuthenticationObject(); global $c_annonymous_account_array; $currentUser = $this->_environment->getCurrentUserItem(); if (!empty($c_annonymous_account_array[mb_strtolower($currentUser->getUserID(), 'UTF-8') . '_' . $currentUser->getAuthSource()]) && $currentUser->isOnlyReadUser()) { $this->_popup_controller->setErrorReturn("1014", "anonymous account"); exit; } else { if ($currentUser->getUserID() == $form_data['merge_user_id'] && (empty($form_data['auth_source']) || $currentUser->getAuthSource() == $form_data['auth_source'])) { $this->_popup_controller->setErrorReturn("1015", "invalid account"); } else { $user_manager = $this->_environment->getUserManager(); $user_manager->setUserIDLimitBinary($form_data['merge_user_id']); $user_manager->select(); $user = $user_manager->get(); $first_user = $user->getFirst(); $current_user = $this->_environment->getCurrentUserItem(); if (!empty($first_user)) { if (empty($form_data['auth_source'])) { $authManager = $authentication->getAuthManager($current_user->getAuthSource()); } else { $authManager = $authentication->getAuthManager($form_data['auth_source']); } if (!$authManager->checkAccount($form_data['merge_user_id'], $form_data['merge_user_password'])) { $this->_popup_controller->setErrorReturn("1016", "authentication error"); exit; } } else { $this->_popup_controller->setErrorReturn("1015", "invalid account"); exit; } } } $currentUser = $this->_environment->getCurrentUserItem(); if (isset($form_data['auth_source'])) { $authSourceOld = $form_data['auth_source']; } else { $authSourceOld = $this->_environment->getCurrentPortalItem()->getAuthDefault(); } ini_set('display_errors', 'on'); error_reporting(E_ALL); $authentication->mergeAccount($currentUser->getUserID(), $currentUser->getAuthSource(), $form_data['merge_user_id'], $authSourceOld); // set return $this->_popup_controller->setSuccessfullItemIDReturn($currentUser->getItemID()); } break; case "account_lock_room": $current_user = $this->_environment->getCurrentUserItem(); $current_user->reject(); $current_user->save(); // set return $this->_popup_controller->setSuccessfullItemIDReturn($current_user->getItemID()); break; case "account_delete_room": $current_user = $this->_environment->getCurrentUserItem(); $current_user->delete(); // remove link from group room if ($current_context->isGroupRoom()) { $group_item = $current_context->getLinkedGroupItem(); $group_item->removeMember($current_user->getRelatedUserItemInContext($group_item->getContextID())); } // set return $this->_popup_controller->setSuccessfullItemIDReturn($current_user->getItemID()); break; case "account_lock_portal": $current_user = $this->_environment->getCurrentUserItem(); $portalUser_item = $current_user->getRelatedCommSyUserItem(); $portalUser_item->reject(); $portalUser_item->save(); // delete session $session_manager = $this->_environment->getSessionManager(); $session = $this->_environment->getSessionItem(); $session_manager->delete($session->getSessionID()); $this->_environment->setSessionItem(null); // return $this->_popup_controller->setSuccessfullItemIDReturn($current_user->getItemID()); break; case "account_delete_portal": $current_user = $this->_environment->getCurrentUserItem(); $portalUser_item = $current_user->getRelatedCommSyUserItem(); $authentication = $this->_environment->getAuthenticationObject(); $authentication->delete($portalUser_item->getItemID()); // delete session $session_manager = $this->_environment->getSessionManager(); $session = $this->_environment->getSessionItem(); $session_manager->delete($session->getSessionID()); $this->_environment->setSessionItem(null); // return $this->_popup_controller->setSuccessfullItemIDReturn($current_user->getItemID()); break; case 'account': if ($this->_popup_controller->checkFormData('account')) { $authentication = $this->_environment->getAuthenticationObject(); $currentUser = $this->_environment->getCurrentUserItem(); // get portal user if in room context if (!$this->_environment->inPortal()) { $portalUser = $this->_environment->getPortalUserItem(); } else { $portalUser = $this->_environment->getCurrentUserItem(); } $translator = $this->_environment->getTranslationObject(); // Datenschutz if ($current_portal_item->getPasswordGeneration() > 0) { if (!$portalUser->isPasswordInGeneration(md5($form_data['new_password']))) { // password if (!empty($form_data['new_password'])) { $auth_manager = $authentication->getAuthManager($currentUser->getAuthSource()); $auth_source = $currentUser->getAuthSource(); $old_password = $auth_manager->getItem($form_data['user_id'])->getPasswordMD5(); if ($old_password == md5($form_data['old_password'])) { $change_pw = true; // if password options are set, check password $auth_source_manager = $this->_environment->getAuthSourceManager(); $auth_source_item = $auth_source_manager->getItem($currentUser->getAuthSource()); $error_array = array(); if ($auth_source_item->getPasswordLength() > 0) { if (strlen($form_data['new_password']) < $auth_source_item->getPasswordLength()) { $error_array[] = $translator->getMessage('PASSWORD_INFO_LENGTH', $auth_source_item->getPasswordLength()); //$this->_popup_controller->setErrorReturn('1022', 'new password too short'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureBigchar() == 1) { if (!preg_match('~[A-Z]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_BIG'); //$this->_popup_controller->setErrorReturn('1023', 'new password no big character'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureSmallchar() == 1) { if (!preg_match('~[a-z]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_SMALL'); //$this->_popup_controller->setErrorReturn('1026', 'new password no small character'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureNumber() == 1) { if (!preg_match('~[0-9]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_NUMBER'); //$this->_popup_controller->setErrorReturn('1027', 'new password no number'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureSpecialchar() == 1) { if (!preg_match('~[^a-zA-Z0-9]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_SPECIAL'); //$this->_popup_controller->setErrorReturn('1024', 'new password no special character'); $change_pw = false; } } unset($auth_source); if ($change_pw) { $portalUser->setPasswordExpireDate($current_portal_item->getPasswordExpiration()); $portalUser->save(); $auth_manager->changePassword($form_data['user_id'], $form_data['new_password']); } else { $this->_popup_controller->setErrorReturn('1022', $error_array); } } else { $error_array[] = $translator->getMessage('PASSWORD_OLD_NOT_EQUAL'); $this->_popup_controller->setErrorReturn('1023', $error_array); #$this->_popup_controller->setErrorReturn('1009', 'password change error'); } $error_number = $auth_manager->getErrorNumber(); if (!empty($error_number)) { // TODO:$error_string .= $translator->getMessage('COMMON_ERROR_DATABASE').$error_number.'<br />'; } else { $portalUser->setNewGenerationPassword($old_password); } } } else { $this->_popup_controller->setErrorReturn('1025', 'password generation error'); } } else { if (!empty($form_data['new_password'])) { $auth_manager = $authentication->getAuthManager($currentUser->getAuthSource()); $old_password = $auth_manager->getItem($form_data['user_id'])->getPasswordMD5(); if ($old_password == md5($form_data['old_password'])) { $change_pw = true; // if password options are set, check password $auth_source_manager = $this->_environment->getAuthSourceManager(); $auth_source_item = $auth_source_manager->getItem($currentUser->getAuthSource()); $error_array = array(); if ($auth_source_item->getPasswordLength() > 0) { if (strlen($form_data['new_password']) < $auth_source_item->getPasswordLength()) { $error_array[] = $translator->getMessage('PASSWORD_INFO_LENGTH', $auth_source_item->getPasswordLength()) . '<br>'; //$this->_popup_controller->setErrorReturn('1022', 'new password too short'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureBigchar() == 1) { if (!preg_match('~[A-Z]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_BIG'); //$this->_popup_controller->setErrorReturn('1023', 'new password no big character'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureSmallchar() == 1) { if (!preg_match('~[a-z]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_SMALL'); //$this->_popup_controller->setErrorReturn('1026', 'new password no small character'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureNumber() == 1) { if (!preg_match('~[0-9]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_NUMBER'); //$this->_popup_controller->setErrorReturn('1027', 'new password no number'); $change_pw = false; } } if ($auth_source_item->getPasswordSecureSpecialchar() == 1) { if (!preg_match('~[^a-zA-Z0-9]+~u', $form_data['new_password'])) { $error_array[] = $translator->getMessage('PASSWORD_INFO_SPECIAL'); //$this->_popup_controller->setErrorReturn('1024', 'new password no special character'); $change_pw = false; } } unset($auth_source); if ($change_pw) { $portalUser->setPasswordExpireDate($current_portal_item->getPasswordExpiration()); $portalUser->save(); $auth_manager->changePassword($form_data['user_id'], $form_data['new_password']); } else { $this->_popup_controller->setErrorReturn('1022', $error_array); } } else { $error_array[] = $translator->getMessage('PASSWORD_OLD_NOT_EQUAL'); $this->_popup_controller->setErrorReturn('1023', $error_array); #$this->_popup_controller->setErrorReturn('1008', 'password change error'); } $error_number = $auth_manager->getErrorNumber(); if (!empty($error_number)) { // TODO:$error_string .= $translator->getMessage('COMMON_ERROR_DATABASE').$error_number.'<br />'; } else { $portalUser->setNewGenerationPassword($old_password); } } } // user id if (!empty($form_data['user_id']) && $form_data['user_id'] != $portalUser->getUserID()) { $check = true; $auth_source = $portalUser->getAuthSource(); if (!empty($auth_source)) { $authentication = $this->_environment->getAuthenticationObject(); if (!$authentication->is_free($form_data['user_id'], $auth_source)) { $this->_popup_controller->setErrorReturn("1011", "user id error(duplicated)", array()); $check = false; } elseif (withUmlaut($form_data['user_id'])) { $this->_popup_controller->setErrorReturn("1012", "user id error(umlaut)", array()); $check = false; } } else { $this->_popup_controller->setErrorReturn("1013", "user id error(auth source error)", array()); $check = false; } if ($check === true) { if ($authentication->changeUserID($form_data['user_id'], $portalUser)) { $session_manager = $this->_environment->getSessionManager(); $session = $this->_environment->getSessionItem(); $session_id_old = $session->getSessionID(); $session_manager->delete($session_id_old, true); $session->createSessionID($form_data['user_id']); $cookie = $session->getValue('cookie'); if ($cookie == 1) { $session->setValue('cookie', 2); } $session_manager->save($session); unset($session_manager); $portalUser->setUserID($form_data['user_id']); $currentUser->setUserID($form_data['user_id']); require_once 'functions/misc_functions.php'; plugin_hook('user_save', $portalUser); } } else { $this->_popup_controller->setErrorReturn("117", "user id error(duplicated, umlaut, etc)", array()); } } else { // $success_1 = true } $save = false; // language if (!empty($form_data['language']) && $form_data['language'] != $portalUser->getLanguage()) { $portalUser->setLanguage($form_data['language']); $save = true; if ($this->_environment->inPrivateRoom()) { $currentUser->setLanguage($form_data['language']); $currentUser->save(); } } if (isset($form_data['mail_account'])) { $currentUser->setAccountWantMail('yes'); $currentUser->save(); #$save = true; } else { $currentUser->setAccountWantMail('no'); $currentUser->save(); #$save = true; } if (isset($form_data['mail_room'])) { $currentUser->setOpenRoomWantMail('yes'); $currentUser->save(); #$save = true; } else { $currentUser->setOpenRoomWantMail('no'); $currentUser->save(); #$save = true; } // mail settings // if(!empty($form_data['mail_account'])) { // if($portalUser->getAccountWantMail() == 'no') { // $portalUser->setAccountWantMail('yes'); // $save = true; // } // } else { // if($portalUser->getAccountWantMail() == 'yes') { // $portalUser->setAccountWantMail('no'); // $save = true; // } // } // if(!empty($form_data['mail_room'])) { // if($portalUser->getOpenRoomWantMail() == 'no') { // $portalUser->setOpenRoomWantMail('yes'); // $save = true; // } // } else { // if($portalUser->getOpenRoomWantMail() == 'yes') { // $portalUser->setOpenRoomWantMail('no'); // $save = true; // } // } /* if(!empty($form_data['mail_delete_entry'])) { if($portalUser->getDeleteEntryWantMail() == 'no') { $portalUser->setDeleteEntryWantMail('yes'); $save = true; } } else { if($portalUser->getDeleteEntryWantMail() == 'yes') { $portalUser->setDeleteEntryWantMail('no'); $save = true; } } */ $change_name = false; $text_converter = $this->_environment->getTextConverter(); $form_data['forname'] = $text_converter->sanitizeHTML($form_data['forname']); $form_data['surname'] = $text_converter->sanitizeHTML($form_data['surname']); // forname if (!empty($form_data['forname']) && $portalUser->getFirstName() != $form_data['forname']) { $portalUser->setFirstName($form_data['forname']); $change_name = true; $save = true; } // surname if (!empty($form_data['surname']) && $portalUser->getLastName() != $form_data['surname']) { $portalUser->setLastName($form_data['surname']); $change_name = true; $save = true; } // auto save if (!empty($form_data['auto_save'])) { if ($form_data['auto_save'] == 'on') { $portalUser->turnAutoSaveOn(); } else { $portalUser->turnAutoSaveOff(); } $save = true; } else { $portalUser->turnAutoSaveOff(); $save = true; } global $c_email_upload; if ($c_email_upload && !$portalUser->isRoot()) { $own_room = $currentUser->getOwnRoom(); if (isset($form_data['email_to_commsy']) and !empty($form_data['email_to_commsy'])) { $own_room->setEmailToCommSy(); } else { $own_room->unsetEmailToCommSy(); } if (isset($form_data['email_to_commsy_secret']) and !empty($form_data['email_to_commsy_secret'])) { $own_room->setEmailToCommSySecret($form_data['email_to_commsy_secret']); } else { $own_room->setEmailToCommSySecret(''); } $own_room->save(); $save = true; } if ($save === true) { $portalUser->save(); } // change firstname and lastname in all other user_items of this user if ($change_name === true) { $user_manager = $this->_environment->getUserManager(); $dummy_user = $user_manager->getNewItem(); // forname $value = $form_data['forname']; if (empty($value)) { $value = -1; } $dummy_user->setFirstName($value); // surname $value = $form_data['surname']; if (empty($value)) { $value = -1; } $dummy_user->setLastName($value); $portalUser->changeRelatedUser($dummy_user); } // set return $this->_popup_controller->setSuccessfullItemIDReturn($portalUser->getItemID()); } break; /**** IMPORT ****/ /**** IMPORT ****/ case 'import': if ($this->_popup_controller->checkFormData('upload_import_private_room')) { if (!empty($additional["fileInfo"])) { $temp_stamp = time(); rename($additional["fileInfo"]["file"], 'var/temp/upload_' . $temp_stamp . '.zip'); $zip = new ZipArchive(); $res = $zip->open('var/temp/upload_' . $temp_stamp . '.zip'); if ($res === TRUE) { $zip->extractTo('var/temp/' . $temp_stamp); $zip->close(); $commsy_work_dir = getcwd(); chdir('var/temp/' . $temp_stamp); foreach (glob("commsy_xml_export_import_*.xml") as $filename) { $xml = simplexml_load_file($filename, null, LIBXML_NOCDATA); //el($xml); $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($xml->asXML()); //el($dom->saveXML()); $options = array(); chdir($commsy_work_dir); $room_manager = $this->_environment->getRoomManager(); $room_manager->import_item($xml, null, $options); chdir('var/temp/' . $temp_stamp); $files = scandir('.'); foreach ($files as $file) { if (strpos($file, 'files') === 0) { $directory_name_array = explode('_', $file); $directory_old_id = $directory_name_array[1]; $disc_manager = $this->_environment->getDiscManager(); $disc_manager->setPortalID($this->_environment->getCurrentPortalID()); $directory_new_id = $options[$directory_old_id]; if ($directory_new_id != '') { $disc_manager->setContextID($directory_new_id); $new_file_path = $disc_manager->getFilePath(); chdir($file); $files_to_copy = glob('./*'); foreach ($files_to_copy as $file_to_copy) { if (!(strpos($file, 'default_cs_gradient') === 0)) { $file_to_copy = str_ireplace('./', '', $file_to_copy); $file_name_array = explode('.', $file_to_copy); $file_old_id = $file_name_array[0]; $file_new_id = $options[$file_old_id]; if ($file_new_id != '') { $file_to_copy_temp = str_ireplace($file_old_id . '.', $file_new_id . '.', $file_to_copy); $file_to_copy_temp = './' . $file_to_copy_temp; $file_to_go = str_replace('./', $commsy_work_dir . '/' . $new_file_path, $file_to_copy_temp); copy($file_to_copy, $file_to_go); } } } chdir('..'); } } } } chdir($commsy_work_dir); } } } break; /**** USER PICTURE ****/ /**** USER PICTURE ****/ case 'user_picture': if ($this->_popup_controller->checkFormData('user_picture')) { /* handle user picture upload */ if (!empty($additional["fileInfo"])) { $currentUser = $this->_environment->getCurrentUserItem(); $portalUser = $currentUser->getRelatedCommSyUserItem(); $srcfile = $additional["fileInfo"]["file"]; $targetfile = $srcfile . "_converted"; $session = $this->_environment->getSessionItem(); $session->unsetValue("add_files"); // resize image to a maximum width of 150px and keep ratio $size = getimagesize($srcfile); list($x_orig, $y_orig, $type) = $size; $verhaeltnis = $y_orig / $x_orig; $max_width = 150; $ratio = 1.334; // 3:4 if ($verhaeltnis < $ratio) { // wider than 1:$ratio $source_width = $y_orig * $max_width / ($max_width * $ratio); $source_height = $y_orig; $source_x = ($x_orig - $source_width) / 2; $source_y = 0; } else { // higher than 1:$ratio $source_width = $x_orig; $source_height = $x_orig * ($max_width * $ratio) / $max_width; $source_x = 0; $source_y = ($y_orig - $source_height) / 2; } // create image switch ($type) { case '1': $im = imagecreatefromgif($srcfile); break; case '2': $im = imagecreatefromjpeg($srcfile); break; case '3': $im = imagecreatefrompng($srcfile); break; } $newimg = imagecreatetruecolor($max_width, $max_width * $ratio); imagecopyresampled($newimg, $im, 0, 0, $source_x, $source_y, $max_width, ceil($max_width * $ratio), $source_width, $source_height); imagepng($newimg, $targetfile); // clean up imagedestroy($im); imagedestroy($newimg); // determ new file name $filename_info = pathinfo($additional["fileInfo"]["name"]); $filename = 'cid' . $this->_environment->getCurrentContextID() . '_' . $currentUser->getItemID() . '.' . $filename_info['extension']; // copy file and set picture $disc_manager = $this->_environment->getDiscManager(); $disc_manager->copyFile($targetfile, $filename, true); $currentUser->setPicture($filename); $modifier = $this->_environment->getCurrentUserItem(); if (isset($portalUser)) { if ($disc_manager->copyImageFromRoomToRoom($filename, $portalUser->getContextID())) { $value_array = explode('_', $filename); $old_room_id = $value_array[0]; $old_room_id = str_replace('cid', '', $old_room_id); $valu_array[0] = 'cid' . $portalUser->getContextID(); $new_picture_name = implode('_', $value_array); $portalUser->setPicture($new_picture_name); $portalUser->setModificatorItem($modifier); $portalUser->setModificationDate(getCurrentDateTimeInMySQL()); $portalUser->save(); } } // save $currentUser->setModificatorItem($modifier); $currentUser->setModificationDate(getCurrentDateTimeInMySQL()); $currentUser->save(); } // set return $this->_popup_controller->setSuccessfullDataReturn($filename); } break; /**** USER ****/ /**** USER ****/ case 'user': $currentUser = $this->_environment->getCurrentUserItem(); $portalUser = $currentUser->getRelatedCommSyUserItem(); $text_converter = $this->_environment->getTextConverter(); $currentContext = $this->_environment->getCurrentContextItem(); if ($this->_popup_controller->checkFormData('user')) { function setValue($currentUser, $portalUser_item, $method, $value) { if (isset($value)) { // set for user call_user_func_array(array($currentUser, $method), array($value)); if (isset($portalUser_item)) { // set for portal user call_user_func_array(array($portalUser_item, $method), array($value)); } } } setValue($currentUser, $portalUser, 'setTitle', $text_converter->sanitizeHTML($form_data['title'])); setValue($currentUser, $portalUser, 'setBirthday', $text_converter->sanitizeHTML($form_data['birthday'])); $email_old = $portalUser->getEmail(); setValue($currentUser, $portalUser, 'setEmail', $text_converter->sanitizeHTML($form_data['mail'])); if ($portalUser->hasToChangeEmail() and $email_old != $form_data['mail']) { $portalUser->unsetHasToChangeEmail(); $form_data['mail_all'] = 1; } unset($email_old); if ($currentContext->isPortal()) { if ($form_data['mail_hide']) { $portalUser->setDefaultMailNotVisible(); } else { $portalUser->setDefaultMailVisible(); } if ($form_data['mail_hide_all']) { $user_list = $currentUser->getRelatedUserList(); $user_item = $user_list->getFirst(); while ($user_item) { if ($form_data['mail_hide']) { $user_item->setEmailNotVisible(); } else { $user_item->setEmailVisible(); } $user_item->save(); $user_item = $user_list->getNext(); } $currentUser->setDefaultMailNotVisible(); $currentUser->save(); } } else { if ($form_data['mail_hide']) { $currentUser->setEmailNotVisible(); } else { $currentUser->setEmailVisible(); } if ($form_data['mail_hide_all']) { $user_list = $currentUser->getRelatedUserList(); $user_item = $user_list->getFirst(); while ($user_item) { if ($form_data['mail_hide']) { $user_item->setEmailNotVisible(); } else { $user_item->setEmailVisible(); } $user_item->save(); $user_item = $user_list->getNext(); } $currentUser->setDefaultMailNotVisible(); $currentUser->save(); } } // im portal nur default wert // im raum default wert und raum wert? setValue($currentUser, $portalUser, 'setTelephone', $text_converter->sanitizeHTML($form_data['telephone'])); setValue($currentUser, $portalUser, 'setCellularphone', $text_converter->sanitizeHTML($form_data['cellularphone'])); setValue($currentUser, $portalUser, 'setStreet', $text_converter->sanitizeHTML($form_data['street'])); setValue($currentUser, $portalUser, 'setZipcode', $text_converter->sanitizeHTML($form_data['zipcode'])); setValue($currentUser, $portalUser, 'setCity', $text_converter->sanitizeHTML($form_data['city'])); setValue($currentUser, $portalUser, 'setRoom', $text_converter->sanitizeHTML($form_data['room'])); setValue($currentUser, $portalUser, 'setOrganisation', $text_converter->sanitizeHTML($form_data['organisation'])); setValue($currentUser, $portalUser, 'setPosition', $text_converter->sanitizeHTML($form_data['position'])); setValue($currentUser, $portalUser, 'setICQ', $text_converter->sanitizeHTML($form_data['icq'])); setValue($currentUser, $portalUser, 'setMSN', $text_converter->sanitizeHTML($form_data['msn'])); setValue($currentUser, $portalUser, 'setSkype', $text_converter->sanitizeHTML($form_data['skype'])); setValue($currentUser, $portalUser, 'setYahoo', $text_converter->sanitizeHTML($form_data['yahoo'])); setValue($currentUser, $portalUser, 'setJabber', $text_converter->sanitizeHTML($form_data['jabber'])); setValue($currentUser, $portalUser, 'setHomepage', $text_converter->sanitizeHTML($form_data['homepage'])); setValue($currentUser, $portalUser, 'setDescription', $form_data['description']); // delete picture handling if (isset($form_data['delete_picture']) && $currentUser->getPicture()) { $disc_manager = $this->_environment->getDiscManager(); // unlink file if ($disc_manager->existsFile($currentUser->getPicture())) { $disc_manager->unlinkFile($currentUser->getPicture()); } // set non picture $currentUser->setPicture(''); if (isset($portalUser)) { $portalUser->setPicture(''); } } // set modificator and modification date and save $modifier = $this->_environment->getCurrentUserItem(); $currentUser->setModificatorItem($modifier); $currentUser->setModificationDate(getCurrentDateTimeInMySQL()); $currentUser->save(); if (isset($portalUser)) { $portalUser->setModificatorItem($modifier); $portalUser->setModificationDate(getCurrentDateTimeInMySQL()); $portalUser->save(); } /* change all option */ // get a dummy user $user_manager = $this->_environment->getUserManager(); $dummy_user = $user_manager->getNewItem(); $changeAll = false; function setChangeAllValue($currentUser, $dummy_user_item, $method_set, $method_get, $checked) { if (isset($checked)) { $value = call_user_func_array(array($currentUser, $method_get), array()); if (empty($value)) { $value = -1; } call_user_func_array(array($dummy_user_item, $method_set), array($value)); } return $checked; } $changeAll = $changeAll || setChangeAllValue($currentUser, $dummy_user, 'setTitle', 'getTitle', $form_data['title_all']); $changeAll = $changeAll || setChangeAllValue($currentUser, $dummy_user, 'setBirthday', 'getBirthday', $form_data['birthday_all']); $changeAll = $changeAll || setChangeAllValue($currentUser, $dummy_user, 'setEmail', 'getEmail', $form_data['mail_all']); if (isset($form_data['mail_all'])) { $changeAll = true; if (!$currentUser->isEmailVisible()) { $dummy_user->setEmailNotVisible(); } else { $dummy_user->setEmailVisible(); } } $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setTelephone', 'getTelephone', $form_data['telephone_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setCellularphone', 'getCellularphone', $form_data['cellularphone_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setStreet', 'getStreet', $form_data['street_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setZipcode', 'getZipcode', $form_data['zipcode_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setCity', 'getCity', $form_data['city_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setRoom', 'getRoom', $form_data['room_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setOrganisation', 'getOrganisation', $form_data['organisation_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setPosition', 'getPosition', $form_data['position_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setICQ', 'getICQ', $form_data['messenger_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setMSN', 'getMSN', $form_data['messenger_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setSkype', 'getSkype', $form_data['messenger_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setYahoo', 'getYahoo', $form_data['messenger_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setJabber', 'getJabber', $form_data['messenger_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setHomepage', 'getHomepage', $form_data['homepage_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setDescription', 'getDescription', $form_data['description_all']) || $changeAll; $changeAll = setChangeAllValue($currentUser, $dummy_user, 'setPicture', 'getPicture', $form_data['picture_all']) || $changeAll; if ($changeAll === true) { $currentUser->changeRelatedUser($dummy_user); } $manager = $this->_environment->getLinkModifierItemManager(); $manager->markEdited($currentUser->getItemID()); // set return $this->_popup_controller->setSuccessfullItemIDReturn($currentUser->getItemID()); } break; /**** NEWSLETTER ****/ /**** NEWSLETTER ****/ case 'newsletter': if ($this->_popup_controller->checkFormData('newsletter')) { $currentUser = $this->_environment->getCurrentUserItem(); $room_item = $currentUser->getOwnRoom(); $set_to = 'none'; if (isset($form_data['newsletter']) && !empty($form_data['newsletter'])) { if ($form_data['newsletter'] == 2) { $set_to = 'weekly'; } elseif ($form_data['newsletter'] == 3) { $set_to = 'daily'; } } // set $room_item->setPrivateRoomNewsletterActivity($set_to); // save $room_item->save(); // set return $this->_popup_controller->setSuccessfullItemIDReturn($room_item->getItemID()); } break; case 'cs_bar': if ($this->_popup_controller->checkFormData('cs_bar')) { $currentUser = $this->_environment->getCurrentUserItem(); $room_item = $currentUser->getOwnRoom(); //--- $wordpress_manager = $this->_environment->getWordpressManager(); $wiki_manager = $this->_environment->getWikiManager(); if ($additional['action'] == 'create_wordpress') { if (isset($form_data['use_comments']) and !empty($form_data['use_comments']) and $form_data['use_comments'] == 'yes') { $room_item->setWordpressUseComments(); } else { $room_item->unsetWordpressUseComments(); } if (isset($form_data['use_comments_moderation']) and !empty($form_data['use_comments_moderation']) and $form_data['use_comments_moderation'] == 'yes') { $room_item->setWordpressUseCommentsModeration(); } else { $room_item->unsetWordpressUseCommentsModeration(); } if (isset($form_data['wordpresslink']) and !empty($form_data['wordpresslink']) and $form_data['wordpresslink'] == 'yes') { $room_item->setWordpressHomeLink(); } else { $room_item->unsetWordpressHomeLink(); } if (isset($form_data['skin_choice']) and !empty($form_data['skin_choice'])) { $room_item->setWordpressSkin($form_data['skin_choice']); } if (isset($form_data['wordpresstitle']) and !empty($form_data['wordpresstitle'])) { $room_item->setWordpressTitle($form_data['wordpresstitle']); } else { $room_item->setWordpressTitle($room_item->getTitle()); } if (isset($form_data['wordpressdescription']) and !empty($form_data['wordpressdescription'])) { $room_item->setWordpressDescription($form_data['wordpressdescription']); } else { $room_item->setWordpressDescription(''); } if (isset($form_data['member_role']) and !empty($form_data['member_role'])) { $room_item->setWordpressMemberRole($form_data['member_role']); } else { $room_item->setWordpressMemberRole(); } $room_item->setWithWordpressFunctions(); $room_item->setWordpressExists(); $room_item->setWordpressActive(); // save $room_item->save(); // create or change new wordpress $success = $wordpress_manager->createWordpress($room_item); } else { if ($additional['action'] == 'delete_wordpress') { if ($wordpress_manager->deleteWordpress($room_item->getWordpressId())) { $current_user = $this->_environment->getCurrentUserItem(); $room_item->setModificatorItem($current_user); $room_item->setModificationDate(getCurrentDateTimeInMySQL()); $room_item->unsetWordpressExists(); $room_item->setWordpressInActive(); $room_item->setWordpressSkin('twentyten'); $room_item->setWordpressTitle($room_item->getTitle()); $room_item->setWordpressDescription(''); $room_item->setWordpressId(0); // Save item $room_item->save(); } } else { if ($additional['action'] == 'create_wiki') { // Set modificator and modification date #if ( isset($form_data['wikilink']) and !empty($form_data['wikilink']) and $form_data['wikilink'] == 'yes') { $room_item->setWikiHomeLink(); #} else { # $room_item->unsetWikiHomeLink(); #} if (isset($form_data['wikilink2']) and !empty($form_data['wikilink2']) and $form_data['wikilink2'] == 'yes') { $room_item->setWikiPortalLink(); } else { $room_item->unsetWikiPortalLink(); } if (isset($form_data['wiki_skin_choice']) and !empty($form_data['wiki_skin_choice'])) { $room_item->setWikiSkin($form_data['wiki_skin_choice']); } if (isset($form_data['wikititle']) and !empty($form_data['wikititle'])) { $room_item->setWikiTitle($form_data['wikititle']); } else { $room_item->setWikiTitle($room_item->getTitle()); } if (isset($form_data['admin']) and !empty($form_data['admin'])) { $room_item->setWikiAdminPW($form_data['admin']); } if (isset($form_data['edit']) and !empty($form_data['edit'])) { $room_item->setWikiEditPW($form_data['edit']); } else { $room_item->setWikiEditPW(''); } if (isset($form_data['read']) and !empty($form_data['read'])) { $room_item->setWikiReadPW($form_data['read']); } else { $room_item->setWikiReadPW(''); } #if ( isset($form_data['use_commsy_login']) ) { $room_item->setWikiUseCommSyLogin(); #} else { # $room_item->unsetWikiUseCommSyLogin(); #} if (isset($form_data['community_read_access'])) { $room_item->setWikiCommunityReadAccess(); } else { $room_item->unsetWikiCommunityReadAccess(); } if (isset($form_data['community_write_access'])) { $room_item->setWikiCommunityWriteAccess(); } else { $room_item->unsetWikiCommunityWriteAccess(); } if (isset($form_data['portal_read_access'])) { $room_item->setWikiPortalReadAccess(); } else { $room_item->unsetWikiPortalReadAccess(); } if (isset($form_data['room_mod_write_access'])) { $room_item->setWikiRoomModWriteAccess(); } else { $room_item->unsetWikiRoomModWriteAccess(); } if (isset($form_data['show_login_box'])) { $room_item->setWikiShowCommSyLogin(); } else { $room_item->unsetWikiShowCommSyLogin(); } #if ( isset($form_data['enable_fckeditor']) ) { $room_item->setWikiEnableFCKEditor(); #} else { # $room_item->unsetWikiEnableFCKEditor(); #} #if ( isset($form_data['enable_sitemap']) ) { $room_item->setWikiEnableSitemap(); #} else { # $room_item->unsetWikiEnableSitemap(); #} #if ( isset($form_data['enable_statistic']) ) { $room_item->setWikiEnableStatistic(); #} else { # $room_item->unsetWikiEnableStatistic(); #} #if ( isset($form_data['enable_search']) ) { $room_item->setWikiEnableSearch(); #} else { # $room_item->unsetWikiEnableSearch(); #} #if ( isset($form_data['enable_rss']) ) { $room_item->setWikiEnableRss(); #} else { # $room_item->unsetWikiEnableRss(); #} if (isset($form_data['enable_calendar'])) { $room_item->setWikiEnableCalendar(); } else { $room_item->unsetWikiEnableCalendar(); } if (isset($form_data['enable_gallery'])) { $room_item->setWikiEnableGallery(); } else { $room_item->unsetWikiEnableGallery(); } if (isset($form_data['enable_notice'])) { $room_item->setWikiEnableNotice(); } else { $room_item->unsetWikiEnableNotice(); } #if ( isset($form_data['enable_pdf']) ) { $room_item->setWikiEnablePdf(); #} else { # $room_item->unsetWikiEnablePdf(); #} if (isset($form_data['enable_rater'])) { $room_item->setWikiEnableRater(); } else { $room_item->unsetWikiEnableRater(); } #if ( isset($form_data['enable_listcategories']) ) { $room_item->setWikiEnableListCategories(); #} else { # $room_item->unsetWikiEnableListCategories(); #} if (isset($form_data['new_page_template']) && $_POST['new_page_template'] != '') { $room_item->setWikiNewPageTemplate($_POST['new_page_template']); } else { $room_item->unsetWikiNewPageTemplate(); } if (isset($form_data['enable_swf'])) { $room_item->setWikiEnableSwf(); } else { $room_item->unsetWikiEnableSwf(); } if (isset($form_data['enable_wmplayer'])) { $room_item->setWikiEnableWmplayer(); } else { $room_item->unsetWikiEnableWmplayer(); } if (isset($form_data['enable_quicktime'])) { $room_item->setWikiEnableQuicktime(); } else { $room_item->unsetWikiEnableQuicktime(); } if (isset($form_data['enable_youtube_google_vimeo'])) { $room_item->setWikiEnableYoutubeGoogleVimeo(); } else { $room_item->unsetWikiEnableYoutubeGoogleVimeo(); } include_once 'functions/development_functions.php'; // Discussion #if ( isset($form_data['enable_discussion']) ) { $room_item->setWikiEnableDiscussion(); if (isset($form_data['new_discussion'])) { $_POST['new_discussion'] = $form_data['new_discussion']; $room_item->WikiSetNewDiscussion($form_data['new_discussion']); } #} else { # $room_item->unsetWikiEnableDiscussion(); #} $enable_discussion_discussions = array(); $form_data_keys = array_keys($form_data); foreach ($form_data_keys as $form_data_key) { if (stristr($form_data_key, 'enable_discussion_discussions_')) { $enable_discussion_discussions[] = $form_data[$form_data_key]; } } $_POST['enable_discussion_discussions'] = $enable_discussion_discussions; if (isset($form_data['enable_discussion_notification'])) { $room_item->setWikiEnableDiscussionNotification(); } else { $room_item->unsetWikiEnableDiscussionNotification(); } if (isset($form_data['enable_discussion_notification_groups'])) { $room_item->setWikiEnableDiscussionNotificationGroups(); } else { $room_item->unsetWikiEnableDiscussionNotificationGroups(); } if (isset($form_data['wiki_section_edit'])) { $room_item->setWikiWithSectionEdit(); } else { $room_item->setWikiWithoutSectionEdit(); } if (isset($form_data['wiki_section_edit_header'])) { $room_item->setWikiWithHeaderForSectionEdit(); } else { $room_item->setWikiWithoutHeaderForSectionEdit(); } $room_item->setWikiExists(); $room_item->setWikiActive(); $wiki_manager->createWiki($room_item); // Save item - after createWiki() -> old discussions might be deleted $room_item->save(); $enable_wiki_groups = array(); $form_data_keys = array_keys($form_data); foreach ($form_data_keys as $form_data_key) { if (stristr($form_data_key, 'enable_wiki_groups_')) { $enable_wiki_groups[] = $form_data[$form_data_key]; } } // WSDL-xml hier noch nicht zugreifbar, daher weiterhin die alte Variante if (!empty($enable_wiki_groups)) { //global $c_use_soap_for_wiki; //if(!$c_use_soap_for_wiki){ $wiki_manager->setWikiGroupsAsPublic($enable_wiki_groups); //} else { // $wiki_manager->setWikiGroupsAsPublic_soap($_POST['enable_wiki_groups']); //} } else { //global $c_use_soap_for_wiki; //if(!$c_use_soap_for_wiki){ $wiki_manager->setWikiGroupsAsPublic(array()); //} else { // $wiki_manager->setWikiGroupsAsPublic_soap(array()); //} } } else { if ($additional['action'] == 'delete_wiki') { $room_item->setModificatorItem($currentUser); $room_item->setModificationDate(getCurrentDateTimeInMySQL()); $room_item->unsetWikiExists(); $room_item->setWikiInActive(); $room_item->setWikiSkin('pmwiki'); $room_item->setWikiTitle($room_item->getTitle()); $room_item->unsetWikiEnableDiscussion(); $room_item->unsetWikiEnableDiscussionNotification(); $room_item->unsetWikiEnableDiscussionNotificationGroups(); $room_item->unsetWikiDiscussionArray(); // Save item $room_item->save(); // delete wiki $wiki_manager->deleteWiki($room_item); } else { if ($additional['action'] == 'chat') { if (isset($form_data['chatlink']) and !empty($form_data['chatlink']) and $form_data['chatlink'] == 'yes') { $room_item->setChatLinkActive(); } else { $room_item->setChatLinkInactive(); } $room_item->save(); } elseif (substr($additional['action'], 0, 7) == 'plugin_') { $plugin = substr($additional['action'], 7); $plugin_class = $this->_environment->getPluginClass($plugin); if (!empty($plugin_class) and method_exists($plugin_class, 'isConfigurableInPortal')) { if ($this->_environment->inPortal() and $plugin_class->isConfigurableInPortal() or !$this->_environment->inServer() and method_exists($plugin_class, 'isConfigurableInRoom') and $plugin_class->isConfigurableInRoom(CS_PRIVATEROOM_TYPE) or !$this->_environment->inServer() and method_exists($plugin_class, 'isConfigurableInRoom') and $plugin_class->isConfigurableInRoom() and $plugin == 'voyeur') { if (!empty($form_data[$plugin . '_on']) and $form_data[$plugin . '_on'] == 'yes') { $room_item->setPluginOn($plugin); } else { $room_item->setPluginOff($plugin); } $values = $form_data; $values['current_context_item'] = $room_item; if ($this->_environment->inPortal() and method_exists($plugin_class, 'configurationAtPortal')) { $plugin_class->configurationAtPortal('save_config', $values); } elseif (!$this->_environment->inServer() and method_exists($plugin_class, 'configurationAtRoom')) { $plugin_class->configurationAtRoom('save_config', $values); } } } $room_item->save(); } else { if ($additional['action'] == 'export_private_room') { $currentUserItem = $this->_environment->getCurrentUserItem(); $privateroom_manager = $this->_environment->getPrivateRoomManager(); $privateroom_item = $privateroom_manager->getRelatedOwnRoomForUser($currentUserItem, $this->_environment->getCurrentPortalID()); $room_manager = $this->_environment->getRoomManager(); $xml = $room_manager->export_item($privateroom_item->getItemID()); //$xml = $room_manager->export_item(488); $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($xml->asXML()); //el($dom->saveXML()); $filename = 'var/temp/commsy_xml_export_import_' . $privateroom_item->getItemID() . '.xml'; if (file_exists($filename)) { unlink($filename); } $xmlfile = fopen($filename, 'a'); fputs($xmlfile, $dom->saveXML()); fclose($xmlfile); //Location where export is saved $zipfile = 'var/temp/commsy_export_import_' . $privateroom_item->getItemID() . '.zip'; if (file_exists($zipfile)) { unlink($zipfile); } //Location that will be backuped $disc_manager = $this->_environment->getDiscManager(); $disc_manager->setPortalID($this->_environment->getCurrentPortalID()); $backup_paths = array(); $room_item = $privateroom_manager->getItem($privateroom_item->getItemID()); $disc_manager->setContextID($room_item->getItemId()); $backup_paths[$room_item->getItemId()] = $disc_manager->getFilePath(); if (class_exists('ZipArchive')) { include_once 'functions/misc_functions.php'; $zip = new ZipArchive(); $filename_zip = $zipfile; if ($zip->open($filename_zip, ZIPARCHIVE::CREATE) !== TRUE) { include_once 'functions/error_functions.php'; trigger_error('can not open zip-file ' . $filename_zip, E_USER_WARNNG); } $temp_dir = getcwd(); foreach ($backup_paths as $item_id => $backup_path) { chdir($backup_path); $zip = addFolderToZip('.', $zip, 'files_' . $item_id); chdir($temp_dir); } $zip->addFile($filename, basename($filename)); $zip->close(); unset($zip); #header('Content-disposition: attachment; filename=commsy_export_import_'.$_POST['room'].'.zip'); #header('Content-type: application/zip'); #readfile($zipfile); //export_privateroom $this->_popup_controller->setSuccessfullDataReturn(array('commsy_export' => '/commsy.php?cid=' . $this->_environment->getCurrentPortalID() . '&mod=export_privateroom&fct=getfile')); } else { include_once 'functions/error_functions.php'; trigger_error('can not initiate ZIP class, please contact your system administrator', E_USER_WARNNG); } } } } } } } //--- if (isset($form_data['show_widget_view']) && !empty($form_data['show_widget_view'])) { if ($form_data['show_widget_view'] == 'yes') { $room_item->setCSBarShowWidgets('1'); } else { $room_item->setCSBarShowWidgets('-1'); } } else { $room_item->setCSBarShowWidgets('-1'); } if (isset($form_data['show_roomwide_search']) && !empty($form_data['show_roomwide_search'])) { if ($form_data['show_roomwide_search'] == 'yes') { $room_item->setPortletShowRoomWideSearchBox('1'); } else { $room_item->setPortletShowRoomWideSearchBox('-1'); } } else { $room_item->setPortletShowRoomWideSearchBox('-1'); } if (isset($form_data['show_newest_entries']) && !empty($form_data['show_newest_entries'])) { if ($form_data['show_newest_entries'] == 'yes') { $room_item->setPortletShowNewEntryList('1'); } else { $room_item->setPortletShowNewEntryList('-1'); } } else { $room_item->setPortletShowNewEntryList('-1'); } if (isset($form_data['show_active_rooms']) && !empty($form_data['show_active_rooms'])) { if ($form_data['show_active_rooms'] == 'yes') { $room_item->setPortletShowActiveRoomList('1'); } else { $room_item->setPortletShowActiveRoomList('-1'); } } else { $room_item->setPortletShowActiveRoomList('-1'); } if (isset($form_data['show_calendar_view']) && !empty($form_data['show_calendar_view'])) { if ($form_data['show_calendar_view'] == 'yes') { $room_item->setCSBarShowCalendar('1'); } else { $room_item->setCSBarShowCalendar('-1'); } } else { $room_item->setCSBarShowCalendar('-1'); } if (isset($form_data['show_stack_view']) && !empty($form_data['show_stack_view'])) { if ($form_data['show_stack_view'] == 'yes') { $room_item->setCSBarShowStack('1'); } else { $room_item->setCSBarShowStack('-1'); } } else { $room_item->setCSBarShowStack('-1'); } if (isset($form_data['show_portfolio_view']) && !empty($form_data['show_portfolio_view'])) { if ($form_data['show_portfolio_view'] == 'yes') { $room_item->setCSBarShowPortfolio('1'); } else { $room_item->setCSBarShowPortfolio('-1'); } } else { $room_item->setCSBarShowPortfolio('-1'); } // portal2portal if (isset($form_data['show_connection_view']) && !empty($form_data['show_connection_view'])) { if ($form_data['show_connection_view'] == 'yes') { $room_item->setCSBarShowConnection('1'); } else { $room_item->setCSBarShowConnection('-1'); } } else { $room_item->setCSBarShowConnection('-1'); } if (isset($form_data['show_old_room_switcher']) && !empty($form_data['show_old_room_switcher'])) { if ($form_data['show_old_room_switcher'] == 'yes') { $room_item->setCSBarShowOldRoomSwitcher('1'); } else { $room_item->setCSBarShowOldRoomSwitcher('-1'); } } else { $room_item->setCSBarShowOldRoomSwitcher('-1'); } // save $room_item->save(); // set return $this->_popup_controller->setSuccessfullItemIDReturn($room_item->getItemID()); } break; } } // // save user // else { // $room_item = $environment->getCurrentContextItem(); // // Define rubric connections // $rubric_connection = array(); // $current_rubrics = $room_item->getAvailableRubrics(); // foreach ( $current_rubrics as $rubric ) { // switch ( $rubric ) { // case CS_GROUP_TYPE: // $rubric_connection[] = CS_GROUP_TYPE; // break; // case CS_INSTITUTION_TYPE: // $rubric_connection[] = CS_INSTITUTION_TYPE; // break; // } // } // $profile_view->setRubricConnections($rubric_connection); // $params = $environment->getCurrentParameterArray(); // unset($params['is_saved']); // $profile_view->setAction(curl($environment->getCurrentContextID(),$environment->getCurrentModule(),$environment->getCurrentFunction(),$params)); // if (!$currentUser->mayEditRegular($current_user)) { // $profile_view->warnChanger(); // $params = array(); // $params['environment'] = $environment; // $params['with_modifying_actions'] = true; // $params['width'] = 500; // $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); // unset($params); // $errorbox->setText($translator->getMessage('COMMON_EDIT_AS_MODERATOR')); // } // $profile_view->setForm($form); // } } }
// Uebersetzungstabelle commsy -> mediabird $current_user_item = $environment->getCurrentUserItem(); $portal_user_item = $current_user_item->getRelatedCommSyUserItem(); // last login include_once('functions/date_functions.php'); $current_user_item->setLastLoginPlugin(getCurrentDateTimeInMySQL(),$system); $current_user_item->setChangeModificationOnSave(false); $current_user_item->save(); if ( !$environment->inPortal() and !$environment->inServer() ) { if ( isset($portal_user_item) ) { $portal_user_item->setLastLoginPlugin(getCurrentDateTimeInMySQL(),$system); $portal_user_item->setChangeModificationOnSave(false); $portal_user_item->save(); } } $commsy_user_id = $portal_user_item->getItemID(); $fullname = $portal_user_item->getFullname(); $pic_url = $portal_user_item->getPictureUrl(true,false); unset($portal_user_item); unset($current_user_item); $mbuser = $external_id_manager->getExternalId($system,$commsy_user_id); if ( !empty($mbuser) ) {
function undeleteLinks($item) { $query = 'UPDATE ' . $this->addDatabasePrefix('link_items') . ' SET ' . 'modification_date="' . getCurrentDateTimeInMySQL() . '",' . 'deletion_date=NULL,' . 'deleter_id=NULL' . ' WHERE deletion_date>="' . encode(AS_DB, $item->getDeletionDate()) . '"' . ' AND (first_item_id="' . encode(AS_DB, $item->getItemID()) . '"' . ' OR second_item_id="' . encode(AS_DB, $item->getItemID()) . '")'; $result = $this->_db_connector->performQuery($query); if (!isset($result) or !$result) { include_once 'functions/error_functions.php'; trigger_error('Problems deleting (updating) links of an item from query: "' . $query . '"', E_USER_WARNING); } // reset cache $this->_resetCache(); }
function copyDataFromRoomToRoom($old_id, $new_id, $user_id = '', $id_array = '') { $retour = array(); $current_date = getCurrentDateTimeInMySQL(); $current_data_array = array(); $query = ''; $query .= 'SELECT * FROM ' . $this->addDatabasePrefix($this->_db_table) . ' WHERE context_id="' . encode(AS_DB, $old_id) . '" AND deleter_id IS NULL AND deletion_date IS NULL'; $result = $this->_db_connector->performQuery($query); if (!isset($result)) { include_once 'functions/error_functions.php'; trigger_error('Problems getting data "' . $this->_db_table . '" from query: "' . $query . '"', E_USER_WARNING); } else { $item_id = 'files_id'; $modification_date = 'creation_date'; $sql = 'SELECT ' . $item_id . ',' . $modification_date . ',extras FROM ' . $this->addDatabasePrefix($this->_db_table) . ' WHERE context_id="' . encode(AS_DB, $new_id) . '"'; $sql .= ' AND extras LIKE "%s:4:\\"COPY\\";a:2:{s:7:\\"ITEM_ID\\";%"'; $sql .= ' AND deleter_id IS NULL AND deletion_date IS NULL;'; $sql_result = $this->_db_connector->performQuery($sql); if (!isset($sql_result)) { include_once 'functions/error_functions.php'; trigger_error('Problems getting data "' . $this->_db_table . '".', E_USER_WARNING); } else { foreach ($sql_result as $sql_row) { include_once 'functions/text_functions.php'; $extra_array = mb_unserialize($sql_row['extras']); $current_data_array[$extra_array['COPY']['ITEM_ID']] = $sql_row[$item_id]; #$current_copy_date_array[$extra_array['COPY']['ITEM_ID']] = $extra_array['COPY']['DATETIME']; #$current_mod_date_array[$extra_array['COPY']['ITEM_ID']] = $sql_row[$modification_date]; } } foreach ($result as $query_result) { $do_it = true; if (array_key_exists($query_result['files_id'], $current_data_array)) { $retour[CS_FILE_TYPE . $query_result['files_id']] = $current_data_array[$query_result['files_id']]; $do_it = false; } if ($do_it) { $insert_query = ''; $insert_query .= 'INSERT INTO ' . $this->addDatabasePrefix($this->_db_table) . ' SET'; $first = true; $old_item_id = ''; foreach ($query_result as $key => $value) { $value = encode(FROM_DB, $value); if ($key == 'files_id') { $old_item_id = $value; } elseif ($key == 'context_id') { $after = $key . '="' . $new_id . '"'; } elseif ($key == 'modification_date' or $key == 'creation_date') { $after = $key . '="' . $current_date . '"'; } elseif (!empty($user_id) and ($key == 'creator_id' or $key == 'modifier_id')) { $after = $key . '="' . $user_id . '"'; } elseif ($key == 'deletion_date' or $key == 'deleter_id' or $key == 'material_id' or $key == 'material_vid') { // do nothing } elseif ($key == 'has_html' and empty($value)) { // do nothing } elseif ($key == 'extras' and !empty($old_item_id)) { include_once 'functions/text_functions.php'; $extra_array = mb_unserialize($value); $extra_array['COPY']['ITEM_ID'] = $old_item_id; $extra_array['COPY']['COPYING_DATE'] = $current_date; $value = serialize($extra_array); $after = $key . '="' . encode(AS_DB, $value) . '"'; } else { $after = $key . '="' . encode(AS_DB, $value) . '"'; } if (!empty($after)) { if ($first) { $first = false; $before = ' '; } else { $before = ','; } $insert_query .= $before . $after; unset($after); } } $result_insert = $this->_db_connector->performQuery($insert_query); if (!isset($result_insert)) { include_once 'functions/error_functions.php'; trigger_error('Problem creating item from query: "' . $insert_query . '"', E_USER_ERROR); } else { $new_item_id = $result_insert; if (!empty($old_item_id)) { $retour[CS_FILE_TYPE . $old_item_id] = $new_item_id; // copy file $disc_manager = $this->_environment->getDiscManager(); $disc_manager->setPortalID($this->_environment->getCurrentPortalID()); $file_item = $this->getItem($old_item_id); if (!empty($file_item)) { $result = $disc_manager->copyFileFromRoomToRoom($old_id, $old_item_id, $file_item->getFileName(), $new_id, $new_item_id); if (!$result) { //include_once('functions/error_functions.php'); //trigger_error('can not copy file on disc',E_USER_ERROR); } } else { include_once 'functions/error_functions.php'; trigger_error('can not get old file item', E_USER_ERROR); } unset($file_item); unset($disc_manager); } else { include_once 'functions/error_functions.php'; trigger_error('lost old item id at copying data', E_USER_ERROR); } } } } } /* $disc_manager = $this->_environment->getDiscManager(); $disc_manager->setPortalID($this->_environment->getCurrentPortalID()); // copy files foreach ($retour as $old_file_id => $new_file_id) { $real_old_file_id = str_replace(CS_FILE_TYPE,'',$old_file_id); $file_item = $this->getItem($real_old_file_id); if (!empty($file_item)) { $result = $disc_manager->copyFileFromRoomToRoom($old_id,$real_old_file_id,$file_item->getFileName(),$new_id,$new_file_id); if (!$result) { //include_once('functions/error_functions.php'); //trigger_error('can not copy file on disc',E_USER_ERROR); } } else { include_once('functions/error_functions.php'); trigger_error('can not get old file item',E_USER_ERROR); } } unset($disc_manager); */ return $retour; }
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('&', '&', $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('&', '&', $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; }
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') { $date_item = null; } else { $date_manager = $this->_environment->getDateManager(); $date_item = $date_manager->getItem($current_iid); } $this->_popup_controller->performChecks($date_item, $form_data, $additional); // TODO: check rights */ /****************************/ if ($current_iid != 'NEW' and !isset($date_item)) { } elseif (!($current_iid == 'NEW' and $current_user->isUser() or $current_iid != 'NEW' and isset($date_item) and $date_item->mayEdit($current_user))) { /****************************/ } elseif ($this->_edit_type != 'normal') { $this->cleanup_session($current_iid); // Set modificator and modification date $current_user = $environment->getCurrentUserItem(); $date_item->setModificatorItem($current_user); if ($this->_edit_type == 'buzzwords') { // buzzwords $date_item->setBuzzwordListByID($form_data['buzzwords']); } if ($this->_edit_type == 'tags') { // buzzwords $date_item->setTagListByID($form_data['tags']); } $date_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($date_item->getItemID()); // set return $this->_popup_controller->setSuccessfullItemIDReturn($date_item->getItemID(), CS_DATE_TYPE); } else { //Acces granted $this->cleanup_session($current_iid); // save item if ($this->_popup_controller->checkFormData()) { $session = $this->_environment->getSessionItem(); $item_is_new = false; // Create new item if (!isset($date_item)) { $date_manager = $environment->getDateManager(); $date_item = $date_manager->getNewItem(); $date_item->setContextID($environment->getCurrentContextID()); $date_item->setCreatorItem($current_user); $date_item->setCreationDate(getCurrentDateTimeInMySQL()); $item_is_new = true; } $values_before_change = array(); $values_before_change['title'] = $date_item->getTitle(); $values_before_change['startingTime'] = $date_item->getStartingTime(); $values_before_change['endingTime'] = $date_item->getEndingTime(); $values_before_change['place'] = $date_item->getPlace(); $values_before_change['color'] = $date_item->getColor(); $values_before_change['description'] = $date_item->getDescription(); // Set modificator and modification date $date_item->setModificatorItem($current_user); // Set attributes if (isset($form_data['title'])) { $date_item->setTitle($form_data['title']); } if (isset($form_data['description'])) { $date_item->setDescription($this->_popup_controller->getUtils()->cleanCKEditor($form_data['description'])); } if (isset($form_data['external_viewer']) and isset($form_data['external_viewer_accounts'])) { $user_ids = explode(" ", $form_data['external_viewer_accounts']); $date_item->setExternalViewerAccounts($user_ids); } else { $date_item->unsetExternalViewerAccounts(); } if (isset($form_data['private_editing'])) { $date_item->setPrivateEditing('0'); } else { $date_item->setPrivateEditing('1'); } if (isset($form_data['rights_tab'])) { if (isset($form_data['public'])) { $date_item->setPublic($form_data['public']); } if (isset($form_data['public'])) { if ($date_item->isPublic() != $form_data['public']) { $date_item->setPublic($form_data['public']); } } else { if (isset($form_data['private_editing'])) { $date_item->setPrivateEditing('0'); } else { $date_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; $date_item->setModificationDate($dt_hiding_datetime); } else { if ($date_item->isNotActivated()) { $date_item->setModificationDate(getCurrentDateTimeInMySQL()); } } } if (isset($form_data['mode'])) { $date_item->setDateMode('1'); } else { $date_item->setDateMode('0'); } // variables for datetime-format of end and beginning $dt_start_time = '00:00:00'; $dt_end_time = '00:00:00'; $dt_start_date = '0000-00-00'; $dt_end_date = '0000-00-00'; $converted_time_start = convertTimeFromInput($form_data['timeStart']); if ($converted_time_start['conforms'] == TRUE) { $date_item->setStartingTime($converted_time_start['datetime']); $dt_start_time = $converted_time_start['datetime']; } else { $date_item->setStartingTime($converted_time_start['display']); } $converted_day_start = convertDateFromInput($form_data['dayStart'], $environment->getSelectedLanguage()); if ($converted_day_start['conforms'] == TRUE) { $date_item->setStartingDay($converted_day_start['datetime']); $dt_start_date = $converted_day_start['datetime']; } else { $date_item->setStartingDay($converted_day_start['display']); } if (!empty($form_data['dayEnd'])) { $converted_day_end = convertDateFromInput($form_data['dayEnd'], $environment->getSelectedLanguage()); if ($converted_day_end['conforms'] == TRUE) { if ($converted_day_end["timestamp"] < $converted_day_start["timestamp"]) { $converted_day_end["datetime"] = $converted_day_start["datetime"]; } $date_item->setEndingDay($converted_day_end['datetime']); $dt_end_date = $converted_day_end['datetime']; } else { $date_item->setEndingDay($converted_day_end['display']); } } else { $date_item->setEndingDay(''); } if (!empty($form_data['timeEnd'])) { $converted_time_end = convertTimeFromInput($form_data['timeEnd']); if ($converted_time_end['conforms'] == TRUE) { if ($converted_time_end["timestamp"] < $converted_time_start["timestamp"]) { $converted_time_end["datetime"] = $converted_time_start["datetime"]; } $date_item->setEndingTime($converted_time_end['datetime']); $dt_end_time = $converted_time_end['datetime']; } else { $date_item->setEndingTime($converted_time_end['display']); } } else { $date_item->setEndingTime(''); } if ($dt_end_date == '0000-00-00') { $dt_end_date = $dt_start_date; } $date_item->setDateTime_start($dt_start_date . ' ' . $dt_start_time); $date_item->setDateTime_end($dt_end_date . ' ' . $dt_end_time); if (!empty($form_data['place'])) { $date_item->setPlace($form_data['place']); } else { $date_item->setPlace(''); } // 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($date_item, $file_ids, $form_data["files"]); // color if (isset($form_data['date_addon_color'])) { $date_item->setColor($form_data['date_addon_color']); } // buzzwords // save buzzwords $this->saveBuzzwords($environment, $date_item, $form_data['buzzwords']); // tags if (isset($form_data['tags_tab'])) { $date_item->setTagListByID($form_data['tags']); } // Save item #$date_item->save(); // Save recurrent items $errors = array(); if (isset($form_data['recurring']) or isset($form_data['recurring_date']) or $date_item->getRecurrenceId() != '' and $date_item->getRecurrenceId() != 0) { if (isset($form_data['recurring_week_days_monday'])) { $form_data['recurring_week_days'][] = $form_data['recurring_week_days_monday']; } if (isset($form_data['recurring_week_days_tuesday'])) { $form_data['recurring_week_days'][] = $form_data['recurring_week_days_tuesday']; } if (isset($form_data['recurring_week_days_wednesday'])) { $form_data['recurring_week_days'][] = $form_data['recurring_week_days_wednesday']; } if (isset($form_data['recurring_week_days_thusday'])) { $form_data['recurring_week_days'][] = $form_data['recurring_week_days_thusday']; } if (isset($form_data['recurring_week_days_friday'])) { $form_data['recurring_week_days'][] = $form_data['recurring_week_days_friday']; } if (isset($form_data['recurring_week_days_saturday'])) { $form_data['recurring_week_days'][] = $form_data['recurring_week_days_saturday']; } if (isset($form_data['recurring_week_days_sunday'])) { $form_data['recurring_week_days'][] = $form_data['recurring_week_days_sunday']; } $errors = $this->checkValues($form_data); if (empty($errors)) { $date_item->save(); if ($additional['part'] == 'all' and !isset($form_data['recurring_ignore'])) { $this->save_recurring_dates($date_item, true, array(), $form_data); } elseif ($additional['part'] == 'recurring') { $vales_to_change = array(); if ($values_before_change['title'] != $date_item->getTitle()) { $vales_to_change[] = 'title'; } if ($values_before_change['startingTime'] != $date_item->getStartingTime()) { $vales_to_change[] = 'startingTime'; } if ($values_before_change['endingTime'] != $date_item->getEndingTime()) { $vales_to_change[] = 'endingTime'; } if ($values_before_change['place'] != $date_item->getPlace()) { $vales_to_change[] = 'place'; } if ($values_before_change['color'] != $date_item->getColor()) { $vales_to_change[] = 'color'; } if ($values_before_change['description'] != $date_item->getDescription()) { $vales_to_change[] = 'description'; } $this->save_recurring_dates($date_item, false, $vales_to_change, $form_data); } } } else { $date_item->save(); } // this will update the right box list if ($item_is_new) { if ($session->issetValue('cid' . $environment->getCurrentContextID() . '_' . CS_DATE_TYPE . '_index_ids')) { $id_array = array_reverse($session->getValue('cid' . $environment->getCurrentContextID() . '_' . CS_DATE_TYPE . '_index_ids')); } else { $id_array = array(); } $id_array[] = $date_item->getItemID(); $id_array = array_reverse($id_array); $session->setValue('cid' . $environment->getCurrentContextID() . '_' . CS_DATE_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($date_item->getItemID()); // set return if (empty($errors)) { $this->_popup_controller->setSuccessfullItemIDReturn($date_item->getItemID()); } else { $this->_popup_controller->setErrorReturn(101, '', $errors); } } } // Redirect /*cleanup_session($current_iid); $session->unsetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_buzzword_ids'); $session->unsetValue('buzzword_post_vars'); $session->unsetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_tag_ids'); $session->unsetValue('tag_post_vars'); $session->unsetValue('cid'.$environment->getCurrentContextID().'_linked_items_index_selected_ids'); $session->unsetValue('linked_items_post_vars'); $context_item = $environment->getCurrentContextItem(); $seldisplay_mode = $session->getValue($environment->getCurrentContextID().'_dates_seldisplay_mode'); if (empty($seldisplay_mode)){ $seldisplay_mode = $context_item->getDatesPresentationStatus(); } if (isset($form_data['seldisplay_mode']) or $seldisplay_mode== 'calendar') { if ($seldisplay_mode == 'calendar') { $noticed_manager = $environment->getNoticedManager(); $noticed = $noticed_manager->getLatestNoticed($date_item->getItemID()); if ( empty($noticed) or $noticed['read_date'] < $date_item->getModificationDate() ) { $noticed_manager->markNoticed($date_item->getItemID(),0); } } $params = array(); $params = getCalendarParameterArrayByItem($date_item); $params['seldisplay_mode'] = $seldisplay_mode; if($params['presentation_mode'] == '1' and !empty($params['week'])){ $converted_day_start = convertDateFromInput($form_data['dayStart'],$environment->getSelectedLanguage()); if ($converted_day_start['conforms'] == TRUE) { $year = mb_substr($converted_day_start['datetime'],0,4); $month = mb_substr($converted_day_start['datetime'],5,2); $day = mb_substr($converted_day_start['datetime'],8,2); $d_time = mktime ( 3, 0, 0, $month, $day, $year ); $wday = date ( "w", $d_time ); $parameter_week = mktime ( 3, 0, 0, $month, $day - ( $wday - 1 ), $year ); $params['week'] = $parameter_week; } } unsetCalendarSessionArray(); /* $history = $session->getValue('history'); $i = 1; $j = $i+1; $funct = 'index'; while (isset($history[$j]['function']) and $history[$i]['function'] == 'edit'){ $funct = $history[$j]['function']; $i++; $j++; } if ($funct !='index'){ $params['iid'] = $current_iid; if ( !is_numeric($current_iid) ) { $params['iid'] = $date_item->getItemID(); } redirect($environment->getCurrentContextID(),CS_DATE_TYPE, 'detail',$params); /* }else{ redirect($environment->getCurrentContextID(),CS_DATE_TYPE, 'index',$params); } }else{ $params = array(); $params['iid'] = $date_item->getItemID(); redirect($environment->getCurrentContextID(), CS_DATE_TYPE, 'detail', $params); } $this->_return = 'success'; } }*/ }
function deleteAnnouncementsofUser($uid) { // create backup of item $this->backupItem($uid, array('title' => 'title', 'description' => 'description', 'modification_date' => 'modification_date', 'public' => 'public')); $current_datetime = getCurrentDateTimeInMySQL(); $query = 'SELECT ' . $this->addDatabasePrefix($this->_db_table) . '.* FROM ' . $this->addDatabasePrefix($this->_db_table) . ' WHERE ' . $this->addDatabasePrefix($this->_db_table) . '.creator_id = "' . encode(AS_DB, $uid) . '"'; $result = $this->_db_connector->performQuery($query); if (!empty($result)) { foreach ($result as $rs) { $insert_query = 'UPDATE ' . $this->addDatabasePrefix($this->_db_table) . ' SET'; $insert_query .= ' title = "' . encode(AS_DB, $this->_translator->getMessage('COMMON_AUTOMATIC_DELETE_TITLE')) . '",'; $insert_query .= ' description = "' . encode(AS_DB, $this->_translator->getMessage('COMMON_AUTOMATIC_DELETE_DESCRIPTION')) . '",'; $insert_query .= ' modification_date = "' . $current_datetime . '",'; $insert_query .= ' public = "1"'; $insert_query .= ' WHERE item_id = "' . encode(AS_DB, $rs['item_id']) . '"'; $result2 = $this->_db_connector->performQuery($insert_query); if (!isset($result2) or !$result2) { include_once 'functions/error_functions.php'; trigger_error('Problems automatic deleting ' . $this->_db_table . '.', E_USER_WARNING); } unset($result2); } unset($result); } }
public function getListContent() { include_once 'classes/cs_list.php'; include_once 'classes/views/cs_view.php'; $environment = $this->_environment; $context_item = $environment->getCurrentContextItem(); $converter = $this->_environment->getTextConverter(); $params = $this->_environment->getCurrentParameterArray(); $return = array(); $last_selected_tag = ''; $seltag_array = array(); // Find current topic selection // if(isset($_GET['seltag']) && $_GET['seltag'] == 'yes') { // $i = 0; // while(!isset($_GET['seltag_' . $i])) { // $i++; // } // $seltag_array[] = $_GET['seltag_' . $i]; // $j = 0; // while(isset($_GET['seltag_' . $i]) && $_GET['seltag_' . $i] != '-2') { // if(!empty($_GET['seltag_' . $i])) { // $seltag_array[$i] = $_GET['seltag_' . $i]; // $j++; // } // $i++; // } // $last_selected_tag = $seltag_array[$j-1]; // } // get selected seltags $seltag_array = array(); foreach ($params as $key => $value) { if (substr($key, 0, 7) == 'seltag_') { // set seltag array $seltag_array[$key] = $value; } elseif (substr($key, 0, 6) == 'seltag') { $seltag_array[$key . '_' . $value] = "true"; } } // Get data from database $discussion_manager = $environment->getDiscussionManager(); $discussion_manager->setContextLimit($environment->getCurrentContextID()); $all_ids = $discussion_manager->getIds(); $count_all = count($all_ids); if (isset($all_ids[0])) { $newest_id = $all_ids[0]; $item = $discussion_manager->getItem($newest_id); $date = $item->getModificationDate(); $now = getCurrentDateTimeInMySQL(); if ($date <= $now) { $sel_activating_status = 1; } } elseif ($count_all == 0) { $sel_activating_status = 1; } $discussion_manager->resetData(); if (!empty($this->_list_parameter_arrray['ref_iid']) and $this->getViewMode() == 'attached') { $discussion_manager->setRefIDLimit($this->_list_parameter_arrray['ref_iid']); } if (!empty($this->_list_parameter_arrray['ref_user']) and $this->getViewMode() == 'attached') { $discussion_manager->setRefUserLimit($this->_list_parameter_arrray['ref_user']); } if (!empty($this->_list_parameter_arrray['sort'])) { $discussion_manager->setSortOrder($this->_list_parameter_arrray['sort']); } if ($this->_list_parameter_arrray['sel_activating_status'] == 2) { $discussion_manager->showNoNotActivatedEntries(); } if (!empty($this->_list_parameter_arrray['search'])) { $discussion_manager->setSearchLimit($this->_list_parameter_arrray['search']); } if (!empty($this->_list_parameter_arrray['selgroup'])) { $discussion_manager->setGroupLimit($this->_list_parameter_arrray['selgroup']); } if (!empty($this->_list_parameter_arrray['seltopic'])) { $discussion_manager->setTopicLimit($this->_list_parameter_arrray['seltopic']); } if (!empty($this->_list_parameter_arrray['selinstitution'])) { $discussion_manager->setTopicLimit($this->_list_parameter_arrray['selinstitution']); } if (!empty($this->_list_parameter_arrray['selbuzzword'])) { $discussion_manager->setBuzzwordLimit($this->_list_parameter_arrray['selbuzzword']); } if (!empty($this->_list_parameter_arrray['last_selected_tag'])) { $discussion_manager->setTagLimit($this->_list_parameter_arrray['last_selected_tag']); } if (!empty($seltag_array)) { $discussion_manager->setTagArrayLimit($seltag_array); } if ($this->_list_parameter_arrray['interval'] > 0) { $discussion_manager->setIntervalLimit($this->_list_parameter_arrray['from'] - 1, $this->_list_parameter_arrray['interval']); } if ($this->_list_parameter_arrray['interval'] > 0) { $discussion_manager->setIntervalLimit($this->_list_parameter_arrray['from'] - 1, $this->_list_parameter_arrray['interval']); } if (!empty($only_show_array)) { $discussion_manager->resetLimits(); $discussion_manager->setIDArrayLimit($only_show_array); } $discussion_manager->select(); $list = $discussion_manager->get(); $ids = $discussion_manager->getIDArray(); $count_all_shown = count($ids); $this->_page_text_fragment_array['count_entries'] = $this->getCountEntriesText($this->_list_parameter_arrray['from'], $this->_list_parameter_arrray['interval'], $count_all, $count_all_shown); $this->_browsing_icons_parameter_array = $this->getBrowsingIconsParameterArray($this->_list_parameter_arrray['from'], $this->_list_parameter_arrray['interval'], $count_all_shown); $session = $this->_environment->getSessionItem(); $session->setValue('cid' . $environment->getCurrentContextID() . '_discussion_index_ids', $ids); $id_array = array(); $item = $list->getFirst(); while ($item) { $id_array[] = $item->getItemID(); $item = $list->getNext(); } $assessment_manager = $environment->getAssessmentManager(); $assessment_manager->getAssessmentForItemAverageByIDArray($id_array); $link_manager = $environment->getLinkManager(); $file_id_array = $link_manager->getAllFileLinksForListByIDs($id_array); $file_manager = $environment->getFileManager(); $file_manager->setIDArrayLimit($file_id_array); $file_manager->select(); $discarticle_manager = $environment->getDiscussionArticleManager(); $discarticle_list = $discarticle_manager->getAllDiscArticlesItemListByIDArray($id_array); $item = $discarticle_list->getFirst(); while ($item) { $id_array[] = $item->getItemID(); $item = $discarticle_list->getNext(); } $noticed_manager = $environment->getNoticedManager(); $noticed_manager->getLatestNoticedByIDArray($id_array); $noticed_manager->getLatestNoticedAnnotationsByIDArray($id_array); // gibt noch keine Anmerkungen $link_manager = $environment->getLinkManager(); $file_id_array = $link_manager->getAllFileLinksForListByIDs($id_array); $file_manager = $environment->getFileManager(); $file_manager->setIDArrayLimit($file_id_array); $file_manager->select(); // prepare item array $item = $list->getFirst(); $item_array = array(); $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = false; $view = new cs_view($params); while ($item) { $assessment_stars_text_array = array('non_active', 'non_active', 'non_active', 'non_active', 'non_active'); $current_context = $environment->getCurrentContextItem(); if ($current_context->isAssessmentActive()) { $assessment_manager = $environment->getAssessmentManager(); $assessment = $assessment_manager->getAssessmentForItemAverage($item); if (isset($assessment[0])) { $assessment = sprintf('%1.1f', (double) $assessment[0]); } else { $assessment = 0; } $php_version = explode('.', phpversion()); if ($php_version[0] >= 5 && $php_version[1] >= 3) { // if php version is equal to or above 5.3 $assessment_count_stars = round($assessment, 0, PHP_ROUND_HALF_UP); } else { // if php version is below 5.3 $assessment_count_stars = round($assessment); } for ($i = 0; $i < $assessment_count_stars; $i++) { $assessment_stars_text_array[$i] = 'active'; } } $noticed_text = $this->_getItemChangeStatus($item); $all_and_unread_articles = $item->getAllAndUnreadArticles(); // files $attachment_infos = array(); $file_count = $item->getFileListWithFilesFromArticles()->getCount(); $file_list = $item->getFileListWithFilesFromArticles(); $file = $file_list->getFirst(); while ($file) { $lightbox = false; if ((!isset($_GET['download']) || $_GET['download'] !== 'zip') && in_array($file->getExtension(), array('png', 'jpg', 'jpeg', 'gif'))) { $lightbox = true; } $info = array(); $info['file_name'] = $converter->text_as_html_short($file->getDisplayName()); $info['file_icon'] = $file->getFileIcon(); $info['file_url'] = $file->getURL(); $info['file_size'] = $file->getFileSize(); $info['lightbox'] = $lightbox; $attachment_infos[] = $info; $file = $file_list->getNext(); } $moddate = $item->getModificationDate(); if ($item->getCreationDate() != $item->getModificationDate() and !strstr($moddate, '9999-00-00')) { $mod_date = $this->_environment->getTranslationObject()->getDateInLang($item->getModificationDate()); } else { $mod_date = $this->_environment->getTranslationObject()->getDateInLang($item->getCreationDate()); } $activated_text = ''; $activating_date = $item->getActivatingDate(); if (strstr($activating_date, '9999-00-00')) { $activated_text = $this->_environment->getTranslationObject()->getMessage('COMMON_NOT_ACTIVATED'); } else { $activated_text = $this->_environment->getTranslationObject()->getMessage('COMMON_ACTIVATING_DATE') . ' ' . $this->_environment->getTranslationObject()->getDateInLang($item->getActivatingDate()); } $creator = $item->getCreatorItem(); if (empty($creator)) { $creator_id = ''; } else { $creator_id = $item->getCreatorItem()->getItemID(); } $item_array[] = array('iid' => $item->getItemID(), 'title' => $item->getTitle(), 'date' => $this->_environment->getTranslationObject()->getDateInLang($item->getModificationDate()), 'modificator' => $this->getItemModificator($item), 'assessment_array' => $assessment_stars_text_array, 'noticed' => $noticed_text, 'article_count' => $all_and_unread_articles['count'], 'article_unread' => $all_and_unread_articles['unread'], 'attachment_count' => $file_count, 'attachment_infos' => $attachment_infos, 'activated_text' => $activated_text, 'creator_id' => $creator_id, 'activated' => !$item->isNotActivated()); $item = $list->getNext(); } // append return $return = array('items' => $item_array, 'count_all' => $count_all_shown); return $return; }
public function save($form_data, $additional = array()) { $environment = $this->_environment; $current_user = $this->_environment->getCurrentUserItem(); $current_context = $this->_environment->getCurrentContextItem(); if (isset($additional['action']) && $additional['action'] === 'upload_picture') { $current_iid = $additional['iid']; } else { $current_iid = $form_data['iid']; } $translator = $this->_environment->getTranslationObject(); if ($current_iid === 'NEW') { $user_item = null; } else { $user_manager = $this->_environment->getUserManager(); $user_item = $user_manager->getItem($current_iid); } $this->_popup_controller->performChecks($user_item, $form_data, $additional); // TODO: check rights */ /****************************/ if ($current_iid != 'NEW' and !isset($user_item)) { } elseif (!($current_iid == 'NEW' and $current_user->isUser() or $current_iid != 'NEW' and isset($user_item) and $user_item->mayEdit($current_user))) { /****************************/ } else { //Acces granted $this->cleanup_session($current_iid); // upload picture if (isset($additional['action']) && $additional['action'] === 'upload_picture') { if ($this->_popup_controller->checkFormData('file_upload')) { /* handle picture upload */ if (!empty($additional["fileInfo"])) { $srcfile = $additional["fileInfo"]["file"]; $targetfile = $srcfile . "_converted"; $session = $this->_environment->getSessionItem(); $session->unsetValue("add_files"); // resize image to a maximum width of 150px and keep ratio $size = getimagesize($srcfile); $x_orig = $size[0]; $y_orig = $size[1]; //$verhaeltnis = $x_orig/$y_orig; $verhaeltnis = $y_orig / $x_orig; $max_width = 150; //$ratio = 1.618; // Goldener Schnitt //$ratio = 1.5; // 2:3 $ratio = 1.334; // 3:4 //$ratio = 1; // 1:1 if ($verhaeltnis < $ratio) { // Breiter als 1:$ratio $source_width = $size[1] * $max_width / ($max_width * $ratio); $source_height = $size[1]; $source_x = ($size[0] - $source_width) / 2; $source_y = 0; } else { // Höher als 1:$ratio $source_width = $size[0]; $source_height = $size[0] * ($max_width * $ratio) / $max_width; $source_x = 0; $source_y = ($size[1] - $source_height) / 2; } switch ($size[2]) { case '1': $im = imagecreatefromgif($srcfile); break; case '2': $im = imagecreatefromjpeg($srcfile); break; case '3': $im = imagecreatefrompng($srcfile); break; } $newimg = imagecreatetruecolor($max_width, $max_width * $ratio); imagecopyresampled($newimg, $im, 0, 0, $source_x, $source_y, $max_width, ceil($max_width * $ratio), $source_width, $source_height); imagepng($newimg, $targetfile); imagedestroy($im); imagedestroy($newimg); // determ new file name $filename_info = pathinfo($targetfile); $filename = 'cid' . $this->_environment->getCurrentContextID() . '_' . $user_item->getUserID(); // . '_'. $additional["fileInfo"]["name"]; // copy file and set picture $disc_manager = $this->_environment->getDiscManager(); $disc_manager->copyFile($targetfile, $filename, true); $user_item->setPicture($filename); $user_item->save(); // set return $this->_popup_controller->setSuccessfullDataReturn($filename); } } } else { // save item if ($this->_popup_controller->checkFormData('basic')) { $session = $this->_environment->getSessionItem(); $item_is_new = false; // Set modificator and modification date $current_user = $environment->getCurrentUserItem(); $user_item->setModificatorItem($current_user); // Set attributes if (isset($form_data['title'])) { $user_item->setTitle($form_data['title']); } if (isset($form_data['email_visibility']) and !empty($form_data['email_visibility'])) { $user_item->setEmailNotVisible(); } else { $user_item->setEmailVisible(); } if (isset($form_data['description'])) { $user_item->setDescription($this->_popup_controller->getUtils()->cleanCKEditor($form_data['description'])); } if (!empty($form_data['commsy_visible'])) { if ($form_data['commsy_visible'] == 1) { $user_item->setVisibleToLoggedIn(); } elseif ($form_data['commsy_visible'] == 2) { $user_item->setVisibleToAll(); } } if (isset($form_data['telephone'])) { $user_item->setTelephone($form_data['telephone']); } if (isset($form_data['birthday'])) { $user_item->setBirthday($form_data['birthday']); } if (isset($form_data['cellularphone'])) { $user_item->setCellularphone($form_data['cellularphone']); } if (isset($form_data['homepage'])) { $user_item->setHomepage($form_data['homepage']); } if (isset($form_data['organisation'])) { $user_item->setOrganisation($form_data['organisation']); } if (isset($form_data['position'])) { $user_item->setPosition($form_data['position']); } if (isset($form_data['icq'])) { $user_item->setICQ($form_data['icq']); } if (isset($form_data['skype'])) { $user_item->setSkype($form_data['skype']); } if (isset($form_data['yahoo'])) { $user_item->setYahoo($form_data['yahoo']); } if (isset($form_data['msn'])) { $user_item->setMSN($form_data['msn']); } if (isset($form_data['jabber'])) { $user_item->setJabber($form_data['jabber']); } if (isset($form_data['email'])) { $user_item->setEmail($form_data['email']); } if (isset($form_data['street'])) { $user_item->setStreet($form_data['street']); } if (isset($form_data['zipcode'])) { $user_item->setZipcode($form_data['zipcode']); } if (isset($form_data['city'])) { $user_item->setCity($form_data['city']); } if (isset($form_data['room'])) { $user_item->setRoom($form_data['room']); } if ($user_item->getPicture() && isset($form_data['delete_picture'])) { $disc_manager = $this->_environment->getDiscManager(); if ($disc_manager->existsFile($user_item->getPicture())) { $disc_manager->unlinkFile($user_item->getPicture()); } $user_item->setPicture(''); } if (!empty($form_data['language'])) { $user_item->setLanguage($form_data['language']); } if (isset($form_data['want_mail_get_account'])) { $user_item->setAccountWantMail($form_data['want_mail_get_account']); } if (isset($form_data['mail_delete_entry'])) { $user_item->setDeleteEntryWantMail($form_data['mail_delete_entry']); } else { $user_item->setDeleteEntryWantMail('no'); } if (isset($form_data['want_mail_publish_material'])) { $user_item->setPublishMaterialWantMail($form_data['want_mail_publish_material']); } if (isset($form_data['want_mail_open_room'])) { $user_item->setOpenRoomWantMail($form_data['want_mail_open_room']); } $user_item->setModificationDate(getCurrentDateTimeInMySQL()); // Save item $user_item->save(); // save session $this->_environment->getSessionManager()->save($session); // Add modifier to all users who ever edited this item $manager = $environment->getLinkModifierItemManager(); $manager->markEdited($user_item->getItemID()); // set return $this->_popup_controller->setSuccessfullItemIDReturn($user_item->getItemID()); } } } }
function deleteMaterialsOfUser($uid) { // create backup of item $disable_overwrite = $this->_environment->getConfiguration('c_datenschutz_disable_overwriting'); $this->backupItem($uid, array('title' => 'title', 'description' => 'description', 'modification_date' => 'modification_date', 'public' => 'public'), array('author', 'publishing_date', 'extras')); $current_datetime = getCurrentDateTimeInMySQL(); $query = 'SELECT ' . $this->addDatabasePrefix('materials') . '.* FROM ' . $this->addDatabasePrefix('materials') . ' WHERE ' . $this->addDatabasePrefix('materials') . '.creator_id = "' . $uid . '"'; $result = $this->_db_connector->performQuery($query); if (isset($result)) { foreach ($result as $rs) { $insert_query = 'UPDATE ' . $this->addDatabasePrefix('materials') . ' SET'; if (!empty($disable_overwrite) and $disable_overwrite == 'flag') { $insert_query .= ' public = "-1",'; $insert_query .= ' modification_date = "' . $current_datetime . '"'; } else { $insert_query .= ' title = "' . encode(AS_DB, $this->_translator->getMessage('COMMON_AUTOMATIC_DELETE_TITLE')) . '",'; $insert_query .= ' description = "' . encode(AS_DB, $this->_translator->getMessage('COMMON_AUTOMATIC_DELETE_DESCRIPTION')) . '",'; $insert_query .= ' author = "",'; $insert_query .= ' publishing_date = "",'; $insert_query .= ' extras = "",'; $insert_query .= ' modification_date = "' . $current_datetime . '",'; $insert_query .= ' public = "1"'; } $insert_query .= ' WHERE item_id = "' . $rs['item_id'] . '"'; $result2 = $this->_db_connector->performQuery($insert_query); if (!isset($result2) or !$result2) { include_once 'functions/error_functions.php'; trigger_error('Problems automatic deleting materials from query: "' . $insert_query . '"', E_USER_WARNING); } } } }
public function actionEdit() { //$this->assign('detail', 'content', $this->getDetailContent()); $session = $this->_environment->getSessionItem(); // get post data $this->getPostData(); /* * * // Linked item from "NEW" dropdown-menu if(isset($_GET['linked_item'])){ $entry_new_array = array(); $entry_new_array[] = $_GET['linked_item']; $session->setValue('cid'.$environment->getCurrentContextID().'_linked_items_index_selected_ids',$entry_new_array); } if(isset($_GET['mylist_id'])){ $session->setValue('cid'.$environment->getCurrentContextID().'_linked_items_mylist_id',$_GET['mylist_id']); } // Function used for redirecting to connected rubrics if (isset($_GET['return_attach_buzzword_list'])){ $_POST = $session->getValue('buzzword_post_vars'); unset($_POST['option']); unset($_POST['right_box_option']); } if (isset($_GET['return_attach_tag_list'])){ $_POST = $session->getValue('tag_post_vars'); unset($_POST['option']); unset($_POST['right_box_option']); } if (isset($_GET['return_attach_item_list'])){ $_POST = $session->getValue('linked_items_post_vars'); unset($_POST['option']); unset($_POST['right_box_option']); } // Function used for cleaning up the session. This function // deletes ALL session variables this page writes. function cleanup_session ($current_iid) { global $session,$environment; $session->unsetValue($environment->getCurrentModule().'_add_buzzwords'); $session->unsetValue($environment->getCurrentModule().'_add_tags'); $session->unsetValue($environment->getCurrentModule().'_add_files'); $session->unsetValue($current_iid.'_post_vars'); } // Get the current user and context $current_user = $environment->getCurrentUserItem(); $context_item = $environment->getCurrentContextItem(); // Get the translator object $translator = $environment->getTranslationObject(); // Get item to be edited if ( !empty($_GET['iid']) ) { $current_iid = $_GET['iid']; } elseif ( !empty($_POST['iid']) ) { $current_iid = $_POST['iid']; } else { $current_iid = 'NEW'; } $with_anchor = false; // Coming back from attaching something if ( !empty($_GET['backfrom']) ) { $backfrom = $_GET['backfrom']; } else { $backfrom = false; } // Load item from database if ( $current_iid == 'NEW' ) { $discussion_item = NULL; } else { $discussion_manager = $environment->getDiscussionManager(); $discussion_item = $discussion_manager->getItem($current_iid); if(empty($_POST)){ $buzzword_array = array(); $buzzwords = $discussion_item->getBuzzwordList(); $buzzword = $buzzwords->getFirst(); while($buzzword){ $buzzword_array[] = $buzzword->getItemID(); $buzzword = $buzzwords->getNext(); } $session->setValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_buzzword_ids',$buzzword_array); } if(empty($_POST)){ $tag_array = array(); $tags = $discussion_item->getTagList(); $tag = $tags->getFirst(); while($tag){ $tag_array[] = $tag->getItemID(); $tag = $tags->getNext(); } $session->setValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_tag_ids',$tag_array); } if(empty($_POST)){ $link_item_array = array(); $link_item_array = $discussion_item->getAllLinkedItemIDArray(); $session->setValue('cid'.$environment->getCurrentContextID().'_linked_items_index_selected_ids',$link_item_array); } } // Check access rights if ( $context_item->isProjectRoom() and $context_item->isClosed() ) { $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); unset($params); $errorbox->setText($translator->getMessage('PROJECT_ROOM_IS_CLOSED', $context_item->getTitle())); $page->add($errorbox); } elseif ( $current_iid != 'NEW' and !isset($discussion_item) ) { $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); unset($params); $errorbox->setText($translator->getMessage('ITEM_DOES_NOT_EXIST', $current_iid)); $page->add($errorbox); } elseif ( !(($current_iid == 'NEW' and $current_user->isUser()) or ($current_iid != 'NEW' and isset($discussion_item) and $discussion_item->mayEditIgnoreClose($current_user))) ) { $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); } // Access granted else { // Find out what to do if ( isset($_POST['option']) ) { $command = $_POST['option']; } else { $command = ''; } // Cancel editing if ( isOption($command, $translator->getMessage('COMMON_CANCEL_BUTTON')) ) { $session->unsetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_buzzword_ids'); $session->unsetValue('buzzword_post_vars'); $session->unsetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_tag_ids'); $session->unsetValue('tag_post_vars'); $session->unsetValue('cid'.$environment->getCurrentContextID().'_linked_items_index_selected_ids'); $session->unsetValue('linked_items_post_vars'); cleanup_session($current_iid); if ( $current_iid == 'NEW' ) { redirect($environment->getCurrentContextID(), 'discussion', 'index', ''); } else { $params = array(); $params['iid'] = $current_iid; redirect($environment->getCurrentContextID(), 'discussion', 'detail', $params); } } // Show form and/or save item else { // Initialize the form $class_params= array(); $class_params['environment'] = $environment; $form = $class_factory->getClass(DISCUSSION_FORM,$class_params); unset($class_params); include_once('include/inc_fileupload_edit_page_handling.php'); include_once('include/inc_right_boxes_handling.php'); // Load form data from postvars if ( !empty($_POST) ) { if (empty($session_post_vars)){ $session_post_vars = $_POST; } if ( isset($post_file_ids) AND !empty($post_file_ids) ) { $session_post_vars['filelist'] = $post_file_ids; } if ( isset($post_buzzword_ids) AND !empty($post_buzzword_ids) ) { $session_post_vars['buzzwordlist'] = $post_buzzword_ids; } if ( isset($post_tag_ids) AND !empty($post_tag_ids) ) { $session_post_vars['taglist'] = $post_tag_ids; } $form->setFormPost($session_post_vars); } // Back from multi upload elseif ( $from_multiupload ) { $session_post_vars = array(); if ( isset($post_file_ids) AND !empty($post_file_ids) ) { $session_post_vars['filelist'] = $post_file_ids; } $form->setFormPost($session_post_vars); } // Load form data from database elseif ( isset($discussion_item) ) { $form->setItem($discussion_item); // Files $file_list = $discussion_item->getFileList(); if ( !$file_list->isEmpty() ) { $file_array = array(); $file_item = $file_list->getFirst(); while ( $file_item ) { $temp_array = array(); $temp_array['name'] = $file_item->getDisplayName(); $temp_array['file_id'] = (int)$file_item->getFileID(); $file_array[] = $temp_array; $file_item = $file_list->getNext(); } if ( !empty($file_array)) { $session->setValue($environment->getCurrentModule().'_add_files', $file_array); } } } // Create data for a new item elseif ( $current_iid == 'NEW' ) { cleanup_session($current_iid); } else { include_once('functions/error_functions.php');trigger_error('discussion_edit was called in an unknown manner', E_USER_ERROR); } // If it is a new discussion, also show the text field for // the initial discussion article if ( $current_iid == 'NEW' ) { $form->setNewDiscussion(true); } else { $form->setNewDiscussion(false); } if ($session->issetValue($environment->getCurrentModule().'_add_files')) { $form->setSessionFileArray($session->getValue($environment->getCurrentModule().'_add_files')); } $form->prepareForm(); $form->loadValues(); // Save item if ( !empty($command) and (isOption($command, $translator->getMessage('DISCUSSIONS_SAVE_BUTTON')) or isOption($command, $translator->getMessage('DISCUSSIONS_CHANGE_BUTTON'))) ) { $correct = $form->check(); if ( $correct ) { $item_is_new = false; // New Item? if ( !isset($discussion_item) ) { $new_discussion = true; } else { $new_discussion = false; } if ($new_discussion) { $discussion_manager = $environment->getDiscussionManager(); $discussion_item = $discussion_manager->getNewItem(); $discussion_item->setContextID($environment->getCurrentContextID()); $user = $environment->getCurrentUserItem(); $discussion_item->setCreatorItem($user); $discussion_item->setCreationDate(getCurrentDateTimeInMySQL()); $item_is_new = true; } // Set modificator and modification date $user = $environment->getCurrentUserItem(); $discussion_item->setModificatorItem($user); // Set attributes if ( isset($_POST['title']) ) { $discussion_item->setTitle($_POST['title']); } if ( isset($_POST['public']) ) { if ( $discussion_item->isPublic() != $_POST['public'] ) { $discussion_item->setPublic($_POST['public']); } } else { if ( isset($_POST['private_editing']) ) { $discussion_item->setPrivateEditing('0'); } else { $discussion_item->setPrivateEditing('1'); } } if ( isset($_POST['external_viewer']) and isset($_POST['external_viewer_accounts']) ) { $user_ids = explode(" ",$_POST['external_viewer_accounts']); $discussion_item->setExternalViewerAccounts($user_ids); }else{ $discussion_item->unsetExternalViewerAccounts(); } if ( isset($_POST['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_day_start = convertDateFromInput($_POST['dayStart'],$environment->getSelectedLanguage()); if ($converted_day_start['conforms'] == TRUE) { $dt_hiding_datetime = $converted_day_start['datetime'].' '; $converted_time_start = convertTimeFromInput($_POST['timeStart']); if ($converted_time_start['conforms'] == TRUE) { $dt_hiding_datetime .= $converted_time_start['datetime']; }else{ $dt_hiding_datetime .= $dt_hiding_time; } }else{ $dt_hiding_datetime = $dt_hiding_date.' '.$dt_hiding_time; } $discussion_item->setModificationDate($dt_hiding_datetime); }else{ if($discussion_item->isNotActivated()){ $discussion_item->setModificationDate(getCurrentDateTimeInMySQL()); } } if ($session->issetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_buzzword_ids')){ $discussion_item->setBuzzwordListByID($session->getValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_buzzword_ids')); $session->unsetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_buzzword_ids'); } if ($session->issetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_tag_ids')){ $discussion_item->setTagListByID($session->getValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_tag_ids')); $session->unsetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_tag_ids'); } if ($session->issetValue('cid'.$environment->getCurrentContextID().'_linked_items_index_selected_ids')){ $discussion_item->setLinkedItemsByIDArray(array_unique($session->getValue('cid'.$environment->getCurrentContextID().'_linked_items_index_selected_ids'))); $session->unsetValue('cid'.$environment->getCurrentContextID().'_linked_items_index_selected_ids'); } // Save item $discussion_item->save(); if ($session->issetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_index_ids')){ $id_array = array_reverse($session->getValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_index_ids')); }else{ $id_array = array(); } if ($item_is_new){ $id_array[] = $discussion_item->getItemID(); $id_array = array_reverse($id_array); $session->setValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_index_ids',$id_array); } // Also save the initial discussion article if ( $new_discussion ) { $discarticle_manager = $environment->getDiscussionArticlesManager(); $discarticle_item = $discarticle_manager->getNewItem(); $discarticle_item->setContextID($environment->getCurrentContextID()); $user = $environment->getCurrentUserItem(); $discarticle_item->setCreatorItem($user); $discarticle_item->setCreationDate(getCurrentDateTimeInMySQL()); $discarticle_item->setDiscussionID($discussion_item->getItemId()); if (isset($_POST['subject'])) { $discarticle_item->setSubject($_POST['subject']); } if ( isset($_POST['description'])) { $discarticle_item->setDescription($_POST['description']); } if (isset($_POST['discussion_type']) and $_POST['discussion_type']==2){ $discarticle_item->setPosition('1'); } $item_files_upload_to = $discarticle_item; include_once('include/inc_fileupload_edit_page_save_item.php'); $discarticle_item->save(); // ... and update the discussion item $discussion_item->setLatestArticleID($discarticle_item->getItemID()); $discussion_item->setLatestArticleModificationDate($discarticle_item->getCreationDate()); $discussion_status = $context_item->getDiscussionStatus(); if ($discussion_status == 3){ if ($_POST['discussion_type']==2){ $discussion_item->setDiscussionType('threaded'); }else{ $discussion_item->setDiscussionType('simple'); } }elseif($discussion_status == 2){ $discussion_item->setDiscussionType('threaded'); }else{ $discussion_item->setDiscussionType('simple'); } $discussion_item->save(); } if ($session->issetValue('cid'.$environment->getCurrentContextID().'_linked_items_mylist_id')){ $mylist_manager = $environment->getMylistManager(); $mylist_item = $mylist_manager->getItem($session->getValue('cid'.$environment->getCurrentContextID().'_linked_items_mylist_id')); $id_array = $mylist_item->getAllLinkedItemIDArrayLabelVersion(); if (!in_array($discussion_item->getItemID(),$id_array)){ $id_array[] = $discussion_item->getItemID(); } $mylist_item->saveLinksByIDArray($id_array); } $session->unsetValue('cid'.$environment->getCurrentContextID().'_linked_items_mylist_id'); // Redirect cleanup_session($current_iid); $session->unsetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_buzzword_ids'); $session->unsetValue('buzzword_post_vars'); $session->unsetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_tag_ids'); $session->unsetValue('tag_post_vars'); $session->unsetValue('cid'.$environment->getCurrentContextID().'_linked_items_index_selected_ids'); $session->unsetValue('linked_items_post_vars'); $params = array(); $params['iid'] = $discussion_item->getItemID();; redirect($environment->getCurrentContextID(), 'discussion', 'detail', $params); } } // Display form $class_params = array(); $class_params['environment'] = $environment; $class_params['with_modifying_actions'] = true; $form_view = $class_factory->getClass(FORM_VIEW,$class_params); unset($class_params); if ($with_anchor){ $form_view->withAnchor(); } if (!mayEditRegular($current_user, $discussion_item)) { $form_view->warnChanger(); $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $params['width'] = 500; $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); unset($params); $errorbox->setText($translator->getMessage('COMMON_EDIT_AS_MODERATOR')); $page->add($errorbox); } $form_view->setAction(curl($environment->getCurrentContextID(),'discussion','edit','')); $form_view->setForm($form); $page->add($form_view); } } ?> */ if ($this->_item_id !== null) { $discarticle_manager = $this->_environment->getDiscussionArticlesManager(); $this->_item = $discarticle_manager->getItem($this->_item_id); } // find the discussion this article belongs to if ($this->_item !== NULL) { $discussion_id = $this->_item->getDiscussionID(); $ref_position = $this->_item->getPosition(); } else { if (!empty($_GET['did'])) { $discussion_id = $_GET['did']; } elseif (!empty($_POST['discussion_id'])) { $discussion_id = $_POST['discussion_id']; } elseif (!empty($_GET['discussion_id'])) { $discussion_id = $_GET['discussion_id']; } else { /* if ( $session->issetValue($current_iid.'_post_vars') ) { $session_postvars = $session->getValue($current_iid.'_post_vars'); if ( isset($session_postvars['discussion_id']) ) { $discussion_id = $session_postvars['discussion_id']; } else { include_once('functions/error_functions.php');trigger_error('A discussion id must be given for new discussion articles.', E_USER_ERROR); } } elseif ( $session->issetValue($environment->getCurrentModule().'_multi_upload_post_vars') ) { $session_postvars = $session->getValue($environment->getCurrentModule().'_multi_upload_post_vars'); if ( isset($session_postvars['discussion_id']) ) { $discussion_id = $session_postvars['discussion_id']; } else { include_once('functions/error_functions.php');trigger_error('Lost discussion id for discussion articles.', E_USER_ERROR); } } else { include_once('functions/error_functions.php');trigger_error('A discussion id must be given for new discussion articles.', E_USER_ERROR); } */ } /* $discussion_manager = $this->_environment->getDiscussionManager(); $discussion = $discussion_manager->getItem($discussion_id); /* * $discussion_type = $discussion->getDiscussionType(); $ref_position = '1'; if ( $discussion_type == 'threaded' ) { if ( !empty($_GET['ref_position']) ) { $ref_position = $_GET['ref_position']; } elseif ( !empty($_POST['ref_position']) ) { $ref_position = $_POST['ref_position']; } elseif ( !empty($_GET['ref_position']) ) { $ref_position = $_GET['ref_position']; } else { if ( $session->issetValue($current_iid.'_post_vars') ) { $session_postvars = $session->getValue($current_iid.'_post_vars'); if ( isset($session_postvars['ref_position']) ) { $ref_position = $session_postvars['ref_position']; } else { include_once('functions/error_functions.php');trigger_error('A ref_position id must be given for new discussion articles.', E_USER_ERROR); } } elseif ( $session->issetValue($environment->getCurrentModule().'_multi_upload_post_vars') ) { $session_postvars = $session->getValue($environment->getCurrentModule().'_multi_upload_post_vars'); if ( isset($session_postvars['ref_position']) ) { $ref_position = $session_postvars['ref_position']; } else { include_once('functions/error_functions.php');trigger_error('A ref_position id must be given for new discussion articles.', E_USER_ERROR); } } else { include_once('functions/error_functions.php');trigger_error('A ref_position id must be given for new discussion articles.', E_USER_ERROR); } } if ( !empty($_GET['ref_did']) ) { $ref_did = $_GET['ref_did']; } elseif ( !empty($_POST['ref_did']) ) { $ref_did = $_POST['ref_did']; }elseif ( !empty($_GET['ref_did']) ) { $ref_did = $_GET['ref_did']; } } */ } /* // Check access rights if ( $context_item->isProjectRoom() and $context_item->isClosed() ) { $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); unset($params); $errorbox->setText($translator->getMessage('PROJECT_ROOM_IS_CLOSED', $context_item->getTitle())); $page->add($errorbox); } elseif ( $current_iid != 'NEW' and !isset($discarticle_item) ) { $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); unset($params); $errorbox->setText($translator->getMessage('ITEM_DOES_NOT_EXIST', $current_iid)); $page->add($errorbox); } elseif ( !(($current_iid == 'NEW' and $current_user->isUser()) or ($current_iid != 'NEW' and isset($discarticle_item) and $discarticle_item->mayEdit($current_user))) ) { $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); } // Access granted else { */ $translator = $this->_environment->getTranslationObject(); // cancel editing if (isOption($this->_command, $translator->getMessage('COMMON_CANCEL_BUTTON'))) { /* if (isset($discarticle_item) and !empty($discarticle_item)){ $discarticle_id = 'anchor'.$discarticle_item->getItemID(); } else { $discarticle_id = ''; } cleanup_session($current_iid); if ( $current_iid == 'NEW' and empty($discussion_id) ) { redirect($environment->getCurrentContextID(), 'discussion', 'index', ''); } else { $params = array(); $params['iid'] = $discussion_id; redirect($environment->getCurrentContextID(), 'discussion', 'detail', $params, $discarticle_id); } */ // show form and/or save item } else { if (isset($_GET['back_to_discussion_detail_view']) && !empty($command) && !(isOption($command, $translator->getMessage('DISCARTICLE_SAVE_BUTTON')) || isOption($command, $translator->getMessage('DISCARTICLE_CHANGE_BUTTON')))) { /* // Handle requests from discussion_detail_view if( isset($_GET['back_to_discussion_detail_view']) && !empty($command) && !(isOption($command, $translator->getMessage('DISCARTICLE_SAVE_BUTTON')) || isOption($command, $translator->getMessage('DISCARTICLE_CHANGE_BUTTON'))) ) { $session_item = $environment->getSessionItem(); if( (!$session_item->issetValue($environment->getCurrentModule().'_add_files') && isset($discarticle_item))) { // get files from database $file_list = $discarticle_item->getFileList(); if ( !$file_list->isEmpty() ) { $file_array = array(); $file_item = $file_list->getFirst(); while ( $file_item ) { $temp_array = array(); $temp_array['name'] = $file_item->getDisplayName(); $temp_array['file_id'] = (int)$file_item->getFileID(); $file_array[] = $temp_array; $file_item = $file_list->getNext(); } if ( !empty($file_array)) { $session->setValue($environment->getCurrentModule().'_add_files', $file_array); } } } include_once('include/inc_fileupload_edit_page_handling.php'); */ $post_file_ids = array(); if (isset($_POST['filelist'])) { $post_file_ids = $_POST['filelist']; } // set session post vars $session_post_vars = $_POST; if (isset($post_file_ids) && !empty($post_file_ids)) { $session_post_vars['filelist'] = $post_file_ids; } $session_item->setValue('back_to_discussion_detail_view_postvars', $session_post_vars); if (isset($discarticle_item)) { $session_item->setValue('back_to_discussion_detail_view_last_upload', 'edit' . $discarticle_item->getItemID()); } else { $session_item->setValue('back_to_discussion_detail_view_last_upload', 'new' . $_GET['answer_to']); } // redirect //cleanup_session($current_iid); /* * // Redirect //cleanup_session($current_iid); $params = array(); $params['iid'] = $_POST['discussion_id']; $anchor = ''; if($_GET['back_to_discussion_detail_view'] == 'new') { // new $params['ref_position'] = $_POST['ref_position']; $params['answer_to'] = $_GET['answer_to']; } else { // edit $params['discarticle_action'] = 'edit'; $params['discarticle_iid'] = $discarticle_item->getItemID(); } redirect( $environment->getCurrentContextID(), 'discussion', 'detail', $params, 'discarticle_form'); * * */ } /* // Initialize the form $class_params= array(); $class_params['environment'] = $environment; $form = $class_factory->getClass(DISCARTICLE_FORM,$class_params); unset($class_params); $form->setDiscussionID($discussion_id); $form->setRefPosition($ref_position); if (isset($ref_did)){ $form->setRefDid($ref_did); } */ $post_file_ids = array(); if (isset($_POST['filelist'])) { $post_file_ids = $_POST['filelist']; } // load form data from postvars if (!empty($_POST)) { $session_post_vars = $_POST; if (isset($post_file_ids) && !empty($post_file_ids)) { $session_post_vars['filelist'] = $post_file_ids; } //$form->setFormPost($session_post_vars); } elseif (isset($this->_item)) { /* * $form->setItem($discarticle_item); // Files $file_list = $discarticle_item->getFileList(); if ( !$file_list->isEmpty() ) { $file_array = array(); $file_item = $file_list->getFirst(); while ( $file_item ) { $temp_array = array(); $temp_array['name'] = $file_item->getDisplayName(); $temp_array['file_id'] = (int)$file_item->getFileID(); $file_array[] = $temp_array; $file_item = $file_list->getNext(); } if ( !empty($file_array)) { $session->setValue($environment->getCurrentModule().'_add_files', $file_array); } } */ } elseif ($this->_item_id === null) { $this->cleanup_session($this->_item_id); } else { include_once 'functions/error_functions.php'; trigger_error('discarticle_edit was called in an unknown manner', E_USER_ERROR); } if ($session->issetValue($this->_environment->getCurrentModule() . '_add_files')) { //$form->setSessionFileArray($session->getValue($environment->getCurrentModule().'_add_files')); //die("UPLOAD"); } // save item if ($this->_command === 'new') { // TODO: implement form check $correct = true; if ($correct) { // create new item if (!isset($this->_item)) { $discarticle_manager = $this->_environment->getDiscussionArticlesManager(); $discarticle_item = $discarticle_manager->getNewItem(); $discarticle_item->setContextID($this->_environment->getCurrentContextID()); $user = $this->_environment->getCurrentUserItem(); $discarticle_item->setCreatorItem($user); $discarticle_item->setCreationDate(getCurrentDateTimeInMySQL()); $discarticle_item->setDiscussionID($discussion_id); $discussion_manager = $this->_environment->getDiscussionManager(); $discussion_item = $discussion_manager->getItem($discussion_id); $discussion_type = $discussion_item->getDiscussionType(); if ($discussion_type === 'threaded') { // load discussion articles /* $discussionarticles_manager = $environment->getDiscussionArticlesManager(); $discussionarticles_manager->setDiscussionLimit($discussion_id,''); $discussionarticles_manager->select(); $articles_list = $discussionarticles_manager->get(); $article = $articles_list->getFirst(); $position_array = array(); while($article){ $article_position = $article->getPosition(); if ($article_position > $ref_position){ $position_array[]= $article_position; } $article= $articles_list->getNext(); } sort($position_array); $in = in_array($ref_position.'.1001',$position_array); if (!$in){ $discarticle_item->setPosition($ref_position.'.1001'); } else { $ref_pos_array = explode('.',$ref_position); $compare_array = array(); $end = count($position_array)-1; for ($i = 0; $i <= $end; $i++){ $value_array = explode('.',$position_array[$i]); $in = true; $end2 = count($ref_pos_array)-1; for ($j = 0; $j <= $end2; $j++){ if ( isset($value_array[$j]) and $ref_pos_array[$j] != $value_array[$j]){ $in = false; } } if ($in and count($value_array) == count($ref_pos_array)+1){ $compare_array[] = $value_array[count($ref_pos_array)]; } } $lenght = count($compare_array)-1; $result = $compare_array[$lenght]; $end_result = $result+1; $discarticle_item->setPosition($ref_position.'.'.$end_result); */ } else { $discarticle_item->setPosition('1'); } } // set modificator and modification date $user = $this->_environment->getCurrentUserItem(); $discarticle_item->setModificatorItem($user); $discarticle_item->setModificationDate(getCurrentDateTimeInMySQL()); // set attributes if (isset($_POST['form_data']['title'])) { $discarticle_item->setSubject($_POST['form_data']['title']); } if (isset($_POST['form_data']['description'])) { $discarticle_item->setDescription($_POST['form_data']['description']); } // set links to connected rubrics if (isset($_POST[CS_MATERIAL_TYPE])) { $discarticle_item->setMaterialListByID($_POST[CS_MATERIAL_TYPE]); } else { $discarticle_item->setMaterialListByID(array()); } $this->setFilesForItem($discarticle_item, $post_file_ids); // save item $discarticle_item->save(); // redirect $this->cleanup_session($this->_item_id); $params = array(); $params['iid'] = $discarticle_item->getDiscussionID(); redirect($this->_environment->getCurrentContextID(), 'discussion', 'detail', $params, 'disc_article_' . $discarticle_item->getItemID()); } } /* // Display form $class_params = array(); $class_params['environment'] = $environment; $class_params['with_modifying_actions'] = true; $form_view = $class_factory->getClass(FORM_VIEW,$class_params); unset($class_params); if ($with_anchor){ $form_view->withAnchor(); } $discussion_manager = $environment->getDiscussionManager(); if ( isset($discarticle_item) ){ $discussion_item = $discussion_manager->getItem($discarticle_item->getDiscussionID()); if (!mayEditRegular($current_user, $discarticle_item)) { $form_view->warnChanger(); $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $params['width'] = 500; $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); unset($params); $errorbox->setText($translator->getMessage('COMMON_EDIT_AS_MODERATOR')); $page->add($errorbox); } } $form_view->setAction(curl($environment->getCurrentContextID(),'discarticle','edit','')); $form_view->setForm($form); $page->add($form_view);*/ } /* } */ // mark as read and noticed //$this->markRead(); //$this->markNoticed(); // set list actions //$this->assign('list', 'actions', $this->getListActions()); /* // set paging information $paging = array( 'num_pages' => ceil($this->_num_entries / $this->_paging['limit']), 'actual_page' => floor($this->_paging['offset'] / $this->_paging['limit']) + 1, 'from' => $this->_paging['offset'] + 1, 'to' => $this->_paging['offset'] + $this->_paging['limit'] ); $this->assign('list', 'paging', $paging); $this->assign('list', 'num_entries', $this->_num_entries); */ }
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()); } } }
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(); } }
if ($environment->inProjectRoom()){ //Gruppenoptionen $current_user = $environment->getCurrentUserItem(); $context_item->setModificatorItem($current_user); $context_item->setModificationDate(getCurrentDateTimeInMySQL()); if ( isset($_POST['grouproom']) and !empty($_POST['grouproom']) and $_POST['grouproom'] == 1 ) { $context_item->setGrouproomActive(); } else { $context_item->setGrouproomInactive(); } } // Bewertungsfunktion $current_user = $environment->getCurrentUserItem(); $context_item->setModificatorItem($current_user); $context_item->setModificationDate(getCurrentDateTimeInMySQL()); if(isset($_POST['assessment']) && !empty($_POST['assessment']) && $_POST['assessment'] == 1) { $context_item->setAssessmentActive(); } else { $context_item->setAssessmentInactive(); } // Save item $context_item->save(); $form_view->setItemIsSaved(); $is_saved = true; } } // Load form data from postvars if ( !empty($_POST) and !$is_saved) { $form->setFormPost($_POST); }
public function save($form_data, $additional = array()) { $session = $this->_environment->getSessionItem(); 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()); } } // get the current user and room $current_user = $this->_environment->getCurrentUserItem(); $room_item = $this->_environment->getCurrentContextItem(); // get history from session $history = $session->getValue('history'); // load item from database $annotation_item = null; if ($form_data["iid"] !== 'NEW') { $annotation_manager = $this->_environment->getAnnotationManager(); $annotation_item = $annotation_manager->getItem($form_data["iid"]); } // save the history if (isset($_GET['mode']) && $_GET['mode'] === 'annotate' && $history[0]['module'] !== 'annotation') { $session->setValue('annotation_history_context', $history[0]['context']); $session->setValue('annotation_history_module', $history[0]['module']); $session->setValue('annotation_history_function', $history[0]['function']); $session->setValue('annotation_history_parameter', $history[0]['parameter']); } // check access rights $item_manager = $this->_environment->getItemManager(); if ($form_data["iid"] !== 'NEW' && !isset($annotation_item)) { /* * $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); unset($params); $errorbox->setText($translator->getMessage('ITEM_DOES_NOT_EXIST', $current_iid)); $page->add($errorbox); */ } elseif (!($form_data["iid"] === 'NEW' && $current_user->isUser() || $form_data["iid"] !== 'NEW' && isset($annotation_item) && $annotation_item->mayEdit($current_user) || $form_data["iid"] === 'NEW' && isset($_GET['ref_iid']) && $item_manager->getExternalViewerForItem($_GET['ref_iid'], $current_user->getUserID()))) { /* * $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 { $translator = $this->_environment->getTranslationObject(); // load form data from postvars if (!empty($_POST)) { $session_post_vars = $_POST; if (isset($post_file_ids) && !empty($post_file_ids)) { $session_post_vars['filelist'] = $post_file_ids; } //$form->setFormPost($session_post_vars); } elseif (isset($annotation_item)) { /* * $form->setItem($annotation_item); // Files $file_list = $annotation_item->getFileList(); if ( !$file_list->isEmpty() ) { $file_array = array(); $file_item = $file_list->getFirst(); while ( $file_item ) { $temp_array = array(); $temp_array['name'] = $file_item->getDisplayName(); $temp_array['file_id'] = (int)$file_item->getFileID(); $file_array[] = $temp_array; $file_item = $file_list->getNext(); } if ( !empty($file_array)) { $session->setValue($environment->getCurrentModule().'_add_files', $file_array); } } */ } elseif ($form_data["iid"] === 'NEW') { /* * $form->setRefID($_GET['ref_iid']); if ( !empty($_GET['version']) ) { $form->setVersion($_GET['version']); } */ } else { include_once 'functions/error_functions.php'; trigger_error('annotation_edit was called in an unknown manner', E_USER_ERROR); } if ($session->issetValue($this->_environment->getCurrentModule() . '_add_files')) { //$form->setSessionFileArray($session->getValue($environment->getCurrentModule().'_add_files')); } /* * $form->prepareForm(); $form->loadValues(); */ // save item if ($this->_popup_controller->checkFormData()) { $user = $this->_environment->getCurrentUserItem(); // create new item $isNew = false; if ($annotation_item === null) { $annotation_manager = $this->_environment->getAnnotationManager(); $annotation_item = $annotation_manager->getNewItem(); $annotation_item->setContextID($this->_environment->getCurrentContextID()); $annotation_item->setCreatorItem($user); $annotation_item->setCreationDate(getCurrentDateTimeInMySQL()); if ($additional["annotatedId"]) { $annotation_item->setLinkedItemID($additional["annotatedId"]); } else { if (isset($additional["portfolioId"])) { $annotation_item->setLinkedItemID($additional["portfolioId"]); } } if ($additional["versionId"]) { $annotation_item->setLinkedVersionItemID($additional["versionId"]); } $isNew = true; } // set modificator and modification date $annotation_item->setModificatorItem($user); $annotation_item->setModificationDate(getCurrentDateTimeInMySQL()); // set attributes if (isset($form_data['title'])) { $annotation_item->setTitle($form_data['title']); } if (isset($form_data['description'])) { $annotation_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($annotation_item, $file_ids, $form_data["files"]); // add modifier to all users who ever edited this item $manager = $this->_environment->getLinkModifierItemManager(); $manager->markEdited($annotation_item->getItemID()); $annotation_item->save(); // reset id array $session->setValue('cid' . $this->_environment->getCurrentContextID() . '_annotation_index_ids', array($annotation_item->getItemID())); // check for portfolio link if (isset($additional["portfolioId"])) { if ($isNew === true) { $portfolioManager = $this->_environment->getPortfolioManager(); $portfolioManager->setPortfolioAnnotation($additional["portfolioId"], $annotation_item->getItemID(), $additional["portfolioRow"], $additional["portfolioColumn"]); } $this->_popup_controller->setSuccessfullItemIDReturn($annotation_item->getItemID()); } else { $this->_popup_controller->setSuccessfullItemIDReturn($annotation_item->getLinkedItemID()); } } } }
public function save($form_data, $additional = array()) { $environment = $this->_environment; $user = $environment->getCurrentUserItem(); $material_manager = $this->_environment->getMaterialManager(); $current_iid = $form_data['iid']; if ($current_iid === 'NEW') { $section_item = null; } else { $section_manager = $this->_environment->getSectionManager(); $section_item = $section_manager->getItem($current_iid); } $check_passed = $this->_popup_controller->checkFormData('general'); if ($check_passed === true) { $material_ref_id = $additional['ref_iid']; if (isset($additional['version_id'])) { $material_item = $material_manager->getItemByVersion($material_ref_id, $additional['version_id']); } else { $material_item = $material_manager->getItem($material_ref_id); } // Create new item if (!isset($section_item)) { $section_manager = $environment->getSectionManager(); $section_item = $section_manager->getNewItem(); $section_item->setContextID($environment->getCurrentContextID()); $user = $environment->getCurrentUserItem(); $section_item->setCreatorItem($user); $section_item->setCreationDate(getCurrentDateTimeInMySQL()); } // new version? /* if ((!empty($command) AND isOption($command,$translator->getMessage('MATERIAL_VERSION_BUTTON'))) or ($form_data['material_modification_date'] != $this->_material_item->getModificationDate())) { $version = $this->_material_item->getVersionID()+1; $this->_material_item->save(); $this->_material_item = $this->_material_item->cloneCopy(); $this->_material_item->setVersionID($version); $infoBox_forAutoNewVersion = "&autoVersion=true"; } */ // Set modificator and modification date $user = $environment->getCurrentUserItem(); $section_item->setModificatorItem($user); $section_item->setModificationDate(getCurrentDateTimeInMySQL()); // Set attributes if (isset($form_data['title'])) { $section_item->setTitle($form_data['title']); } if (isset($form_data['description'])) { $section_item->setDescription($this->_popup_controller->getUtils()->cleanCKEditor($form_data['description'])); } //TODO: Nummer auslesen (weil Eintragsordnung per drag & drop veränderbar) if (isset($form_data['number'])) { $section_item->setNumber($form_data['number']); } if (isset($material_item)) { $section_item->setLinkedItemID($material_item->getItemID()); } // Set links to connected rubrics if (isset($form_data[CS_MATERIAL_TYPE])) { $section_item->setMaterialListByID($form_data[CS_MATERIAL_TYPE]); } else { $section_item->setMaterialListByID(array()); } // Update the material regarding the latest section informations... // (this takes care of saving the section itself, too) $material_item->setModificatorItem($user); if (!$material_item->isNotActivated()) { $material_item->setModificationDate($section_item->getModificationDate()); } else { $material_item->setModificationDate($material_item->getModificationDate()); } $section_list = $material_item->getSectionList(); // 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($section_item, $file_ids, $form_data["files"]); $section_list->set($section_item); $material_item->setSectionList($section_list); $material_item->setSectionSaveID($section_item->getItemId()); $external_view_array = $material_item->getExternalViewerArray(); $material_item->setExternalViewerAccounts($external_view_array); $material_item->save(); // set return $this->_popup_controller->setSuccessfullItemIDReturn($material_item->getItemID()); } }
/** * mark an array of items/version as read by the current user * * @param $id_array * @param $version_id */ function markNoticedArray($id_array, $version_id) { if (!empty($this->_current_user_id)) { $query = 'INSERT IGNORE INTO ' . $this->addDatabasePrefix('noticed') . ' (item_id, version_id, user_id, read_date) VALUES '; foreach ($id_array as $key => $id) { $query .= '("' . encode(AS_DB, $id) . '", "' . encode(AS_DB, $version_id) . '", "' . encode(AS_DB, $this->_current_user_id) . '", "' . getCurrentDateTimeInMySQL() . '")'; if (isset($id_array[$key + 1])) { $query .= ', '; } } $result = $this->_db_connector->performQuery($query); if (!isset($result)) { include_once 'functions/error_functions.php'; trigger_error('Problems marking item as read from query: "' . $query . '"'); } } }
$converted_day_start = convertDateFromInput($_POST['dayStart'],$environment->getSelectedLanguage()); if ($converted_day_start['conforms'] == TRUE) { $dt_hiding_datetime = $converted_day_start['datetime'].' '; $converted_time_start = convertTimeFromInput($_POST['timeStart']); if ($converted_time_start['conforms'] == TRUE) { $dt_hiding_datetime .= $converted_time_start['datetime']; }else{ $dt_hiding_datetime .= $dt_hiding_time; } }else{ $dt_hiding_datetime = $dt_hiding_date.' '.$dt_hiding_time; } $topic_item->setModificationDate($dt_hiding_datetime); } else { if($topic_item->isNotActivated()){ $topic_item->setModificationDate(getCurrentDateTimeInMySQL()); } } if ( isset($_POST['path_active']) and $_POST['path_active'] == 1 ) { $topic_item->activatePath(); } elseif ( isset($_POST['path_active']) and $_POST['path_active'] == -1 ) { $topic_item->deactivatePath(); } if ($session->issetValue('cid'.$environment->getCurrentContextID().'_linked_items_index_selected_ids')){ $topic_item->setLinkedItemsByIDArray(array_unique($session->getValue('cid'.$environment->getCurrentContextID().'_linked_items_index_selected_ids'))); $session->unsetValue('cid'.$environment->getCurrentContextID().'_linked_items_index_selected_ids'); } // Save item $topic_item->save(); if ($session->issetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_index_ids')){
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; } }