本文整理汇总了PHP中getCurrentDateTimeInMySQL函数的典型用法代码示例。如果您正苦于以下问题:PHP getCurrentDateTimeInMySQL函数的具体用法?PHP getCurrentDateTimeInMySQL怎么用?PHP getCurrentDateTimeInMySQL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getCurrentDateTimeInMySQL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getSecondFolder
function _getSecondFolder($second_folder)
{
$second_folder = (string) $second_folder;
if (!empty($second_folder)) {
$array = array();
$retour = '';
for ($i = 0; $i < strlen($second_folder); $i++) {
if ($i > 0 and $i % 4 == 0) {
$retour .= '/';
}
$retour .= $second_folder[$i];
}
$retour .= '_';
} else {
include_once 'functions/date_functions.php';
$retour = md5(getCurrentDateTimeInMySQL());
}
return $retour;
}
示例2: array
$params = array();
$params['focus_element_onload'] = 'new_buzzword';
redirect($environment->getCurrentContextID(), 'buzzwords', 'edit', $params);
}
}elseif (!empty($command) and isOption($command, $translator->getMessage('BUZZWORDS_COMBINE_BUTTON'))){
if ( (isset($_POST['sel1']) and !empty($_POST['sel1'])) and
(isset($_POST['sel2']) and !empty($_POST['sel2'])) and
(isset($_POST['sel1']) and isset($_POST['sel2']) and $_POST['sel1'] !=$_POST['sel2'])
){
$link_manager = $environment->getLinkManager();
$link_manager->combineBuzzwords($_POST['sel1'],$_POST['sel2']);
$buzzword_manager = $environment->getLabelManager();
$buzzword_item1 = $buzzword_manager->getItem($_POST['sel1']);
$buzzword_item2 = $buzzword_manager->getItem($_POST['sel2']);
$buzzword_item1->setName($buzzword_item1->getName().'/'.$buzzword_item2->getName());
$buzzword_item1->setModificationDate(getCurrentDateTimeInMySQL());
$buzzword_item1->save();
$buzzword_item2->delete();
$params = array();
$params['focus_element_onload'] = 'sel1';
redirect($environment->getCurrentContextID(), 'buzzwords', 'edit', $params);
}
}
// Display form
$params = array();
$params['environment'] = $environment;
$params['with_modifying_actions'] = true;
$form_view = $class_factory->getClass(FORM_VIEW,$params);
unset($params);
示例3: save
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;
//.........这里部分代码省略.........
示例4: isOption
$values = $_POST;
$form->setFormPost($values);
}
$form->prepareForm();
$form->loadValues();
if ( !empty($command) and
isOption($command, $translator->getMessage('DATES_SELECTION_BUTTON')) ) {
$date_manager = $environment->getDateManager();
foreach($date_array as $dates_data){
$dates_item = $date_manager->getNewItem();
$dates_item->setContextID($environment->getCurrentContextID());
$user = $environment->getCurrentUserItem();
$dates_item->setCreatorItem($user);
$dates_item->setCreationDate(getCurrentDateTimeInMySQL());
if (isset($dates_data[$_POST['title']])){
$dates_item->setTitle($dates_data[$_POST['title']]);
}else{
$dates_item->setTitle($translator->getMessage('COMMON_TITLE'));
}
if (isset($dates_data[$_POST['description']])){
$dates_item->setDescription($dates_data[$_POST['description']]);
}
if (isset($_POST['mode'])){
$dates_item->setDateMode('1');
}else{
$dates_item->setDateMode('0');
}
$dates_item->setPublic('1');
if (isset($dates_data[$_POST['starttime']])){
示例5: elseif
$email_addresses[$environment->getSelectedLanguage()][] = $moderator_item->getEmail();
} elseif ($language == 'user' and $moderator_item->getLanguage() != 'browser') {
$email_addresses[$moderator_item->getLanguage()][] = $moderator_item->getEmail();
} else {
$email_addresses[$room_item->getLanguage()][] = $moderator_item->getEmail();
}
$recipients .= $moderator_item->getFullname().LF;
}
$moderator_item = $user_list->getNext();
}
foreach ($email_addresses as $language => $email_array) {
if (count($email_array) > 0) {
$old_lang = $translator->getSelectedLanguage();
$translator->setSelectedLanguage($language);
$subject = $translator->getMessage('USER_JOIN_CONTEXT_MAIL_SUBJECT',$user_item->getFullname(),$room_item->getTitle());
$body = $translator->getMessage('MAIL_AUTO',$translator->getDateInLang(getCurrentDateTimeInMySQL()),getTimeInLang(getCurrentDateTimeInMySQL()));
$body .= LF.LF;
if ( $room_item->isCommunityRoom() ) {
$portal = $environment->getCurrentContextItem();
if($portal->getHideAccountname()){
// Hide useraccountname
$user_id = $translator->getMessage('USER_ACCOUNT_NOT_VISIBLE');
$body .= $translator->getMessage('USER_JOIN_COMMUNITY_MAIL_BODY_BY_MODERATOR',$user_item->getFullname(),$user_id,$user_item->getEmail(),$room_item->getTitle(),$current_user->getFullname());
} else {
$body .= $translator->getMessage('USER_JOIN_COMMUNITY_MAIL_BODY_BY_MODERATOR',$user_item->getFullname(),$user_item->getUserID(),$user_item->getEmail(),$room_item->getTitle(),$current_user->getFullname());
}
} else {
$portal = $environment->getCurrentContextItem();
if($portal->getHideAccountname()){
// Hide useraccountname
$user_id = $translator->getMessage('USER_ACCOUNT_NOT_VISIBLE');
示例6: getCountUserPasswordExpiredByContextID
public function getCountUserPasswordExpiredByContextID($cid)
{
$retour = 0;
$date = getCurrentDateTimeInMySQL();
$query = "SELECT count(DISTINCT " . $this->addDatabasePrefix("user") . ".item_id) as number FROM " . $this->addDatabasePrefix("user") . " WHERE " . $this->addDatabasePrefix("user") . ".expire_date IS NOT NULL AND " . $this->addDatabasePrefix("user") . ".context_id = '" . encode(AS_DB, $cid) . "' AND " . $this->addDatabasePrefix("user") . ".expire_date <= '" . encode(AS_DB, $date) . "'";
$query .= " and deletion_date IS NULL";
$result = $this->_db_connector->performQuery($query);
if (!isset($result)) {
include_once 'functions/error_functions.php';
trigger_error('Problems counting open accounts.', E_USER_WARNING);
} else {
foreach ($result as $rs) {
$retour = $rs['number'];
}
unset($result);
}
return $retour;
}
示例7: update
/** save session item -- TBD: needed any more?
* this method saves a session item into the database table "session"
*
* @param object cs_session_item the session item
*/
function update($item)
{
// cookie management
if (!$item->issetValue('cookie') or $item->getValue('cookie') == 2) {
$this->_saveSessionIDInCookie($item->getSessionID(), $item->getToolName());
if ($item->getValue('cookie') == 2) {
$item->setValue('cookie', 1);
}
}
include_once 'functions/date_functions.php';
$current_date_time = getCurrentDateTimeInMySQL();
$session_data = serialize($item->_data);
include_once 'functions/text_functions.php';
$query = "UPDATE session SET session_value='" . encode(AS_DB, $session_data) . "',\n created='" . $current_date_time . "'\n WHERE session_id='" . encode(AS_DB, $item->getSessionID()) . "';";
$this->_last_query = $query;
$result = $this->_db_conntector->performQuery($query);
if (!isset($result) or !$result) {
include_once 'functions/error_functions.php';
trigger_error('Problems saving session values for: ' . $item->getSessionID() . '.', E_USER_WARNING);
}
unset($item);
}
示例8: actionEdit
public function actionEdit()
{
$session = $this->_environment->getSessionItem();
$translator = $this->_environment->getTranslationObject();
// get the current user and room
$current_user = $this->_environment->getCurrentUserItem();
$current_context = $this->_environment->getCurrentContextItem();
// get post data
$this->getPostData();
// check access rights
if ($current_context->isProjectRoom() && $current_context->isClosed()) {
/*
* $params = array();
$params['environment'] = $environment;
$params['with_modifying_actions'] = true;
$errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params);
unset($params);
$errorbox->setText($translator->getMessage('PROJECT_ROOM_IS_CLOSED', $context_item->getTitle()));
$page->add($errorbox);
*/
} elseif ($this->_item_id !== "NEW" && !isset($this->_item)) {
/*
* $params = array();
$params['environment'] = $environment;
$params['with_modifying_actions'] = true;
$errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params);
unset($params);
$errorbox->setText($translator->getMessage('ITEM_DOES_NOT_EXIST', $current_iid));
$page->add($errorbox);
*/
} elseif (!($this->_item_id === "NEW" && $current_user->isUser() || $this->_item_id !== "NEW" && isset($this->_item) && $this->_item->mayEdit($current_user))) {
/*
* $params = array();
$params['environment'] = $environment;
$params['with_modifying_actions'] = true;
$errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params);
unset($params);
$errorbox->setText($translator->getMessage('LOGIN_NOT_ALLOWED'));
$page->add($errorbox);
*/
} else {
if ($this->_command !== null && (isOption($this->_command, CS_OPTION_SAVE) || isOption($this->_command, CS_OPTION_CHANGE) || isOption($this->_command, CS_OPTION_NEW))) {
if ($this->checkFormData()) {
if (!isset($step_item)) {
$step_manager = $this->_environment->getStepManager();
$step_item = $step_manager->getNewItem();
$step_item->setContextID($this->_environment->getCurrentContextID());
$user = $this->_environment->getCurrentUserItem();
$step_item->setCreatorItem($user);
$step_item->setCreationDAte(getCurrentDateTimeInMySQL());
$step_item->setTodoID($_POST["todo_id"]);
}
$todo_manager = $this->_environment->getTodoManager();
$todo_item = $todo_manager->getItem($_POST["todo_id"]);
// set modificator and modification date
$user = $this->_environment->getCurrentUserItem();
$step_item->setModificatorItem($user);
$step_item->setModificationDate(getCurrentDateTimeInMySQL());
// set attributes
if (isset($_POST["form_data"]["title"])) {
$step_item->setTitle($_POST["form_data"]["title"]);
}
if (isset($_POST["form_data"]["ckeditor_step"])) {
$step_item->setDescription($_POST["form_data"]["ckeditor_step"]);
}
if (isset($_POST["form_data"]["minutes"])) {
$minutes = $_POST["form_data"]["minutes"];
$minutes = str_replace(",", ".", $minutes);
if (isset($_POST["form_data"]["time_type"])) {
$step_item->setTimeType($_POST["form_data"]["time_type"]);
switch ($_POST["form_data"]["time_type"]) {
case 2:
$minutes = $minutes * 60;
break;
case 3:
$minutes = $minutes * 60 * 8;
break;
}
}
$step_item->setMinutes($minutes);
}
// save
$step_item->save();
$status = $todo_item->getStatus();
if ($status == $translator->getMessage("TODO_NOT_STARTED")) {
$todo_item->setStatus(2);
}
$todo_item->setModificationDate(getCurrentDateTimeInMySQL());
$todo_item->save();
/*
// Set links to connected rubrics
if ( isset($_POST[CS_MATERIAL_TYPE]) ) {
$step_item->setMaterialListByID($_POST[CS_MATERIAL_TYPE]);
} else {
$step_item->setMaterialListByID(array());
}
$item_files_upload_to = $step_item;
include_once('include/inc_fileupload_edit_page_save_item.php');
*/
//.........这里部分代码省略.........
示例9: delete
/** delete a task
* this method deletes a new task
*
* @param integer item_id item id of the task
*/
function delete($item_id)
{
$current_datetime = getCurrentDateTimeInMySQL();
$current_user = $this->_environment->getCurrentUserItem();
$user_id = $current_user->getItemID();
unset($current_user);
$query = 'UPDATE ' . $this->addDatabasePrefix('tasks') . ' SET ' . 'deletion_date="' . $current_datetime . '",' . 'deleter_id="' . encode(AS_DB, $user_id) . '",' . 'status="CLOSED"' . ' WHERE item_id="' . encode(AS_DB, $item_id) . '"';
$result = $this->_db_connector->performQuery($query);
if (!isset($result) or !$result) {
include_once 'functions/error_functions.php';
trigger_error('Problems deleting tasks from query: "' . $query . '"', E_USER_WARNING);
} else {
parent::delete($item_id);
}
}
示例10: deleteByFileID
/** delete link , but it is just an update
* this method deletes all links from an item, but only as an update to restore it later and for evaluation
*
* @param integer file_id id of the file item
*/
function deleteByFileID($file_id)
{
$query = 'UPDATE ' . $this->addDatabasePrefix($this->_db_table) . ' SET ' . 'deletion_date="' . getCurrentDateTimeInMySQL() . '",' . 'deleter_id="' . encode(AS_DB, $this->_current_user->getItemID()) . '"' . ' WHERE file_id="' . encode(AS_DB, $file_id) . '";';
$result = $this->_db_connector->performQuery($query);
if (!isset($result) or !$result) {
include_once 'functions/error_functions.php';
trigger_error('Problems deleting (updating) links of an item from query: "' . $query . '". - ' . __FILE__ . ' - ' . __LINE__, E_USER_WARNING);
}
}
示例11: _update
/** update a room - internal, do not use -> use method save
* this method updates a room
*
* @param object cs_context_item a commsy room
*/
public function _update($item)
{
if ($this->_update_with_changing_modification_information) {
parent::_update($item);
}
$query = 'UPDATE ' . $this->addDatabasePrefix($this->_db_table) . ' SET ';
if ($this->_update_with_changing_modification_information) {
$query .= 'modification_date="' . getCurrentDateTimeInMySQL() . '",';
$modifier_id = $this->_current_user->getItemID();
if (!empty($modifier_id)) {
$query .= 'modifier_id="' . encode(AS_DB, $modifier_id) . '",';
}
}
if ($item->isOpenForGuests()) {
$open_for_guests = 1;
} else {
$open_for_guests = 0;
}
if ($item->isContinuous()) {
$continuous = 1;
} else {
$continuous = -1;
}
if ($item->isTemplate()) {
$template = 1;
} else {
$template = -1;
}
if ($item->getActivityPoints()) {
$activity = $item->getActivityPoints();
} else {
$activity = '0';
}
if ($item->getPublic()) {
$public = '1';
} else {
$public = '0';
}
if ($item->isTemplate()) {
$title = $item->getTitlePure();
} else {
$title = $item->getTitle();
}
$query .= 'title="' . encode(AS_DB, $title) . '",' . "extras='" . encode(AS_DB, serialize($item->getExtraInformation())) . "'," . "status='" . encode(AS_DB, $item->getStatus()) . "'," . "activity='" . encode(AS_DB, $activity) . "'," . "public='" . encode(AS_DB, $public) . "'," . "continuous='" . $continuous . "'," . "template='" . $template . "'," . "is_open_for_guests='" . $open_for_guests . "'" . ' WHERE item_id="' . encode(AS_DB, $item->getItemID()) . '"';
$result = $this->_db_connector->performQuery($query);
if (!isset($result) or !$result) {
include_once 'functions/error_functions.php';
trigger_error('Problems updating ' . $this->_db_table . ' item from query: "' . $query . '"', E_USER_WARNING);
}
}
示例12: save
//.........这里部分代码省略.........
case '1':
$im = imagecreatefromgif($srcfile);
break;
case '2':
$im = imagecreatefromjpeg($srcfile);
break;
case '3':
$im = imagecreatefrompng($srcfile);
break;
}
$newimg = imagecreatetruecolor($max_width, $max_width * $ratio);
imagecopyresampled($newimg, $im, 0, 0, $source_x, $source_y, $max_width, ceil($max_width * $ratio), $source_width, $source_height);
imagepng($newimg, $targetfile);
// clean up
imagedestroy($im);
imagedestroy($newimg);
// determ new file name
$filename_info = pathinfo($additional["fileInfo"]["name"]);
$filename = 'cid' . $this->_environment->getCurrentContextID() . '_' . $currentUser->getItemID() . '.' . $filename_info['extension'];
// copy file and set picture
$disc_manager = $this->_environment->getDiscManager();
$disc_manager->copyFile($targetfile, $filename, true);
$currentUser->setPicture($filename);
$modifier = $this->_environment->getCurrentUserItem();
if (isset($portalUser)) {
if ($disc_manager->copyImageFromRoomToRoom($filename, $portalUser->getContextID())) {
$value_array = explode('_', $filename);
$old_room_id = $value_array[0];
$old_room_id = str_replace('cid', '', $old_room_id);
$valu_array[0] = 'cid' . $portalUser->getContextID();
$new_picture_name = implode('_', $value_array);
$portalUser->setPicture($new_picture_name);
$portalUser->setModificatorItem($modifier);
$portalUser->setModificationDate(getCurrentDateTimeInMySQL());
$portalUser->save();
}
}
// save
$currentUser->setModificatorItem($modifier);
$currentUser->setModificationDate(getCurrentDateTimeInMySQL());
$currentUser->save();
}
// set return
$this->_popup_controller->setSuccessfullDataReturn($filename);
}
break;
/**** USER ****/
/**** USER ****/
case 'user':
$currentUser = $this->_environment->getCurrentUserItem();
$portalUser = $currentUser->getRelatedCommSyUserItem();
$text_converter = $this->_environment->getTextConverter();
$currentContext = $this->_environment->getCurrentContextItem();
if ($this->_popup_controller->checkFormData('user')) {
function setValue($currentUser, $portalUser_item, $method, $value)
{
if (isset($value)) {
// set for user
call_user_func_array(array($currentUser, $method), array($value));
if (isset($portalUser_item)) {
// set for portal user
call_user_func_array(array($portalUser_item, $method), array($value));
}
}
}
setValue($currentUser, $portalUser, 'setTitle', $text_converter->sanitizeHTML($form_data['title']));
示例13: include_once
// Uebersetzungstabelle commsy -> mediabird
$current_user_item = $environment->getCurrentUserItem();
$portal_user_item = $current_user_item->getRelatedCommSyUserItem();
// last login
include_once('functions/date_functions.php');
$current_user_item->setLastLoginPlugin(getCurrentDateTimeInMySQL(),$system);
$current_user_item->setChangeModificationOnSave(false);
$current_user_item->save();
if ( !$environment->inPortal()
and !$environment->inServer()
) {
if ( isset($portal_user_item) ) {
$portal_user_item->setLastLoginPlugin(getCurrentDateTimeInMySQL(),$system);
$portal_user_item->setChangeModificationOnSave(false);
$portal_user_item->save();
}
}
$commsy_user_id = $portal_user_item->getItemID();
$fullname = $portal_user_item->getFullname();
$pic_url = $portal_user_item->getPictureUrl(true,false);
unset($portal_user_item);
unset($current_user_item);
$mbuser = $external_id_manager->getExternalId($system,$commsy_user_id);
if ( !empty($mbuser) ) {
示例14: undeleteLinks
function undeleteLinks($item)
{
$query = 'UPDATE ' . $this->addDatabasePrefix('link_items') . ' SET ' . 'modification_date="' . getCurrentDateTimeInMySQL() . '",' . 'deletion_date=NULL,' . 'deleter_id=NULL' . ' WHERE deletion_date>="' . encode(AS_DB, $item->getDeletionDate()) . '"' . ' AND (first_item_id="' . encode(AS_DB, $item->getItemID()) . '"' . ' OR second_item_id="' . encode(AS_DB, $item->getItemID()) . '")';
$result = $this->_db_connector->performQuery($query);
if (!isset($result) or !$result) {
include_once 'functions/error_functions.php';
trigger_error('Problems deleting (updating) links of an item from query: "' . $query . '"', E_USER_WARNING);
}
// reset cache
$this->_resetCache();
}
示例15: copyDataFromRoomToRoom
function copyDataFromRoomToRoom($old_id, $new_id, $user_id = '', $id_array = '')
{
$retour = array();
$current_date = getCurrentDateTimeInMySQL();
$current_data_array = array();
$query = '';
$query .= 'SELECT * FROM ' . $this->addDatabasePrefix($this->_db_table) . ' WHERE context_id="' . encode(AS_DB, $old_id) . '" AND deleter_id IS NULL AND deletion_date IS NULL';
$result = $this->_db_connector->performQuery($query);
if (!isset($result)) {
include_once 'functions/error_functions.php';
trigger_error('Problems getting data "' . $this->_db_table . '" from query: "' . $query . '"', E_USER_WARNING);
} else {
$item_id = 'files_id';
$modification_date = 'creation_date';
$sql = 'SELECT ' . $item_id . ',' . $modification_date . ',extras FROM ' . $this->addDatabasePrefix($this->_db_table) . ' WHERE context_id="' . encode(AS_DB, $new_id) . '"';
$sql .= ' AND extras LIKE "%s:4:\\"COPY\\";a:2:{s:7:\\"ITEM_ID\\";%"';
$sql .= ' AND deleter_id IS NULL AND deletion_date IS NULL;';
$sql_result = $this->_db_connector->performQuery($sql);
if (!isset($sql_result)) {
include_once 'functions/error_functions.php';
trigger_error('Problems getting data "' . $this->_db_table . '".', E_USER_WARNING);
} else {
foreach ($sql_result as $sql_row) {
include_once 'functions/text_functions.php';
$extra_array = mb_unserialize($sql_row['extras']);
$current_data_array[$extra_array['COPY']['ITEM_ID']] = $sql_row[$item_id];
#$current_copy_date_array[$extra_array['COPY']['ITEM_ID']] = $extra_array['COPY']['DATETIME'];
#$current_mod_date_array[$extra_array['COPY']['ITEM_ID']] = $sql_row[$modification_date];
}
}
foreach ($result as $query_result) {
$do_it = true;
if (array_key_exists($query_result['files_id'], $current_data_array)) {
$retour[CS_FILE_TYPE . $query_result['files_id']] = $current_data_array[$query_result['files_id']];
$do_it = false;
}
if ($do_it) {
$insert_query = '';
$insert_query .= 'INSERT INTO ' . $this->addDatabasePrefix($this->_db_table) . ' SET';
$first = true;
$old_item_id = '';
foreach ($query_result as $key => $value) {
$value = encode(FROM_DB, $value);
if ($key == 'files_id') {
$old_item_id = $value;
} elseif ($key == 'context_id') {
$after = $key . '="' . $new_id . '"';
} elseif ($key == 'modification_date' or $key == 'creation_date') {
$after = $key . '="' . $current_date . '"';
} elseif (!empty($user_id) and ($key == 'creator_id' or $key == 'modifier_id')) {
$after = $key . '="' . $user_id . '"';
} elseif ($key == 'deletion_date' or $key == 'deleter_id' or $key == 'material_id' or $key == 'material_vid') {
// do nothing
} elseif ($key == 'has_html' and empty($value)) {
// do nothing
} elseif ($key == 'extras' and !empty($old_item_id)) {
include_once 'functions/text_functions.php';
$extra_array = mb_unserialize($value);
$extra_array['COPY']['ITEM_ID'] = $old_item_id;
$extra_array['COPY']['COPYING_DATE'] = $current_date;
$value = serialize($extra_array);
$after = $key . '="' . encode(AS_DB, $value) . '"';
} else {
$after = $key . '="' . encode(AS_DB, $value) . '"';
}
if (!empty($after)) {
if ($first) {
$first = false;
$before = ' ';
} else {
$before = ',';
}
$insert_query .= $before . $after;
unset($after);
}
}
$result_insert = $this->_db_connector->performQuery($insert_query);
if (!isset($result_insert)) {
include_once 'functions/error_functions.php';
trigger_error('Problem creating item from query: "' . $insert_query . '"', E_USER_ERROR);
} else {
$new_item_id = $result_insert;
if (!empty($old_item_id)) {
$retour[CS_FILE_TYPE . $old_item_id] = $new_item_id;
// copy file
$disc_manager = $this->_environment->getDiscManager();
$disc_manager->setPortalID($this->_environment->getCurrentPortalID());
$file_item = $this->getItem($old_item_id);
if (!empty($file_item)) {
$result = $disc_manager->copyFileFromRoomToRoom($old_id, $old_item_id, $file_item->getFileName(), $new_id, $new_item_id);
if (!$result) {
//include_once('functions/error_functions.php');
//trigger_error('can not copy file on disc',E_USER_ERROR);
}
} else {
include_once 'functions/error_functions.php';
trigger_error('can not get old file item', E_USER_ERROR);
}
unset($file_item);
unset($disc_manager);
//.........这里部分代码省略.........