/** * Get single instance of ModuleHandler */ public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
function init() { // forbit access if the user is not an administrator if (!$this->grant->manager && !$this->grant->is_admin) { return $this->stop("msg_is_not_administrator"); } // change into administration layout //$this->setTemplatePath('./modules/cympusadmin/tpl'); $this->setLayoutPath('./modules/cympusadmin/tpl'); $this->setLayoutFile(_CYMPUSADMIN_LAYOUT_); Context::loadLang(_XE_PATH_ . 'modules/cympusadmin/lang/'); if ($this->grant->is_admin) { // parse admin menu $oXmlParser = new XmlParser(); $xml_obj = $oXmlParser->loadXmlFile('./modules/cympusadmin/conf/' . _CYMPUSADMIN_MENU_); $admin_menu = cympusadmin::getMenu($xml_obj->menu->item); Context::set('cympusadmin_menu', $admin_menu); } else { $output = ModuleHandler::triggerCall('cympusadmin.getManagerMenu', 'before', $manager_menu); if (!$output->toBool()) { return $output; } Context::set('cympusadmin_menu', $manager_menu); } $news = getNewsFromAgency(); Context::set('news', $news); Context::set('admin_bar', 'false'); $oModuleModel =& getModel('module'); $module_info = $oModuleModel->getModuleInfoXml('cympusadmin'); Context::set('cympus_modinfo', $module_info); return new Object(); }
/** * Constructor */ protected function __construct() { global $section, $action; parent::__construct(__FILE__); // register backend if (class_exists('backend')) { $backend = backend::getInstance(); $import_menu = $backend->getMenu('shop_import'); if (!is_null($import_menu)) { $import_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_import_items'), url_GetFromFilePath($this->path . 'images/import.svg'), window_Open('shop_import_items', 350, $this->getLanguageConstant('title_import_items'), true, true, backend_UrlMake($this->name, 'import')), 6)); $import_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_import_english'), url_GetFromFilePath($this->path . 'images/import.svg'), window_Open('shop_import_items', 350, $this->getLanguageConstant('title_import_items'), true, true, backend_UrlMake($this->name, 'import_english')), 6)); } } // register delivery method and create menu items if (ModuleHandler::is_loaded('backend') && ModuleHandler::is_loaded('shop')) { require_once 'units/method.php'; require_once 'units/pickup_method.php'; Paid_DeliveryMethod::getInstance($this); Pickup_DeliveryMethod::getInstance($this); } if (ModuleHandler::is_loaded('head_tag') && $section == 'shop' && $action == 'checkout') { $head_tag = head_tag::getInstance(); $head_tag->addTag('script', array('src' => url_GetFromFilePath($this->path . 'include/pikaday.js'), 'type' => 'text/javascript')); $head_tag->addTag('link', array('href' => url_GetFromFilePath($this->path . 'include/pikaday.css'), 'rel' => 'stylesheet', 'type' => 'text/css')); $head_tag->addTag('link', array('href' => url_GetFromFilePath($this->path . 'include/checkout.css'), 'rel' => 'stylesheet', 'type' => 'text/css')); } if (ModuleHandler::is_loaded('backend') && ModuleHandler::is_loaded('head_tag') && $section == 'backend') { $head_tag = head_tag::getInstance(); $head_tag->addTag('script', array('src' => url_GetFromFilePath($this->path . 'include/backend.js'), 'type' => 'text/javascript')); } // connect transaction handling event Events::connect('shop', 'transaction-completed', 'on_transaction_completed', $this); }
function dispMemberSignUpForm() { $oMemberModel =& getModel('member'); if ($oMemberModel->isLogged()) { return $this->stop('msg_already_logged'); } $trigger_output = ModuleHandler::triggerCall('member.dispMemberSignUpForm', 'before', $this->member_config); if (!$trigger_output->toBool()) { return $trigger_output; } if ($this->member_config->enable_join != 'Y') { return $this->stop('msg_signup_disabled'); } $oMemberAdminView =& getAdminView('member'); $formTags = $oMemberAdminView->_getMemberInputTag($member_info); Context::set('formTags', $formTags); $member_config = $oMemberModel->getMemberConfig(); Context::set('member_config', $member_config); global $lang; $identifierForm->title = $lang->{$member_config->identifier}; $identifierForm->name = $member_config->identifier; $identifierForm->value = $member_info->{$member_config->identifier}; Context::set('identifierForm', $identifierForm); // Set a template file $this->setTemplateFile('signup_form'); }
/** * Perform database initialization. * * @param boolean $create_database * @return boolean */ function database_initialize($create_database) { global $db, $db_config, $data_path; $result = false; $database_exists = false; $sql_file = 'units/database/init.sql'; $xml_file = $data_path . 'system_init.xml'; if (!file_exists($sql_file) || !file_exists($xml_file)) { trigger_error('Can not initialize database, missing configuration!', E_USER_ERROR); return $result; } // make a log entry trigger_error('Initializing database: ' . $db_config['name'], E_USER_NOTICE); // get initialization SQL $sql = file_get_contents($sql_file); // create database if needed if ($create_database) { try { $db->create($db_config['name']); $db->select($db_config['name']); $database_exists = true; } catch (Exception $error) { $database_exists = false; } } else { $database_exists = true; } // create database if ($database_exists && $db->multi_query($sql)) { $module_manager = ModuleManager::getInstance(); $module_handler = ModuleHandler::getInstance(); $admin_manager = UserManager::getInstance(); // populate tables $raw_data = file_get_contents($xml_file); $data = new XMLParser($raw_data, $xml_file); $data->parse(); // go over XML file and insert data foreach ($data->document->tagChildren as $item) { switch ($item->tagName) { case 'module': // insert data $module_manager->insertData(array('name' => $item->tagAttrs['name'], 'order' => $item->tagAttrs['order'], 'preload' => $item->tagAttrs['preload'] == 'yes' ? 1 : 0, 'active' => 1)); // initialize module $module = $module_handler->_loadModule($item->tagAttrs['name']); if (!is_null($module)) { $module->onInit(); } break; case 'user': $salt = hash('sha256', UserManager::SALT . strval(time())); $password = hash_hmac('sha256', $item->tagAttrs['password'], $salt); $admin_manager->insertData(array('username' => $item->tagAttrs['username'], 'password' => $password, 'fullname' => $item->tagAttrs['fullname'], 'level' => $item->tagAttrs['level'], 'verified' => 1, 'salt' => $salt)); break; } } // set result $result = true; } return $result; }
/** * display the pop-up menu of the post * Print, scrap, vote-up(recommen), vote-down(non-recommend), report features added * @return void */ function getCommentMenu() { // get the post's id number and the current login information $comment_srl = Context::get('target_srl'); $mid = Context::get('cur_mid'); $logged_info = Context::get('logged_info'); $act = Context::get('cur_act'); // array values for menu_list, "comment post, target, url" $menu_list = array(); // call a trigger ModuleHandler::triggerCall('comment.getCommentMenu', 'before', $menu_list); $oCommentController =& getController('comment'); // feature that only member can do if ($logged_info->member_srl) { $oCommentModel =& getModel('comment'); $columnList = array('comment_srl', 'module_srl', 'member_srl', 'ipaddress'); $oComment = $oCommentModel->getComment($comment_srl, false, $columnList); $module_srl = $oComment->get('module_srl'); $member_srl = $oComment->get('member_srl'); $oModuleModel =& getModel('module'); $comment_config = $oModuleModel->getModulePartConfig('document', $module_srl); if ($comment_config->use_vote_up != 'N' && $member_srl != $logged_info->member_srl) { // Add a vote-up button for positive feedback $url = sprintf("doCallModuleAction('comment','procCommentVoteUp','%s')", $comment_srl); $oCommentController->addCommentPopupMenu($url, 'cmd_vote', '', 'javascript'); } if ($comment_config->use_vote_down != 'N' && $member_srl != $logged_info->member_srl) { // Add a vote-down button for negative feedback $url = sprintf("doCallModuleAction('comment','procCommentVoteDown','%s')", $comment_srl); $oCommentController->addCommentPopupMenu($url, 'cmd_vote_down', '', 'javascript'); } // Add the report feature against abused posts $url = sprintf("doCallModuleAction('comment','procCommentDeclare','%s')", $comment_srl); $oCommentController->addCommentPopupMenu($url, 'cmd_declare', '', 'javascript'); } // call a trigger (after) ModuleHandler::triggerCall('comment.getCommentMenu', 'after', $menu_list); // find a comment by IP matching if an administrator. if ($logged_info->is_admin == 'Y') { $oCommentModel =& getModel('comment'); $oComment = $oCommentModel->getComment($comment_srl); if ($oComment->isExists()) { // Find a post of the corresponding ip address $url = getUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'ipaddress', 'search_keyword', $oComment->getIpAddress()); $oCommentController->addCommentPopupMenu($url, 'cmd_search_by_ipaddress', $icon_path, 'TraceByIpaddress'); $url = sprintf("var params = new Array(); params['ipaddress_list']='%s'; exec_xml('spamfilter', 'procSpamfilterAdminInsertDeniedIP', params, completeCallModuleAction)", $oComment->getIpAddress()); $oCommentController->addCommentPopupMenu($url, 'cmd_add_ip_to_spamfilter', '', 'javascript'); } } // Changing a language of pop-up menu $menus = Context::get('comment_popup_menu_list'); $menus_count = count($menus); for ($i = 0; $i < $menus_count; $i++) { $menus[$i]->str = Context::getLang($menus[$i]->str); } // get a list of final organized pop-up menus $this->add('menus', $menus); }
function dispBoardMessage($msg_code) { $msg = Context::getLang($msg_code); $oMessageObject =& ModuleHandler::getModuleInstance('message', 'mobile'); $oMessageObject->setError(-1); $oMessageObject->setMessage($msg); $oMessageObject->dispMessage(); $this->setTemplatePath($oMessageObject->getTemplatePath()); $this->setTemplateFile($oMessageObject->getTemplateFile()); }
/** * @brief 선택된 게시물의 팝업메뉴 표시 * * 인쇄, 스크랩, 추천, 비추천, 신고 기능 추가 **/ function getCommentMenu() { // 요청된 게시물 번호와 현재 로그인 정보 구함 $comment_srl = Context::get('target_srl'); $mid = Context::get('cur_mid'); $logged_info = Context::get('logged_info'); $act = Context::get('cur_act'); // menu_list 에 "표시할글,target,url" 을 배열로 넣는다 $menu_list = array(); // trigger 호출 ModuleHandler::triggerCall('comment.getCommentMenu', 'before', $menu_list); $oCommentController =& getController('comment'); // 회원이어야만 가능한 기능 if ($logged_info->member_srl) { // 추천 버튼 추가 $url = sprintf("doCallModuleAction('comment','procCommentVoteUp','%s')", $comment_srl); $oCommentController->addCommentPopupMenu($url, 'cmd_vote', './modules/document/tpl/icons/vote_up.gif', 'javascript'); // 비추천 버튼 추가 $url = sprintf("doCallModuleAction('comment','procCommentVoteDown','%s')", $comment_srl); $oCommentController->addCommentPopupMenu($url, 'cmd_vote_down', './modules/document/tpl/icons/vote_down.gif', 'javascript'); // 신고 기능 추가 $url = sprintf("doCallModuleAction('comment','procCommentDeclare','%s')", $comment_srl); $oCommentController->addCommentPopupMenu($url, 'cmd_declare', './modules/document/tpl/icons/declare.gif', 'javascript'); } // trigger 호출 (after) ModuleHandler::triggerCall('comment.getCommentMenu', 'after', $menu_list); // 관리자일 경우 ip로 글 찾기 if ($logged_info->is_admin == 'Y') { $oCommentModel =& getModel('comment'); $oComment = $oCommentModel->getComment($comment_srl); if ($oComment->isExists()) { // ip주소에 해당하는 글 찾기 $url = getUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'ipaddress', 'search_keyword', $oComment->get('ipaddress')); $icon_path = './modules/member/tpl/images/icon_management.gif'; $oCommentController->addCommentPopupMenu($url, 'cmd_search_by_ipaddress', $icon_path, 'TraceByIpaddress'); $url = sprintf("var params = new Array(); params['ipaddress']='%s'; exec_xml('spamfilter', 'procSpamfilterAdminInsertDeniedIP', params, completeCallModuleAction)", $oComment->getIpAddress()); $oCommentController->addCommentPopupMenu($url, 'cmd_add_ip_to_spamfilter', './modules/document/tpl/icons/declare.gif', 'javascript'); } } // 팝업메뉴의 언어 변경 $menus = Context::get('comment_popup_menu_list'); $menus_count = count($menus); for ($i = 0; $i < $menus_count; $i++) { $menus[$i]->str = Context::getLang($menus[$i]->str); } // 최종적으로 정리된 팝업메뉴 목록을 구함 $this->add('menus', $menus); }
function init($module = null) { // change into administration layout $config = getModel('cympusadmin')->getConfig(); $args = new stdClass(); $args->module = 'cympusadmin'; $module_list = getModel('module')->getModuleSrlList($args); if (!empty($module_list)) { foreach ($module_list as $module_info) { $cympus_module_info = $module_info; } } $module_path = './modules/cympusadmin/'; $template_path = sprintf("%sskins/%s/", $module_path, $cympus_module_info->skin); if (!is_dir($template_path) || !$cympus_module_info->skin) { $config->admin_skins = 'default'; $template_path = sprintf("%sskins/%s/", $module_path, $cympus_module_info->skin); } if ($module) { $module->setLayoutPath($template_path); $module->setLayoutFile(_CYMPUSADMIN_LAYOUT_); } else { $this->setLayoutPath($template_path); $this->setLayoutFile(_CYMPUSADMIN_LAYOUT_); } Context::loadLang(_XE_PATH_ . 'modules/cympusadmin/lang/'); $logged_info = Context::get('logged_info'); if ($logged_info->is_admin == 'Y') { // parse admin menu $oXmlParser = new XmlParser(); $xml_obj = $oXmlParser->loadXmlFile('./modules/cympusadmin/conf/' . _CYMPUSADMIN_MENU_); $admin_menu = cympusadmin::getMenu($xml_obj->menu->item); Context::set('cympusadmin_menu', $admin_menu); } else { $output = ModuleHandler::triggerCall('cympusadmin.getManagerMenu', 'before', $manager_menu); if (!$output->toBool()) { return $output; } Context::set('cympusadmin_menu', $manager_menu); } $news = getNewsFromAgency(); Context::set('news', $news); Context::set('admin_bar', 'false'); $oModuleModel = getModel('module'); $module_info = $oModuleModel->getModuleInfoXml('cympusadmin'); Context::set('cympus_modinfo', $module_info); return new Object(); }
/** * @brief get textyle custom menu **/ function getTextyleCustomMenu() { static $custom_menu = null; if (is_null($custom_menu)) { $oModuleModel =& getModel('module'); $config = $oModuleModel->getModuleConfig('textyle'); $custom_menu->hidden_menu = $config->hidden_menu; if (!$custom_menu->hidden_menu) { $custom_menu->hidden_menu = array(); } $custom_menu->attached_menu = $config->attached_menu; if (!$custom_menu->attached_menu) { $custom_menu->attached_menu = array(); } } $output = ModuleHandler::triggerCall('textyle.getTextyleCustomMenu', 'after', $custom_menu); if (!$output->toBool()) { return $output; } return $custom_menu; }
/** * @brief additional configuration support **/ function dispPlanetAdminAdditionalSetup() { $output = ModuleHandler::triggerCall('module.dispAdditionSetup', 'before', $content); $output = ModuleHandler::triggerCall('module.dispAdditionSetup', 'after', $content); Context::set('setup_content', $content); // 템플릿 파일 지정 $this->setTemplateFile('additional_setup'); }
/** * @brief Display member join form */ function dispMemberSignUpForm() { //setcookie for redirect url in case of going to member sign up setcookie("XE_REDIRECT_URL", $_SERVER['HTTP_REFERER']); $member_config = $this->member_config; $oMemberModel = getModel('member'); // Get the member information if logged-in if ($oMemberModel->isLogged()) { return $this->stop('msg_already_logged'); } // call a trigger (before) $trigger_output = ModuleHandler::triggerCall('member.dispMemberSignUpForm', 'before', $member_config); if (!$trigger_output->toBool()) { return $trigger_output; } // Error appears if the member is not allowed to join if ($member_config->enable_join != 'Y') { return $this->stop('msg_signup_disabled'); } $oMemberAdminView = getAdminView('member'); $formTags = $oMemberAdminView->_getMemberInputTag($member_info); Context::set('formTags', $formTags); global $lang; $identifierForm = new stdClass(); $identifierForm->title = $lang->{$member_config->identifier}; $identifierForm->name = $member_config->identifier; $identifierForm->value = $member_info->{$member_config->identifier}; Context::set('identifierForm', $identifierForm); $this->addExtraFormValidatorMessage(); // Set a template file $this->setTemplateFile('signup_form'); }
/** * Restore document from trash module, called by trash module * This method is passived * @param object|array $originObject * @return object */ function restoreTrash($originObject) { if (is_array($originObject)) { $originObject = (object) $originObject; } $oDocumentController = getController('document'); $oDocumentModel = getModel('document'); $oDB =& DB::getInstance(); $oDB->begin(); //DB restore $output = $oDocumentController->insertDocument($originObject, false, true, false); if (!$output->toBool()) { return new Object(-1, $output->getMessage()); } //FILE restore $oDocument = $oDocumentModel->getDocument($originObject->document_srl); // If the post was not temorarily saved, set the attachment's status to be valid if ($oDocument->hasUploadedFiles() && $originObject->member_srl != $originObject->module_srl) { $args = new stdClass(); $args->upload_target_srl = $oDocument->document_srl; $args->isvalid = 'Y'; $output = executeQuery('file.updateFileValid', $args); } // call a trigger (after) if ($output->toBool()) { $trigger_output = ModuleHandler::triggerCall('document.restoreTrash', 'after', $originObject); if (!$trigger_output->toBool()) { $oDB->rollback(); return $trigger_output; } } // commit $oDB->commit(); return new Object(0, 'success'); }
function deleteMaterial($material_srl) { if (strpos($material_srl, ',') === false) { $args->material_srl = $material_srl; } else { $args->material_srls = $material_srl; } $output = executeQuery('material.deleteMaterial', $args); // delete thumnail image $oFileModel =& getModel('file'); $file_list = array(); if (strpos(',', $material_srl) === false) { $file_list = $oFileModel->getFiles($material_srl); } else { $material_srls = explode(',', $material_srl); foreach ($material_srls as $srl) { $files = $oFileModel->getFiles($srl); if ($files) { $file_list = array_merge($file_list, $files); } } } if (count($file_list)) { foreach ($file_list as $k => $file) { $ext = substr(strrchr($file->source_filename, '.'), 1); $_filename = sprintf("%s%s.%%s.%s", preg_replace("/\\/[^\\/]*\$/", "/", $file->uploaded_filename), $material_srl, $ext); $s_filename = sprintf($_filename, 'S'); $l_filename = sprintf($_filename, 'L'); FileHandler::removeFile($s_filename); FileHandler::removeFile($l_filename); } } $obj->document_srl = $material_srl; // trigger 호출 (after) if ($output->toBool()) { $trigger_output = ModuleHandler::triggerCall('material.deleteMaterial', 'after', $obj); if (!$trigger_output->toBool()) { return $trigger_output; } } return $output; }
/** * Report posts * @param int $document_srl * @param string $declare_message * @return void|Object */ function declaredDocument($document_srl, $declare_message = '') { // Fail if session information already has a reported document if ($_SESSION['declared_document'][$document_srl]) { return new Object(-1, 'failed_declared'); } // Check if previously reported $args = new stdClass(); $args->document_srl = $document_srl; $output = executeQuery('document.getDeclaredDocument', $args); if (!$output->toBool()) { return $output; } $declared_count = $output->data->declared_count ? $output->data->declared_count : 0; $trigger_obj = new stdClass(); $trigger_obj->document_srl = $document_srl; $trigger_obj->declared_count = $declared_count; // Call a trigger (before) $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj); if (!$trigger_output->toBool()) { return $trigger_output; } // Get the original document $oDocumentModel = getModel('document'); $oDocument = $oDocumentModel->getDocument($document_srl, false, false); // Pass if the author's IP address is as same as visitor's. if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { $_SESSION['declared_document'][$document_srl] = true; return new Object(-1, 'failed_declared'); } // Check if document's author is a member. if ($oDocument->get('member_srl')) { // Create a member model object $oMemberModel = getModel('member'); $member_srl = $oMemberModel->getLoggedMemberSrl(); // Pass after registering a session if author's information is same as the currently logged-in user's. if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) { $_SESSION['declared_document'][$document_srl] = true; return new Object(-1, 'failed_declared'); } } // Use member_srl for logged-in members and IP address for non-members. $args = new stdClass(); if ($member_srl) { $args->member_srl = $member_srl; } else { $args->ipaddress = $_SERVER['REMOTE_ADDR']; } $args->document_srl = $document_srl; $args->declare_message = trim(htmlspecialchars($declare_message)); $output = executeQuery('document.getDocumentDeclaredLogInfo', $args); // Pass after registering a sesson if reported/declared documents are in the logs. if ($output->data->count) { $_SESSION['declared_document'][$document_srl] = true; return new Object(-1, 'failed_declared'); } // begin transaction $oDB =& DB::getInstance(); $oDB->begin(); // Add the declared document if ($declared_count > 0) { $output = executeQuery('document.updateDeclaredDocument', $args); } else { $output = executeQuery('document.insertDeclaredDocument', $args); } if (!$output->toBool()) { $oDB->rollback(); return $output; } // Leave logs $output = executeQuery('document.insertDocumentDeclaredLog', $args); if (!$output->toBool()) { $oDB->rollback(); return $output; } $this->add('declared_count', $declared_count + 1); // Call a trigger (after) $trigger_obj->declared_count = $declared_count + 1; ModuleHandler::triggerCall('document.declaredDocument', 'after', $trigger_obj); // commit $oDB->commit(); // Leave in the session information $_SESSION['declared_document'][$document_srl] = true; $this->setMessage('success_declared'); }
/** * Report a blamed comment * @param $comment_srl * @return void */ function declaredComment($comment_srl) { // Fail if session information already has a reported document if ($_SESSION['declared_comment'][$comment_srl]) { return new Object(-1, 'failed_declared'); } // check if already reported $args = new stdClass(); $args->comment_srl = $comment_srl; $output = executeQuery('comment.getDeclaredComment', $args); if (!$output->toBool()) { return $output; } $declared_count = $output->data->declared_count ? $output->data->declared_count : 0; $trigger_obj = new stdClass(); $trigger_obj->comment_srl = $comment_srl; $trigger_obj->declared_count = $declared_count; // Call a trigger (before) $trigger_output = ModuleHandler::triggerCall('comment.declaredComment', 'before', $trigger_obj); if (!$trigger_output->toBool()) { return $trigger_output; } // get the original comment $oCommentModel = getModel('comment'); $oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE); // failed if both ip addresses between author's and the current user are same. if ($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { $_SESSION['declared_comment'][$comment_srl] = TRUE; return new Object(-1, 'failed_declared'); } // if the comment author is a member if ($oComment->get('member_srl')) { // create the member model object $oMemberModel = getModel('member'); $member_srl = $oMemberModel->getLoggedMemberSrl(); // session registered if the author information matches to the current logged-in user's. if ($member_srl && $member_srl == $oComment->get('member_srl')) { $_SESSION['declared_comment'][$comment_srl] = TRUE; return new Object(-1, 'failed_declared'); } } // If logged-in, use the member_srl. otherwise use the ipaddress. if ($member_srl) { $args->member_srl = $member_srl; } else { $args->ipaddress = $_SERVER['REMOTE_ADDR']; } $args->comment_srl = $comment_srl; $log_output = executeQuery('comment.getCommentDeclaredLogInfo', $args); // session registered if log info contains report log. if ($log_output->data->count) { $_SESSION['declared_comment'][$comment_srl] = TRUE; return new Object(-1, 'failed_declared'); } // begin transaction $oDB =& DB::getInstance(); $oDB->begin(); // execute insert if ($output->data->declared_count > 0) { $output = executeQuery('comment.updateDeclaredComment', $args); } else { $output = executeQuery('comment.insertDeclaredComment', $args); } if (!$output->toBool()) { $oDB->rollback(); return $output; } // leave the log $output = executeQuery('comment.insertCommentDeclaredLog', $args); // Call a trigger (after) $trigger_obj->declared_count = $declared_count + 1; $trigger_output = ModuleHandler::triggerCall('comment.declaredComment', 'after', $trigger_obj); if (!$trigger_output->toBool()) { $oDB->rollback(); return $trigger_output; } $oDB->commit(); // leave into the session information $_SESSION['declared_comment'][$comment_srl] = TRUE; $this->setMessage('success_declared'); }
/** * @brief display the additional setup panel * additonal setup panel is for connecting the service modules with other modules **/ function dispBoardAdminBoardAdditionSetup() { // sice content is obtained from other modules via call by reference, declare it first $content = ''; // get the addtional setup trigger // the additional setup triggers can be used in many modules $output = ModuleHandler::triggerCall('module.dispAdditionSetup', 'before', $content); $output = ModuleHandler::triggerCall('module.dispAdditionSetup', 'after', $content); Context::set('setup_content', $content); // setup the template file $this->setTemplateFile('addition_setup'); }
/** * Get content of real module * * @param string $module module name * @param string $mid module id * @param string $skin skin name * @param string $skinType PC(P) or mobile(M) * @return string content of real module */ private function procRealModule($module, $mid, $skin, $skinType) { // if form site design and preview module, find target module if ($module && !$mid) { $args = new stdClass(); $args->module = $module; $output = executeQuery('layout.getOneModuleInstanceByModuleName', $args); if (!$output->toBool()) { throw new Exception($output->getMessage()); } // if there is no module instance, error... if (!$output->data) { throw new Exception(Context::getLang('msg_unabled_preview')); } $mid = current($output->data)->mid; } elseif (!$module && !$mid) { $oModuleModel = getModel('module'); $columnList = array('modules.mid', 'sites.index_module_srl'); $startModuleInfo = $oModuleModel->getSiteInfo(0, $columnList); $mid = $startModuleInfo->mid; } $oModuleHandler = new ModuleHandler('', '', $mid, '', ''); // Adhoc... $oModuleHandler->act = ''; $oModuleHandler->init(); // Adhoc... $oModuleHandler->module_info->use_mobile = 'Y'; $oModuleHandler->module_info->is_skin_fix = 'Y'; $oModuleHandler->module_info->is_mskin_fix = 'Y'; if ($skinType == 'M') { Mobile::setMobile(TRUE); $oModuleHandler->module_info->mskin = $skin; } else { Mobile::setMobile(FALSE); $oModuleHandler->module_info->skin = $skin; } // Proc module $oModule = $oModuleHandler->procModule(); if (!$oModule->toBool()) { throw new Exception(Context::getLang('not_support_layout_preview')); } // get module html require_once _XE_PATH_ . "classes/display/HTMLDisplayHandler.php"; $handler = new HTMLDisplayHandler(); return $handler->toDoc($oModule); }
/** * Search Result * * @return Object */ function IS() { $oFile = getClass('file'); $oModuleModel = getModel('module'); $logged_info = Context::get('logged_info'); // Check permissions if (!$this->grant->access) { return new Object(-1, 'msg_not_permitted'); } $config = $oModuleModel->getModuleConfig('integration_search'); if (!$config) { $config = new stdClass(); } if (!$config->skin) { $config->skin = 'default'; $template_path = sprintf('%sskins/%s', $this->module_path, $config->skin); } else { //check theme $config_parse = explode('|@|', $config->skin); if (count($config_parse) > 1) { $template_path = sprintf('./themes/%s/modules/integration_search/', $config_parse[0]); } else { $template_path = sprintf('%sskins/%s', $this->module_path, $config->skin); } } // Template path $this->setTemplatePath($template_path); $skin_vars = $config->skin_vars ? unserialize($config->skin_vars) : new stdClass(); Context::set('module_info', $skin_vars); $target = $config->target; if (!$target) { $target = 'include'; } if (empty($config->target_module_srl)) { $module_srl_list = array(); } else { $module_srl_list = explode(',', $config->target_module_srl); } // https://github.com/xpressengine/xe-core/issues/1522 // 검색 대상을 지정하지 않았을 때 검색 제한 if ($target === 'include' && !count($module_srl_list)) { $oMessageObject = ModuleHandler::getModuleInstance('message'); $oMessageObject->setError(-1); $oMessageObject->setMessage('msg_not_enabled'); $oMessageObject->dispMessage(); $this->setTemplatePath($oMessageObject->getTemplatePath()); $this->setTemplateFile($oMessageObject->getTemplateFile()); return; } // Set a variable for search keyword $is_keyword = Context::get('is_keyword'); // Set page variables $page = (int) Context::get('page'); if (!$page) { $page = 1; } // Search by search tab $where = Context::get('where'); // Create integration search model object if ($is_keyword) { $oIS = getModel('integration_search'); switch ($where) { case 'document': $search_target = Context::get('search_target'); if (!in_array($search_target, array('title', 'content', 'title_content', 'tag'))) { $search_target = 'title'; } Context::set('search_target', $search_target); $output = $oIS->getDocuments($target, $module_srl_list, $search_target, $is_keyword, $page, 10); Context::set('output', $output); $this->setTemplateFile("document", $page); break; case 'comment': $output = $oIS->getComments($target, $module_srl_list, $is_keyword, $page, 10); Context::set('output', $output); $this->setTemplateFile("comment", $page); break; case 'trackback': $search_target = Context::get('search_target'); if (!in_array($search_target, array('title', 'url', 'blog_name', 'excerpt'))) { $search_target = 'title'; } Context::set('search_target', $search_target); $output = $oIS->getTrackbacks($target, $module_srl_list, $search_target, $is_keyword, $page, 10); Context::set('output', $output); $this->setTemplateFile("trackback", $page); break; case 'multimedia': $output = $oIS->getImages($target, $module_srl_list, $is_keyword, $page, 20); Context::set('output', $output); $this->setTemplateFile("multimedia", $page); break; case 'file': $output = $oIS->getFiles($target, $module_srl_list, $is_keyword, $page, 20); Context::set('output', $output); $this->setTemplateFile("file", $page); break; default: $output['document'] = $oIS->getDocuments($target, $module_srl_list, 'title', $is_keyword, $page, 5); $output['comment'] = $oIS->getComments($target, $module_srl_list, $is_keyword, $page, 5); $output['trackback'] = $oIS->getTrackbacks($target, $module_srl_list, 'title', $is_keyword, $page, 5); $output['multimedia'] = $oIS->getImages($target, $module_srl_list, $is_keyword, $page, 5); $output['file'] = $oIS->getFiles($target, $module_srl_list, $is_keyword, $page, 5); Context::set('search_result', $output); Context::set('search_target', 'title'); $this->setTemplateFile("index", $page); break; } } else { $this->setTemplateFile("no_keywords"); } $security = new Security(); $security->encodeHTML('is_keyword', 'search_target', 'where', 'page'); }
if (!$output->toBool()) { return $output; } // update mobile Layout $args->extra_vars = serialize($extra_vars); $output = $oLayoutAdminController->updateLayout($args); if (!$output->toBool()) { return $output; } $siteDesignPath = _XE_PATH_ . 'files/site_design/'; FileHandler::makeDir($siteDesignPath); $designInfo = new stdClass(); $designInfo->layout_srl = $layout_srl; $designInfo->mlayout_srl = $mlayout_srl; $moduleList = array('page', 'board', 'editor'); $moutput = ModuleHandler::triggerCall('menu.getModuleListInSitemap', 'after', $moduleList); if ($moutput->toBool()) { $moduleList = array_unique($moduleList); } $skinTypes = array('skin' => 'skins/', 'mskin' => 'm.skins/'); $designInfo->module = new stdClass(); $oModuleModel = getModel('module'); /* @var $oModuleModel moduleModel */ foreach ($skinTypes as $key => $dir) { $skinType = $key == 'skin' ? 'P' : 'M'; foreach ($moduleList as $moduleName) { $designInfo->module->{$moduleName} = new stdClass(); $designInfo->module->{$moduleName}->{$key} = $oModuleModel->getModuleDefaultSkin($moduleName, $skinType, 0, false); } } $designInfo->module->board->skin = 'xedition';
/** * Delete User */ function deleteMember($member_srl) { // Call a trigger (before) $trigger_obj = new stdClass(); $trigger_obj->member_srl = $member_srl; $output = ModuleHandler::triggerCall('member.deleteMember', 'before', $trigger_obj); if (!$output->toBool()) { return $output; } // Create a model object $oMemberModel = getModel('member'); // Bringing the user's information if (!$this->memberInfo || $this->memberInfo->member_srl != $member_srl || !isset($this->memberInfo->is_admin)) { $columnList = array('member_srl', 'is_admin'); $this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList); } if (!$this->memberInfo) { return new Object(-1, 'msg_not_exists_member'); } // If managers can not be deleted if ($this->memberInfo->is_admin == 'Y') { return new Object(-1, 'msg_cannot_delete_admin'); } $oDB =& DB::getInstance(); $oDB->begin(); $args = new stdClass(); $args->member_srl = $member_srl; // Delete the entries in member_auth_mail $output = executeQuery('member.deleteAuthMail', $args); if (!$output->toBool()) { $oDB->rollback(); return $output; } executeQuery('member.deleteMemberModifyNickNameLog', $args); // TODO: If the table is not an upgrade may fail. /* if(!$output->toBool()) { $oDB->rollback(); return $output; } */ // Delete the entries in member_group_member $output = executeQuery('member.deleteMemberGroupMember', $args); if (!$output->toBool()) { $oDB->rollback(); return $output; } // member removed from the table $output = executeQuery('member.deleteMember', $args); if (!$output->toBool()) { $oDB->rollback(); return $output; } // Call a trigger (after) ModuleHandler::triggerCall('member.deleteMember', 'after', $trigger_obj); $oDB->commit(); // Name, image, image, mark, sign, delete $this->procMemberDeleteImageName($member_srl); $this->procMemberDeleteImageMark($member_srl); $this->procMemberDeleteProfileImage($member_srl); $this->delSignature($member_srl); $this->_clearMemberCache($member_srl); return $output; }
/** * excute the member method specified by $act variable * @return boolean true : success false : fail * */ function proc() { // pass if stop_proc is true if ($this->stop_proc) { debugPrint($this->message, 'ERROR'); return FALSE; } // trigger call $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'before', $this); if (!$triggerOutput->toBool()) { $this->setError($triggerOutput->getError()); $this->setMessage($triggerOutput->getMessage()); return FALSE; } // execute an addon(call called_position as before_module_proc) $called_position = 'before_module_proc'; $oAddonController = getController('addon'); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc"); if (FileHandler::exists($addon_file)) { include $addon_file; } if (isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) { // Check permissions if ($this->module_srl && !$this->grant->access) { $this->stop("msg_not_permitted_act"); return FALSE; } // integrate skin information of the module(change to sync skin info with the target module only by seperating its table) $is_default_skin = !Mobile::isFromMobilePhone() && $this->module_info->is_skin_fix == 'N' || Mobile::isFromMobilePhone() && $this->module_info->is_mskin_fix == 'N'; $usedSkinModule = !($this->module == 'page' && ($this->module_info->page_type == 'OUTSIDE' || $this->module_info->page_type == 'WIDGET')); if ($usedSkinModule && $is_default_skin && $this->module != 'admin' && strpos($this->act, 'Admin') === false && $this->module == $this->module_info->module) { $dir = Mobile::isFromMobilePhone() ? 'm.skins' : 'skins'; $valueName = Mobile::isFromMobilePhone() ? 'mskin' : 'skin'; $oModuleModel = getModel('module'); $skinType = Mobile::isFromMobilePhone() ? 'M' : 'P'; $skinName = $oModuleModel->getModuleDefaultSkin($this->module, $skinType); if ($this->module == 'page') { $this->module_info->{$valueName} = $skinName; } else { $isTemplatPath = strpos($this->getTemplatePath(), '/tpl/') !== FALSE; if (!$isTemplatPath) { $this->setTemplatePath(sprintf('%s%s/%s/', $this->module_path, $dir, $skinName)); } } } $oModuleModel = getModel('module'); $oModuleModel->syncSkinInfoToModuleInfo($this->module_info); Context::set('module_info', $this->module_info); // Run $output = $this->{$this->act}(); } else { return FALSE; } // trigger call $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'after', $this); if (!$triggerOutput->toBool()) { $this->setError($triggerOutput->getError()); $this->setMessage($triggerOutput->getMessage()); return FALSE; } // execute an addon(call called_position as after_module_proc) $called_position = 'after_module_proc'; $oAddonController = getController('addon'); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc"); if (FileHandler::exists($addon_file)) { include $addon_file; } if (is_a($output, 'Object') || is_subclass_of($output, 'Object')) { $this->setError($output->getError()); $this->setMessage($output->getMessage()); if (!$output->toBool()) { return FALSE; } } // execute api methos of the module if view action is and result is XMLRPC or JSON if ($this->module_info->module_type == 'view') { if (Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON') { $oAPI = getAPI($this->module_info->module, 'api'); if (method_exists($oAPI, $this->act)) { $oAPI->{$this->act}($this); } } } return TRUE; }
/** * @brief 모듈 객체를 생성함 **/ function &getModuleInstance($module, $type = 'view', $kind = '') { $class_path = ModuleHandler::getModulePath($module); if (!is_dir(_XE_PATH_ . $class_path)) { return NULL; } if (__DEBUG__ == 3) { $start_time = getMicroTime(); } if ($kind != 'admin') { $kind = 'svc'; } // global 변수에 미리 생성해 둔 객체가 없으면 새로 생성 if (!$GLOBALS['_loaded_module'][$module][$type][$kind]) { /** * 모듈의 위치를 파악 **/ // 상위 클래스명 구함 if (!class_exists($module)) { $high_class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module); if (!file_exists($high_class_file)) { return NULL; } require_once $high_class_file; } // 객체의 이름을 구함 switch ($type) { case 'controller': if ($kind == 'admin') { $instance_name = sprintf("%sAdmin%s", $module, "Controller"); $class_file = sprintf('%s%s%s.admin.%s.php', _XE_PATH_, $class_path, $module, $type); } else { $instance_name = sprintf("%s%s", $module, "Controller"); $class_file = sprintf('%s%s%s.%s.php', _XE_PATH_, $class_path, $module, $type); } break; case 'model': if ($kind == 'admin') { $instance_name = sprintf("%sAdmin%s", $module, "Model"); $class_file = sprintf('%s%s%s.admin.%s.php', _XE_PATH_, $class_path, $module, $type); } else { $instance_name = sprintf("%s%s", $module, "Model"); $class_file = sprintf('%s%s%s.%s.php', _XE_PATH_, $class_path, $module, $type); } break; case 'api': $instance_name = sprintf("%s%s", $module, "API"); $class_file = sprintf('%s%s%s.api.php', _XE_PATH_, $class_path, $module); break; case 'wap': $instance_name = sprintf("%s%s", $module, "WAP"); $class_file = sprintf('%s%s%s.wap.php', _XE_PATH_, $class_path, $module); break; case 'smartphone': $instance_name = sprintf("%s%s", $module, "SPhone"); $class_file = sprintf('%s%s%s.smartphone.php', _XE_PATH_, $class_path, $module); break; case 'class': $instance_name = $module; $class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module); break; default: $type = 'view'; if ($kind == 'admin') { $instance_name = sprintf("%sAdmin%s", $module, "View"); $class_file = sprintf('%s%s%s.admin.view.php', _XE_PATH_, $class_path, $module, $type); } else { $instance_name = sprintf("%s%s", $module, "View"); $class_file = sprintf('%s%s%s.view.php', _XE_PATH_, $class_path, $module, $type); } break; } // 클래스 파일의 이름을 구함 if (!file_exists($class_file)) { return NULL; } // eval로 객체 생성 require_once $class_file; $eval_str = sprintf('$oModule = new %s();', $instance_name); @eval($eval_str); if (!is_object($oModule)) { return NULL; } // 해당 위치에 속한 lang 파일을 읽음 Context::loadLang($class_path . 'lang'); // 생성된 객체에 자신이 호출된 위치를 세팅해줌 $oModule->setModule($module); $oModule->setModulePath($class_path); // 요청된 module에 constructor가 있으면 실행 if (!isset($GLOBALS['_called_constructor'][$instance_name])) { $GLOBALS['_called_constructor'][$instance_name] = true; if (@method_exists($oModule, $instance_name)) { $oModule->{$instance_name}(); } } // GLOBALS 변수에 생성된 객체 저장 $GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule; } if (__DEBUG__ == 3) { $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time; } // 객체 리턴 return $GLOBALS['_loaded_module'][$module][$type][$kind]; }
/** * Install module * * Call module's moduleInstall(), moduleUpdate() and create tables. * * @return void */ function installModule() { $path = $this->package->path; if ($path != ".") { $path_array = explode("/", $path); $target_name = array_pop($path_array); $type = substr(array_pop($path_array), 0, -1); } if ($type == "module") { $oModuleModel = getModel('module'); $oInstallController = getController('install'); $module_path = ModuleHandler::getModulePath($target_name); if ($oModuleModel->checkNeedInstall($target_name)) { $oInstallController->installModule($target_name, $module_path); } if ($oModuleModel->checkNeedUpdate($target_name)) { $oModule = getModule($target_name, 'class'); if (method_exists($oModule, 'moduleUpdate')) { $oModule->moduleUpdate(); } } } }
function dispIssuetrackerAdminAdditionSetup() { $content = ''; // 추가 설정을 위한 트리거 호출 // 이슈트래커 모듈이지만 차후 다른 모듈에서의 사용도 고려하여 trigger 이름을 공용으로 사용할 수 있도록 하였음 $output = ModuleHandler::triggerCall('module.dispAdditionSetup', 'before', $content); $output = ModuleHandler::triggerCall('module.dispAdditionSetup', 'after', $content); Context::set('setup_content', $content); // 템플릿 파일 지정 $this->setTemplateFile('addition_setup'); }
/** * @brief when menu add in sitemap, select module list * this menu showing with trigger * @param int $site_srl * @return array */ function getModuleListInSitemap($site_srl = 0) { $oModuleModel = getModel('module'); $moduleList = array('page'); $output = $oModuleModel->getModuleListByInstance($site_srl); if (is_array($output->data)) { foreach ($output->data as $value) { if ($value->instanceCount > 1) { $moduleList[] = $value->module; } } } // after trigger $output = ModuleHandler::triggerCall('menu.getModuleListInSitemap', 'after', $moduleList); if (!$output->toBool()) { return $output; } $localModuleList = array_unique($moduleList); $oAutoinstallModel = getModel('autoinstall'); // get have instance $remotePackageList = $oAutoinstallModel->getHaveInstance(array('path')); $remoteModuleList = array(); foreach ($remotePackageList as $package) { if (strpos($package->path, './modules/') !== 0) { continue; } $pathInfo = explode('/', $package->path); $remoteModuleList[] = $pathInfo[2]; } // all module list $allModuleList = FileHandler::readDir('./modules', '/^([a-zA-Z0-9_-]+)$/'); // union have instance and all module list $haveInstance = array_intersect($remoteModuleList, $allModuleList); $haveDirectory = array_intersect($localModuleList, $allModuleList); // union $moduleList = array_unique(array_merge($haveDirectory, $haveInstance)); $moduleInfoList = array(); Context::loadLang('modules/page/lang'); if (is_array($moduleList)) { foreach ($moduleList as $value) { $moduleInfo = $oModuleModel->getModuleInfoXml($value); if ($value == 'page') { $pageTypeName = Context::getLang('page_type_name'); $moduleInfo->title = $pageTypeName['ARTICLE']; $moduleInfoList['ARTICLE'] = $moduleInfo; $wModuleInfo = clone $moduleInfo; unset($wModuleInfo->default_skin, $wModuleInfo->default_mskin); $wModuleInfo->title = $pageTypeName['WIDGET']; $wModuleInfo->no_skin = 'Y'; $moduleInfoList['WIDGET'] = $wModuleInfo; $oModuleInfo = clone $moduleInfo; unset($oModuleInfo->default_skin, $oModuleInfo->default_mskin); $oModuleInfo->title = $pageTypeName['OUTSIDE']; $oModuleInfo->no_skin = 'Y'; $moduleInfoList['OUTSIDE'] = $oModuleInfo; } else { $moduleInfoList[$value] = $moduleInfo; } } } return $moduleInfoList; }
/** * @brief list transactions */ function dispEpayAdminTransactions() { // transactions $args->page = Context::get('page'); $output = executeQueryArray('epay.getTransactionList', $args); if (!$output->toBool()) { return $output; } $list = $output->data; ModuleHandler::triggerCall('epay.getTransactionList', 'after', $list); Context::set('list', $list); Context::set('total_count', $output->total_count); Context::set('total_page', $output->total_page); Context::set('page', $output->page); Context::set('page_navigation', $output->page_navigation); // module instances $output = executeQueryArray('epay.getAllModInstList'); $modinst_list = array(); $list = $output->data; if (!is_array($list)) { $list = array(); } foreach ($list as $key => $modinfo) { $modinst_list[$modinfo->module_srl] = $modinfo; } Context::set('modinst_list', $modinst_list); $this->setTemplateFile('transactions'); }
* @brief Declare constants for generic use and for checking to avoid a direct call from the Web **/ define('__XE__', TRUE); /** * @brief Include the necessary configuration files **/ require dirname(__FILE__) . '/config/config.inc.php'; /** * @brief Initialize by creating Context object * Set all Request Argument/Environment variables **/ $oContext = Context::getInstance(); $oContext->init(); /** * @brief If default_url is set and it is different from the current url, attempt to redirect for SSO authentication and then process the module **/ if ($oContext->checkSSO()) { $oModuleHandler = new ModuleHandler(); try { if ($oModuleHandler->init()) { $oModuleHandler->displayContent($oModuleHandler->procModule()); } } catch (Exception $e) { htmlHeader(); echo Context::getLang($e->getMessage()); htmlFooter(); } } $oContext->close(); /* End of file index.php */ /* Location: ./index.php */
/** * @brief update item **/ function procNproductAdminUpdateItem() { $oMemberModel =& getModel('member'); $oDocumentModel =& getModel('document'); $oNproductModel =& getModel('nproduct'); $oDocumentController =& getController('document'); $item_srl = Context::get('item_srl'); $module_srl = Context::get('disp_module_srl'); $item_name = Context::get('item_name'); $item_code = Context::get('item_code'); $category_id = Context::get('category_id'); $document_srl = Context::get('document_srl'); $description = Context::get('description'); $price = Context::get('price'); $discount_amount = Context::get('discount_amount'); $discount_info = Context::get('discount_info'); $taxfree = Context::get('taxfree'); $display = Context::get('display'); $delivery_info = Context::get('delivery_info'); $group_srl_list = Context::get('group_srl_list'); // update document $doc_args->document_srl = $document_srl; //$doc_args->category_srl = $category_id; $doc_args->module_srl = $module_srl; $doc_args->content = $description; $doc_args->title = $item_name; $doc_args->list_order = $doc_args->document_srl * -1; $doc_args->tags = Context::get('tag'); $doc_args->allow_comment = 'Y'; $output = $oDocumentController->updateDocument($oDocumentModel->getDocument($document_srl), $doc_args); if (!$output->toBool()) { return $output; } if (Context::get('delete_file')) { $delete_file_srl = Context::get('delete_file'); $this->deleteNproductFile($delete_file_srl, $item_srl); } // update item $args->item_srl = $item_srl; $args->item_name = $item_name; $args->item_code = $item_code; $args->module_srl = $module_srl; $args->node_route = 'f.'; if ($category_id) { $args->category_id = $category_id; $category_info = $oNproductModel->getCategoryInfo($category_id); $args->node_route = 'f.'; if ($category_info) { $args->node_route = $category_info->node_route . $category_info->node_id . '.'; } } $args->proc_module = Context::get('proc_module'); $args->document_srl = $document_srl; $args->price = $price; $args->discount_amount = $discount_amount; $args->discount_info = $discount_info; $args->taxfree = $taxfree; $args->display = $display; $args->delivery_info = $delivery_info; $args->group_srl_list = serialize($group_srl_list); $args->related_items = Context::get('related_items'); $args->minimum_order_quantity = Context::get('minimum_order_quantity'); $args->item_stock = Context::get('item_stock'); if ($args->item_stock < 0) { $args->item_stock = -1; } // extras $extra_vars = $oNproductModel->getExtraVars($module_srl); $extra_vars = delObjectVars($extra_vars, $args); $args->extra_vars = serialize($extra_vars); // before $output = ModuleHandler::triggerCall('nproduct.updateItem', 'before', $args); if (!$output->toBool()) { return $output; } /* * extra_vars update */ foreach ($extra_vars as $key => $val) { $ex_args->item_srl = $item_srl; $ex_args->name = $key; $ex_args->value = $val->getValuePlain(); $output = executeQuery('nproduct.deleteNproductExtraVars', $ex_args); if (!$output->toBool()) { return $output; } $output = executeQuery('nproduct.insertNproductExtraVars', $ex_args); if (!$output->toBool()) { return $output; } } /* * end */ $output = executeQuery('nproduct.updateItemAdmin', $args); if (!$output->toBool()) { return $output; } // update group discount $args->item_srl = $item_srl; $output = executeQuery('nproduct.deleteGroupDiscount', $args); if (!$output->toBool()) { return $output; } unset($args); $group_list = $oMemberModel->getGroups(); foreach ($group_list as $key => $val) { if (Context::get('group_discount_' . $val->group_srl)) { $opt = Context::get('group_opt_' . $val->group_srl); if (!$opt) { $opt = '1'; } $args->item_srl = $item_srl; $args->module_srl = $module_srl; $args->group_srl = $val->group_srl; $args->opt = $opt; $args->price = Context::get('group_discount_' . $val->group_srl); $output = executeQuery('nproduct.insertGroupDiscount', $args); if (!$output->toBool()) { return $output; } unset($args); } } $this->procNproductAdminUpdateItemFile(); // after $output = ModuleHandler::triggerCall('nproduct.updateItem', 'after', $args); if (!$output->toBool()) { return $output; } $this->setRedirectUrl(getNotEncodedUrl('', 'module', Context::get('module'), 'act', 'dispNproductAdminUpdateItem', 'module_srl', Context::get('module_srl'), 'item_srl', $item_srl, 's_item_name', Context::get('s_item_name'), 'category', Context::get('category'))); }
/** * @brief Delete module * * Attempt to delete all related information when deleting a module. **/ function deleteModule($module_srl) { if (!$module_srl) { return new Object(-1, 'msg_invalid_request'); } // check start module $oModuleModel =& getModel('module'); $columnList = array('sites.index_module_srl'); $start_module = $oModuleModel->getSiteInfo(0, $columnList); if ($module_srl == $start_module->index_module_srl) { return new Object(-1, 'msg_cannot_delete_startmodule'); } // Call a trigger (before) $trigger_obj->module_srl = $module_srl; $output = ModuleHandler::triggerCall('module.deleteModule', 'before', $trigger_obj); if (!$output->toBool()) { return $output; } // begin transaction $oDB =& DB::getInstance(); $oDB->begin(); $args->module_srl = $module_srl; // Delete module information from the DB $output = executeQuery('module.deleteModule', $args); if (!$output->toBool()) { $oDB->rollback(); return $output; } // Delete permission information $this->deleteModuleGrants($module_srl); // Remove skin information $this->deleteModuleSkinVars($module_srl); // Delete module extra vars $this->deleteModuleExtraVars($module_srl); // Remove the module manager $this->deleteAdminId($module_srl); // Call a trigger (after) if ($output->toBool()) { $trigger_output = ModuleHandler::triggerCall('module.deleteModule', 'after', $trigger_obj); if (!$trigger_output->toBool()) { $oDB->rollback(); return $trigger_output; } } // commit $oDB->commit(); //remove from cache $oCacheHandler =& CacheHandler::getInstance('object'); if ($oCacheHandler->isSupport()) { $cache_key = 'object_module_info:' . $args->module_srl; $oCacheHandler->delete($cache_key); $cache_key = 'object:module_extra_vars_' . $args->module_srl; $oCacheHandler->delete($cache_key); } return $output; }