Beispiel #1
0
 function _check_start_end_time()
 {
     //check start date and time
     $environment = $this->_environment;
     $lang = $environment->getUserLanguage();
     $date_start = convertDateFromInput($this->_form_post['dayStart'], $lang);
     $time_start = convertTimeFromInput($this->_form_post['timeStart']);
     if ($date_start['conforms'] != '') {
         $start_timestamp = $date_start['timestamp'];
         if ($time_start['conforms'] != '') {
             $start_timestamp .= $time_start['timestamp'];
         } else {
             $start_timestamp .= '000000';
         }
     }
     $date_end = convertDateFromInput($this->_form_post['dayEnd'], $lang);
     $time_end = convertTimeFromInput($this->_form_post['timeEnd']);
     if ($date_end['conforms'] != '') {
         $end_timestamp = $date_end['timestamp'];
     } else {
         $end_timestamp = $date_start['timestamp'];
     }
     if ($time_end['conforms'] != '') {
         $end_timestamp .= $time_end['timestamp'];
     } else {
         $end_timestamp .= '000000';
     }
     if ($date_start['conforms'] != '') {
         if ($date_end['conforms'] != '' and $end_timestamp - $start_timestamp < 0) {
             $this->_error_array[] = $this->_translator->getMessage('DATES_END_DATE_BEFORE_START_DATE');
         }
     }
 }
Beispiel #2
0
 /** get the time of the item
  * this method returns the item place in the right formatted style
  *
  * @return string title
  *
  * @author CommSy Development Group
  */
 function _getItemTime($item)
 {
     $parse_time_start = convertTimeFromInput($item->getStartingTime());
     $conforms = $parse_time_start['conforms'];
     if ($conforms == TRUE) {
         $time = getTimeLanguage($parse_time_start['datetime']);
     } else {
         $time = $item->getStartingTime();
     }
     if ($item->issetPrivatDate()) {
         $time = '<i>' . $this->_text_as_html_short($time) . '</i>';
     } else {
         $time = $this->_text_as_html_short($this->_compareWithSearchText($time));
     }
     return $time;
 }
Beispiel #3
0
               $dates_item->setStartingTime($converted_time_start['datetime']);
               $dt_start_time = $converted_time_start['datetime'];
            } else {
               $dates_item->setStartingTime($converted_time_start['display']);
            }

            $converted_day_start = convertDateFromInput($_POST['dayStart'],$environment->getSelectedLanguage());
            if ($converted_day_start['conforms'] == TRUE) {
               $dates_item->setStartingDay($converted_day_start['datetime']);
               $dt_start_date = $converted_day_start['datetime'];
            } else {
               $dates_item->setStartingDay($converted_day_start['display']);
            }

            if (!empty($_POST['timeEnd'])) {
               $converted_time_end = convertTimeFromInput($_POST['timeEnd']);
               if ($converted_time_end['conforms'] == TRUE) {
                  $dates_item->setEndingTime($converted_time_end['datetime']);
                  $dt_end_time = $converted_time_end['datetime'];
               } else {
                  $dates_item->setEndingTime($converted_time_end['display']);
               }
            } else {
               $dates_item->setEndingTime('');
            }

            if (!empty($_POST['dayEnd'])) {
               $converted_day_end = convertDateFromInput($_POST['dayEnd'],$environment->getSelectedLanguage());
               if ($converted_day_end['conforms'] == TRUE) {
                  $dates_item->setEndingDay($converted_day_end['datetime']);
                  $dt_end_date = $converted_day_end['datetime'];
 public function save($form_data, $additional = array())
 {
     $environment = $this->_environment;
     $current_user = $this->_environment->getCurrentUserItem();
     $current_context = $this->_environment->getCurrentContextItem();
     $text_converter = $this->_environment->getTextConverter();
     $current_iid = $form_data['iid'];
     if (isset($form_data['editType'])) {
         $this->_edit_type = $form_data['editType'];
     }
     $translator = $this->_environment->getTranslationObject();
     if ($current_iid === 'NEW') {
         $announcement_item = null;
     } else {
         $announcement_manager = $this->_environment->getAnnouncementManager();
         $announcement_item = $announcement_manager->getItem($current_iid);
     }
     $this->_popup_controller->performChecks($announcement_item, $form_data, $additional);
     // TODO: check rights */
     /****************************/
     if ($current_iid != 'NEW' and !isset($announcement_item)) {
     } elseif (!($current_iid == 'NEW' and $current_user->isUser() or $current_iid != 'NEW' and isset($announcement_item) and $announcement_item->mayEdit($current_user))) {
         /****************************/
     } elseif ($this->_edit_type != 'normal') {
         $this->cleanup_session($current_iid);
         // Set modificator and modification date
         $current_user = $environment->getCurrentUserItem();
         $announcement_item->setModificatorItem($current_user);
         if ($this->_edit_type == 'buzzwords') {
             // buzzwords
             $announcement_item->setBuzzwordListByID($form_data['buzzwords']);
         }
         if ($this->_edit_type == 'tags') {
             // buzzwords
             $announcement_item->setTagListByID($form_data['tags']);
         }
         $announcement_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($announcement_item->getItemID());
         // set return
         $this->_popup_controller->setSuccessfullItemIDReturn($announcement_item->getItemID(), CS_ANNOUNCEMENT_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($announcement_item)) {
                 $announcement_manager = $environment->getAnnouncementManager();
                 $announcement_item = $announcement_manager->getNewItem();
                 $announcement_item->setContextID($environment->getCurrentContextID());
                 $current_user = $environment->getCurrentUserItem();
                 $announcement_item->setCreatorItem($current_user);
                 $announcement_item->setCreationDate(getCurrentDateTimeInMySQL());
                 $item_is_new = true;
             }
             // Set modificator and modification date
             $current_user = $environment->getCurrentUserItem();
             $announcement_item->setModificatorItem($current_user);
             // Set attributes
             if (isset($form_data['title'])) {
                 $announcement_item->setTitle($form_data['title']);
             }
             if (isset($form_data['description'])) {
                 $announcement_item->setDescription($this->_popup_controller->getUtils()->cleanCKEditor($form_data['description']));
             }
             if (isset($form_data['dayEnd'])) {
                 $date2 = convertDateFromInput($form_data['dayEnd'], $environment->getSelectedLanguage());
                 if (!empty($form_data['timeEnd'])) {
                     $time_end = $form_data['timeEnd'];
                 } else {
                     $time_end = '22:00';
                 }
                 //
                 if (!mb_ereg("(([2][0-3])|([01][0-9])):([0-5][0-9])", $time_end)) {
                     //test if end_time is in a valid timeformat
                     $time_end = '22:00';
                 }
                 $time2 = convertTimeFromInput($time_end);
                 // convertTimeFromInput
                 if ($date2['conforms'] == TRUE and $time2['conforms'] == TRUE) {
                     $announcement_item->setSecondDateTime($date2['datetime'] . ' ' . $time2['datetime']);
                 } else {
                     $announcement_item->setSecondDateTime($date2['display'] . ' ' . $time2['display']);
                 }
             }
             // 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($announcement_item, $file_ids, $form_data["files"]);
             if (isset($form_data['private_editing'])) {
                 $announcement_item->setPrivateEditing('0');
             } else {
                 $announcement_item->setPrivateEditing('1');
             }
             if (isset($form_data['rights_tab'])) {
                 if (isset($form_data['public'])) {
                     $announcement_item->setPublic($form_data['public']);
                 }
                 if (isset($form_data['public'])) {
                     if ($announcement_item->isPublic() != $form_data['public']) {
                         $announcement_item->setPublic($form_data['public']);
                     }
                 } else {
                     if (isset($form_data['private_editing'])) {
                         $announcement_item->setPrivateEditing('0');
                     } else {
                         $announcement_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;
                     $announcement_item->setModificationDate($dt_hiding_datetime);
                 } else {
                     if ($announcement_item->isNotActivated()) {
                         $announcement_item->setModificationDate(getCurrentDateTimeInMySQL());
                     }
                 }
             }
             // buzzwords
             // save buzzwords
             $this->saveBuzzwords($environment, $announcement_item, $form_data['buzzwords']);
             // tags
             if (isset($form_data['tags_tab'])) {
                 $announcement_item->setTagListByID($form_data['tags']);
             }
             // Save item
             $announcement_item->save();
             // this will update the right box list
             if ($item_is_new) {
                 if ($session->issetValue('cid' . $environment->getCurrentContextID() . '_' . CS_ANNOUNCEMENT_TYPE . '_index_ids')) {
                     $id_array = array_reverse($session->getValue('cid' . $environment->getCurrentContextID() . '_' . CS_ANNOUNCEMENT_TYPE . '_index_ids'));
                 } else {
                     $id_array = array();
                 }
                 $id_array[] = $announcement_item->getItemID();
                 $id_array = array_reverse($id_array);
                 $session->setValue('cid' . $environment->getCurrentContextID() . '_' . CS_ANNOUNCEMENT_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($announcement_item->getItemID());
             // set return
             $this->_popup_controller->setSuccessfullItemIDReturn($announcement_item->getItemID(), CS_ANNOUNCEMENT_TYPE);
         }
     }
 }
 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 ($current_iid === 'NEW') {
         $discussion_item = null;
     } else {
         $discussion_manager = $this->_environment->getDiscussionManager();
         $discussion_item = $discussion_manager->getItem($current_iid);
     }
     $this->_popup_controller->performChecks($discussion_item, $form_data, $additional);
     if (isset($form_data['editType'])) {
         $this->_edit_type = $form_data['editType'];
     }
     $this->_is_new = $discussion_item === null;
     // TODO: check 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 (!($current_iid === 'NEW' && $current_user->isUser() || $current_iid !== 'NEW' && isset($discussion_item) && $discussion_item->mayEditIgnoreClose($current_user))) {
         /*
         *    $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);
         */
     } elseif ($this->_edit_type != 'normal') {
         $this->cleanup_session($current_iid);
         // Set modificator and modification date
         $current_user = $this->_environment->getCurrentUserItem();
         $discussion_item->setModificatorItem($current_user);
         if ($this->_edit_type == 'buzzwords') {
             // buzzwords
             $discussion_item->setBuzzwordListByID($form_data['buzzwords']);
         }
         if ($this->_edit_type == 'tags') {
             // buzzwords
             $discussion_item->setTagListByID($form_data['tags']);
         }
         $discussion_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($discussion_item->getItemID());
         // set return
         $this->_popup_controller->setSuccessfullItemIDReturn($discussion_item->getItemID(), CS_DISCUSSION_TYPE);
     } else {
         $this->cleanup_session($current_iid);
         // save item
         if ($this->_popup_controller->checkFormData()) {
             $session = $this->_environment->getSessionItem();
             if ($discussion_item === null) {
                 $discussion_manager = $this->_environment->getDiscussionManager();
                 $discussion_item = $discussion_manager->getNewItem();
                 $discussion_item->setContextID($this->_environment->getCurrentContextID());
                 $discussion_item->setCreatorItem($current_user);
                 $discussion_item->setCreationDate(getCurrentDateTimeInMySQL());
             }
             $discussion_item->setModificatorItem($current_user);
             // set attributes
             if (isset($form_data['title'])) {
                 $discussion_item->setTitle($form_data['title']);
             }
             if (isset($form_data['public'])) {
                 if ($discussion_item->isPublic() != $form_data['public']) {
                     $discussion_item->setPublic($form_data['public']);
                 }
             } else {
                 if (isset($form_data['private_editing'])) {
                     $discussion_item->setPrivateEditing('0');
                 } else {
                     $discussion_item->setPrivateEditing('1');
                 }
             }
             if (isset($form_data['external_viewer']) && isset($form_data['external_viewer_accounts'])) {
                 $user_ids = explode(" ", $form_data['external_viewer_accounts']);
                 $discussion_item->setExternalViewerAccounts($user_ids);
             } else {
                 $discussion_item->unsetExternalViewerAccounts();
             }
             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;
                 $discussion_item->setModificationDate($dt_hiding_datetime);
             } else {
                 if ($discussion_item->isNotActivated()) {
                     $discussion_item->setModificationDate(getCurrentDateTimeInMySQL());
                 }
             }
             // buzzwords
             // save buzzwords
             $this->saveBuzzwords($environment, $discussion_item, $form_data['buzzwords']);
             // tags
             // tags
             if (isset($form_data['tags_tab'])) {
                 $discussion_item->setTagListByID($form_data['tags']);
             }
             // save item
             $discussion_item->save();
             // this will update the right box list
             $id_array = array();
             if ($session->issetValue('cid' . $this->_environment->getCurrentContextID() . '_' . CS_DISCUSSION_TYPE . '_index_ids')) {
                 $id_array = array_reverse($session->getValue('cid' . $this->_environment->getCurrentContextID() . '_' . CS_DISCUSSION_TYPE . '_index_ids'));
             }
             $id_array[] = $discussion_item->getItemID();
             $id_array = array_reverse($id_array);
             $session->setValue('cid' . $this->_environment->getCurrentContextID() . '_' . CS_DISCUSSION_TYPE . '_index_ids', $id_array);
             // this will update the right box list
             if ($discussion_item === null) {
                 if ($session->issetValue('cid' . $environment->getCurrentContextID() . '_' . CS_ANNOUNCEMENT_TYPE . '_index_ids')) {
                     $id_array = array_reverse($session->getValue('cid' . $environment->getCurrentContextID() . '_' . CS_ANNOUNCEMENT_TYPE . '_index_ids'));
                 } else {
                     $id_array = array();
                 }
                 $id_array[] = $announcement_item->getItemID();
                 $id_array = array_reverse($id_array);
                 $session->setValue('cid' . $environment->getCurrentContextID() . '_' . CS_ANNOUNCEMENT_TYPE . '_index_ids', $id_array);
             }
             // save session
             $this->_environment->getSessionManager()->save($session);
             // save initial discussion article
             if ($current_iid === 'NEW') {
                 $discarticle_manager = $this->_environment->getDiscussionArticlesManager();
                 $discarticle_item = $discarticle_manager->getNewItem();
                 $discarticle_item->setContextID($this->_environment->getCurrentContextID());
                 $discarticle_item->setCreatorItem($current_user);
                 $discarticle_item->setCreationDate(getCurrentDateTimeInMySQL());
                 $discarticle_item->setDiscussionID($discussion_item->getItemID());
                 if (isset($form_data['subject'])) {
                     $discarticle_item->setSubject($form_data['subject']);
                 }
                 if (isset($form_data['description'])) {
                     $discarticle_item->setDescription($this->_popup_controller->getUtils()->cleanCKEditor($form_data['description']));
                 }
                 if (isset($form_data['discussion_type']) && $form_data['discussion_type'] == 2) {
                     $discarticle_item->setPosition('1');
                 }
                 // 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($discarticle_item, $file_ids, $form_data["files"]);
                 $discarticle_item->save();
                 // update discussion item
                 $discussion_item->setLatestArticleID($discarticle_item->getItemID());
                 $discussion_item->setLatestArticleModificationDate($discarticle_item->getCreationDate());
                 if ($form_data['discussion_type'] == 2) {
                     $discussion_item->setDiscussionType('threaded');
                 } else {
                     $discussion_item->setDiscussionType('simple');
                 }
                 $discussion_item->save();
             }
             // set return
             $this->_popup_controller->setSuccessfullItemIDReturn($discussion_item->getItemID());
         }
     }
 }
Beispiel #6
0
function isDatetimeCorrect($language, $date, $time = '')
{
    $retour = false;
    $date_result = convertDateFromInput($date, $language);
    if (empty($time) or preg_replace('/[A-Za-z ]/', '', $time) != $time) {
        $time_result['conforms'] = '1';
        $time_result['datetime'] = '00:00:00';
    } else {
        $time_result = convertTimeFromInput($time);
    }
    if (empty($date_result['error']) and empty($time_result['error']) and !empty($date_result['conforms']) and !empty($time_result['conforms'])) {
        if (!empty($time_result['datetime']) and !empty($date_result['datetime'])) {
            $value = $date_result['datetime'] . ' ' . $time_result['datetime'];
            if ($value == date('Y-m-d H:i:s', datetime2Timestamp($value))) {
                $retour = true;
            }
        }
    }
    return $retour;
}
Beispiel #7
0
 public function getListContent()
 {
     $session = $this->_environment->getSessionItem();
     include_once 'classes/cs_list.php';
     include_once 'classes/views/cs_view.php';
     $environment = $this->_environment;
     $translator = $environment->getTranslationObject();
     $context_item = $environment->getCurrentContextItem();
     $current_user = $environment->getCurrentUser();
     $converter = $environment->getTextConverter();
     $home_rubric_limit = CS_HOME_RUBRIC_LIST_LIMIT;
     $id_array = array();
     $v_id_array = array();
     $sub_id_array = array();
     $disc_id_array = array();
     $rubrics = $this->getRubrics();
     $rubric_list = array();
     $rubric_list_array = array();
     // determe rubrics to show on home list
     foreach ($rubrics as $rubric) {
         list($rubric_name, $postfix) = explode('_', $rubric);
         // continue if postfix is none or nodisplay
         if ($postfix === 'none' || $postfix === 'nodisplay') {
             continue;
         }
         // TODO: where does activity come from?
         // continue if name of rubric is activity
         if ($rubric_name === 'activity') {
             continue;
         }
         // store hidden state
         $return[$rubric_name]['hidden'] = $postfix === 'short' ? false : true;
         // check rights
         if ($current_user->isUser() && $this->_with_modifying_actions && $rubric_name != CS_USER_TYPE) {
             $return[$rubric_name]['rights']['new'] = true;
         } else {
             $return[$rubric_name]['rights']['new'] = false;
         }
         $rubric_list[] = $rubric_name;
         $list = new cs_list();
         $rubric = '';
         switch ($rubric_name) {
             case CS_ANNOUNCEMENT_TYPE:
                 $manager = $environment->getAnnouncementManager();
                 $manager->reset();
                 $manager->setContextLimit($environment->getCurrentContextID());
                 $count_all = $manager->getCountAll();
                 $manager->setDateLimit(getCurrentDateTimeInMySQL());
                 $manager->setSortOrder('modified');
                 $manager->showNoNotActivatedEntries();
                 $count_select = $manager->getCountAll();
                 $manager->setIntervalLimit(0, $home_rubric_limit);
                 if ($home_rubric_limit < $count_select) {
                     $home_rubric_limit = CS_HOME_RUBRIC_LIST_LIMIT;
                 }
                 $manager->select();
                 $list = $manager->get();
                 break;
             case CS_DATE_TYPE:
                 $manager = $environment->getDatesManager();
                 $manager->reset();
                 $manager->setContextLimit($environment->getCurrentContextID());
                 $manager->setDateModeLimit(2);
                 $count_all = $manager->getCountAll();
                 $manager->setFutureLimit();
                 $manager->setDateModeLimit(3);
                 $manager->showNoNotActivatedEntries();
                 $count_select = $manager->getCountAll();
                 $manager->setIntervalLimit(0, $home_rubric_limit);
                 if ($home_rubric_limit < $count_select) {
                     $home_rubric_limit = CS_HOME_RUBRIC_LIST_LIMIT;
                 }
                 $manager->select();
                 $list = $manager->get();
                 $rubric = 'dates';
                 break;
             case CS_PROJECT_TYPE:
                 $room_type = CS_PROJECT_TYPE;
                 $manager = $environment->getProjectManager();
                 $manager->reset();
                 $manager->setContextLimit($environment->getCurrentPortalID());
                 if (!isset($c_cache_cr_pr) or !$c_cache_cr_pr) {
                     $manager->setCommunityRoomLimit($environment->getCurrentContextID());
                 } else {
                     # use redundant infos in community room
                     $manager->setIDArrayLimit($context_item->getInternalProjectIDArray());
                 }
                 $count_all = $manager->getCountAll();
                 $manager->setSortOrder('activity_rev');
                 if ($count_all > 10) {
                     $manager->setIntervalLimit(0, 10);
                 }
                 $manager->select();
                 $list = $manager->get();
                 break;
             case CS_GROUP_TYPE:
                 $manager = $environment->getGroupManager();
                 $manager->reset();
                 $manager->setContextLimit($environment->getCurrentContextID());
                 $manager->select();
                 $list = $manager->get();
                 $count_all = $list->getCount();
                 break;
             case CS_TODO_TYPE:
                 $manager = $environment->getTodoManager();
                 $manager->reset();
                 $manager->setContextLimit($environment->getCurrentContextID());
                 $count_all = $manager->getCountAll();
                 $manager->setStatusLimit(4);
                 $manager->setSortOrder('date');
                 $manager->showNoNotActivatedEntries();
                 $count_select = $manager->getCountAll();
                 $manager->setIntervalLimit(0, $home_rubric_limit);
                 if ($home_rubric_limit < $count_select) {
                     $home_rubric_limit = CS_HOME_RUBRIC_LIST_LIMIT;
                 }
                 $manager->select();
                 $list = $manager->get();
                 $item = $list->getFirst();
                 $tmp_id_array = array();
                 while ($item) {
                     $tmp_id_array[] = $item->getItemID();
                     $item = $list->getNext();
                 }
                 $step_manager = $environment->getStepManager();
                 $step_list = $step_manager->getAllStepItemListByIDArray($tmp_id_array);
                 $item = $step_list->getFirst();
                 while ($item) {
                     $sub_id_array[] = $item->getItemID();
                     $item = $step_list->getNext();
                 }
                 unset($step_list);
                 unset($step_manager);
                 unset($manager);
                 break;
             case CS_TOPIC_TYPE:
                 $manager = $environment->getTopicManager();
                 $manager->reset();
                 $manager->setContextLimit($environment->getCurrentContextID());
                 $manager->showNoNotActivatedEntries();
                 $manager->select();
                 $list = $manager->get();
                 $count_all = $list->getCount();
                 break;
             case CS_INSTITUTION_TYPE:
                 $manager = $environment->getInstitutionManager();
                 $manager->reset();
                 $manager->setContextLimit($environment->getCurrentContextID());
                 $manager->select();
                 $list = $manager->get();
                 $count_all = $list->getCount();
                 break;
             case CS_USER_TYPE:
                 $manager = $environment->getUserManager();
                 $manager->reset();
                 $manager->setContextLimit($environment->getCurrentContextID());
                 $manager->setUserLimit();
                 $count_all = $manager->getCountAll();
                 if (!$current_user->isGuest()) {
                     $manager->setVisibleToAllAndCommsy();
                 } else {
                     $manager->setVisibleToAll();
                 }
                 $manager->setAgeLimit($context_item->getTimeSpread());
                 $manager->select();
                 $list = $manager->get();
                 break;
             case CS_MATERIAL_TYPE:
                 #	                        $short_list_view = $class_factory->getClass(MATERIAL_SHORT_VIEW,$param_class_array);
                 $manager = $environment->getMaterialManager();
                 $manager->reset();
                 $manager->create_tmp_table($environment->getCurrentContextID());
                 $manager->setContextLimit($environment->getCurrentContextID());
                 $count_all = $manager->getCountAll();
                 $manager->setOrder('date');
                 if ($environment->inProjectRoom()) {
                     $manager->setAgeLimit($context_item->getTimeSpread());
                 } else {
                     $manager->setIntervalLimit(0, 5);
                     $home_rubric_limit = 5;
                 }
                 $manager->showNoNotActivatedEntries();
                 $count_select = $manager->getCountAll();
                 $manager->setIntervalLimit(0, $home_rubric_limit);
                 $home_rubric_limit = CS_HOME_RUBRIC_LIST_LIMIT;
                 if ($home_rubric_limit < $count_select) {
                     $home_rubric_limit = CS_HOME_RUBRIC_LIST_LIMIT;
                 }
                 $manager->select();
                 $list = $manager->get();
                 $manager->delete_tmp_table();
                 $item = $list->getFirst();
                 $tmp_id_array = array();
                 while ($item) {
                     $tmp_id_array[] = $item->getItemID();
                     $item = $list->getNext();
                 }
                 $section_manager = $environment->getSectionManager();
                 $section_list = $section_manager->getAllSectionItemListByIDArray($tmp_id_array);
                 $item = $section_list->getFirst();
                 while ($item) {
                     $sub_id_array[] = $item->getItemID();
                     $v_id_array[$item->getItemID()] = $item->getVersionID();
                     $item = $section_list->getNext();
                 }
                 break;
             case CS_DISCUSSION_TYPE:
                 $manager = $environment->getDiscussionManager();
                 $manager->reset();
                 $manager->setContextLimit($environment->getCurrentContextID());
                 $count_all = $manager->getCountAll();
                 if ($environment->inProjectRoom() or $environment->inGroupRoom()) {
                     $manager->setAgeLimit($context_item->getTimeSpread());
                 } elseif ($environment->inCommunityRoom()) {
                     $manager->setIntervalLimit(0, 5);
                     $home_rubric_limit = 5;
                 }
                 $manager->showNoNotActivatedEntries();
                 $count_select = $manager->getCountAll();
                 $manager->setIntervalLimit(0, $home_rubric_limit);
                 $home_rubric_limit = CS_HOME_RUBRIC_LIST_LIMIT;
                 if ($home_rubric_limit < $count_select) {
                     $home_rubric_limit = CS_HOME_RUBRIC_LIST_LIMIT;
                 }
                 $manager->select();
                 $list = $manager->get();
                 $item = $list->getFirst();
                 $disc_id_array = array();
                 while ($item) {
                     $disc_id_array[] = $item->getItemID();
                     $item = $list->getNext();
                 }
                 $discarticle_manager = $environment->getDiscussionArticleManager();
                 $discarticle_list = $discarticle_manager->getAllDiscArticlesItemListByIDArray($disc_id_array);
                 $item = $discarticle_list->getFirst();
                 while ($item) {
                     $disc_id_array[] = $item->getItemID();
                     $item = $discarticle_list->getNext();
                 }
                 break;
         }
         $rubric_list_array[$rubric_name] = $list;
         $rubric_count_all_array[$rubric_name] = $count_all;
         $tmp = $list->getFirst();
         $ids = array();
         while ($tmp) {
             $id_array[] = $tmp->getItemID();
             if ($rubric_name == CS_MATERIAL_TYPE) {
                 $v_id_array[$tmp->getItemID()] = $tmp->getVersionID();
             }
             $ids[] = $tmp->getItemID();
             $tmp = $list->getNext();
         }
         if (empty($rubric)) {
             $session->setValue('cid' . $environment->getCurrentContextID() . '_' . $rubric_name . '_index_ids', $ids);
         } else {
             $session->setValue('cid' . $environment->getCurrentContextID() . '_' . $rubric . '_index_ids', $ids);
         }
     }
     $noticed_manager = $environment->getNoticedManager();
     $id_array = array_merge($id_array, $disc_id_array);
     $id_array = array_merge($id_array, $sub_id_array);
     $noticed_manager->getLatestNoticedByIDArray($id_array);
     $noticed_manager->getLatestNoticedAnnotationsByIDArray($id_array);
     $link_manager = $environment->getLinkManager();
     $file_id_array = $link_manager->getAllFileLinksForListByIDs($id_array, $v_id_array);
     $file_manager = $environment->getFileManager();
     $file_manager->setIDArrayLimit($file_id_array);
     $file_manager->select();
     $manager = $environment->getProjectManager();
     $room_max_activity = 0;
     if ($this->_environment->inCommunityRoom()) {
         $manager->setContextLimit($environment->getCurrentPortalID());
         global $c_cache_cr_pr;
         if (!isset($c_cache_cr_pr) or !$c_cache_cr_pr) {
             $room_max_activity = $manager->getMaxActivityPointsInCommunityRoom($environment->getCurrentContextID());
         } else {
             $current_context_item = $environment->getCurrentContextItem();
             $room_max_activity = $manager->getMaxActivityPointsInCommunityRoomInternal($current_context_item->getInternalProjectIDArray());
             unset($current_context_item);
         }
     }
     $user_manager = $this->_environment->getUserManager();
     foreach ($rubric_list_array as $key => $list) {
         $item_array = array();
         $column1_addon = '';
         $modificator_id = '';
         $item = $list->getFirst();
         $recurringDateArray = array();
         $params = array();
         $params['environment'] = $environment;
         $params['with_modifying_actions'] = false;
         $view = new cs_view($params);
         while ($item) {
             $may_enter = false;
             $noticed_text = $this->_getItemChangeStatus($item);
             #						$noticed_text = '';
             switch ($key) {
                 case CS_ANNOUNCEMENT_TYPE:
                     $column1 = $item->getTitle();
                     $parse_day_start = convertDateFromInput($item->getSeconddateTime(), $this->_environment->getSelectedLanguage());
                     $conforms = $parse_day_start['conforms'];
                     if ($conforms === true) {
                         $column2 = $translator->getDateInLang($parse_day_start['datetime']);
                     } else {
                         $column2 = $item->getSeconddateTime();
                     }
                     $column3 = $item->getModificatorItem()->getFullName();
                     $modificator_id = $item->getModificatorItem()->getItemID();
                     break;
                 case CS_DATE_TYPE:
                     $displayDate = true;
                     $column1_addon = false;
                     // is this a recurring date?
                     if ($item->getRecurrencePattern()) {
                         // did we already displayed the first date?
                         if (!isset($recurringDateArray[$item->getRecurrenceId()])) {
                             // if not - this is the starting date
                             $recurringDateArray[$item->getRecurrenceId()] = $item;
                         } else {
                             $displayDate = false;
                         }
                     }
                     if ($displayDate) {
                         $column1 = $item->getTitle();
                         if ($item->getRecurrencePattern()) {
                             $column1_addon = true;
                         }
                         $parse_day_start = convertDateFromInput($item->getStartingDay(), $this->_environment->getSelectedLanguage());
                         $conforms = $parse_day_start['conforms'];
                         if ($conforms == TRUE) {
                             $date = $translator->getDateInLang($parse_day_start['datetime']);
                         } else {
                             $date = $item->getStartingDay();
                         }
                         $parse_time_start = convertTimeFromInput($item->getStartingTime());
                         $conforms = $parse_time_start['conforms'];
                         if ($conforms == TRUE) {
                             $time = getTimeLanguage($parse_time_start['datetime']);
                         } else {
                             $time = $item->getStartingTime();
                         }
                         if (!empty($time)) {
                             $time = ', ' . $time;
                         }
                         $column2 = $view->_text_as_html_short($date . $time);
                         $column3 = $item->getPlace();
                     } else {
                         // go to next item
                         $item = $list->getNext();
                         /*
                          * the "2" is needed, to continue the while loop an not only
                          * the nested switch statement
                          */
                         continue 2;
                     }
                     break;
                 case CS_DISCUSSION_TYPE:
                     $column1 = $item->getTitle();
                     $column2 = $this->_environment->getTranslationObject()->getDateInLang($item->getModificationDate());
                     $column3 = $item->getModificatorItem()->getFullName();
                     $modificator_id = $item->getModificatorItem()->getItemID();
                     $reader_array = $item->getAllAndUnreadArticles();
                     $column1_addon = $reader_array['unread'] . ' / ' . $reader_array['count'];
                     break;
                 case CS_USER_TYPE:
                     $column1 = '';
                     $title = $item->getTitle();
                     if (!empty($title)) {
                         $column1 = $item->getTitle() . ' ';
                     }
                     $column1 .= $view->_text_as_html_short($item->getFullname());
                     ##################################################
                     # messenger - MUSS NOCH AUFGERÄUMT WERDEN: HTML INS TEMPLATE
                     ##################################################
                     global $c_commsy_domain;
                     $host = $c_commsy_domain;
                     global $c_commsy_url_path;
                     $url_to_img = $host . $c_commsy_url_path . '/images/messenger';
                     $icq_number = $item->getICQ();
                     if (!empty($icq_number)) {
                         //$column1 .= '   <img style="vertical-align:middle;" src="http://status.icq.com/online.gif?icq='.rawurlencode($icq_number).'&amp;img=5" alt="ICQ Online Status" />'.LF;
                     }
                     $msn_number = $item->getMSN();
                     if (!empty($msn_number)) {
                         //$column1 .= '<a href="http://www.IMStatusCheck.com/?msn">'.LF;
                         //$column1 .= '   <img style="vertical-align:middle;" src="http://www.IMStatusCheck.com/status/msn/'.rawurlencode($msn_number).'?icons" alt="MSN Online Status" />'.LF;
                         //$column1 .= '</a>'.LF;
                     }
                     $skype_number = $item->getSkype();
                     if (!empty($skype_number)) {
                         //$column1 .= '<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"></script>'.LF;
                         //$column1 .= '<a href="skype:'.rawurlencode($skype_number).'?chat">'.LF;
                         //$column1 .= '   <img src="http://mystatus.skype.com/smallicon/'.rawurlencode($skype_number).'" style="vertical-align:middle; border: none;" width="16" height="16" alt="Skype Online Status" />'.LF;
                         //$column1 .= '</a>'.LF;
                     }
                     $yahoo_number = $item->getYahoo();
                     if (!empty($yahoo_number)) {
                         //$column1 .= '<a href="http://messenger.yahoo.com/edit/send/?.target='.rawurlencode($yahoo_number).'">'.LF;
                         //$column1 .= '   <img style="vertical-align:middle;" src="http://opi.yahoo.com/yahooonline/u='.rawurlencode($yahoo_number).'/m=g/t=0/l='.$this->_environment->getSelectedLanguage().'/opi.jpg" alt="Yahoo Online Status Indicator" />'.LF;
                         //$column1 .= '</a>'.LF;
                     }
                     ##################################################
                     # messenger - END
                     ##################################################
                     $phone = $item->getTelephone();
                     $handy = $item->getCellularphone();
                     $column2 = '';
                     if (!empty($phone)) {
                         $column2 .= $view->_text_as_html_short($phone) . LF;
                     }
                     if (!empty($phone) and !empty($handy)) {
                         $column2 .= BRLF;
                     }
                     if (!empty($handy)) {
                         $column2 .= $view->_text_as_html_short($handy) . LF;
                     }
                     if ($item->isEmailVisible()) {
                         $email = $item->getEmail();
                         $email_text = $email;
                         $column3 = curl_mailto($item->getEmail(), $view->_text_as_html_short(chunkText($email_text, 20)), $email_text);
                     } else {
                         $column3 = $translator->getMessage('USER_EMAIL_HIDDEN');
                     }
                     break;
                 case CS_GROUP_TYPE:
                     $column1 = $item->getTitle();
                     $members = $item->getMemberItemList();
                     $column2 = $translator->getMessage('GROUP_MEMBERS') . ': ' . $members->getCount();
                     $linked_item_array = $item->getAllLinkedItemIDArray();
                     $column3 = $translator->getMessage('COMMON_REFERENCED_LATEST_ENTRIES') . ': ' . count($linked_item_array);
                     break;
                 case CS_TOPIC_TYPE:
                     $column1 = $item->getTitle();
                     $column2 = $this->_environment->getTranslationObject()->getDateInLang($item->getModificationDate());
                     $linked_item_array = $item->getAllLinkedItemIDArray();
                     $column3 = $translator->getMessage('COMMON_REFERENCED_LATEST_ENTRIES') . ': ' . count($linked_item_array);
                     break;
                 case CS_INSTITUTION_TYPE:
                     $column1 = $item->getTitle();
                     $members = $item->getMemberItemList();
                     $column2 = $translator->getMessage('GROUP_MEMBERS') . ': ' . $members->getCount();
                     $linked_item_array = $item->getAllLinkedItemIDArray();
                     $column3 = $translator->getMessage('COMMON_REFERENCED_LATEST_ENTRIES') . ': ' . count($linked_item_array);
                     break;
                 case CS_PROJECT_TYPE:
                     $column1 = $item->getTitle();
                     $column2 = $translator->getMessage('GROUP_MEMBERS') . ': ' . $item->getAllUsers();
                     $column3 = $this->_getItemActivity($item, $room_max_activity);
                     $user_manager->setUserIDLimit($current_user->getUserID());
                     $user_manager->setAuthSourceLimit($current_user->getAuthSource());
                     $user_manager->setContextLimit($item->getItemID());
                     $user_manager->select();
                     $user_list = $user_manager->get();
                     if (!empty($user_list)) {
                         $room_user = $user_list->getFirst();
                     } else {
                         $room_user = '';
                     }
                     if ($current_user->isRoot()) {
                         $may_enter = true;
                     } elseif (!empty($room_user)) {
                         $may_enter = $item->mayEnter($room_user);
                     } else {
                         $may_enter = false;
                     }
                     break;
                 case CS_TODO_TYPE:
                     $column1 = $item->getTitle();
                     $original_date = $item->getDate();
                     $date = getDateInLang($original_date);
                     $status = $item->getStatus();
                     $actual_date = date("Y-m-d H:i:s");
                     if ($status != $translator->getMessage('TODO_DONE') and $original_date < $actual_date) {
                         $date = '<span class="required">' . $date . '</span>';
                     }
                     if ($original_date == '9999-00-00 00:00:00') {
                         $date = $translator->getMessage('TODO_NO_END_DATE');
                     }
                     $column2 = $date;
                     $column3 = $this->_getTodoItemProcess($item, $translator);
                     break;
                 default:
                     $column1 = $item->getTitle();
                     $column2 = $this->_environment->getTranslationObject()->getDateInLang($item->getModificationDate());
                     $modificatorItem = $item->getModificatorItem();
                     if ($modificatorItem) {
                         $column3 = $modificatorItem->getFullName();
                         $modificator_id = $modificatorItem->getItemID();
                     } else {
                         $column3 = $translator->getMessage('COMMON_DELETED_USER');
                         $modificator_id = null;
                     }
             }
             // files
             $with_files = false;
             $file_count = 0;
             if (in_array($key, $this->getRubricsWithFiles())) {
                 $with_files = true;
                 $attachment_infos = array();
                 if ($key == CS_MATERIAL_TYPE) {
                     $file_count = $item->getFileListWithFilesFromSections()->getCount();
                     $file_list = $item->getFileListWithFilesFromSections();
                 } elseif ($key == CS_DISCUSSION_TYPE) {
                     $file_count = $item->getFileListWithFilesFromArticles()->getCount();
                     $file_list = $item->getFileListWithFilesFromArticles();
                 } else {
                     $file_count = $item->getFileList()->getCount();
                     $file_list = $item->getFileList();
                 }
                 $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_name'] = $converter->filenameFormatting($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();
                 }
             }
             $item_array[] = array('iid' => $item->getItemID(), 'user_iid' => $modificator_id, 'column_1' => $column1, 'column_1_addon' => $column1_addon, 'column_2' => $column2, 'column_3' => $column3, 'noticed' => $noticed_text, 'has_attachments' => $with_files, 'attachment_count' => $file_count, 'attachment_infos' => $attachment_infos, 'may_enter' => $may_enter);
             $item = $list->getNext();
         }
         $return[$key]['items'] = $item_array;
         // message tag
         $message_tag = '';
         //TODO: complete missing tags
         $shown = 0;
         switch ($key) {
             case CS_ANNOUNCEMENT_TYPE:
                 $message_tag = $translator->getMessage('COMMON_' . mb_strtoupper($key) . '_SHORT_VIEW_DESCRIPTION', $list->getCount(), $rubric_count_all_array[$key]);
                 break;
             case CS_DATE_TYPE:
                 $message_tag = $translator->getMessage('HOME_DATES_SHORT_VIEW_DESCRIPTION', $list->getCount(), $rubric_count_all_array[$key]);
                 break;
             case CS_PROJECT_TYPE:
                 if ($this->_environment->inProjectRoom()) {
                     $message_tag = $translator->getMessage('PROJECT_SHORT_DESCRIPTION', 5);
                 } elseif ($this->_environment->inCommunityRoom()) {
                     if (isset($list) && $list->isNotEmpty() && $list->getCount() < 10) {
                         $count = $list->getCount();
                     } else {
                         $count = '10';
                     }
                     $message_tag = $translator->getMessage('COMMUNITY_SHORT_DESCRIPTION') . ' ' . $count;
                 }
                 break;
             case CS_GROUP_TYPE:
                 $message_tag = $translator->getMessage('HOME_GROUP_SHORT_VIEW_DESCRIPTION', $list->getCount());
                 break;
             case CS_TODO_TYPE:
                 $message_tag = $translator->getMessage('TODO_SHORT_VIEW_DESCRIPTION', $list->getCount(), $rubric_count_all_array[$key]);
                 break;
             case CS_TOPIC_TYPE:
                 if (isset($list) && $list->isNotEmpty()) {
                     $shown = $list->getCount();
                 } else {
                     $shown = 0;
                 }
                 $message_tag = $translator->getMessage('HOME_TOPIC_SHORT_VIEW_DESCRIPTION', $shown);
                 break;
             case CS_INSTITUTION_TYPE:
                 if ($rubric_count_all_array[$key] > 0) {
                     $message_tag = $translator->getMessage('HOME_INSTITUTION_SHORT_VIEW_DESCRIPTION', $list->getCount());
                 }
                 break;
             case CS_USER_TYPE:
                 if ($this->_environment->inProjectRoom()) {
                     global $who_is_online;
                     if (isset($who_is_online) && $who_is_online) {
                         $shown = $list->getCount();
                         if ($shown > 0) {
                             $days = $context_item->isProjectRoom() ? $context_item->getTimeSpread() : 90;
                             $item = $list->getFirst();
                             $count_active_now = 0;
                             while ($item) {
                                 $lastlogin = $item->getLastLogin();
                                 if ($lastlogin > getCurrentDateTimeMinusMinutesInMySQL($days)) {
                                     $count_active_now++;
                                 }
                                 $item = $list->getNext();
                             }
                         }
                         $message_tag = $translator->getMessage('HOME_USER_SHORT_VIEW_DESCRIPTION2', $shown, $count_active_now, $rubric_count_all_array[$key], $days);
                     } else {
                         $message_tag = $translator->getMessage('HOME_USER_SHORT_VIEW_DESCRIPTION', $list->getCount(), $rubric_count_all_array[$key]);
                     }
                 } else {
                     $message_tag = $translator->getMessage('COMMON_SHORT_CONTACT_VIEW_DESCRIPTION', $list->getCount(), $rubric_count_all_array[$key]);
                 }
                 break;
             case CS_MATERIAL_TYPE:
                 if ($this->_environment->inProjectRoom()) {
                     $period = $context_item->getTimeSpread();
                     $message_tag = $translator->getMessage('COMMON_SHORT_VIEW_DESCRIPTION', $list->getCount(), $period, $rubric_count_all_array[$key]);
                 } else {
                     $message_tag = $translator->getMessage('COMMON_SHORT_MATERIAL_VIEW_DESCRIPTION', $list->getCount(), $rubric_count_all_array[$key]);
                 }
                 break;
             case CS_DISCUSSION_TYPE:
                 $shown = $list->getCount();
                 if ($this->_environment->inProjectRoom() || $this->_environment->inGroupRoom()) {
                     $period = $context_item->getTimeSpread();
                     $message_tag = $translator->getMessage('COMMON_SHORT_VIEW_DESCRIPTION', $shown, $period, $rubric_count_all_array[$key]);
                 } elseif ($this->_environment->inCommunityRoom()) {
                     if ($shown != 1) {
                         $message_tag = $translator->getMessage('COMMON_SHORT_VIEW_DESCRIPTION_CR', $shown, $rubric_count_all_array[$key]);
                     } else {
                         $message_tag = $translator->getMessage('COMMON_SHORT_VIEW_DESCRIPTION_CR_ONE', $shown, $rubric_count_all_array[$key]);
                     }
                 }
                 break;
         }
         $return[$key]['message_tag'] = $message_tag;
     }
     // TODO attachment_count...
     // append return
     /*
     					$return = array(
     						'items'		=> $rubric_array/*,
     						'count_all'	=> $count_all_shown*/
     /*);
      */
     return $return;
 }
 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());
         }
     }
 }
Beispiel #9
0
 /** get the time of the item
  * this method returns the item place in the right formatted style
  *
  * @return string title
  *
  * @author CommSy Development Group
  */
 function _getItemTime($item)
 {
     $parse_time_start = convertTimeFromInput($item->getStartingTime());
     $conforms = $parse_time_start['conforms'];
     if ($conforms == TRUE) {
         $time = getTimeLanguage($parse_time_start['datetime']);
     } else {
         $time = $item->getStartingTime();
     }
     return $this->_text_as_html_short($time);
 }
Beispiel #10
0
 /** get the single entry of the list view as HTML
  * this method returns the single entry in HTML-Code
  *
  * @returns string $item as HMTL
  *
  * @param object item     the single list entry
  */
 function _getItemAsHTML($item)
 {
     $html = LF . '<!-- BEGIN OF DATE ITEM DETAIL -->' . LF;
     // DATE AND TIME //
     $formal_data = array();
     // set up style of days and times
     $parse_time_start = convertTimeFromInput($item->getStartingTime());
     $conforms = $parse_time_start['conforms'];
     if ($conforms == TRUE) {
         $start_time_print = getTimeLanguage($parse_time_start['datetime']);
     } else {
         $start_time_print = $this->_text_as_html_short($this->_compareWithSearchText($item->getStartingTime()));
     }
     $parse_time_end = convertTimeFromInput($item->getEndingTime());
     $conforms = $parse_time_end['conforms'];
     if ($conforms == TRUE) {
         $end_time_print = getTimeLanguage($parse_time_end['datetime']);
     } else {
         $end_time_print = $this->_text_as_html_short($this->_compareWithSearchText($item->getEndingTime()));
     }
     $parse_day_start = convertDateFromInput($item->getStartingDay(), $this->_environment->getSelectedLanguage());
     $conforms = $parse_day_start['conforms'];
     if ($conforms == TRUE) {
         $start_day_print = $item->getStartingDayName() . ', ' . $this->_translator->getDateInLang($parse_day_start['datetime']);
     } else {
         $start_day_print = $this->_text_as_html_short($this->_compareWithSearchText($item->getStartingDay()));
     }
     $parse_day_end = convertDateFromInput($item->getEndingDay(), $this->_environment->getSelectedLanguage());
     $conforms = $parse_day_end['conforms'];
     if ($conforms == TRUE) {
         $end_day_print = $item->getEndingDayName() . ', ' . $this->_translator->getDateInLang($parse_day_end['datetime']);
     } else {
         $end_day_print = $this->_text_as_html_short($this->_compareWithSearchText($item->getEndingDay()));
     }
     //formating dates and times for displaying
     $date_print = "";
     $time_print = "";
     if ($end_day_print != "") {
         //with ending day
         $date_print = $this->_translator->getMessage('DATES_AS_OF') . ' ' . $start_day_print . ' ' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_day_print;
         if ($parse_day_start['conforms'] and $parse_day_end['conforms']) {
             //start and end are dates, not strings
             $date_print .= ' (' . getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']) . ' ' . $this->_translator->getMessage('DATES_DAYS') . ')';
         }
         if ($start_time_print != "" and $end_time_print == "") {
             //starting time given
             $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
             if ($parse_time_start['conforms'] == true) {
                 $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print == "" and $end_time_print != "") {
             //endtime given
             $time_print = $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             if ($parse_time_end['conforms'] == true) {
                 $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print != "" and $end_time_print != "") {
             //all times given
             if ($parse_time_end['conforms'] == true) {
                 $end_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
             if ($parse_time_start['conforms'] == true) {
                 $start_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
             $date_print = $this->_translator->getMessage('DATES_AS_OF') . ' ' . $start_day_print . ', ' . $start_time_print . '<br />' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_day_print . ', ' . $end_time_print;
             if ($parse_day_start['conforms'] and $parse_day_end['conforms']) {
                 $date_print .= ' (' . getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']) . ' ' . $this->_translator->getMessage('DATES_DAYS') . ')';
             }
         }
     } else {
         //without ending day
         $date_print = $this->_translator->getMessage('DATES_ON_DAY') . ' ' . $start_day_print;
         if ($start_time_print != "" and $end_time_print == "") {
             //starting time given
             $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
             if ($parse_time_start['conforms'] == true) {
                 $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print == "" and $end_time_print != "") {
             //endtime given
             $time_print = $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             if ($parse_time_end['conforms'] == true) {
                 $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print != "" and $end_time_print != "") {
             //all times given
             if ($parse_time_end['conforms'] == true) {
                 $end_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
             if ($parse_time_start['conforms'] == true) {
                 $start_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
             $time_print = $this->_translator->getMessage('DATES_FROM_TIME_LOWER') . ' ' . $start_time_print . ' ' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
         }
     }
     if ($parse_day_start['timestamp'] == $parse_day_end['timestamp'] and $parse_day_start['conforms'] and $parse_day_end['conforms']) {
         $date_print = $this->_translator->getMessage('DATES_ON_DAY') . ' ' . $start_day_print;
         if ($start_time_print != "" and $end_time_print == "") {
             //starting time given
             $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
         } elseif ($start_time_print == "" and $end_time_print != "") {
             //endtime given
             $time_print = $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
         } elseif ($start_time_print != "" and $end_time_print != "") {
             //all times given
             $time_print = $this->_translator->getMessage('DATES_FROM_TIME_LOWER') . ' ' . $start_time_print . ' ' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
         }
     }
     // Date and time
     $temp_array = array();
     $temp_array[] = $this->_translator->getMessage('DATES_DATETIME');
     if ($time_print != '') {
         $temp_array[] = $date_print . BRLF . $time_print;
     } else {
         $temp_array[] = $date_print;
     }
     $formal_data[] = $temp_array;
     // Place
     $place = $item->getPlace();
     if (!empty($place)) {
         $place = $this->_compareWithSearchText($place);
         $temp_array = array();
         $temp_array[] = $this->_translator->getMessage('DATES_PLACE');
         $temp_array[] = $this->_text_as_html_short($place);
         $formal_data[] = $temp_array;
     }
     // Color
     $color = $item->getColor();
     if (!empty($color)) {
         $temp_array = array();
         $temp_array[] = $this->_translator->getMessage('DATES_COLOR');
         $temp_array[] = '<img src="images/spacer.gif" style="height:10px; width:10px; background-color:' . $this->_text_as_html_short($color) . '; border:1px solid #cccccc;"/>';
         $formal_data[] = $temp_array;
     }
     // Files
     $files = $this->_getFilesForFormalData($item);
     if (!empty($files)) {
         $temp_array = array();
         $temp_array[] = $this->_translator->getMessage('MATERIAL_FILES');
         $temp_array[] = implode(BRLF, $files);
         $formal_data[] = $temp_array;
     }
     if (!empty($formal_data)) {
         $html .= $this->_getFormalDataAsHTML($formal_data);
         $html .= BRLF;
     }
     // Members
     $user = $this->_environment->getCurrentUser();
     $member_html = '';
     $members = $item->getParticipantsItemList();
     if ($members->isEmpty()) {
         $member_html .= '   ' . $this->_translator->getMessage('TODO_NO_PROCESSOR') . LF;
     } else {
         $member = $members->getFirst();
         $count = $members->getCount();
         $counter = 0;
         while ($member) {
             $counter++;
             if ($member->isUser()) {
                 $linktext = $member->getFullname();
                 $linktext = $this->_compareWithSearchText($linktext);
                 $linktext = $this->_text_converter->text_as_html_short($linktext);
                 if ($member->maySee($user)) {
                     $params = array();
                     $params['iid'] = $member->getItemID();
                     $param_zip = $this->_environment->getValueOfParameter('download');
                     if (empty($param_zip) or $param_zip != 'zip') {
                         $member_html .= ahref_curl($this->_environment->getCurrentContextID(), 'user', 'detail', $params, $linktext);
                     } else {
                         $member_html .= $linktext;
                     }
                     unset($params);
                 } else {
                     $member_html .= '<span class="disabled">' . $linktext . '</span>' . LF;
                 }
                 if ($counter != $count) {
                     $member_html .= ', ';
                 }
             } else {
                 $link_title = chunkText($member->getFullName(), 35);
                 $link_title = $this->_compareWithSearchText($link_title);
                 $link_title = $this->_text_converter->text_as_html_short($link_title);
                 $param_zip = $this->_environment->getValueOfParameter('download');
                 if (empty($param_zip) or $param_zip != 'zip') {
                     $member_html .= ahref_curl($this->_environment->getCurrentContextID(), $this->_environment->getCurrentModule(), $this->_environment->getCurrentFunction(), array(), $link_title, $this->_translator->getMessage('USER_STATUS_REJECTED'), '_self', '', '', '', '', 'class="disabled"', '', '', true);
                 } else {
                     $member_html .= $link_title;
                 }
                 if ($counter != $count) {
                     $member_html .= ', ';
                 }
             }
             $member = $members->getNext();
         }
     }
     $temp_array[0] = $this->_translator->getMessage('DATE_PARTICIPANTS');
     $temp_array[1] = $member_html;
     $formal_data = array();
     $formal_data[] = $temp_array;
     if (!empty($formal_data)) {
         $html .= $this->_getFormalDataAsHTML($formal_data);
         $html .= BRLF;
     }
     // Description
     $desc = $item->getDescription();
     if (!empty($desc)) {
         $desc = $this->_text_as_html_long($this->_compareWithSearchText($this->_cleanDataFromTextArea($desc)));
         $desc = $this->_show_images($desc, $item, true);
         $html .= $this->getScrollableContent($desc, $item, '', true) . LF;
     }
     $html .= '<!-- END OF DATE ITEM DETAIL -->' . "\n\n";
     return $html;
 }
Beispiel #11
0
 /** create the form, INTERNAL
  * this methods creates the form with the form definitions
  *
  * @author CommSy Development Topic
  */
 function _createForm()
 {
     // rubrics
     $iid = $_GET['iid'];
     $manager = $this->_environment->getItemManager();
     $item = $manager->getItem($iid);
     $module = $item->getItemType();
     $link_module = $module;
     if ($module == 'label' or $module == 'labels') {
         $label_manager = $this->_environment->getLabelManager();
         $label = $label_manager->getItem($iid);
         $link_module = $label->getLabelType();
     }
     $item_manager = $this->_environment->getManager($module);
     $item = $item_manager->getItem($iid);
     $item_name = $item->getTitle();
     $context_name = $this->_context_name;
     $article = '';
     // Wenn man mit HTTPS auf Commsy surft und eine Email generiert
     // sollte diese Mail auch https links erstellen.
     if (!empty($_SERVER["HTTPS"]) and $_SERVER["HTTPS"]) {
         $url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $this->_environment->getCurrentContextID() . '&mod=' . $link_module . '&fct=detail' . '&iid=' . $item->getItemID();
     } else {
         $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $this->_environment->getCurrentContextID() . '&mod=' . $link_module . '&fct=detail' . '&iid=' . $item->getItemID();
     }
     $link = $url;
     $rubric_type_pretty = '';
     $content = '';
     //generate module name for the interface- a pretty version of module...
     if ($module == 'new' or $module == 'news') {
         $news_content = $this->_translator->getMessage('COMMON_NEWS') . ': ' . $item->getTitle() . LF;
         $content = $news_content;
     } elseif ($module == CS_DATE_TYPE) {
         $rubric_type_pretty = $this->_translator->getMessage('COMMON_DATES');
         // set up style of days and times
         $parse_time_start = convertTimeFromInput($item->getStartingTime());
         $conforms = $parse_time_start['conforms'];
         if ($conforms == TRUE) {
             $start_time_print = getTimeLanguage($parse_time_start['datetime']);
         } else {
             $start_time_print = $item->getStartingTime();
         }
         $parse_time_end = convertTimeFromInput($item->getEndingTime());
         $conforms = $parse_time_end['conforms'];
         if ($conforms == TRUE) {
             $end_time_print = getTimeLanguage($parse_time_end['datetime']);
         } else {
             $end_time_print = $item->getEndingTime();
         }
         $parse_day_start = convertDateFromInput($item->getStartingDay(), $this->_environment->getSelectedLanguage());
         $conforms = $parse_day_start['conforms'];
         if ($conforms == TRUE) {
             $start_day_print = getDateInLang($parse_day_start['datetime']);
         } else {
             $start_day_print = $item->getStartingDay();
         }
         $parse_day_end = convertDateFromInput($item->getEndingDay(), $this->_environment->getSelectedLanguage());
         $conforms = $parse_day_end['conforms'];
         if ($conforms == TRUE) {
             $end_day_print = getDateLanguage($parse_day_end['datetime']);
         } else {
             $end_day_print = $item->getEndingDay();
         }
         //formating dates and times for displaying
         $date_print = "";
         $time_print = "";
         if ($end_day_print != "") {
             //with ending day
             $date_print = $this->_translator->getMessage('DATES_AS_OF') . ' ' . $start_day_print . ' ' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_day_print;
             if ($parse_day_start['conforms'] and $parse_day_end['conforms']) {
                 //start and end are dates, not strings
                 $date_print .= ' (' . getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']) . ' ' . $this->_translator->getMessage('DATES_DAYS') . ')';
             }
             if ($start_time_print != "" and $end_time_print == "") {
                 //starting time given
                 $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
                 if ($parse_time_start['conforms'] == true) {
                     $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
                 }
             } elseif ($start_time_print == "" and $end_time_print != "") {
                 //endtime given
                 $time_print = $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
                 if ($parse_time_end['conforms'] == true) {
                     $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
                 }
             } elseif ($start_time_print != "" and $end_time_print != "") {
                 //all times given
                 if ($parse_time_end['conforms'] == true) {
                     $end_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
                 }
                 if ($parse_time_start['conforms'] == true) {
                     $start_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
                 }
                 $date_print = $this->_translator->getMessage('DATES_AS_OF') . ' ' . $start_day_print . ', ' . $start_time_print . '<br />' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_day_print . ', ' . $end_time_print;
                 if ($parse_day_start['conforms'] and $parse_day_end['conforms']) {
                     $date_print .= ' (' . getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']) . ' ' . $this->_translator->getMessage('DATES_DAYS') . ')';
                 }
             }
         } else {
             //without ending day
             $date_print = $start_day_print;
             if ($start_time_print != "" and $end_time_print == "") {
                 //starting time given
                 $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
                 if ($parse_time_start['conforms'] == true) {
                     $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
                 }
             } elseif ($start_time_print == "" and $end_time_print != "") {
                 //endtime given
                 $time_print = $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
                 if ($parse_time_end['conforms'] == true) {
                     $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
                 }
             } elseif ($start_time_print != "" and $end_time_print != "") {
                 //all times given
                 if ($parse_time_end['conforms'] == true) {
                     $end_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
                 }
                 if ($parse_time_start['conforms'] == true) {
                     $start_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
                 }
                 $time_print = $this->_translator->getMessage('DATES_FROM_TIME_LOWER') . ' ' . $start_time_print . ' ' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             }
         }
         if ($parse_day_start['timestamp'] == $parse_day_end['timestamp'] and $parse_day_start['conforms'] and $parse_day_end['conforms']) {
             $date_print = $this->_translator->getMessage('DATES_ON_DAY') . ' ' . $start_day_print;
             if ($start_time_print != "" and $end_time_print == "") {
                 //starting time given
                 $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
             } elseif ($start_time_print == "" and $end_time_print != "") {
                 //endtime given
                 $time_print = $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             } elseif ($start_time_print != "" and $end_time_print != "") {
                 //all times given
                 $time_print = $this->_translator->getMessage('DATES_FROM_TIME_LOWER') . ' ' . $start_time_print . ' ' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             }
         }
         // Date and time
         $dates_content = '';
         $dates_content = $this->_translator->getMessage('DATES_DATETIME') . ': ' . $item_name . LF;
         if ($time_print != '') {
             $dates_content .= $this->_translator->getMessage('COMMON_TIME') . ': ' . $date_print . ',' . $time_print . LF;
         } else {
             $dates_content .= $this->_translator->getMessage('COMMON_TIME') . ': ' . $date_print . LF;
         }
         // Place
         $place = $item->getPlace();
         if (!empty($place)) {
             $dates_content .= $this->_translator->getMessage('DATES_PLACE') . ': ';
             $dates_content .= $place . LF;
         }
         $content = $dates_content;
     } elseif ($module == 'discussion' or $module == 'discussions') {
         $discussion_content = $this->_translator->getMessage('COMMON_DISCUSSION') . ': ' . $item->getTitle() . LF;
         $article_count = $item->getAllArticlesCount();
         $discussion_content .= $this->_translator->getMessage('DISCUSSION_DISCARTICLE_COUNT') . ': ' . $article_count . LF;
         $time = $item->getLatestArticleModificationDate();
         $discussion_content .= $this->_translator->getMessage('DISCUSSION_LAST_ENTRY') . ': ' . getDateTimeInLang($time) . LF;
         $content = $discussion_content;
     } elseif ($module == 'material' or $module == 'materials') {
         $material_content = $this->_translator->getMessage('COMMON_MATERIAL') . ': ' . $item->getTitle() . LF;
         $content = $material_content;
     } elseif ($module == 'announcement' or $module == CS_ANNOUNCEMENT_TYPE) {
         $announcement_content = $this->_translator->getMessage('COMMON_ANNOUNCEMENT') . ': ' . $item->getTitle() . LF;
         $content = $announcement_content;
     } elseif ($module == 'label' or $module == 'labels') {
         $label_manager = $this->_environment->getLabelManager();
         $label = $label_manager->getItem($iid);
         $module = $label->getLabelType();
         if ($module == 'group' or $module == 'groups') {
             $group_content = $this->_translator->getMessage('COMMON_GROUP') . ': ' . $item->getTitle() . LF;
             $content = $group_content;
         } elseif ($module == 'institution' or $module == 'institutions') {
             $institution_content = $this->_translator->getMessage('INSTITUTION') . ': ' . $item->getTitle() . LF;
             $content = $institution_content;
         }
     }
     if ($this->_environment->inProjectRoom()) {
         $emailtext = $this->_translator->getMessage('RUBRIC_EMAIL_DEFAULT_PROJECT', $context_name) . LF;
     } elseif ($this->_environment->inGroupRoom()) {
         $emailtext = $this->_translator->getMessage('RUBRIC_EMAIL_DEFAULT_GROUPROOM', $context_name) . LF;
     } else {
         $emailtext = $this->_translator->getMessage('RUBRIC_EMAIL_DEFAULT_COMMUNITY', $context_name) . LF;
     }
     if (empty($content)) {
         $emailtext .= LF . LF;
     } else {
         $emailtext .= $content;
     }
     $emailtext .= $this->_translator->getMessage('RUBRIC_EMAIL_DEFAULT_PROJECT_END', $link);
     $this->_form->addTextField('subject', '', $this->_translator->getMessage('COMMON_MAIL_SUBJECT'), '', '', '57', true);
     $this->_form->addTextArea('mailcontent', $emailtext, $this->_translator->getMessage('COMMON_MAIL_CONTENT'), $this->_translator->getMessage('COMMON_MAIL_CONTENT_DESC'), '60', '15', '', true, false, false);
     if ($module == 'date') {
         $this->_form->addCheckBox('attendees', '2', false, $this->_translator->getMessage('COMMON_MAIL_SEND_TO_ASIGNED_PEOPLE'), $this->_translator->getMessage('COMMON_MAIL_SEND_TO_ATTENDEES'));
     } elseif ($module == 'todo') {
         $this->_form->addCheckBox('processors', '2', false, $this->_translator->getMessage('COMMON_MAIL_SEND_TO_ASIGNED_PEOPLE'), $this->_translator->getMessage('COMMON_MAIL_SEND_TO_PROCESSORS'));
     }
     if ($this->_environment->inProjectRoom() and !empty($this->_group_array)) {
         $context_item = $this->_environment->getCurrentContextItem();
         if ($context_item->withRubric(CS_GROUP_TYPE)) {
             $this->_initCheckBoxGroup();
         }
     } else {
         $context_item = $this->_environment->getCurrentContextItem();
         if ($context_item->withRubric(CS_INSTITUTION_TYPE) and !empty($this->_institution_array)) {
             $this->_initCheckBoxInstitution();
         }
     }
     $projekt_room_show_mail_to_all = false;
     //Projectroom and no groups enabled -> send mails to group all
     if ($context_item->isProjectRoom() and !$context_item->withRubric(CS_GROUP_TYPE)) {
         $cid = $this->_environment->getCurrentContextId();
         $user_manager = $this->_environment->getUserManager();
         $user_manager->setUserLimit();
         $user_manager->setContextLimit($cid);
         $count = $user_manager->getCountAll();
         $all_iid = $this->_group_array[0]['value'];
         if ($item->getItemType() != CS_DATE_TYPE and $item->getItemType() != CS_TODO_TYPE) {
             $this->_form->addText('receiver_text', $this->_translator->getMessage('COMMON_MAIL_RECEIVER'), $this->_translator->getMessage('COMMON_MAIL_ALL_IN_ROOM', $count));
             $this->_form->addHidden('groups[0]', $all_iid);
         } else {
             $this->_form->combine();
             $this->_form->addCheckbox('groups[0]', $all_iid, false, $this->_translator->getMessage('COMMON_MAIL_RECEIVER'), $this->_translator->getMessage('COMMON_MAIL_ALL_IN_ROOM', $count));
         }
     }
     if ($context_item->isCommunityRoom() and !$context_item->withRubric(CS_INSTITUTION_TYPE)) {
         $cid = $this->_environment->getCurrentContextId();
         $user_manager = $this->_environment->getUserManager();
         $user_manager->setUserLimit();
         $user_manager->setContextLimit($cid);
         $count = $user_manager->getCountAll();
         if ($item->getItemType() != CS_DATE_TYPE and $item->getItemType() != CS_TODO_TYPE) {
             $this->_form->addText('receiver_text', $this->_translator->getMessage('COMMON_MAIL_RECEIVER'), $this->_translator->getMessage('COMMON_MAIL_ALL_IN_ROOM', $count));
             $this->_form->addHidden('send_to_all', true);
         } else {
             $this->_form->combine();
             $this->_form->addCheckbox('send_to_all', 1, false, $this->_translator->getMessage('COMMON_MAIL_RECEIVER'), $this->_translator->getMessage('COMMON_MAIL_ALL_IN_ROOM', $count));
         }
     }
     // send to all members in group rooms
     if ($context_item->isGroupRoom()) {
         $cid = $this->_environment->getCurrentContextID();
         $user_manager = $this->_environment->getUserManager();
         $user_manager->setUserLimit();
         $user_manager->setContextLimit($cid);
         $count = $user_manager->getCountAll();
         if ($item->getItemType() != CS_DATE_TYPE and $item->getItemType() != CS_TODO_TYPE) {
             $this->_form->addText('receiver_text', $this->_translator->getMessage('COMMON_MAIL_RECEIVER'), $this->_translator->getMessage('COMMON_MAIL_ALL_IN_ROOM', $count));
             $this->_form->addHidden('send_to_all', true);
         } else {
             $this->_form->combine();
             $this->_form->addCheckbox('send_to_all', 1, false, $this->_translator->getMessage('COMMON_MAIL_RECEIVER'), $this->_translator->getMessage('COMMON_MAIL_ALL_IN_ROOM', $count));
         }
     }
     $yesno[][] = array();
     $yesno['0']['text'] = $this->_translator->getMessage('COMMON_YES');
     $yesno['0']['value'] = $this->_translator->getMessage('COMMON_YES');
     $yesno['1']['text'] = $this->_translator->getMessage('COMMON_NO');
     $yesno['1']['value'] = $this->_translator->getMessage('COMMON_NO');
     $this->_form->addRadioGroup('copytosender', $this->_translator->getMessage('MAILCOPY_TO_SENDER'), $this->_translator->getMessage('MAILCOPY_TO_SENDER_DESC'), $yesno, $this->_translator->getMessage('COMMON_NO'), true, false);
     // buttons
     $this->_form->addButtonBar('option', $this->_translator->getMessage('COMMON_MAIL_SEND_BUTTON'), $this->_translator->getMessage('COMMON_CANCEL_BUTTON'));
 }
 protected function getDetailContent()
 {
     $converter = $this->_environment->getTextConverter();
     $translator = $this->_environment->getTranslationObject();
     // description
     $desc = $this->_item->getDescription();
     if (!empty($desc)) {
         $converter->setFileArray($this->getItemFileList());
         if ($this->_with_old_text_formating) {
             $desc = $converter->textFullHTMLFormatting($desc);
         } else {
             //$desc = $converter->cleanDataFromTextArea($desc);
             //$desc = $converter->compareWithSearchText...
             //$desc = $converter->text_as_html_long($desc);
             //$desc = $converter->show_images($desc, $this->_item, true);
             $desc = $converter->textFullHTMLFormatting($desc);
         }
     }
     // set up style of days and times
     // time
     $parse_time_start = convertTimeFromInput($this->_item->getStartingTime());
     $conforms = $parse_time_start['conforms'];
     if ($conforms === true) {
         $start_time_print = getTimeLanguage($parse_time_start['datetime']);
     } else {
         // TODO: compareWithSearchText
         $start_time_print = $converter->text_as_html_short($this->_item->getStartingTime());
     }
     $parse_time_end = convertTimeFromInput($this->_item->getEndingTime());
     $conforms = $parse_time_end['conforms'];
     if ($conforms === true) {
         $end_time_print = getTimeLanguage($parse_time_end['datetime']);
     } else {
         // TODO: compareWithSearchText
         $end_time_print = $converter->text_as_html_short($this->_item->getEndingTime());
     }
     // day
     $parse_day_start = convertDateFromInput($this->_item->getStartingDay(), $this->_environment->getSelectedLanguage());
     $conforms = $parse_day_start['conforms'];
     if ($conforms === true) {
         $start_day_print = $this->_item->getStartingDayName() . ', ' . $translator->getDateInLang($parse_day_start['datetime']);
     } else {
         // TODO: compareWithSearchText
         $start_day_print = $converter->text_as_html_short($this->_item->getStartingDay());
     }
     $parse_day_end = convertDateFromInput($this->_item->getEndingDay(), $this->_environment->getSelectedLanguage());
     $conforms = $parse_day_end['conforms'];
     if ($conforms === true) {
         $end_day_print = $this->_item->getEndingDayName() . ', ' . $translator->getDateInLang($parse_day_end['datetime']);
     } else {
         // TODO: compareWithSearchText
         $end_day_print = $converter->text_as_html_short($this->_item->getEndingDay());
     }
     // formate dates and times for displaying
     $date_print = '';
     $time_print = '';
     if ($end_day_print !== '') {
         // with ending day
         $date_print = $translator->getMessage('DATES_AS_OF') . ' ' . $start_day_print . ' ' . $translator->getMessage('DATES_TILL') . ' ' . $end_day_print;
         if ($parse_day_start['conforms'] && $parse_day_end['conforms']) {
             // start and end are dates, not string <- ???
             $date_print .= ' (' . getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']) . ' ' . $translator->getMessage('DATES_DAYS') . ')';
         }
         if ($start_time_print !== '' && $end_time_print === '') {
             // only start time given
             $time_print = $translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
             if ($parse_time_start['conforms'] === true) {
                 $time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print === '' && $end_time_print !== '') {
             // only end time given
             $time_print = $translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             if ($parse_time_end['conforms'] === true) {
                 $time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print !== '' && $end_time_print !== '') {
             // all times given
             if ($parse_time_end['conforms'] === true) {
                 $end_time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
             }
             if ($parse_time_start['conforms'] === true) {
                 $start_time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
             }
             $date_print = $translator->getMessage('DATES_AS_OF') . ' ' . $start_day_print . ', ' . $start_time_print . '<br/>' . $translator->getMessage('DATES_TILL') . ' ' . $end_day_print . ', ' . $end_time_print;
             if ($parse_day_start['conforms'] && $parse_day_end['conforms']) {
                 $date_print .= ' (' . getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']) . ' ' . $translator->getMessage('DATES_DAYS') . ')';
             }
         }
     } else {
         // without ending day
         $date_print = $translator->getMessage('DATES_ON_DAY') . ' ' . $start_day_print;
         if ($start_time_print !== '' && $end_time_print == '') {
             // starting time given
             $time_print = $translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
             if ($parse_time_start['conforms'] === true) {
                 $time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print === '' && $end_time_print !== '') {
             // end time given
             $time_print = $translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             if ($parse_time_end['conforms'] === true) {
                 $time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print !== '' && $end_time_print !== '') {
             // all times given
             if ($parse_time_end['conforms'] === true) {
                 $end_time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
             }
             if ($parse_time_start['conforms'] === true) {
                 $start_time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
             }
             $time_print = $translator->getMessage('DATES_FROM_TIME_LOWER') . ' ' . $start_time_print . ' ' . $translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
         }
     }
     if ($parse_day_start['timestamp'] === $parse_day_end['timestamp'] && $parse_day_start['conforms'] && $parse_day_end['conforms']) {
         $date_print = $translator->getMessage('DATES_ON_DAY') . ' ' . $start_day_print;
         if ($start_time_print !== '' && $end_time_print === '') {
             // starting time given
             $time_print = $translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
         } elseif ($start_time_print === '' && $end_time_print !== '') {
             // endtime given
             $time_print = $translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
         } elseif ($start_time_print !== '' && $end_time_print !== '') {
             // all times given
             $time_print = $translator->getMessage('DATES_FROM_TIME_LOWER') . ' ' . $start_time_print . ' ' . $translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
         }
     }
     // date and time
     $datetime = $date_print;
     if ($time_print !== '') {
         $datetime .= BRLF . $time_print;
     }
     // place
     $place = $this->_item->getPlace();
     if (!empty($place)) {
         // TODO: compareWithSearchText
         $place = $place;
     }
     // color
     $color = $this->_item->getColor();
     if (!empty($color)) {
         $color = $converter->text_as_html_short($color);
     }
     $formal = array();
     if ($this->_item->isNotActivated()) {
         $activating_date = $this->_item->getActivatingDate();
         $text = '';
         if (strstr($activating_date, '9999-00-00')) {
             $activating_text = $translator->getMessage('COMMON_NOT_ACTIVATED');
         } else {
             $activating_text = $translator->getMessage('COMMON_ACTIVATING_DATE') . ' ' . getDateInLang($this->_item->getActivatingDate());
         }
         $temp_array = array();
         $temp_array[] = $translator->getMessage('COMMON_RIGHTS');
         $temp_array[] = $activating_text;
         $formal[] = $temp_array;
     }
     $temp_array = array();
     return array('formal' => $formal, 'privat' => $this->_item->issetPrivatDate(), 'datetime' => $datetime, 'place' => $place, 'color' => $color, 'files' => $this->getFileContent(), 'member' => $this->getMember(), 'item_id' => $this->_item->getItemID(), 'title' => $this->_item->getTitle(), 'description' => $desc, 'moredetails' => $this->getCreatorInformationAsArray($this->_item));
 }
 public function save($form_data, $additional = array())
 {
     $environment = $this->_environment;
     $current_user = $this->_environment->getCurrentUserItem();
     $current_context = $this->_environment->getCurrentContextItem();
     $text_converter = $this->_environment->getTextConverter();
     if (isset($additional['action']) && $additional['action'] === 'upload_picture') {
         $current_iid = $additional['iid'];
     } else {
         $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 {
         $item_manager = $this->_environment->getTopicManager();
         $item = $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') {
             // buzzwords
             $item->setBuzzwordListByID($form_data['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_TOPIC_TYPE);
     } else {
         //Acces granted
         $this->cleanup_session($current_iid);
         // upload picture
         if (isset($additional['action']) && $additional['action'] === 'upload_picture') {
             if ($this->_popup_controller->checkFormData('picture_upload')) {
                 /* handle group picture upload */
                 if (!empty($additional["fileInfo"])) {
                     $srcfile = $additional["fileInfo"]["file"];
                     $targetfile = $srcfile . "_converted";
                     $session = $this->_environment->getSessionItem();
                     $session->unsetValue("add_files");
                     // determ new file name
                     $filename_info = pathinfo($targetfile);
                     $filename = 'cid' . $this->_environment->getCurrentContextID() . '_iid' . $item->getItemID() . '_' . $additional["fileInfo"]["name"];
                     // copy file and set picture
                     $disc_manager = $this->_environment->getDiscManager();
                     $disc_manager->copyFile($targetfile, $filename, true);
                     $item->setPicture($filename);
                     $item->save();
                     $this->_popup_controller->setSuccessfullDataReturn($filename);
                 }
             }
         } else {
             // save item
             if ($this->_popup_controller->checkFormData('general')) {
                 $session = $this->_environment->getSessionItem();
                 $item_is_new = false;
                 // Create new item
                 if (!isset($item)) {
                     $item_manager = $environment->getTopicManager();
                     $item = $item_manager->getNewItem();
                     $item->setContextID($environment->getCurrentContextID());
                     $current_user = $environment->getCurrentUserItem();
                     $item->setCreatorItem($current_user);
                     $item->setCreationDate(getCurrentDateTimeInMySQL());
                     $item->setLabelType(CS_TOPIC_TYPE);
                     $item_is_new = true;
                 }
                 // Set modificator and modification date
                 $current_user = $environment->getCurrentUserItem();
                 $item->setModificatorItem($current_user);
                 // Set attributes
                 if (isset($form_data['title'])) {
                     $item->setName($text_converter->sanitizeHTML($form_data['title']));
                 }
                 if (isset($form_data['description'])) {
                     $item->setDescription($this->_popup_controller->getUtils()->cleanCKEditor($form_data['description']));
                 }
                 if (isset($form_data['public'])) {
                     $item->setPublic($form_data['public']);
                 }
                 // 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['private_editing'])) {
                     $item->setPrivateEditing('0');
                 } else {
                     $item->setPrivateEditing('1');
                 }
                 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 {
                     $item->setModificationDate(getCurrentDateTimeInMySQL());
                 }
                 if ($item->getPicture() && isset($form_data['delete_picture'])) {
                     $disc_manager = $this->_environment->getDiscManager();
                     if ($disc_manager->existsFile($item->getPicture())) {
                         $disc_manager->unlinkFile($item->getPicture());
                     }
                     $item->setPicture('');
                 }
                 // Save item
                 $item->save();
                 // this will update the right box list
                 if ($item_is_new) {
                     if ($session->issetValue('cid' . $environment->getCurrentContextID() . '_' . CS_TOPIC_TYPE . '_index_ids')) {
                         $id_array = array_reverse($session->getValue('cid' . $environment->getCurrentContextID() . '_' . CS_TOPIC_TYPE . '_index_ids'));
                     } else {
                         $id_array = array();
                     }
                     $id_array[] = $item->getItemID();
                     $id_array = array_reverse($id_array);
                     $session->setValue('cid' . $environment->getCurrentContextID() . '_' . CS_TOPIC_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(), CS_TOPIC_TYPE);
             }
         }
     }
 }
 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';
                 }
             }*/
 }
Beispiel #15
0
                  }
               }
               $todo_item->setPlannedTime($minutes);
            }

            if (isset($_POST['dayEnd']) and !empty($_POST['dayEnd'])) {
               $date2 = convertDateFromInput($_POST['dayEnd'],$environment->getSelectedLanguage());
               if (!empty($_POST['timeEnd'])) {
                  $time_end = $_POST['timeEnd'];
               } else {
                  $time_end = '0:00';
               }
               if (!mb_ereg("(([2][0-3])|([01][0-9])):([0-5][0-9])",$time_end)) { //test if end_time is in a valid timeformat
                  $time_end='0:00';
               }
               $time2 = convertTimeFromInput($time_end);   // convertTimeFromInput
               if ($date2['conforms'] == TRUE and $time2['conforms'] == TRUE) {
                  $todo_item->setDate($date2['datetime']. ' '.$time2['datetime']);
               } else {
                  $todo_item->setDate($date2['display']. ' '.$time2['display']);
               }
            }else{
               $todo_item->setDate('9999-00-00 00:00:00');
            }

            // files
            $item_files_upload_to = $todo_item;
            include_once('include/inc_fileupload_edit_page_save_item.php');
            if ($session->issetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_buzzword_ids')){
               $todo_item->setBuzzwordListByID($session->getValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_buzzword_ids'));
               $session->unsetValue('cid'.$environment->getCurrentContextID().'_'.$environment->getCurrentModule().'_buzzword_ids');
 function getTooltipDate($date)
 {
     $parse_time_start = convertTimeFromInput($date->getStartingTime());
     $conforms = $parse_time_start['conforms'];
     if ($conforms == TRUE) {
         $start_time_print = getTimeLanguage($parse_time_start['datetime']);
     } else {
         $start_time_print = $this->_text_as_html_short($this->_compareWithSearchText($date->getStartingTime()));
     }
     $parse_time_end = convertTimeFromInput($date->getEndingTime());
     $conforms = $parse_time_end['conforms'];
     if ($conforms == TRUE) {
         $end_time_print = getTimeLanguage($parse_time_end['datetime']);
     } else {
         $end_time_print = $this->_text_as_html_short($this->_compareWithSearchText($date->getEndingTime()));
     }
     $parse_day_start = convertDateFromInput($date->getStartingDay(), $this->_environment->getSelectedLanguage());
     $conforms = $parse_day_start['conforms'];
     if ($conforms == TRUE) {
         $start_day_print = $date->getStartingDayName() . ', ' . $this->_translator->getDateInLang($parse_day_start['datetime']);
     } else {
         $start_day_print = $this->_text_as_html_short($this->_compareWithSearchText($date->getStartingDay()));
     }
     $parse_day_end = convertDateFromInput($date->getEndingDay(), $this->_environment->getSelectedLanguage());
     $conforms = $parse_day_end['conforms'];
     if ($conforms == TRUE) {
         $end_day_print = $date->getEndingDayName() . ', ' . $this->_translator->getDateInLang($parse_day_end['datetime']);
     } else {
         $end_day_print = $this->_text_as_html_short($this->_compareWithSearchText($date->getEndingDay()));
     }
     //formating dates and times for displaying
     $date_print = "";
     $time_print = "";
     if ($end_day_print != "") {
         //with ending day
         $date_print = $this->_translator->getMessage('DATES_AS_OF') . ' ' . $start_day_print . ' ' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_day_print;
         if ($parse_day_start['conforms'] and $parse_day_end['conforms']) {
             //start and end are dates, not strings
             $date_print .= ' (' . getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']) . ' ' . $this->_translator->getMessage('DATES_DAYS') . ')';
         }
         if ($start_time_print != "" and $end_time_print == "") {
             //starting time given
             $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
             if ($parse_time_start['conforms'] == true) {
                 $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print == "" and $end_time_print != "") {
             //endtime given
             $time_print = $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             if ($parse_time_end['conforms'] == true) {
                 $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print != "" and $end_time_print != "") {
             //all times given
             if ($parse_time_end['conforms'] == true) {
                 $end_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
             if ($parse_time_start['conforms'] == true) {
                 $start_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
             $date_print = $this->_translator->getMessage('DATES_AS_OF') . ' ' . $start_day_print . ', ' . $start_time_print . '<br />' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_day_print . ', ' . $end_time_print;
             if ($parse_day_start['conforms'] and $parse_day_end['conforms']) {
                 $date_print .= ' (' . getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']) . ' ' . $this->_translator->getMessage('DATES_DAYS') . ')';
             }
         }
     } else {
         //without ending day
         $date_print = $this->_translator->getMessage('DATES_ON_DAY') . ' ' . $start_day_print;
         if ($start_time_print != "" and $end_time_print == "") {
             //starting time given
             $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
             if ($parse_time_start['conforms'] == true) {
                 $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print == "" and $end_time_print != "") {
             //endtime given
             $time_print = $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             if ($parse_time_end['conforms'] == true) {
                 $time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
         } elseif ($start_time_print != "" and $end_time_print != "") {
             //all times given
             if ($parse_time_end['conforms'] == true) {
                 $end_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
             if ($parse_time_start['conforms'] == true) {
                 $start_time_print .= ' ' . $this->_translator->getMessage('DATES_OCLOCK');
             }
             $time_print = $this->_translator->getMessage('DATES_FROM_TIME_LOWER') . ' ' . $start_time_print . ' ' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
         }
     }
     if ($parse_day_start['timestamp'] == $parse_day_end['timestamp'] and $parse_day_start['conforms'] and $parse_day_end['conforms']) {
         $date_print = $this->_translator->getMessage('DATES_ON_DAY') . ' ' . $start_day_print;
         if ($start_time_print != "" and $end_time_print == "") {
             //starting time given
             $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
         } elseif ($start_time_print == "" and $end_time_print != "") {
             //endtime given
             $time_print = $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
         } elseif ($start_time_print != "" and $end_time_print != "") {
             //all times given
             $time_print = $this->_translator->getMessage('DATES_FROM_TIME_LOWER') . ' ' . $start_time_print . ' ' . $this->_translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
         }
     }
     // Date and time
     $temp_array = array();
     $temp_array[] = $this->_translator->getMessage('DATES_DATETIME');
     if ($time_print != '') {
         $temp_array[] = $date_print . BRLF . $time_print;
     } else {
         $temp_array[] = $date_print;
     }
     $tooltip_date = $temp_array;
     return $tooltip_date;
 }
 /** \brief	Json store query implementation
  *
  * Performes query requests for the personal calendar. Form parameters are taken from parent class.
  */
 public function actionQuery()
 {
     $query = $this->_data["query"];
     $startISO = $this->_data["options"]["startISOTime"];
     $endISO = $this->_data["options"]["endISOTime"];
     $parameters = array();
     $parameters["activatingStatus"] = "2";
     $parameters["selColor"] = "2";
     $parameters["selRoom"] = "2";
     $parameters["todoSelRoom"] = "2";
     $parameters["selStatus"] = "2";
     $parameters["assignedToMe"] = isset($this->_data["options"]["assignedToMe"]) ? $this->_data["options"]["assignedToMe"] : false;
     $month = "09";
     $year = "2012";
     $displayMode = "month";
     // month | year | day ...
     $currentUserItem = $this->_environment->getCurrentUser();
     $privateContextItem = $currentUserItem->getOwnRoom();
     /* get data from database */
     $datesManager = $this->_environment->getDatesManager();
     $todoManager = $this->_environment->getTodoManager();
     $colorArray = $datesManager->getColorArray();
     $datesManager->resetLimits();
     $datesManager->setSortOrder('time');
     /* set paramter limits */
     if ($parameters["activatingStatus"] == "2") {
         $datesManager->showNoNotActivatedEntries();
     }
     if ($parameters["selColor"] != "2") {
         $datesManager->setColorLimit("#" . $parameters["selColor"]);
     }
     if ($paramters["selStatus"] != "2") {
         $datesManager->setDateModeLimit($parameters["selStatus"]);
     }
     /*
     if ( !empty($ref_iid) and $mode == 'attached' ){
     	$dates_manager->setRefIDLimit($ref_iid);
     }
     if ( !empty($ref_user) and $mode == 'attached' ){
     	$dates_manager->setRefUserLimit($ref_user);
     }
     if ( !empty($sort) and ($seldisplay_mode!='calendar' or $seldisplay_mode == 'calendar_month' or $mode == 'formattach' or $mode == 'detailattach') ) {
     	$dates_manager->setSortOrder($sort);
     }
     if ( !empty($search) ) {
     	$dates_manager->setSearchLimit($search);
     }
     if ( !empty($selbuzzword) ) {
     	$dates_manager->setBuzzwordLimit($selbuzzword);
     }
     if ( !empty($last_selected_tag) ){
     	$dates_manager->setTagLimit($last_selected_tag);
     }
     */
     /* get calendar display configuration */
     $configuration = $privateContextItem->getMyCalendarDisplayConfig();
     $datesLimit = array();
     $todoLimit = array();
     foreach ($configuration as $entry) {
         $entryExplode = explode("_", $entry);
         if (sizeof($entryExplode) === 2) {
             list($value, $type) = $entryExplode;
             if ($type === "dates") {
                 $datesLimit[] = $value;
             } else {
                 $todoLimit[] = $value;
             }
         }
     }
     /************************************************************************************
      * We need to collect all room ids relevant for our calendar
      ************************************************************************************/
     $roomIdArray = array();
     // privateroom itself
     $roomIdArray[] = $privateContextItem->getItemID();
     // related group rooms
     $groupRoomList = $currentUserItem->getRelatedGroupList();
     if (isset($groupRoomList) && $groupRoomList->isNotEmpty()) {
         $groupRoomList->reverse();
         $groupRoomItem = $groupRoomList->getFirst();
         while ($groupRoomItem) {
             $projectRoomId = $groupRoomItem->getLinkedProjectItemID();
             if (in_array($projectRoomId, $roomIdArray)) {
                 $roomIdArrayTemp = array();
                 foreach ($roomIdArray as $value) {
                     $roomIdArrayTemp[] = $value;
                     if ($value === $projectRoomId) {
                         $roomIdArrayTemp[] = $groupRoomItem->getItemID();
                     }
                 }
                 $roomIdArray = $roomIdArrayTemp;
             }
             $groupRoomItem = $groupRoomList->getNext();
         }
     }
     // related project rooms
     $projectList = $currentUserItem->getRelatedProjectList();
     if (isset($projectList) && $projectList->isNotEmpty()) {
         $projectItem = $projectList->getFirst();
         while ($projectItem) {
             $roomIdArray[] = $projectItem->getItemID();
             $projectItem = $projectList->getNext();
         }
     }
     // related community rooms
     $communityList = $currentUserItem->getRelatedCommunityList();
     if (isset($communityList) && $communityList->isNotEmpty()) {
         $communityItem = $communityList->getFirst();
         while ($communityItem) {
             $roomIdArray[] = $communityItem->getItemID();
             $communityItem = $communityList->getNext();
         }
     }
     /************************************************************************************
      * Filter id array
      ************************************************************************************/
     $temp = array();
     foreach ($datesLimit as $limit) {
         if (in_array($limit, $roomIdArray)) {
             $temp[] = $limit;
         }
     }
     $temp[] = $privateContextItem->getItemID();
     $datesLimit = $temp;
     $temp = array();
     foreach ($todoLimit as $limit) {
         if (in_array($limit, $roomIdArray)) {
             $temp[] = $limit;
         }
     }
     $temp[] = $privateContextItem->getItemID();
     $todoLimit = $temp;
     if ($parameters["selRoom"] != "2") {
         $datesManager->setContextArrayLimit($parameters["selRoom"]);
     } else {
         $datesManager->setContextArrayLimit($datesLimit);
     }
     if (isset($startISO) && isset($endISO)) {
         $datesManager->setBetweenLimit($startISO, $endISO);
     }
     /************************************************************************************
      * ToDo
      ************************************************************************************/
     /*
     			
     				
     			
     			
     			// todo
     			$todo_sel_room = '';
     			if ( !empty($_GET[CS_TODO_TYPE.'_selroom'])
     					and $_GET[CS_TODO_TYPE.'_selroom'] != '-2'
     					and $_GET[CS_TODO_TYPE.'_selroom'] != '2'
     			) {
     				$todo_sel_room = $_GET[CS_TODO_TYPE.'_selroom'];
     				$room_id_array = array();
     				$room_id_array[] = $todo_sel_room;
     				$view->setSelectedRoom($todo_sel_room,CS_TODO_TYPE);
     				$context_item->setRubrikSelection(CS_TODO_TYPE,'room',$todo_sel_room);
     				$context_item->save();
     			} elseif ( !empty($_GET[CS_TODO_TYPE.'_selroom'])
     					and $_GET[CS_TODO_TYPE.'_selroom'] == '2'
     			) {
     				$todo_sel_room = $_GET[CS_TODO_TYPE.'_selroom'];
     				$view->setSelectedRoom($todo_sel_room,CS_TODO_TYPE);
     				$context_item->setRubrikSelection(CS_TODO_TYPE,'room',$todo_sel_room);
     				$context_item->save();
     			} elseif ( empty($_GET[CS_TODO_TYPE.'_selroom']) ) {
     				$todo_sel_room = $context_item->getRubrikSelection(CS_TODO_TYPE,'room');
     				if ( !empty($todo_sel_room)
     						and $todo_sel_room != '-2'
     						and $todo_sel_room != '2'
     				) {
     					$room_id_array = array();
     					$room_id_array[] = $todo_sel_room;
     					$view->setSelectedRoom($todo_sel_room,CS_TODO_TYPE);
     				}
     			}
     				
     			$todo_sel_status_for_manager = 4;
     			if ( isset($_GET[CS_TODO_TYPE.'_selstatus'])
     					and $_GET[CS_TODO_TYPE.'_selstatus'] != '-2'
     			) {
     				$todo_sel_status = $_GET[CS_TODO_TYPE.'_selstatus'];
     				$view->setSelectedStatus($todo_sel_status,CS_TODO_TYPE);
     				$context_item->setRubrikSelection(CS_TODO_TYPE,'status',$todo_sel_status);
     				$context_item->save();
     				if ( $todo_sel_status > 9 ) {
     					$todo_sel_status_for_manager = $todo_sel_status - 10;
     				} else {
     					$todo_sel_status_for_manager = $todo_sel_status;
     				}
     			} elseif ( empty($_GET[CS_TODO_TYPE.'_selstatus']) ) {
     				$todo_sel_status = $context_item->getRubrikSelection(CS_TODO_TYPE,'status');
     				if ( !empty($todo_sel_status) ) {
     					$view->setSelectedStatus($todo_sel_status,CS_TODO_TYPE);
     					if ( $todo_sel_status > 9 ) {
     						$todo_sel_status_for_manager = $todo_sel_status - 10;
     					} else {
     						$todo_sel_status_for_manager = $todo_sel_status;
     					}
     				}
     			}
     				
     			$todo_sel_assignment = 3;
     			if ( !empty($_GET[CS_TODO_TYPE.'_selassignment'])
     					and $_GET[CS_TODO_TYPE.'_selassignment'] != '-2'
     			) {
     				$todo_sel_assignment = $_GET[CS_TODO_TYPE.'_selassignment'];
     				$view->setSelectedAssignment($todo_sel_assignment,CS_TODO_TYPE);
     				$context_item->setRubrikSelection(CS_TODO_TYPE,'assignment',$todo_sel_assignment);
     				$context_item->save();
     			} elseif ( empty($_GET[CS_TODO_TYPE.'_selassignment']) ) {
     				$todo_sel_assignment = $context_item->getRubrikSelection(CS_TODO_TYPE,'assignment');
     				if ( !empty($todo_sel_assignment) ) {
     					$view->setSelectedAssignment($todo_sel_assignment,CS_TODO_TYPE);
     				}
     			}
     				
     			// filter room id array
     			$temp = array();
     			foreach($configuration_room_todo_limit as $limit) {
     				if(in_array($limit, $room_id_array)) {
     					$temp[] = $limit;
     				}
     			}
     			$temp[] = $current_context->getItemID();
     			$todo_room_id_array = $temp;
     				
     			$todo_manager = $environment->getToDoManager();
     			$todo_manager->setContextArrayLimit($todo_room_id_array);
     			$todo_ids = $todo_manager->getIDArray();
     			$count_all_todos = count($todo_ids);
     			$todo_manager->showNoNotActivatedEntries();
     			$todo_manager->setSortOrder('date');
     			if ( !empty($todo_sel_status_for_manager) ) {
     				$todo_manager->setStatusLimit($todo_sel_status_for_manager);
     			}
     			if ($todo_sel_assignment == '3'){
     				$current_user = $environment->getCurrentUserItem();
     				$user_list = $current_user->getRelatedUserList();
     				$user_item = $user_list->getFirst();
     				$user_id_array = array();
     				while ($user_item){
     					$user_id_array[] = $user_item->getItemID();
     					$user_item = $user_list->getNext();
     				}
     				$todo_manager->setAssignmentLimit($user_id_array);
     				unset($user_id_array);
     				unset($user_list);
     			}
     			if ( !empty($search) ) {
     				$todo_manager->setSearchLimit($search);
     			}
     			$todo_manager->select();
     			$todo_list = $todo_manager->get();
     			$view->setTodoList($todo_list);
     			if ( isset($count_all_todos) ) {
     				$view->setCountAllTodos($count_all_todos);
     			}
     			// todo
     */
     /*
     
     
     
     if ( !empty($only_show_array) ) {
     	$dates_manager->resetLimits();
     	$dates_manager->setWithoutDateModeLimit();
     	$dates_manager->setIDArrayLimit($only_show_array);
     }
     
     $ids = $dates_manager->getIDArray();       // returns an array of item ids
     $count_all_shown = count($ids);
     
     if ( empty($only_show_array) ) {
     	if (($seldisplay_mode=='calendar' or $seldisplay_mode == 'calendar_month') and !($mode == 'formattach' or $mode == 'detailattach') ){
     		if (!empty($year)) {
     			$dates_manager->setYearLimit($year);
     		}
     		if (!empty($month)) {
     		
     		
     		!!!!!!!!
     			if ($displayMode === "month") {
     	$realMonth = (int) mb_substr($month, 4, 2);
     	$datesManager->setMonthLimit($realMonth);
     } else {
     	$realMonth = (int) mb_substr($month, 4, 2);
     	$datesManager->setMonthLimit2($realMonth);
     }
     		!!!!!!!	
     		
     			if (!empty($presentation_mode) and $presentation_mode =='2'){
     				$real_month = mb_substr($month,4,2);
     				$first_char = mb_substr($real_month,0,1);
     				if ($first_char == '0'){
     					$real_month = mb_substr($real_month,1,2);
     				}
     				$dates_manager->setMonthLimit($real_month);
     			}else{
     				$real_month = mb_substr($month,4,2);
     				$first_char = mb_substr($real_month,0,1);
     				if ($first_char == '0'){
     					$real_month = mb_substr($real_month,1,2);
     				}
     				$dates_manager->setMonthLimit2($real_month);
     			}
     		}
     		$dates_manager->setDateModeLimit($selstatus);
     	}
     	if ( $sel_assignment != '2'
     			and $environment->inPrivateRoom()
     			and $environment->inConfigArray('c_use_new_private_room',$environment->getCurrentContextID())
     	) {
     		$current_user = $environment->getCurrentUserItem();
     		$user_list = $current_user->getRelatedUserList();
     		$user_item = $user_list->getFirst();
     		$user_id_array = array();
     		while ($user_item){
     			$user_id_array[] = $user_item->getItemID();
     			$user_item = $user_list->getNext();
     		}
     		$dates_manager->setAssignmentLimit($user_id_array);
     	}
     
     	if ( $interval > 0 ) {
     		$dates_manager->setIntervalLimit($from-1,$interval);
     	}
     }
     */
     if ($displayMode === "month") {
         $datesManager->selectDistinct();
     } else {
         $datesManager->select();
     }
     $dateList = $datesManager->get();
     // post date filter
     if ($parameters["assignedToMe"] === true) {
         // check if user is not root
         if (!$currentUserItem->isRoot()) {
             $userList = $currentUserItem->getRelatedUserList();
             $userList->add($currentUserItem);
             $dateEntry = $dateList->getFirst();
             while ($dateEntry) {
                 // check all related users for participation
                 $user = $userList->getFirst();
                 $isParticipant = false;
                 while ($user) {
                     if ($dateEntry->isParticipant($user)) {
                         $isParticipant = true;
                         break;
                     }
                     $user = $userList->getNext();
                 }
                 if (!$isParticipant) {
                     $dateList->removeElement($dateEntry);
                 }
                 $dateEntry = $dateList->getNext();
             }
         }
     }
     $dateEntry = $dateList->getFirst();
     $dates = array();
     while ($dateEntry) {
         $startDay = $dateEntry->getStartingDay();
         $startTime = $dateEntry->getStartingTime();
         $endDay = $dateEntry->getEndingDay();
         $endTime = $dateEntry->getEndingTime();
         $allDay = false;
         // check start time
         if (empty($startTime)) {
             $startTime = "00:00";
             $allDay = true;
         }
         // check end day
         if (empty($endDay)) {
             $endDay = $startDay;
         }
         // check end time
         if (empty($endTime)) {
             $endTime = $startTime;
         }
         // ensure end > start
         if ($endDay < $startDay) {
             $endDay = $startDay;
             $endTime = $startTime;
         } else {
             if ($endDay === $startDay) {
                 if ($endTime <= $startTime) {
                     $endTime = $startTime;
                 }
             }
         }
         /* convert into timestamps */
         $convertedStartDate = convertDateFromInput($startDay);
         $convertedStartTime = convertTimeFromInput($startTime);
         $timestampStart = mktime(mb_substr($convertedStartTime["timestamp"], 0, 2), mb_substr($convertedStartTime["timestamp"], 2, 2), mb_substr($convertedStartTime["timestamp"], 4, 2), mb_substr($convertedStartDate["timestamp"], 4, 2), mb_substr($convertedStartDate["timestamp"], 6, 2), mb_substr($convertedStartDate["timestamp"], 0, 4));
         $convertedEndDate = convertDateFromInput($endDay);
         $convertedEndTime = convertTimeFromInput($endTime);
         $timestampEnd = mktime(mb_substr($convertedEndTime["timestamp"], 0, 2), mb_substr($convertedEndTime["timestamp"], 2, 2), mb_substr($convertedEndTime["timestamp"], 4, 2), mb_substr($convertedEndDate["timestamp"], 4, 2), mb_substr($convertedEndDate["timestamp"], 6, 2), mb_substr($convertedEndDate["timestamp"], 0, 4));
         /* if equal add offset */
         if ($timestampStart === $timestampEnd) {
             if ($allDay === true) {
                 // if zero hour add one day
                 $timestampEnd += 60 * 60 * 24;
             } else {
                 // add one hour
                 $timestampEnd += 60 * 60;
             }
         }
         // check for all day events
         if ($timeStampStart - $timestampEnd >= 60 * 60 * 24) {
             $allDay = true;
         }
         $context = "public";
         $item_manager = $this->_environment->getItemManager();
         $context_item = $item_manager->getItem($dateEntry->getContextID());
         if ($context_item->getItemType() == 'privateroom') {
             $context = "private";
         }
         $dates[] = array("id" => $dateEntry->getItemID(), "summary" => $dateEntry->getTitle(), "startTime" => date("c", $timestampStart), "endTime" => date("c", $timestampEnd), "allDay" => $allDay, "context" => $context, "contextID" => $dateEntry->getContextID(), "module" => "date");
         $dateEntry = $dateList->getNext();
     }
     $this->rawDataReturn($dates);
 }
Beispiel #18
0
    if(isset($_POST['private_editing'])) {
       $topic_item->setPrivateEditing('0');
    } else {
       $topic_item->setPrivateEditing('1');
    }
 }
 
 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;
     }
     $topic_item->setModificationDate($dt_hiding_datetime);
 } else {
    if($topic_item->isNotActivated()){
       $topic_item->setModificationDate(getCurrentDateTimeInMySQL());
    }
 }
 
 public function actionInit()
 {
     $response = array();
     $iid = $this->_data['itemId'];
     $current_user = $this->_environment->getCurrentUserItem();
     $current_context = $this->_environment->getCurrentContextItem();
     $translator = $this->_environment->getTranslationObject();
     // context information
     $contextInformation = array();
     $contextInformation["name"] = $current_context->getTitle();
     $response['context'] = $contextInformation;
     // group information
     $groupArray = $this->getAllLabelsByType("group");
     // institutions information
     $institutionArray = $this->getAllLabelsByType("institution");
     // get item
     $manager = $this->_environment->getItemManager();
     $item = $manager->getItem($iid);
     $module = $item->getItemType();
     $link_module = $module;
     if ($module == 'label' or $module == 'labels') {
         $label_manager = $this->_environment->getLabelManager();
         $label = $label_manager->getItem($iid);
         $link_module = $label->getLabelType();
     }
     $item_manager = $this->_environment->getManager($module);
     $item = $item_manager->getItem($iid);
     $item_name = $item->getTitle();
     // Wenn man mit HTTPS auf Commsy surft und eine Email generiert
     // sollte diese Mail auch https links erstellen.
     if (!empty($_SERVER["HTTPS"]) and $_SERVER["HTTPS"]) {
         $url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $this->_environment->getCurrentContextID() . '&mod=' . $link_module . '&fct=detail' . '&iid=' . $item->getItemID();
     } else {
         $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?cid=' . $this->_environment->getCurrentContextID() . '&mod=' . $link_module . '&fct=detail' . '&iid=' . $item->getItemID();
     }
     $link = $url;
     $content = '';
     //generate module name for the interface- a pretty version of module...
     if ($module == CS_DATE_TYPE) {
         // set up style of days and times
         $parse_time_start = convertTimeFromInput($item->getStartingTime());
         $conforms = $parse_time_start['conforms'];
         if ($conforms == TRUE) {
             $start_time_print = getTimeLanguage($parse_time_start['datetime']);
         } else {
             $start_time_print = $item->getStartingTime();
         }
         $parse_time_end = convertTimeFromInput($item->getEndingTime());
         $conforms = $parse_time_end['conforms'];
         if ($conforms == TRUE) {
             $end_time_print = getTimeLanguage($parse_time_end['datetime']);
         } else {
             $end_time_print = $item->getEndingTime();
         }
         $parse_day_start = convertDateFromInput($item->getStartingDay(), $this->_environment->getSelectedLanguage());
         $conforms = $parse_day_start['conforms'];
         if ($conforms == TRUE) {
             $start_day_print = getDateInLang($parse_day_start['datetime']);
         } else {
             $start_day_print = $item->getStartingDay();
         }
         $parse_day_end = convertDateFromInput($item->getEndingDay(), $this->_environment->getSelectedLanguage());
         $conforms = $parse_day_end['conforms'];
         if ($conforms == TRUE) {
             $end_day_print = getDateLanguage($parse_day_end['datetime']);
         } else {
             $end_day_print = $item->getEndingDay();
         }
         //formating dates and times for displaying
         $date_print = "";
         $time_print = "";
         if ($end_day_print != "") {
             //with ending day
             $date_print = $translator->getMessage('DATES_AS_OF') . ' ' . $start_day_print . ' ' . $translator->getMessage('DATES_TILL') . ' ' . $end_day_print;
             if ($parse_day_start['conforms'] and $parse_day_end['conforms']) {
                 //start and end are dates, not strings
                 $date_print .= ' (' . getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']) . ' ' . $translator->getMessage('DATES_DAYS') . ')';
             }
             if ($start_time_print != "" and $end_time_print == "") {
                 //starting time given
                 $time_print = $translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
                 if ($parse_time_start['conforms'] == true) {
                     $time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
                 }
             } elseif ($start_time_print == "" and $end_time_print != "") {
                 //endtime given
                 $time_print = $translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
                 if ($parse_time_end['conforms'] == true) {
                     $time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
                 }
             } elseif ($start_time_print != "" and $end_time_print != "") {
                 //all times given
                 if ($parse_time_end['conforms'] == true) {
                     $end_time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
                 }
                 if ($parse_time_start['conforms'] == true) {
                     $start_time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
                 }
                 $date_print = $translator->getMessage('DATES_AS_OF') . ' ' . $start_day_print . ', ' . $start_time_print . '<br />' . $translator->getMessage('DATES_TILL') . ' ' . $end_day_print . ', ' . $end_time_print;
                 if ($parse_day_start['conforms'] and $parse_day_end['conforms']) {
                     $date_print .= ' (' . getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']) . ' ' . $translator->getMessage('DATES_DAYS') . ')';
                 }
             }
         } else {
             //without ending day
             $date_print = $start_day_print;
             if ($start_time_print != "" and $end_time_print == "") {
                 //starting time given
                 $time_print = $translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
                 if ($parse_time_start['conforms'] == true) {
                     $time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
                 }
             } elseif ($start_time_print == "" and $end_time_print != "") {
                 //endtime given
                 $time_print = $translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
                 if ($parse_time_end['conforms'] == true) {
                     $time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
                 }
             } elseif ($start_time_print != "" and $end_time_print != "") {
                 //all times given
                 if ($parse_time_end['conforms'] == true) {
                     $end_time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
                 }
                 if ($parse_time_start['conforms'] == true) {
                     $start_time_print .= ' ' . $translator->getMessage('DATES_OCLOCK');
                 }
                 $time_print = $translator->getMessage('DATES_FROM_TIME_LOWER') . ' ' . $start_time_print . ' ' . $translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             }
         }
         if ($parse_day_start['timestamp'] == $parse_day_end['timestamp'] and $parse_day_start['conforms'] and $parse_day_end['conforms']) {
             $date_print = $translator->getMessage('DATES_ON_DAY') . ' ' . $start_day_print;
             if ($start_time_print != "" and $end_time_print == "") {
                 //starting time given
                 $time_print = $translator->getMessage('DATES_AS_OF_LOWER') . ' ' . $start_time_print;
             } elseif ($start_time_print == "" and $end_time_print != "") {
                 //endtime given
                 $time_print = $translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             } elseif ($start_time_print != "" and $end_time_print != "") {
                 //all times given
                 $time_print = $translator->getMessage('DATES_FROM_TIME_LOWER') . ' ' . $start_time_print . ' ' . $translator->getMessage('DATES_TILL') . ' ' . $end_time_print;
             }
         }
         // Date and time
         $dates_content = '';
         $dates_content = $translator->getMessage('DATES_DATETIME') . ': ' . $item_name . LF;
         if ($time_print != '') {
             $dates_content .= $translator->getMessage('COMMON_TIME') . ': ' . $date_print . ',' . $time_print . LF;
         } else {
             $dates_content .= $translator->getMessage('COMMON_TIME') . ': ' . $date_print . LF;
         }
         // Place
         $place = $item->getPlace();
         if (!empty($place)) {
             $dates_content .= $translator->getMessage('DATES_PLACE') . ': ';
             $dates_content .= $place . LF;
         }
         $content = $dates_content;
     } elseif ($module == 'discussion' or $module == 'discussions') {
         $discussion_content = $translator->getMessage('COMMON_DISCUSSION') . ': ' . $item->getTitle() . LF;
         $article_count = $item->getAllArticlesCount();
         $discussion_content .= $translator->getMessage('DISCUSSION_DISCARTICLE_COUNT') . ': ' . $article_count . LF;
         $time = $item->getLatestArticleModificationDate();
         $discussion_content .= $translator->getMessage('DISCUSSION_LAST_ENTRY') . ': ' . getDateTimeInLang($time) . LF;
         $content = $discussion_content;
     } elseif ($module == 'material' or $module == 'materials') {
         $material_content = $translator->getMessage('COMMON_MATERIAL') . ': ' . $item->getTitle() . LF;
         $content = $material_content;
     } elseif ($module == 'announcement' or $module == CS_ANNOUNCEMENT_TYPE) {
         $announcement_content = $translator->getMessage('COMMON_ANNOUNCEMENT') . ': ' . $item->getTitle() . LF;
         $content = $announcement_content;
     } elseif ($module == 'label' or $module == 'labels') {
         $label_manager = $this->_environment->getLabelManager();
         $label = $label_manager->getItem($iid);
         $module = $label->getLabelType();
         if ($module == 'group' or $module == 'groups') {
             $group_content = $translator->getMessage('COMMON_GROUP') . ': ' . $item->getTitle() . LF;
             $content = $group_content;
         } elseif ($module == 'institution' or $module == 'institutions') {
             $institution_content = $translator->getMessage('INSTITUTION') . ': ' . $item->getTitle() . LF;
             $content = $institution_content;
         }
     }
     if ($this->_environment->inProjectRoom()) {
         $emailtext = $translator->getMessage('RUBRIC_EMAIL_DEFAULT_PROJECT', $current_context->getTitle()) . LF;
     } elseif ($this->_environment->inGroupRoom()) {
         $emailtext = $translator->getMessage('RUBRIC_EMAIL_DEFAULT_GROUPROOM', $current_context->getTitle()) . LF;
     } else {
         $emailtext = $translator->getMessage('RUBRIC_EMAIL_DEFAULT_COMMUNITY', $current_context->getTitle()) . LF;
     }
     if (empty($content)) {
         $emailtext .= LF . LF;
     } else {
         $emailtext .= $content;
     }
     $emailtext .= $translator->getMessage('RUBRIC_EMAIL_DEFAULT_PROJECT_END', $link);
     $response['body'] = strip_tags($emailtext);
     // receiver
     $showAttendees = false;
     if ($module === CS_DATE_TYPE) {
         $showAttendees = true;
         $attendeeType = CS_DATE_TYPE;
     }
     if ($module === CS_TODO_TYPE) {
         $showAttendees = true;
         $attendeeType = CS_TODO_TYPE;
     }
     $response['showAttendees'] = $showAttendees;
     $response['attendeeType'] = $attendeeType;
     $showGroupRecipients = false;
     $showInstitutionRecipients = false;
     if ($this->_environment->inProjectRoom() and !empty($groupArray)) {
         if ($current_context->withRubric(CS_GROUP_TYPE)) {
             $showGroupRecipients = true;
         }
     } else {
         if ($current_context->withRubric(CS_INSTITUTION_TYPE) and !empty($institutionArray)) {
             $showInstitutionRecipients = true;
         }
     }
     //Projectroom and no groups enabled -> send mails to group all
     $withGroups = true;
     if ($current_context->isProjectRoom() && !$current_context->withRubric(CS_GROUP_TYPE)) {
         $showGroupRecipients = true;
         $withGroups = false;
         // get number of users
         $cid = $this->_environment->getCurrentContextId();
         $user_manager = $this->_environment->getUserManager();
         $user_manager->setUserLimit();
         $user_manager->setContextLimit($cid);
         $count = $user_manager->getCountAll();
         $response['numMebers'] = $count;
         $groupArray = array_slice($groupArray, 0, 1);
     }
     $response['showGroupRecipients'] = $showGroupRecipients;
     $response['withGroups'] = $withGroups;
     $response['groups'] = $groupArray;
     $allMembers = false;
     if ($current_context->isCommunityRoom() && !$current_context->withRubric(CS_INSTITUTION_TYPE) || $current_context->isGroupRoom()) {
         $allMembers = true;
         // get number of users
         $cid = $this->_environment->getCurrentContextId();
         $user_manager = $this->_environment->getUserManager();
         $user_manager->setUserLimit();
         $user_manager->setContextLimit($cid);
         $count = $user_manager->getCountAll();
         $response['numMebers'] = $count;
     }
     $response['showInstitutionRecipients'] = $showInstitutionRecipients;
     $response['institutions'] = $institutionArray;
     $response['allMembers'] = $allMembers;
     $response['allowAdditional'] = true;
     $this->setSuccessfullDataReturn($response);
     echo $this->_return;
 }