function _sendPrivateRoomNewsletter() { if (!$this->_send_newsletter) { include_once 'functions/misc_functions.php'; $time_start = getmicrotime(); $retour = array(); $retour['title'] = 'privateroom newsletter'; $retour['description'] = 'send activity newsletter to private room user'; $retour['success'] = false; $retour['success_text'] = 'cron failed'; // get user in room $user = $this->getOwnerUserItem(); if (isset($user) and $this->isPrivateRoomNewsletterActive() and $this->isPrivateroom()) { $url_to_portal = ''; $portal_item = $this->getContextItem(); if (!empty($portal_item)) { $url_to_portal = $portal_item->getURL(); } global $c_commsy_cron_path; if (isset($c_commsy_cron_path)) { $curl_text = $c_commsy_cron_path . 'commsy.php?cid='; } elseif (!empty($url_to_portal)) { $c_commsy_domain = $this->_environment->getConfiguration('c_commsy_domain'); if (stristr($c_commsy_domain, 'https://')) { $curl_text = 'https://'; } else { $curl_text = 'http://'; } $curl_text .= $url_to_portal; $file = 'commsy.php'; $c_single_entry_point = $this->_environment->getConfiguration('c_single_entry_point'); if (!empty($c_single_entry_point)) { $file = $c_single_entry_point; } $curl_text .= '/' . $file . '?cid='; } else { $file = $_SERVER['PHP_SELF']; $file = str_replace('cron_new', 'commsy', $file); $file = str_replace('cron', 'commsy', $file); $curl_text = 'http://' . $_SERVER['HTTP_HOST'] . $file . '?cid='; } $mail_array = array(); $mail_array[] = $user->getEmail(); // get activity informations for room and send mail if (!empty($mail_array)) { // email $id = $user->getItemID(); $portal = $this->getContextItem(); $room_manager = $this->_environment->getRoomManager(); $list = $this->getCustomizedRoomList(); if (!isset($list)) { $list = $room_manager->_getRelatedContextListForUser($user->getUserID(), $user->getAuthSource(), $portal->getItemID(), true, true); } $list2 = new cs_list(); if (!$list->isEmpty()) { $item = $list->getFirst(); while ($item) { if ($item->isPrivateRoom() or !$item->isShownInPrivateRoomHomeByItemID($id) or !$item->isOpen() or $item->getItemID() < 0) { // do nothing } else { $list2->add($item); } unset($item); $item = $list->getNext(); } unset($item); unset($list); } $translator = $this->_environment->getTranslationObject(); $translator->setRubricTranslationArray($this->getRubricTranslationArray()); $mail_sequence = $this->getPrivateRoomNewsletterActivity(); $body = ''; $item = $list2->getFirst(); while ($item) { $conf = $item->getHomeConf(); if (!empty($conf)) { $rubrics = explode(',', $conf); } else { $rubrics = array(); } $count = count($rubrics); $check_managers = array(); $check_rubrics = array(); foreach ($rubrics as $rubric) { list($rubric_name, $rubric_status) = explode('_', $rubric); if ($rubric_status != 'none') { $check_managers[] = $rubric_name; if ($rubric_name == 'discussion') { $check_managers[] = 'discarticle'; } if ($rubric_name == 'material') { $check_managers[] = 'section'; } } } $title = '<a href="' . $curl_text . $item->getItemID() . '&mod=home&fct=index">' . $item->getTitle() . '</a>'; $body_title = BR . BR . $title . '' . LF; $total_count = 0; if ($mail_sequence == 'daily') { $count_total = $item->getPageImpressionsForNewsletter(1); $active = $item->getActiveMembersForNewsletter(1); } else { $count_total = $item->getPageImpressionsForNewsletter(7); $active = $item->getActiveMembersForNewsletter(7); } if ($count_total == 1) { $body_title .= '(' . $count_total . ' ' . $translator->getMessage('ACTIVITY_PAGE_IMPRESSIONS_SINGULAR') . '; '; } else { $body_title .= '(' . $count_total . ' ' . $translator->getMessage('ACTIVITY_PAGE_IMPRESSIONS') . '; '; } $body_title .= $translator->getMessage('ACTIVITY_ACTIVE_MEMBERS') . ': '; $body_title .= $active . '):' . BRLF; $body2 = ''; $annotation_manager = $this->_environment->getManager('annotation'); $annotation_manager->setContextLimit($item->getItemID()); if ($mail_sequence == 'daily') { $annotation_manager->setAgeLimit(1); } else { $annotation_manager->setAgeLimit(7); } $annotation_manager->showNoNotActivatedEntries(); $annotation_manager->select(); $annotation_list = $annotation_manager->get(); for ($i = 0; $i < $count; $i++) { $rubric_array = explode('_', $rubrics[$i]); if ($rubric_array[1] != 'none') { $rubric_manager = $this->_environment->getManager($rubric_array[0]); $rubric_manager->reset(); $rubric_manager->setContextLimit($item->getItemID()); if ($mail_sequence == 'daily') { $rubric_manager->setAgeLimit(1); } else { $rubric_manager->setAgeLimit(7); } if ($rubric_manager instanceof cs_dates_manager) { $rubric_manager->setDateModeLimit(2); } if ($rubric_manager instanceof cs_user_manager) { $rubric_manager->setUserLimit(); } $rubric_manager->showNoNotActivatedEntries(); $rubric_manager->select(); $rubric_list = $rubric_manager->get(); // returns a cs_list of announcement_items $ids = $rubric_manager->getIDs(); $rubric_item = $rubric_list->getFirst(); $user_manager = $this->_environment->getUserManager(); $user_manager->resetLimits(); $user_manager->setUserIDLimit($user->getUserID()); $user_manager->setAuthSourceLimit($user->getAuthSource()); $user_manager->setContextLimit($item->getItemID()); $user_manager->select(); $user_list = $user_manager->get(); if (isset($user_list) and $user_list->isNotEmpty() and $user_list->getCount() == 1) { $ref_user = $user_list->getFirst(); if (isset($ref_user) and $ref_user->getItemID() > 0) { $temp_body = ''; $count_entries = 0; while ($rubric_item) { $noticed_manager = $this->_environment->getNoticedManager(); $noticed = $noticed_manager->getLatestNoticedForUserByID($rubric_item->getItemID(), $ref_user->getItemID()); if (empty($noticed)) { $info_text = ' <span class="changed">[' . $translator->getMessage('COMMON_NEW') . ']</span>'; } elseif ($noticed['read_date'] < $rubric_item->getModificationDate()) { $info_text = ' <span class="changed">[' . $translator->getMessage('COMMON_CHANGED') . ']</span>'; } else { $info_text = ''; } $annotation_item = $annotation_list->getFirst(); $annotation_count = 0; while ($annotation_item) { $annotation_noticed = $noticed_manager->getLatestNoticedForUserByID($annotation_item->getItemID(), $ref_user->getItemID()); if (empty($annotation_noticed)) { $linked_item = $annotation_item->getLinkedItem(); if ($linked_item->getItemID() == $rubric_item->getItemID()) { $annotation_count++; } } $annotation_item = $annotation_list->getNext(); } if ($annotation_count == 1) { $info_text .= ' <span class="changed">[' . $translator->getMessage('COMMON_NEW_ANNOTATION') . ']</span>'; } else { if ($annotation_count > 1) { $info_text .= ' <span class="changed">[' . $translator->getMessage('COMMON_NEW_ANNOTATIONS') . ']</span>'; } } if (!empty($info_text)) { $count_entries++; $params = array(); $params['iid'] = $rubric_item->getItemID(); $title = ''; if ($rubric_item->isA(CS_USER_TYPE)) { $title .= $this->_environment->getTextConverter()->text_as_html_short($rubric_item->getFullname()); } else { $title .= $this->_environment->getTextConverter()->text_as_html_short($rubric_item->getTitle()); } if ($rubric_item->isA(CS_LABEL_TYPE)) { $mod = $rubric_item->getLabelType(); } else { $mod = $rubric_item->getType(); } $title .= $info_text; $ahref_curl = '<a href="' . $curl_text . $item->getItemID() . '&mod=' . $mod . '&fct=detail&iid=' . $params['iid'] . '">' . $title . '</a>'; $temp_body .= BR . ' - ' . $ahref_curl; } $rubric_item = $rubric_list->getNext(); } } } $tempMessage = ''; switch (mb_strtoupper($rubric_array[0], 'UTF-8')) { case 'ANNOUNCEMENT': $tempMessage = $translator->getMessage('ANNOUNCEMENT_INDEX'); break; case 'DATE': $tempMessage = $translator->getMessage('DATES_INDEX'); break; case 'DISCUSSION': $tempMessage = $translator->getMessage('DISCUSSION_INDEX'); break; case 'GROUP': $tempMessage = $translator->getMessage('GROUP_INDEX'); break; case 'INSTITUTION': $tempMessage = $translator->getMessage('INSTITUTION_INDEX'); break; case 'MATERIAL': $tempMessage = $translator->getMessage('MATERIAL_INDEX'); break; case 'MYROOM': $tempMessage = $translator->getMessage('MYROOM_INDEX'); break; case 'PROJECT': $tempMessage = $translator->getMessage('PROJECT_INDEX'); break; case 'TODO': $tempMessage = $translator->getMessage('TODO_INDEX'); break; case 'TOPIC': $tempMessage = $translator->getMessage('TOPIC_INDEX'); break; case 'USER': $tempMessage = $translator->getMessage('USER_INDEX'); break; case 'ENTRY': $tempMessage = $translator->getMessage('ENTRY_INDEX'); break; default: $tempMessage = $translator->getMessage('COMMON_MESSAGETAG_ERROR' . ' cs_privateroom_item(456) '); break; } if ($count_entries == 1) { $ahref_curl = '<a href="' . $curl_text . $item->getItemID() . '&mod=' . $rubric_array[0] . '&fct=index">' . $tempMessage . '</a>'; $body2 .= ' ' . $ahref_curl; $body2 .= ' <span style="font-size:8pt;">(' . $count_entries . ' ' . $translator->getMessage('NEWSLETTER_NEW_SINGLE_ENTRY') . ')</span>'; } elseif ($count_entries > 1) { $ahref_curl = '<a href="' . $curl_text . $item->getItemID() . '&mod=' . $rubric_array[0] . '&fct=index">' . $tempMessage . '</a>'; $body2 .= ' ' . $ahref_curl; $body2 .= ' <span style="font-size:8pt;">(' . $count_entries . ' ' . $translator->getMessage('NEWSLETTER_NEW_ENTRIES') . ')</span>'; } if (!empty($body2) and !empty($temp_body)) { $body2 .= $temp_body . BRLF . LF; } } $j = $i + 1; } $item = $list2->getNext(); if (!empty($body2)) { $body .= $body_title; $body2 .= BRLF; $body .= $body2; } else { $body .= $body_title; $body2 .= ' ' . $translator->getMessage('COMMON_NO_NEW_ENTRIES') . BRLF; $body .= $body2; } } if (empty($body)) { $translator->getMessage('COMMON_NO_NEW_ENTRIES') . LF; } $body .= LF; $portal = $this->getContextItem(); $portal_title = ''; if (isset($portal)) { $portal_title = $portal->getTitle(); } if ($mail_sequence == 'daily') { $body = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_HEADER_DAILY', $portal_title) . LF . LF . $body; } else { $body = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_HEADER_WEEKLY', $portal_title) . LF . LF . $body; } $body .= BRLF . BR . '-----------------------------' . BRLF . LF . $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_FOOTER'); $from = $translator->getMessage('SYSTEM_MAIL_MESSAGE', $portal_title); $to = implode($mail_array, ','); if ($mail_sequence == 'daily') { $subject = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_DAILY') . ': ' . $portal_title; } else { $subject = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_WEEKLY') . ': ' . $portal_title; } // send email include_once 'classes/cs_mail.php'; $mail = new cs_mail(); $mail->set_to($to); $mail->set_from_name($from); $server_item = $this->_environment->getServerItem(); $default_sender_address = $server_item->getDefaultSenderAddress(); if (!empty($default_sender_address)) { $mail->set_from_email($default_sender_address); } else { $mail->set_from_email('@'); } $mail->set_subject($subject); $mail->set_message($body); $mail->setSendAsHTML(); if ($mail->send()) { $retour['success'] = true; $retour['success_text'] = 'send newsletter to ' . $to; $this->_send_newsletter = true; } unset($mail); unset($body); unset($subject); unset($default_sender_address); unset($from); unset($to); unset($user_list); unset($ref_user); unset($translator); unset($room_manager); unset($list); unset($list2); unset($portal); unset($user_manager); unset($file); unset($curl_text); unset($mail_array); unset($rubric_manager); unset($noticed_manager); unset($rubric_list); unset($rubric_item); } else { $retour['success'] = true; $retour['success_text'] = 'no user in room want the newsletter'; } } $time_end = getmicrotime(); $time = round($time_end - $time_start, 0); $retour['time'] = $time; return $retour; } }
function exportItemToWiki_soap($current_item_id, $rubric) { global $c_commsy_path_file; global $c_pmwiki_path_file; global $c_pmwiki_absolute_path_file; global $c_pmwiki_path_url; global $c_commsy_domain; global $c_commsy_url_path; $translator = $this->_environment->getTranslationObject(); $client = $this->getSoapClient(); $client->createDir('uploads/Main', $this->_environment->getSessionID()); $author = ''; $description = ''; if ($rubric == CS_MATERIAL_TYPE) { // Material Item $material_manager = $this->_environment->getMaterialManager(); $material_version_list = $material_manager->getVersionList($current_item_id); $item = $material_version_list->getFirst(); // Informationen $author = $item->getAuthor(); if (empty($author)) { $author = $item->getModificatorItem()->getFullName(); $description = $item->getDescription(); } $informations = '!' . $item->getTitle() . '%0a%0a'; $informations .= '(:table border=0 style="margin-left:0px;":)%0a'; $informations .= '(:cell:)\'\'\'AutorInnen:\'\'\' %0a(:cell:)' . $author . ' %0a'; // Kurzfassung fuer Wiki vorbereiten if (!preg_match('~<!-- KFC TEXT -->[\\S|\\s]*<!-- KFC TEXT -->~u', $description)) { $text_converter = $this->_environment->getTextConverter(); $description = $text_converter->text_for_wiki_export($description); //$description = _text_php2html_long($description); } } elseif ($rubric == CS_DISCUSSION_TYPE) { // Discussion Item $discussion_manager = $this->_environment->getDiscussionManager(); $item = $discussion_manager->getItem($current_item_id); $informations = '!' . $item->getTitle() . '%0a%0a'; } if ($rubric == CS_MATERIAL_TYPE or $rubric == CS_DISCUSSION_TYPE) { global $class_factory; $params = array(); $params['environment'] = $this->_environment; $wiki_view = $class_factory->getClass(WIKI_VIEW, $params); $wiki_view->setItem($item); $description = $wiki_view->formatForWiki($description); $description = $this->encodeUmlaute($description); $description = $this->encodeUrl($description); if ($rubric == CS_MATERIAL_TYPE) { $html_wiki_file = 'Main.CommSyMaterial' . $current_item_id . '.html'; } elseif ($rubric == CS_DISCUSSION_TYPE) { $html_wiki_file = 'Main.CommSy' . $translator->getMessage('COMMON_DISCUSSION') . $current_item_id . '.html'; } $old_dir = getcwd(); $description = '<br />' . "\n" . $description; $client->uploadFile($html_wiki_file, base64_encode($description), 'uploads/Main', $this->_environment->getSessionID()); $c_pmwiki_path_url_upload = preg_replace('~http://[^/]*~u', '', $c_pmwiki_path_url); $returnwiki = '(:includeupload /' . $c_pmwiki_path_url_upload . '/wikis/' . $this->_environment->getCurrentPortalID() . '/' . $this->_environment->getCurrentContextID() . '/uploads/Main/' . $html_wiki_file . ':)'; if ($rubric == CS_MATERIAL_TYPE) { $informations .= '(:cellnr:)\'\'\'Kurzfassung:\'\'\' %0a(:cell:)' . $returnwiki . ' %0a'; } // Dateien $file_list = $item->getFileList(); if (!$file_list->isEmpty()) { $file_array = $file_list->to_array(); $file_link_array = array(); foreach ($file_array as $file) { $new_filename = $this->encodeUrl($file->getDiskFileNameWithoutFolder()); $new_filename = preg_replace('~cid([0-9]*)_~u', '', $new_filename); $new_filename = $new_filename . '.' . $file->getExtension(); $temp_file = file_get_contents($c_commsy_path_file . '/' . $file->getDiskFileName()); $client->uploadFile($new_filename, base64_encode($temp_file), 'uploads/Main', $this->_environment->getSessionID()); $new_link = $this->encodeUrlToHtml($file->getFileName()); $file_link_array[] = '[[' . $c_pmwiki_path_url . '/wikis/' . $this->_environment->getCurrentPortalID() . '/' . $this->_environment->getCurrentContextID() . '/uploads/Main/' . $new_filename . '|' . $new_link . ']]'; } $file_links = implode('\\\\%0a', $file_link_array); $informations .= '(:cellnr:)\'\'\'Dateien:\'\'\' %0a(:cell:)' . $file_links . ' %0a'; } if ($rubric == CS_MATERIAL_TYPE) { // Abschnitte $sub_item_list = $item->getSectionList(); } elseif ($rubric == CS_DISCUSSION_TYPE) { $discussionarticles_manager = $this->_environment->getDiscussionArticlesManager(); $discussionarticles_manager->setDiscussionLimit($item->getItemID(), array()); $discussion_type = $item->getDiscussionType(); if ($discussion_type == 'threaded') { $discussionarticles_manager->setSortPosition(); } if (isset($_GET['status']) and $_GET['status'] == 'all_articles') { $discussionarticles_manager->setDeleteLimit(false); } $discussionarticles_manager->select(); $sub_item_list = $discussionarticles_manager->get(); } $sub_item_descriptions = ''; if (!$sub_item_list->isEmpty()) { $size = $sub_item_list->getCount(); $index_start = 1; if ($rubric == CS_DISCUSSION_TYPE and $size > 0) { $size = $size - 1; $index_start = 0; } $sub_item_link_array = array(); $sub_item_description_array = array(); for ($index = $index_start; $index <= $size; $index++) { $sub_item = $sub_item_list->get($index); if ($rubric == CS_DISCUSSION_TYPE) { $sub_item_link_array[] = '(:cellnr width=50%:)' . ($index + 1) . '. [[#' . $sub_item->getSubject() . '|' . $sub_item->getSubject() . ']] %0a(:cell width=30%:)' . $sub_item->getCreatorItem()->getFullName() . ' %0a(:cell:)' . getDateTimeInLang($sub_item->getModificationDate()) . '%0a'; } else { $sub_item_link_array[] = '[[#' . $sub_item->getTitle() . '|' . $sub_item->getTitle() . ']]'; } // Abschnitt fuer Wiki vorbereiten $description = $sub_item->getDescription(); if (!preg_match('~<!-- KFC TEXT -->[\\S|\\s]*<!-- KFC TEXT -->~u', $description)) { $text_converter = $this->_environment->getTextConverter(); $description = $text_converter->text_for_wiki_export($description); //$description = _text_php2html_long($sub_item->getDescription()); } $params = array(); $params['environment'] = $this->_environment; $params['with_modifying_actions'] = true; $wiki_view = $this->_class_factory->getClass(WIKI_VIEW, $params); unset($params); $wiki_view->setItem($sub_item); $description = $wiki_view->formatForWiki($description); $description = $this->encodeUmlaute($description); $description = $this->encodeUrl($description); if ($rubric == CS_MATERIAL_TYPE) { $html_wiki_file = 'Main.CommSyMaterial' . $current_item_id . '.sub_item.' . $sub_item->getItemID() . '.html'; } elseif ($rubric == CS_DISCUSSION_TYPE) { $html_wiki_file = 'Main.CommSy' . $translator->getMessage('COMMON_DISCUSSION') . $current_item_id . '.sub_item.' . $sub_item->getItemID() . '.html'; } $html_wiki_file = $this->encodeUmlaute($html_wiki_file); $html_wiki_file = $this->encodeUrl($html_wiki_file); $description = '<br />' . "\n" . $description; $client->uploadFile($html_wiki_file, base64_encode($description), 'uploads/Main', $this->_environment->getSessionID()); $c_pmwiki_path_url_upload = preg_replace('~http://[^/]*~u', '', $c_pmwiki_path_url); $returnwiki = '(:includeupload /' . $c_pmwiki_path_url_upload . '/wikis/' . $this->_environment->getCurrentPortalID() . '/' . $this->_environment->getCurrentContextID() . '/uploads/Main/' . $html_wiki_file . ':)'; $description_sub_item_link = str_replace(' ', '', $sub_item->getTitle()); // Dateien (Abschnitte) $files = '%0a%0a'; $file_list = $sub_item->getFileList(); if (!$file_list->isEmpty()) { $file_array = $file_list->to_array(); $file_link_array = array(); foreach ($file_array as $file) { $new_filename = $this->encodeUrl($file->getDiskFileNameWithoutFolder()); $new_filename = preg_replace('~cid([0-9]*)_~u', '', $new_filename); $new_filename = $new_filename . '.' . $file->getExtension(); $temp_file = file_get_contents($c_commsy_path_file . '/' . $file->getDiskFileName()); $client->uploadFile($new_filename, base64_encode($temp_file), 'uploads/Main', $this->_environment->getSessionID()); $new_link = $this->encodeUrlToHtml($file->getFileName()); $file_link_array[] = '[[' . $c_pmwiki_path_url . '/wikis/' . $this->_environment->getCurrentPortalID() . '/' . $this->_environment->getCurrentContextID() . '/uploads/Main/' . $new_filename . '|' . $new_link . ']]'; } $file_links = implode('\\\\%0a', $file_link_array); $files .= '(:table border=0 style="margin-left:0px;":)%0a'; $files .= '(:cell:)\'\'\'Dateien:\'\'\' %0a(:cell:)' . $file_links . ' %0a'; $files .= '(:tableend:) %0a'; } $sub_item_description_array[] = '%0a----%0a%0a====%0a%0a!!' . $sub_item->getTitle() . '%0a[[#' . $description_sub_item_link . ']]%0a' . $returnwiki . $files; } if ($rubric == CS_MATERIAL_TYPE) { $sub_item_links = implode('\\\\%0a', $sub_item_link_array); $informations .= '(:cellnr:)\'\'\'' . $translator->getMessage('MATERIAL_SECTIONS') . ':\'\'\' %0a(:cell:)' . $sub_item_links . ' %0a'; } elseif ($rubric == CS_DISCUSSION_TYPE) { $sub_item_links = implode('', $sub_item_link_array); $informations .= '(:cellnr:)%0a(:cell:)%0a'; $informations .= '(:table border=0 style="margin-left:0px;":)%0a'; $informations .= $sub_item_links; $informations .= '(:tableend:) %0a'; } $informations .= '(:tableend:) %0a'; $sub_item_descriptions = implode('\\\\%0a', $sub_item_description_array); } $buzzword_text = ''; $buzzword_list = $item->getBuzzwordList(); $buzzword = $buzzword_list->getFirst(); $buzzword_file_text = ''; $commentbox_text = ''; while ($buzzword) { if (!empty($buzzword_text)) { $buzzword_text .= ', '; } if (!empty($buzzword_file_text)) { $buzzword_file_text .= ','; } $buzzword_title = cs_ucfirst(str_replace('.', '', str_replace(' ', '', $buzzword->getTitle()))); $buzzword_text .= '[[!' . $buzzword_title . ']]'; $exists_file = $client->getPageExists('Category.' . $buzzword_title, $this->_environment->getSessionID()); if (!$exists_file) { $file_buzzword_contents = file_get_contents($c_commsy_path_file . '/etc/pmwiki/Category.Keyword'); $file_buzzword_contents = str_replace('CS_KEYWORD', $buzzword_title, $file_buzzword_contents); $client->createPage('Category.' . $buzzword_title, $file_buzzword_contents, $this->_environment->getSessionID()); } $buzzword_file_text .= 'Category.' . $buzzword_title; $buzzword = $buzzword_list->getNext(); } if (!empty($buzzword_text)) { $buzzword_text = '%0a\\\\%0a' . $translator->getMessage('COMMON_BUZZWORDS') . ': ' . $buzzword_text; } if ($item->getItemType() == CS_MATERIAL_TYPE) { $wiki_file = 'Main.CommSyMaterial' . $current_item_id . '-Comments'; } elseif ($item->getItemType() == CS_DISCUSSION_TYPE) { $wiki_file = 'Main.CommSy' . $translator->getMessage('COMMON_DISCUSSION') . $current_item_id . '-Comments'; } $exists_file = $client->getPageExists($wiki_file, $this->_environment->getSessionID()); if (!$exists_file) { $commentbox_text = '%0a%0a----%0a\\\\%0a' . '(:include Site.FoxCommentBox:)'; } // Link zurueck ins CommSy global $c_single_entry_point; $link = '[[' . $c_commsy_domain . $c_commsy_url_path . '/' . $c_single_entry_point . '?cid=' . $this->_environment->getCurrentContextID() . '&mod=' . $rubric . '&fct=detail&iid=' . $current_item_id . '|"' . $item->getTitle() . '" im CommSy]]'; $old_dir = getcwd(); // Kurzfassung fuer Wiki vorbereiten if ($rubric == CS_MATERIAL_TYPE) { $file_contents = file_get_contents($c_commsy_path_file . '/etc/pmwiki/Main.Material'); } elseif ($rubric == CS_DISCUSSION_TYPE) { $file_contents = file_get_contents($c_commsy_path_file . '/etc/pmwiki/Main.' . $translator->getMessage('COMMON_DISCUSSION')); } $file_contents_array = explode("\n", $file_contents); for ($index = 0; $index < sizeof($file_contents_array); $index++) { if (stripos($file_contents_array[$index], 'name=') !== false) { if ($rubric == CS_MATERIAL_TYPE) { $file_contents_array[$index] = 'name=Main.CommSyMaterial' . $current_item_id; } elseif ($rubric == CS_DISCUSSION_TYPE) { $file_contents_array[$index] = 'name=Main.CommSy' . $translator->getMessage('COMMON_DISCUSSION') . $current_item_id; } } if (stripos($file_contents_array[$index], 'text=') !== false) { if ($rubric == CS_MATERIAL_TYPE) { $title_text = '(:title CommSy-Material "' . $item->getTitle() . '":)'; } elseif ($rubric == CS_DISCUSSION_TYPE) { $title_text = '(:title CommSy-' . $translator->getMessage('COMMON_DISCUSSION') . ' "' . $item->getTitle() . '":)'; } $file_contents_array[$index] = 'text=' . $informations . $sub_item_descriptions . '%0a%0a----%0a\\\\%0a' . $buzzword_text . '%0a\\\\%0a' . $link . $commentbox_text . '%0a%0a' . $title_text; } if (stripos($file_contents_array[$index], 'targets=') !== false and !empty($buzzword_file_text)) { $file_contents_array[$index] = 'targets=' . $buzzword_file_text; } } $file_contents = implode("\n", $file_contents_array); if (!strstr($file_contents, 'targets=') and !empty($buzzword_file_text)) { $file_contents .= '"\\n"' . 'targets=' . $buzzword_file_text; } if ($rubric == CS_MATERIAL_TYPE) { $file_contents = $file_contents . "\n" . 'title=CommSy-Material "' . $item->getTitle() . '"'; $client->createPage('Main.CommSyMaterial' . $current_item_id, $file_contents, $this->_environment->getSessionID()); } elseif ($rubric == CS_DISCUSSION_TYPE) { $file_contents = $file_contents . 'title=CommSy-' . $translator->getMessage('COMMON_DISCUSSION') . ' "' . $item->getTitle() . '"'; $client->createPage('Main.CommSy' . $translator->getMessage('COMMON_DISCUSSION') . '' . $current_item_id, $file_contents, $this->_environment->getSessionID()); } $item->setExportToWiki('1'); $item->save(); $link_modifier_item_manager = $this->_environment->getLinkModifierItemManager(); $modifiers = $link_modifier_item_manager->getModifiersOfItem($item->getItemID()); $user_manager = $this->_environment->getUserManager(); $user_manager->reset(); $user_manager->setContextLimit($this->_environment->getCurrentContextID()); $user_manager->setIDArrayLimit($modifiers); $user_manager->select(); $user_list = $user_manager->get(); if ($user_list->getCount() >= 1) { $user_item = $user_list->getFirst(); include_once 'classes/cs_mail.php'; $translator = $this->_environment->getTranslationObject(); while ($user_item) { $mail = new cs_mail(); $mail->set_to($user_item->getEmail()); $room = $this->_environment->getCurrentContextItem(); $room_title = ''; if (isset($room)) { $room_title = $room->getTitle(); } $from = $translator->getMessage('SYSTEM_MAIL_MESSAGE', $room_title); $mail->set_from_name($from); $server_item = $this->_environment->getServerItem(); $default_sender_address = $server_item->getDefaultSenderAddress(); if (!empty($default_sender_address)) { $mail->set_from_email($default_sender_address); } else { $mail->set_from_email('@'); } $subject = $translator->getMessage('MATERIAL_EXPORT_WIKI_MAIL_SUBJECT') . ': ' . $room_title; $mail->set_subject($subject); $body = $translator->getMessage('MATERIAL_EXPORT_WIKI_MAIL_BODY', $room_title, $this->_environment->getCurrentUserItem()->getFullname(), $item->getTitle(), $item->getExportToWikiLink()); $mail->set_message($body); $mail->setSendAsHTML(); $mail->send(); $user_item = $user_list->getNext(); } } } $this->updateExportLists($rubric); }
function cron_workflow($logFile, $portal) { global $c_workflow; global $environment; global $cs_special_language_tags; if ($c_workflow) { fwrite($logFile, 'Workflow is active' . LF); $material_manager = $environment->getMaterialManager(); $item_array = $material_manager->getResubmissionItemIDsByDate(date('Y'), date('m'), date('d')); foreach ($item_array as $item) { $temp_material = $material_manager->getItem($item['item_id']); $item_id_current_version = $material_manager->getLatestVersionID($item['item_id']); if (isset($temp_material) && !$temp_material->isDeleted() && $item['version_id'] == $item_id_current_version) { //$temp_material = $material_manager->getItem($item['item_id']); $room_manager = $environment->getRoomManager(); $temp_room = $room_manager->getItem($temp_material->getContextID()); // check if context of room is current portal if ($temp_room->getContextID() != $portal->getItemID()) { continue; } if ($temp_material->getWorkflowResubmission() and $temp_room->withWorkflowResubmission()) { $email_receiver_array = array(); if ($temp_material->getWorkflowResubmissionWho() == 'creator') { $email_receiver_array[] = $temp_material->getCreator(); } else { $temp_list = $temp_material->getModifierList(); $email_receiver_array = $temp_list->to_array(); } $to = ''; $first = true; foreach ($email_receiver_array as $email_receiver) { if ($first) { $to .= $email_receiver->getEmail(); $first = false; } else { $to .= ',' . $email_receiver->getEmail(); } } $additional_receiver = $temp_material->getWorkflowResubmissionWhoAdditional(); if (!empty($additional_receiver)) { $to .= ',' . $additional_receiver; } include_once 'classes/cs_mail.php'; $translator = $environment->getTranslationObject(); $mail = new cs_mail(); $mail->set_to($to); $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $portal->getTitle())); $server_item = $environment->getServerItem(); $default_sender_address = $server_item->getDefaultSenderAddress(); if (!empty($default_sender_address)) { $mail->set_from_email($default_sender_address); } else { $mail->set_from_email('@'); } $mail->set_subject($translator->getMessage('COMMON_WORKFLOW_EMAIL_SUBJECT_RESUBMISSION', $portal->getTitle())); $url_to_portal = ''; if (!empty($portal)) { $url_to_portal = $portal->getURL(); } global $c_commsy_cron_path; if (isset($c_commsy_cron_path)) { $curl_text = $c_commsy_cron_path . 'commsy.php?cid='; } elseif (!empty($url_to_portal)) { $c_commsy_domain = $environment->getConfiguration('c_commsy_domain'); if (stristr($c_commsy_domain, 'https://')) { $curl_text = 'https://'; } else { $curl_text = 'http://'; } $curl_text .= $url_to_portal; $file = 'commsy.php'; $c_single_entry_point = $environment->getConfiguration('c_single_entry_point'); if (!empty($c_single_entry_point)) { $file = $c_single_entry_point; } $curl_text .= '/' . $file . '?cid='; } else { $commsy_file = $_SERVER['PHP_SELF']; $commsy_file = str_replace('cron_new', 'commsy', $commsy_file); $commsy_file = str_replace('cron', 'commsy', $commsy_file); $curl_text = 'http://' . $_SERVER['HTTP_HOST'] . $commsy_file . '?cid='; } $link = '<a href="' . $curl_text . $temp_room->getItemID() . '&mod=material&fct=detail&iid=' . $temp_material->getItemID() . '">' . $temp_material->getTitle() . '</a>'; if (isset($cs_special_language_tags) and !empty($cs_special_language_tags)) { $mail->set_message($translator->getMessage($cs_special_language_tags . '_WORKFLOW_EMAIL_BODY_RESUBMISSION', $temp_room->getTitle(), $temp_material->getTitle(), $link)); } else { $mail->set_message($translator->getMessage('COMMON_WORKFLOW_EMAIL_BODY_RESUBMISSION', $temp_room->getTitle(), $temp_material->getTitle(), $link)); } $mail->setSendAsHTML(); if ($mail->send()) { fwrite($logFile, 'workflow resubmission e-mail send for item: ' . $item['item_id']); } // change the status of the material $material_manager->setWorkflowStatus($temp_material->getItemID(), $temp_material->getWorkflowResubmissionTrafficLight(), $temp_material->getVersionID()); unset($mail); unset($translator); unset($server_item); } unset($temp_material); unset($temp_room); unset($room_manager); } } $item_array = $material_manager->getValidityItemIDsByDate(date('Y'), date('m'), date('d')); foreach ($item_array as $item) { $temp_material = $material_manager->getItem($item['item_id']); $item_id_current_version = $material_manager->getLatestVersionID($item['item_id']); if (isset($temp_material) && !$temp_material->isDeleted() && $item['version_id'] == $item_id_current_version) { //$temp_material = $material_manager->getItem($item['item_id']); $room_manager = $environment->getRoomManager(); $temp_room = $room_manager->getItem($temp_material->getContextID()); // check if context of room is current portal if ($temp_room->getContextID() != $portal->getItemID()) { continue; } if ($temp_material->getWorkflowValidity() and $temp_room->withWorkflowValidity()) { $email_receiver_array = array(); if ($temp_material->getWorkflowValidityWho() == 'creator') { $email_receiver_array[] = $temp_material->getCreator(); } else { $temp_list = $temp_material->getModifierList(); $email_receiver_array = $temp_list->to_array(); } $to = ''; $first = true; foreach ($email_receiver_array as $email_receiver) { if ($first) { $to .= $email_receiver->getEmail(); $first = false; } else { $to .= ',' . $email_receiver->getEmail(); } } $additional_receiver = $temp_material->getWorkflowValidityWhoAdditional(); if (!empty($additional_receiver)) { $to .= ',' . $additional_receiver; } include_once 'classes/cs_mail.php'; $translator = $environment->getTranslationObject(); $mail = new cs_mail(); $mail->set_to($to); $mail->set_from_name($translator->getMessage('SYSTEM_MAIL_MESSAGE', $portal->getTitle())); $server_item = $environment->getServerItem(); $default_sender_address = $server_item->getDefaultSenderAddress(); if (!empty($default_sender_address)) { $mail->set_from_email($default_sender_address); } else { $mail->set_from_email('@'); } $mail->set_subject($translator->getMessage('COMMON_WORKFLOW_EMAIL_SUBJECT_VALIDITY', $portal->getTitle())); $url_to_portal = ''; if (!empty($portal)) { $url_to_portal = $portal->getURL(); } global $c_commsy_cron_path; if (isset($c_commsy_cron_path)) { $curl_text = $c_commsy_cron_path . 'commsy.php?cid='; } elseif (!empty($url_to_portal)) { $c_commsy_domain = $environment->getConfiguration('c_commsy_domain'); if (stristr($c_commsy_domain, 'https://')) { $curl_text = 'https://'; } else { $curl_text = 'http://'; } $curl_text .= $url_to_portal; $file = 'commsy.php'; $c_single_entry_point = $environment->getConfiguration('c_single_entry_point'); if (!empty($c_single_entry_point)) { $file = $c_single_entry_point; } $curl_text .= '/' . $file . '?cid='; } else { $commsy_file = $_SERVER['PHP_SELF']; $commsy_file = str_replace('cron_new', 'commsy', $commsy_file); $commsy_file = str_replace('cron', 'commsy', $commsy_file); $curl_text = 'http://' . $_SERVER['HTTP_HOST'] . $commsy_file . '?cid='; } $link = '<a href="' . $curl_text . $temp_room->getItemID() . '&mod=material&fct=detail&iid=' . $temp_material->getItemID() . '">' . $temp_material->getTitle() . '</a>'; if (isset($cs_special_language_tags) and !empty($cs_special_language_tags)) { $mail->set_message($translator->getMessage($cs_special_language_tags . '_WORKFLOW_EMAIL_BODY_RESUBMISSION', $temp_room->getTitle(), $temp_material->getTitle(), $link)); } else { $mail->set_message($translator->getMessage('COMMON_WORKFLOW_EMAIL_BODY_VALIDITY', $temp_room->getTitle(), $temp_material->getTitle(), $link)); } $mail->setSendAsHTML(); if ($mail->send()) { fwrite($logFile, 'workflow validity e-mail send for item: ' . $item['item_id']); } // change the status of the material $material_manager->setWorkflowStatus($temp_material->getItemID(), $temp_material->getWorkflowValidityTrafficLight(), $temp_material->getVersionID()); unset($mail); unset($translator); unset($server_item); } unset($temp_material); unset($temp_room); unset($room_manager); } } unset($item_array); unset($material_manager); } else { fwrite($logFile, 'Workflow is NOT active' . LF); } }