function _cronIndexFiles() { include_once 'functions/misc_functions.php'; $time_start = getmicrotime(); $retour = array(); $retour['title'] = 'indexing files'; $retour['description'] = 'indexing of uploaded files for search'; $retour['success'] = false; $retour['success_text'] = 'cron failed'; global $c_indexing; if (isset($c_indexing) and !empty($c_indexing) and $c_indexing) { $file_manager = $this->_environment->getFileManager(); $file_manager->resetLimits(); $file_manager->setContextLimit($this->getItemID()); $file_manager->setNewerLimit(getCurrentDateTimeMinusHoursInMySQL(24)); $file_manager->select(); $file_list = $file_manager->get(); if ($file_list->isNotEmpty()) { $indexing_manager = $this->_environment->getFTSearchManager(); $indexing_manager->setRoomID($this->getItemID()); $indexing_manager->setPortalID($this->getContextID()); $indexing_manager->setIncremental(); $indexing_manager->buildFTIndex(); unset($indexing_manager); $retour['success'] = true; $retour['success_text'] = $file_list->getCount() . ' files add to index'; } else { $retour['success'] = true; $retour['success_text'] = 'nothing to do'; } unset($file_list); unset($file_manager); } else { $retour['success_text'] = 'indexing is not enabled'; } $time_end = getmicrotime(); $time = round($time_end - $time_start, 0); $retour['time'] = $time; return $retour; }
/** delete old sessions * this method deletes all sessions in the database table "session" older than 6 hours */ function deleteOldSessions() { include_once 'functions/date_functions.php'; global $c_session_lifetime; if (!empty($c_session_lifetime) and is_int($c_session_lifetime) and $c_session_lifetime > 0 and $c_session_lifetime < 24) { $session_lifetime = $c_session_lifetime; } else { $session_lifetime = 6; } $datetime = getCurrentDateTimeMinusHoursInMySQL($session_lifetime); $query = 'DELETE LOW_PRIORITY FROM session WHERE created<"' . $datetime . '";'; $this->_last_query = $query; $result = $this->_db_conntector->performQuery($query); if (!isset($result) or !$result) { include_once 'functions/error_functions.php'; trigger_error('Problems deleting old session values.', E_USER_WARNING); } }
private function _cronDeleteUnusedRooms() { $cron_array = array(); $cron_array['title'] = 'delete unused rooms'; $cron_array['description'] = 'if rooms (project and community) are unused for ' . $this->getDaysUnusedBeforeDeletingRooms() . ' days this cron deletes it'; $cron_array['success'] = false; $cron_array['success_text'] = 'cron failed'; $days_mail_send_before = $this->getDaysSendMailBeforeDeletingRooms(); // unused project rooms // group rooms will be deleted with project room $count_project = 0; $room_manager = $this->_environment->getProjectManager(); include_once 'functions/date_functions.php'; $datetime_border = getCurrentDateTimeMinusDaysInMySQL($this->getDaysUnusedBeforeDeletingRooms()); $room_manager->setLastLoginOlderLimit($datetime_border); $room_manager->setContextLimit($this->getItemID()); #$room_manager->setNotTemplateLimit(); $room_manager->select(); $room_list = $room_manager->get(); $count_project_all = 0; if (!empty($room_list) and $room_list->isNotEmpty()) { $count_project_all = $room_list->getCount(); $datetime_border_send_mail = getCurrentDateTimeMinusHoursInMySQL(($this->getDaysSendMailBeforeDeletingRooms() - 0.5) * 24); $datetime_border_send_mail2 = getCurrentDateTimeMinusDaysInMySQL($this->getDaysSendMailBeforeDeletingRooms() + 21); $room_item = $room_list->getFirst(); while ($room_item) { $delete = true; if (!empty($days_mail_send_before)) { $send_mail_datetime = $room_item->getDeleteMailSendDateTime(); // room will only deleted configured days after sending email if (empty($send_mail_datetime) or $send_mail_datetime > $datetime_border_send_mail) { $delete = false; } elseif ($send_mail_datetime < $datetime_border_send_mail2) { $delete = false; $room_item->setDeleteMailSendDateTime(''); $room_item->saveWithoutChangingModificationInformation(); } } if ($delete) { $room_item->delete(); $count_project++; } unset($room_item); $room_item = $room_list->getNext(); } } unset($room_list); unset($room_manager); // unused community rooms $count_community = 0; $room_manager = $this->_environment->getCommunityManager(); include_once 'functions/date_functions.php'; $datetime_border = getCurrentDateTimeMinusDaysInMySQL($this->getDaysUnusedBeforeDeletingRooms()); $room_manager->setLastLoginOlderLimit($datetime_border); $room_manager->setContextLimit($this->getItemID()); #$room_manager->setNotTemplateLimit(); $room_manager->select(); $room_list = $room_manager->get(); $count_community_all = 0; if (!empty($room_list) and $room_list->isNotEmpty()) { $count_community_all = $room_list->getCount(); $datetime_border_send_mail = getCurrentDateTimeMinusDaysInMySQL($this->getDaysSendMailBeforeDeletingRooms()); $datetime_border_send_mail2 = getCurrentDateTimeMinusDaysInMySQL($this->getDaysSendMailBeforeDeletingRooms() + 21); $room_item = $room_list->getFirst(); while ($room_item) { $delete = true; if (!empty($days_mail_send_before)) { $send_mail_datetime = $room_item->getDeleteMailSendDateTime(); // room will only deleted configured days after sending email if (empty($send_mail_datetime) or $send_mail_datetime > $datetime_border_send_mail) { $delete = false; } elseif ($send_mail_datetime < $datetime_border_send_mail2) { $delete = false; $room_item->setDeleteMailSendDateTime(''); $room_item->saveWithoutChangingModificationInformation(); } } if ($delete) { $room_item->delete(); $count_community++; } unset($room_item); $room_item = $room_list->getNext(); } } unset($room_list); unset($room_manager); $cron_array['success'] = true; $cron_array['success_text'] = 'delete project rooms: ' . $count_project . ' (possible: ' . $count_project_all . ') - delete community rooms: ' . $count_community . ' (possible: ' . $count_community_all . ')'; return $cron_array; }