Пример #1
0
 /**
  * object insert to trash
  * @param TrashVO $obj
  * @return Object
  */
 function insertTrash($obj)
 {
     $logged_info = Context::get('logged_info');
     $oTrashVO = new TrashVO();
     $oTrashVO =& $obj;
     if (!$oTrashVO->getTrashSrl()) {
         $oTrashVO->setTrashSrl(getNextSequence());
     }
     if (!is_string($oTrashVO->getSerializedObject())) {
         $oTrashVO->setSerializedObject(serialize($oTrashVO->getSerializedObject()));
     }
     $oTrashVO->setIpaddress($_SERVER['REMOTE_ADDR']);
     $oTrashVO->setRemoverSrl($logged_info->member_srl);
     $oTrashVO->setRegdate(date('YmdHis'));
     return executeQuery('trash.insertTrash', $oTrashVO);
 }
Пример #2
0
 /**
  * Move the doc into the trash
  * @param object $obj
  * @return object
  */
 function moveDocumentToTrash($obj)
 {
     $logged_info = Context::get('logged_info');
     $trash_args = new stdClass();
     // Get trash_srl if a given trash_srl doesn't exist
     if (!$obj->trash_srl) {
         $trash_args->trash_srl = getNextSequence();
     } else {
         $trash_args->trash_srl = $obj->trash_srl;
     }
     // Get its module_srl which the document belongs to
     $oDocumentModel = getModel('document');
     $oDocument = $oDocumentModel->getDocument($obj->document_srl);
     $oMemberModel = getModel('member');
     $member_info = $oMemberModel->getMemberInfoByMemberSrl($oDocument->get('member_srl'));
     if ($member_info->is_admin == 'Y' && $logged_info->is_admin != 'Y') {
         return new Object(-1, 'msg_admin_document_no_move_to_trash');
     }
     $trash_args->module_srl = $oDocument->get('module_srl');
     $obj->module_srl = $oDocument->get('module_srl');
     // Cannot throw data from the trash to the trash
     if ($trash_args->module_srl == 0) {
         return false;
     }
     // Data setting
     $trash_args->document_srl = $obj->document_srl;
     $trash_args->description = $obj->description;
     // Insert member's information only if the member is logged-in and not manually registered.
     if (Context::get('is_logged')) {
         $logged_info = Context::get('logged_info');
         $trash_args->member_srl = $logged_info->member_srl;
         // user_id, user_name and nick_name already encoded
         $trash_args->user_id = htmlspecialchars_decode($logged_info->user_id);
         $trash_args->user_name = htmlspecialchars_decode($logged_info->user_name);
         $trash_args->nick_name = htmlspecialchars_decode($logged_info->nick_name);
     }
     // Date setting for updating documents
     $document_args = new stdClass();
     $document_args->module_srl = 0;
     $document_args->document_srl = $obj->document_srl;
     // begin transaction
     $oDB =& DB::getInstance();
     $oDB->begin();
     /*$output = executeQuery('document.insertTrash', $trash_args);
       if (!$output->toBool()) {
       $oDB->rollback();
       return $output;
       }*/
     // new trash module
     require_once _XE_PATH_ . 'modules/trash/model/TrashVO.php';
     $oTrashVO = new TrashVO();
     $oTrashVO->setTrashSrl(getNextSequence());
     $oTrashVO->setTitle($oDocument->variables['title']);
     $oTrashVO->setOriginModule('document');
     $oTrashVO->setSerializedObject(serialize($oDocument->variables));
     $oTrashVO->setDescription($obj->description);
     $oTrashAdminController = getAdminController('trash');
     $output = $oTrashAdminController->insertTrash($oTrashVO);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     $output = executeQuery('document.deleteDocument', $trash_args);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     /*$output = executeQuery('document.updateDocument', $document_args);
       if (!$output->toBool()) {
       $oDB->rollback();
       return $output;
       }*/
     // update category
     if ($oDocument->get('category_srl')) {
         $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
     }
     // remove thumbnails
     FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
     // Set the attachment to be invalid state
     if ($oDocument->hasUploadedFiles()) {
         $args = new stdClass();
         $args->upload_target_srl = $oDocument->document_srl;
         $args->isvalid = 'N';
         executeQuery('file.updateFileValid', $args);
     }
     // Call a trigger (after)
     ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj);
     // commit
     $oDB->commit();
     // Clear cache
     Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($oDocument->document_srl) . $oDocument->document_srl);
     return $output;
 }
 /**
  * comment move to trash
  * @return void|object
  */
 function _moveCommentToTrash($commentSrlList, &$oCommentController, &$oDB, $message_content = NULL)
 {
     require_once _XE_PATH_ . 'modules/trash/model/TrashVO.php';
     if (is_array($commentSrlList)) {
         $logged_info = Context::get('logged_info');
         $oCommentModel = getModel('comment');
         $commentItemList = $oCommentModel->getComments($commentSrlList);
         $oTrashAdminController = getAdminController('trash');
         foreach ($commentItemList as $key => $oComment) {
             $oTrashVO = new TrashVO();
             $oTrashVO->setTrashSrl(getNextSequence());
             $oTrashVO->setTitle(trim(strip_tags($oComment->variables['content'])));
             $oTrashVO->setOriginModule('comment');
             $oTrashVO->setSerializedObject(serialize($oComment->variables));
             $oTrashVO->setDescription($message_content);
             $output = $oTrashAdminController->insertTrash($oTrashVO);
             if (!$output->toBool()) {
                 $oDB->rollback();
                 return $output;
             }
         }
     }
 }
Пример #4
0
 /**
  * Move the doc into the trash
  * @param object $obj
  * @return object
  */
 function moveDocumentToTrash($obj)
 {
     // Get trash_srl if a given trash_srl doesn't exist
     if (!$obj->trash_srl) {
         $trash_args->trash_srl = getNextSequence();
     } else {
         $trash_args->trash_srl = $obj->trash_srl;
     }
     // Get its module_srl which the document belongs to
     $oDocumentModel =& getModel('document');
     $oDocument = $oDocumentModel->getDocument($obj->document_srl);
     $trash_args->module_srl = $oDocument->get('module_srl');
     $obj->module_srl = $oDocument->get('module_srl');
     // Cannot throw data from the trash to the trash
     if ($trash_args->module_srl == 0) {
         return false;
     }
     // Data setting
     $trash_args->document_srl = $obj->document_srl;
     $trash_args->description = $obj->description;
     // Insert member's information only if the member is logged-in and not manually registered.
     if (Context::get('is_logged') && !$manual_inserted) {
         $logged_info = Context::get('logged_info');
         $trash_args->member_srl = $logged_info->member_srl;
         $trash_args->user_id = $logged_info->user_id;
         $trash_args->user_name = $logged_info->user_name;
         $trash_args->nick_name = $logged_info->nick_name;
     }
     // Date setting for updating documents
     $document_args->module_srl = 0;
     $document_args->document_srl = $obj->document_srl;
     // begin transaction
     $oDB =& DB::getInstance();
     $oDB->begin();
     /*$output = executeQuery('document.insertTrash', $trash_args);
     		if (!$output->toBool()) {
     			$oDB->rollback();
     			return $output;
     		}*/
     // new trash module
     require_once _XE_PATH_ . 'modules/trash/model/TrashVO.php';
     $oTrashVO = new TrashVO();
     $oTrashVO->setTrashSrl(getNextSequence());
     $oTrashVO->setTitle($oDocument->variables['title']);
     $oTrashVO->setOriginModule('document');
     $oTrashVO->setSerializedObject(serialize($oDocument->variables));
     $oTrashVO->setDescription($obj->description);
     $oTrashAdminController =& getAdminController('trash');
     $output = $oTrashAdminController->insertTrash($oTrashVO);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     $output = executeQuery('document.deleteDocument', $trash_args);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     /*$output = executeQuery('document.updateDocument', $document_args);
     		if (!$output->toBool()) {
     			$oDB->rollback();
     			return $output;
     		}*/
     // update category
     if ($oDocument->get('category_srl')) {
         $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
     }
     // remove thumbnails
     FileHandler::removeDir(sprintf('files/cache/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
     // Set the attachment to be invalid state
     if ($oDocument->hasUploadedFiles()) {
         $args->upload_target_srl = $oDocument->document_srl;
         $args->isvalid = 'N';
         executeQuery('file.updateFileValid', $args);
     }
     // Call a trigger (after)
     if ($output->toBool()) {
         $trigger_output = ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj);
         if (!$trigger_output->toBool()) {
             $oDB->rollback();
             return $trigger_output;
         }
     }
     // commit
     $oDB->commit();
     // Clear cache
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $oCacheHandler->invalidateGroupKey('documentList');
     }
     return $output;
 }
Пример #5
0
 /**
  * Set trash object from std object
  * @param TrashVO $oTrashVO
  * @param object $stdObject
  * @return void
  */
 function _setTrashObject(&$oTrashVO, $stdObject)
 {
     $oTrashVO->setTrashSrl($stdObject->trash_srl);
     $oTrashVO->setTitle($stdObject->title);
     $oTrashVO->setOriginModule($stdObject->origin_module);
     $oTrashVO->setSerializedObject($stdObject->serialized_object);
     $oTrashVO->setUnserializedObject($stdObject->serialized_object);
     $oTrashVO->setDescription($stdObject->description);
     $oTrashVO->setIpaddress($stdObject->ipaddress);
     $oTrashVO->setRemoverSrl($stdObject->remover_srl);
     $oTrashVO->setUserId($stdObject->user_id);
     $oTrashVO->setNickName($stdObject->nick_name);
     $oTrashVO->setRegdate($stdObject->regdate);
 }