Exemple #1
0
 function alertMsg($message)
 {
     //입력된 메세지 없으면 리턴
     if (!$message) {
         return;
     }
     header("Content-Type: text/html; charset=UTF-8");
     //헤더설정 직접 해주거나(한글인코딩) 아래주석 제거하거나 선택적 사용
     //htmlHeader();
     alertScript($message);
     echo '<script type="text/javascript">history.back()</script>';
     //htmlFooter();
     Context::close();
     exit;
 }
 /**
  * Trackbacks sent
  * @return object
  */
 function procTrackbackSend()
 {
     // Yeokingeul to post numbers and shipping addresses Wanted
     $document_srl = Context::get('target_srl');
     $trackback_url = Context::get('trackback_url');
     $charset = Context::get('charset');
     if (!$document_srl || !$trackback_url || !$charset) {
         return new Object(-1, 'msg_invalid_request');
     }
     // Login Information Wanted
     $logged_info = Context::get('logged_info');
     if (!$logged_info->member_srl) {
         return new Object(-1, 'msg_not_permitted');
     }
     // Posts of the information obtained permission to come and check whether
     $oDocumentModel =& getModel('document');
     $oDocument = $oDocumentModel->getDocument($document_srl);
     if (!$oDocument->isExists() || !$oDocument->getSummary()) {
         return new Object(-1, 'msg_invalid_request');
     }
     if ($oDocument->getMemberSrl() != $logged_info->member_srl) {
         return new Object(-1, 'msg_not_permitted');
     }
     // Specify the title of the module, the current article
     $oModuleModel =& getModel('module');
     $module_info = $oModuleModel->getModuleInfoByModuleSrl($oDocument->get('module_srl'));
     Context::setBrowserTitle($module_info->browser_title);
     // Shipping yeokingeul
     $output = $this->sendTrackback($oDocument, $trackback_url, $charset);
     if ($output->toBool() && !in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
         global $lang;
         htmlHeader();
         alertScript($lang->success_registed);
         reload(true);
         closePopupScript();
         htmlFooter();
         Context::close();
         exit;
     }
     return $output;
 }
 /**
  * Update a group of selected memebrs
  * @return void|Object (void : success, Object : fail)
  */
 function procMemberAdminUpdateMembersGroup()
 {
     $member_srl = Context::get('member_srl');
     if (!$member_srl) {
         return new Object(-1, 'msg_invalid_request');
     }
     $member_srls = explode(',', $member_srl);
     $group_srl = Context::get('group_srls');
     if (!is_array($group_srl)) {
         $group_srls = explode('|@|', $group_srl);
     } else {
         $group_srls = $group_srl;
     }
     $oDB =& DB::getInstance();
     $oDB->begin();
     // Delete a group of selected members
     $args = new stdClass();
     $args->member_srl = $member_srl;
     $output = executeQuery('member.deleteMembersGroup', $args);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     // Add to a selected group
     $group_count = count($group_srls);
     $member_count = count($member_srls);
     for ($j = 0; $j < $group_count; $j++) {
         $group_srl = (int) trim($group_srls[$j]);
         if (!$group_srl) {
             continue;
         }
         for ($i = 0; $i < $member_count; $i++) {
             $member_srl = (int) trim($member_srls[$i]);
             if (!$member_srl) {
                 continue;
             }
             $args = new stdClass();
             $args->member_srl = $member_srl;
             $args->group_srl = $group_srl;
             $output = executeQuery('member.addMemberToGroup', $args);
             if (!$output->toBool()) {
                 $oDB->rollback();
                 return $output;
             }
         }
     }
     $oDB->commit();
     $this->_deleteMemberGroupCache();
     $this->setMessage('success_updated');
     if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
         global $lang;
         htmlHeader();
         alertScript($lang->success_updated);
         reload(true);
         closePopupScript();
         htmlFooter();
         Context::close();
         exit;
     }
 }
 /**
  * layout copy
  * @return void
  */
 function procLayoutAdminCopyLayout()
 {
     $sourceArgs = Context::getRequestVars();
     if ($sourceArgs->layout == 'faceoff') {
         return $this->stop('not supported');
     }
     if (!$sourceArgs->layout_srl) {
         return $this->stop('msg_empty_origin_layout');
     }
     $oLayoutModel = getModel('layout');
     $layout = $oLayoutModel->getLayout($sourceArgs->layout_srl);
     if (!$sourceArgs->title) {
         $sourceArgs->title = array($layout->title . '_' . $this->_makeRandomMid());
     }
     if (!is_array($sourceArgs->title) || count($sourceArgs->title) == 0) {
         return $this->stop('msg_empty_target_layout');
     }
     $output = $oLayoutModel->getLayoutRawData($sourceArgs->layout_srl, array('extra_vars'));
     $args = new stdClass();
     $args->extra_vars = $output->extra_vars;
     $extra_vars = unserialize($args->extra_vars);
     if ($layout->extra_var_count) {
         $reg = "/^.\\/files\\/attach\\/images\\/([0-9]+)\\/(.*)/";
         if ($extra_vars) {
             foreach ($extra_vars as $key => $val) {
                 if ($layout->extra_var->{$key}->type == 'image') {
                     if (!preg_match($reg, $val, $matches)) {
                         continue;
                     }
                     $image_list[$key]->filename = $matches[2];
                     $image_list[$key]->old_file = $val;
                 }
             }
         }
     }
     $oModuleController = getController('module');
     $layout_config = new stdClass();
     $layout_config->header_script = $extra_vars->header_script;
     // Get information to create a layout
     $args->site_srl = (int) $layout->site_srl;
     $args->layout = $layout->layout;
     $args->layout_type = $layout->layout_type;
     if (!$args->layout_type) {
         $args->layout_type = "P";
     }
     $oDB =& DB::getInstance();
     $oDB->begin();
     if (is_array($sourceArgs->title)) {
         foreach ($sourceArgs->title as $key => $value) {
             if (!trim($value)) {
                 continue;
             }
             $args->layout_srl = getNextSequence();
             $args->title = $value;
             if (is_array($image_list)) {
                 foreach ($image_list as $key => $val) {
                     $new_file = sprintf("./files/attach/images/%s/%s", $args->layout_srl, $val->filename);
                     FileHandler::copyFile($val->old_file, $new_file);
                     $extra_vars->{$key} = $new_file;
                 }
                 $args->extra_vars = serialize($extra_vars);
             }
             // for header script
             $oModuleController->insertModulePartConfig('layout', $args->layout_srl, $layout_config);
             // Insert into the DB
             $output = $this->insertLayout($args);
             if (!$output->toBool()) {
                 $oDB->rollback();
                 return $output;
             }
             // initiate if it is faceoff layout
             $this->initLayout($args->layout_srl, $args->layout);
             // update layout info
             $output = $this->updateLayout($args);
             if (!$output->toBool()) {
                 $oDB->rollback();
                 return $output;
             }
             $this->_copyLayoutFile($layout->layout_srl, $args->layout_srl);
         }
     }
     $oDB->commit();
     $this->setMessage('success_registed');
     if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
         global $lang;
         htmlHeader();
         alertScript($lang->success_registed);
         reload(true);
         closePopupScript();
         htmlFooter();
         Context::close();
         exit;
     }
 }
 /**
  * Add a group of friends
  * @return void|Object (success : void, fail : Object)
  **/
 function procCommunicationAddFriendGroup()
 {
     // Check login information
     if (!Context::get('is_logged')) {
         return new Object(-1, 'msg_not_logged');
     }
     $logged_info = Context::get('logged_info');
     // Variables
     $args->friend_group_srl = trim(Context::get('friend_group_srl'));
     $args->member_srl = $logged_info->member_srl;
     $args->title = Context::get('title');
     $args->title = htmlspecialchars($args->title);
     if (!$args->title) {
         return new Object(-1, 'msg_invalid_request');
     }
     // modify if friend_group_srl exists.
     if ($args->friend_group_srl) {
         $output = executeQuery('communication.renameFriendGroup', $args);
         $msg_code = 'success_updated';
         // add if not exists
     } else {
         $output = executeQuery('communication.addFriendGroup', $args);
         $msg_code = 'success_registed';
     }
     if (!$output->toBool()) {
         if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
             global $lang;
             htmlHeader();
             alertScript($lang->fail_to_registed);
             closePopupScript();
             htmlFooter();
             Context::close();
             exit;
         } else {
             return $output;
         }
     } else {
         if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
             global $lang;
             htmlHeader();
             alertScript($lang->success_registed);
             reload(true);
             closePopupScript();
             htmlFooter();
             Context::close();
             exit;
         } else {
             $this->setMessage($msg_code);
         }
     }
 }
 /**
  * @brief List permissions of the module
  */
 function procModuleAdminModuleGrantSetup()
 {
     $module_srls = Context::get('module_srls');
     if (!$module_srls) {
         return new Object(-1, 'msg_invalid_request');
     }
     $modules = explode(',', $module_srls);
     if (count($modules) < 1) {
         return new Object(-1, 'msg_invalid_request');
     }
     $oModuleController = getController('module');
     $oModuleModel = getModel('module');
     $columnList = array('module_srl', 'module');
     $module_info = $oModuleModel->getModuleInfoByModuleSrl($modules[0], $columnList);
     $xml_info = $oModuleModel->getModuleActionXml($module_info->module);
     $grant_list = $xml_info->grant;
     $grant_list->access = new stdClass();
     $grant_list->access->default = 'guest';
     $grant_list->manager = new stdClass();
     $grant_list->manager->default = 'manager';
     $grant = new stdClass();
     foreach ($grant_list as $grant_name => $grant_info) {
         // Get the default value
         $default = Context::get($grant_name . '_default');
         // -1 = Sign only, 0 = all users
         $grant->{$grant_name} = array();
         if (strlen($default)) {
             $grant->{$grant_name}[] = $default;
             continue;
             // Users in a particular group
         } else {
             $group_srls = Context::get($grant_name);
             if ($group_srls) {
                 if (!is_array($group_srls)) {
                     if (strpos($group_srls, '|@|') !== false) {
                         $group_srls = explode('|@|', $group_srls);
                     } elseif (strpos($group_srls, ',') !== false) {
                         $group_srls = explode(',', $group_srls);
                     } else {
                         $group_srls = array($group_srls);
                     }
                 }
                 $grant->{$grant_name} = $group_srls;
             }
             continue;
         }
         $grant->{$group_srls} = array();
         // dead code, too??
     }
     // Stored in the DB
     foreach ($modules as $module_srl) {
         $args = new stdClass();
         $args->module_srl = $module_srl;
         $output = executeQuery('module.deleteModuleGrants', $args);
         if (!$output->toBool()) {
             continue;
         }
         // Permissions stored in the DB
         foreach ($grant as $grant_name => $group_srls) {
             foreach ($group_srls as $val) {
                 $args = new stdClass();
                 $args->module_srl = $module_srl;
                 $args->name = $grant_name;
                 $args->group_srl = $val;
                 $output = executeQuery('module.insertModuleGrant', $args);
                 if (!$output->toBool()) {
                     return $output;
                 }
             }
         }
     }
     $this->setMessage('success_registed');
     if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
         if (Context::get('success_return_url')) {
             $this->setRedirectUrl(Context::get('success_return_url'));
         } else {
             global $lang;
             htmlHeader();
             alertScript($lang->success_registed);
             closePopupScript();
             htmlFooter();
             Context::close();
             exit;
         }
     }
 }
 function procAjaxboardAdminSendPush()
 {
     $message = Context::get('message');
     $notice = Context::get('notice');
     $receiver_srl = Context::get('receiver_srl');
     $receiver_srls = Context::get('receiver_srls');
     if (!$message) {
         return new Object(-1, 'msg_invalid_request');
     }
     if ($notice != 'Y' && !$receiver_srl && !(is_array($receiver_srls) && count($receiver_srls))) {
         return new Object(-1, 'msg_not_exists_member');
     }
     if ($notice == 'Y') {
         $oAjaxboardModel = getModel('ajaxboard');
         $module_config = $oAjaxboardModel->getConfig();
         $args = array('type' => 'noticeOfServer', 'receiver_tokens' => $module_config->token, 'message' => $message);
     } else {
         if ($receiver_srl) {
             $oMemberModel = getModel('member');
             $receiver_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl);
             if ($receiver_info->member_srl != $receiver_srl) {
                 return new Object(-1, 'msg_not_exists_member');
             }
             $args = array('type' => 'notice', 'receiver_srls' => $receiver_srl, 'message' => $message);
         } else {
             $message = nl2br(htmlspecialchars($message, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
             $receiver_srls = implode(',', $receiver_srls);
             $args = array('type' => 'notice', 'receiver_srls' => $receiver_srls, 'message' => $message);
         }
     }
     $oAjaxboardController = getController('ajaxboard');
     $oAjaxboardController->emitEvent($args);
     if (Context::get('is_popup') != 'Y') {
         $this->setMessage('success_sended');
         $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAjaxboardAdminSendPush'));
     } else {
         htmlHeader();
         alertScript(Context::getLang('success_sended'));
         closePopupScript();
         htmlFooter();
         Context::close();
         exit;
     }
 }
 /**
  * layout copy
  * @return void
  */
 function procLayoutAdminCopyLayout()
 {
     $sourceArgs = Context::getRequestVars();
     if ($sourceArgs->layout == 'faceoff') {
         return $this->stop('not supported');
     }
     if (!$sourceArgs->layout_srl) {
         return $this->stop('msg_empty_origin_layout');
     }
     if (!is_array($sourceArgs->title) || count($sourceArgs->title) == 0) {
         return $this->stop('msg_empty_target_layout');
     }
     $oLayoutModel =& getModel('layout');
     $layout = $oLayoutModel->getLayout($sourceArgs->layout_srl);
     $args->extra_vars = $oLayoutModel->getLayoutRawData($sourceArgs->layout_srl, array('extra_vars'));
     $extra_vars = unserialize($args->extra_vars);
     $oModuleController =& getController('module');
     $layout_config->header_script = $extra_vars->header_script;
     // Get information to create a layout
     $args->site_srl = (int) $layout->site_srl;
     $args->layout = $layout->layout;
     $args->layout_type = $layout->type;
     if (!$args->layout_type) {
         $args->layout_type = "P";
     }
     $oDB =& DB::getInstance();
     $oDB->begin();
     if (is_array($sourceArgs->title)) {
         foreach ($sourceArgs->title as $key => $value) {
             if (!trim($value)) {
                 continue;
             }
             $args->layout_srl = getNextSequence();
             $args->title = $value;
             // for header script
             $oModuleController->insertModulePartConfig('layout', $args->layout_srl, $layout_config);
             // Insert into the DB
             $output = $this->insertLayout($args);
             if (!$output->toBool()) {
                 $oDB->rollback();
                 return $output;
             }
             // initiate if it is faceoff layout
             $this->initLayout($args->layout_srl, $args->layout);
             // update layout info
             $output = $this->updateLayout($args);
             if (!$output->toBool()) {
                 $oDB->rollback();
                 return $output;
             }
             $this->_copyLayoutFile($layout->layout_srl, $args->layout_srl);
         }
     }
     $oDB->commit();
     $this->setMessage('success_registed');
     if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
         global $lang;
         htmlHeader();
         alertScript($lang->success_registed);
         reload(true);
         closePopupScript();
         htmlFooter();
         Context::close();
         exit;
     }
 }