function dispatch() { if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $sess_handler =& XsnsSessionHandler::getInstance(); $commu_temp = $sess_handler->getVar('community'); $sess_handler->clearVars(); $ts =& XsnsTextSanitizer::getInstance(); $default = array( 'name' => isset($commu_temp['name']) ? $ts->makeTboxData4PreviewInForm($commu_temp['name']) : '', 'info' => isset($commu_temp['info']) ? $ts->makeTareaData4PreviewInForm($commu_temp['info']) : '', 'cat_id' => isset($commu_temp['cat_id']) ? intval($commu_temp['cat_id']) : 0, 'public_id' => isset($commu_temp['public_id']) ? intval($commu_temp['public_id']) : 1, ); $image_handler =& XsnsImageHandler::getInstance(); $image_handler->deleteImageTemp(); $category_handler =& XsnsCategoryHandler::getInstance(); $category_selector = $category_handler->getSelectorHtml('category', $default['cat_id'], _MD_XSNS_SELBOX_DEFAULT); $public_id = $default['public_id']; $default['public'.$public_id] = ' checked'; $this->context->setAttribute('category_selector', $category_selector); $this->context->setAttribute('default', $default); }
function dispatch() { global $xoopsUser; if($this->isGuest() || !$this->validateToken('COMMUNITY_ADD')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $sess_handler =& XsnsSessionHandler::getInstance(); $commu = $sess_handler->getVar('community'); $commu_handler =& XsnsCommunityHandler::getInstance(); if(!$commu_handler->checkParams(0, $commu['name'], $commu['info'], $commu['cat_id'], $commu['public_id'])){ redirect_header(XOOPS_URL, 2, _NOPERM); } $new_community =& $commu_handler->create(); $new_community->setVars(array( 'name' => $commu['name'], 'uid_admin' => $own_uid, 'uid_sub_admin' => 0, 'info' => $commu['info'], 'c_commu_category_id' => $commu['cat_id'], 'r_datetime' => date('Y-m-d H:i:s'), 'r_date' => date('Y-m-d'), 'public_flag' => $commu['public_id'], )); $category_handler =& XsnsCategoryHandler::getInstance(); if(($cid = $commu_handler->insert($new_community)) && $category_handler->updateSelector()){ // 作成したコミュニティに対して画像を追加 $image_handler =& XsnsImageHandler::getInstance(); $image_handler->setFormLimit(1); $image_handler->uploadImage('c', 1, $cid); // コミュニティの作成者をメンバーに追加 $c_member_handler =& XsnsMemberHandler::getInstance(); $new_member =& $c_member_handler->create(); $new_member->setVars(array( 'uid' => $own_uid, 'c_commu_id' => $cid, 'r_datetime' => date('Y-m-d H:i:s'), )); if($c_member_handler->insert($new_member)){ $sess_handler->clearVars(); redirect_header(XSNS_URL_COMMU.'?cid='.$cid, 2, _MD_XSNS_INDEX_ADD_OK); } } redirect_header(XSNS_URL_COMMU.'?'.XSNS_ACTION_ARG.'=add', 2, _MD_XSNS_INDEX_ADD_NG); }
function getRequestVar($key, $req_type=XSNS_REQUEST_POST) { if($req_type==XSNS_REQUEST_POST){ $value = isset($_POST[$key]) ? $_POST[$key] : NULL; } elseif($req_type==XSNS_REQUEST_GET){ $value = isset($_GET[$key]) ? $_GET[$key] : NULL; } elseif($req_type==XSNS_REQUEST_SESSION){ $sess_handler =& XsnsSessionHandler::getInstance(); $value = $sess_handler->getVar($key); } else{ return NULL; } return $value; }
function XsnsImageHandler() { parent::XsnsRootHandler(); $this->obj_class = "XsnsImage"; $this->table_name = "c_image"; $this->primary_key = "c_image_id"; if(isset($this->module_config['file_upload_path'])){ $this->upload_dir = $this->module_config['file_upload_path']; $this->dir_exists = is_dir($this->upload_dir) ? true : false; } else{ $this->dir_exists = false; } if(isset($this->module_config['image_form_limit'])){ $this->setFormLimit($this->module_config['image_form_limit']); } $this->handler['session'] =& XsnsSessionHandler::getInstance(); }
function dispatch() { if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $cid = $this->getIntRequest('cid', XSNS_REQUEST_GET); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority()){ redirect_header(XOOPS_URL, 2, _NOPERM); } // 画像・ファイルのキャッシュを削除 $image_handler =& XsnsImageHandler::getInstance(); $image_handler->deleteImageTemp(); $file_handler =& XsnsFileHandler::getInstance(); $file_handler->deleteFileTemp(); $sess_handler =& XsnsSessionHandler::getInstance(); $topic_temp = $sess_handler->getVar('topic'); $sess_handler->clearVars(); $ts =& XsnsTextSanitizer::getInstance(); $default = array( 'name' => isset($topic_temp['name']) ? $ts->makeTboxData4PreviewInForm($topic_temp['name']) : '', 'body' => isset($topic_temp['body']) ? $ts->makeTareaData4PreviewInForm($topic_temp['body']) : '', ); $commu_info = array('id' => $cid, 'name' => $community->getVar('name')); $this->context->setAttribute('commu', $commu_info); $this->context->setAttribute('default', $default); }
function dispatch() { global $xoopsUser; if($this->isGuest() || !$this->validateToken('TOPIC_COMMENT_ADD')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $tid = $this->getIntRequest('tid'); if(!isset($tid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $body = $this->getTextRequest('comment_body', XSNS_REQUEST_SESSION); if(!isset($body)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_handler =& XsnsCommunityHandler::getInstance(); $topic_handler =& XsnsTopicHandler::getInstance(); $comment_handler =& XsnsTopicCommentHandler::getInstance(); // トピックの取得 $topic =& $topic_handler->get($tid); if(!is_object($topic) || $topic->getCommentCount() >= 1001){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $cid = $topic->getVar('c_commu_id'); $community =& $commu_handler->get($cid); if(!is_object($community)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_auth = $community->getAuthority(); if($commu_auth < XSNS_AUTH_NON_MEMBER || ($commu_auth < XSNS_AUTH_MEMBER && $community->getVar('public_flag')==3) ){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コメントの投稿 $new_comment =& $comment_handler->create(); $new_comment->setVars(array( 'c_commu_topic_id' => $tid, 'c_commu_id' => $cid, 'uid' => $own_uid, 'body' => $body, 'r_datetime' => date('Y-m-d H:i:s'), 'r_date' => date('Y-m-d'), 'number' => $topic->getCommentCount(), )); if($tcid = $comment_handler->insert($new_comment)){ // 画像のアップロード $image_handler =& XsnsImageHandler::getInstance(); $image_handler->uploadImage('t', 2, $tcid); // ファイルのアップロード $file_handler =& XsnsFileHandler::getInstance(); $file_handler->uploadFile('t', 2, $tcid); // イベント通知 if(include_once(XSNS_TRUST_PATH.'/include/notification.php')){ $tags = array( 'COMMU_NAME' => $community->getVar('name'), 'TOPIC_NAME' => $topic->getVar('name'), 'TOPIC_BODY' => $new_comment->getVar('body', 'e'), // disallow HTML 'AUTHOR_NAME' => $xoopsUser->getVar('uname'), 'TOPIC_URI' => XSNS_URL_TOPIC.'&tid='.$tid, ); // コミュニティメンバー以外には送信しない $c_member_obj_list =& $community->getMemberObjects(); $c_member_ids = array(); foreach($c_member_obj_list as $c_member_obj){ $c_member_ids[] = $c_member_obj->getVar('uid'); } xsns_main_trigger_event('topic', $cid, 'post', $tags, $c_member_ids); } $xoopsUser->incrementPost(); $sess_handler =& XsnsSessionHandler::getInstance(); $sess_handler->clearVars(); redirect_header(XSNS_URL_TOPIC.'&tid='.$tid, 2, _MD_XSNS_TOPIC_ADD_RES_OK); } redirect_header(XSNS_URL_TOPIC.'&tid='.$tid, 2, _MD_XSNS_TOPIC_ADD_RES_NG); }
function dispatch() { global $xoopsUser; $own_uid = is_object($xoopsUser)? $xoopsUser->getVar('uid') : 0; $limit = 20; $tid = $this->getIntRequest('tid', XSNS_REQUEST_GET); if(!isset($tid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $start = $this->getIntRequest('s', XSNS_REQUEST_GET); $commu_handler =& XsnsCommunityHandler::getInstance(); $topic_handler =& XsnsTopicHandler::getInstance(); $user_handler =& XsnsUserHandler::getInstance(); $image_handler =& XsnsImageHandler::getInstance(); $file_handler =& XsnsFileHandler::getInstance(); // トピックの取得 $topic =& $topic_handler->get($tid); if(!is_object($topic)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $topic_uid = $topic->getVar('uid'); // コミュニティの取得 $cid = $topic->getVar('c_commu_id'); $community =& $commu_handler->get($cid); if(!is_object($community) || ($community->getVar('public_flag')==3 && !$community->checkAuthority())){ redirect_header(XOOPS_URL, 2, _NOPERM); } $main_comment =& $topic->getCommentList(1, 0); if(!is_array($main_comment) || !isset($main_comment[0])){ redirect_header(XOOPS_URL, 2, _NOPERM); } $comment_count_all = $topic->getCommentCount() - 1; if($comment_count_all > 1000){ $comment_count_all = 1000; } if($comment_count_all > 0){ if(!isset($start) || $start < 0 || $start > 1000){ $start = $limit * floor(($comment_count_all-1)/$limit); } if($start >= 1000){ $start = 1000 - $limit; } } else{ $start = 0; } $comment_list_temp =& $topic->getCommentList($limit, $start+1); // except No.0 if(is_array($comment_list_temp)){ $comment_list_temp = $main_comment + $comment_list_temp; } else{ $comment_list_temp = $main_comment; } $sess_handler =& XsnsSessionHandler::getInstance(); $comment_temp = $sess_handler->getVar('comment_body'); $sess_handler->clearVars(); $ts =& XsnsTextSanitizer::getInstance(); $default = array( 'comment' => !empty($comment_temp) ? $ts->makeTboxData4PreviewInForm($comment_temp) : '', ); // 引用レスのポップアップウィンドウ生成 ---------------- $res_ids_temp = array(); $this->vars = array( 'comment_list' => array(), 'comment_checked' => array(), 'res_depth' => 0, ); $this->vars['comment_list'] =& $comment_list_temp; foreach($comment_list_temp as $comment){ $this->vars['res_depth'] = 0; $res_ids_temp = $this->getResIds($tid, $comment['number'], $comment['body']); } if(is_array($this->vars['comment_checked'])){ $res_ids = array_keys($this->vars['comment_checked']); $res_list =& $this->getResList($tid, $res_ids); $res_popup_list =& $this->getResPopupList($limit, $res_ids, $res_list); } else{ $res_list = NULL; } //------------------------------------------------------ $comment_list = array(); $commu_auth = $community->getAuthority(); foreach($comment_list_temp as $comment){ $comment_ids[] = $comment['c_commu_topic_comment_id']; } $image_list =& $image_handler->getListByIds(2, $comment_ids); $file_list =& $file_handler->getListByIds(2, $comment_ids); $author_obj_list = array(); foreach($comment_list_temp as $comment){ $comment_uid = intval($comment['uid']); if($comment_uid > 0){ $tcid = intval($comment['c_commu_topic_comment_id']); if(!isset($author_obj_list[$comment_uid])){ $author_obj_list[$comment_uid] =& $user_handler->get($comment_uid); } if(is_object($author_obj_list[$comment_uid])){ $author_info =& $author_obj_list[$comment_uid]->getInfo(); } else{ $author_info = array(); } $id = intval($comment['c_commu_topic_comment_id']); $images = isset($image_list[$id]) ? $image_list[$id] : array(); $files = isset($file_list[$id]) ? $file_list[$id] : array(); $comment_list[] = array( 'uid' => $comment_uid, 'body' => $this->getResQuotedCommentBody($tid, $comment['number'], $res_list), 'author' => $author_info, 'time' => $comment['r_datetime'], 'number' => $comment['number'], 'images' => $images, 'files' => $files, 'show_edit' => $commu_auth>=XSNS_AUTH_SUB_ADMIN || ($commu_auth>=XSNS_AUTH_MEMBER && ($comment_uid==$own_uid || $topic_uid==$own_uid)), 'show_res_add' => ($commu_auth>=XSNS_AUTH_MEMBER), 'url_edit' => XSNS_URL_TOPIC.'&'.XSNS_ACTION_ARG.'=edit&tcid='.$tcid, 'url_del' => XSNS_URL_TOPIC.'&'.XSNS_ACTION_ARG.'=del&tcid='.$tcid, ); } else{ // deleted topic/comment $comment_list[] = array( 'uid' => 0, 'body' => '', 'time' => $comment['r_datetime'], 'number' => $comment['number'], ); } } $comment_count = count($comment_list) - 1; $pager = $this->getPageSelector(XSNS_URL_TOPIC.'&tid='.$tid, $start, $limit, $comment_count, $comment_count_all); $image_handler->DeleteImageTemp(); $file_handler->DeleteFileTemp(); $commu_vars = array( 'id' => $community->getVar('c_commu_id'), 'name' => $community->getVar('name'), 'auth_level' => $commu_auth, ); $topic_vars = array( 'id' => $tid, 'name' => $topic->getVar('name'), ); $this->context->setAttribute('commu', $commu_vars); $this->context->setAttribute('topic', $topic_vars); $this->context->setAttribute('comment_list', $comment_list); $this->context->setAttribute('comment_count', $comment_count); $this->context->setAttribute('comment_count_all', $comment_count_all); $this->context->setAttribute('pager', $pager); $this->context->setAttribute('res_popup_list', $res_popup_list); $this->context->setAttribute('default', array('body' => $default['comment'])); }
function dispatch() { if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $tid = $this->getIntRequest('tid'); if(!isset($tid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $token_handler = new XoopsMultiTokenHandler(); $token = new XoopsFormToken($token_handler->create('TOPIC_COMMENT_ADD')); // Hidden $token_tag = '<input type="hidden" name="'.$token->_name.'" value="'.$token->_value.'">'; $this->context->setAttribute('token_tag', $token_tag); $commu_handler =& XsnsCommunityHandler::getInstance(); $topic_handler =& XsnsTopicHandler::getInstance(); // トピックの取得 $topic =& $topic_handler->get($tid); if(!is_object($topic) || $topic->getCommentCount() >= 1001){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $cid = $topic->getVar('c_commu_id'); $community =& $commu_handler->get($cid); if(!is_object($community)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_auth = $community->getAuthority(); if($commu_auth < XSNS_AUTH_NON_MEMBER || ($commu_auth < XSNS_AUTH_MEMBER && $community->getVar('public_flag')==3) ){ redirect_header(XOOPS_URL, 2, _NOPERM); } $errors = array(); $body = $this->getTextRequest('body'); if(empty($body)){ $errors[] = _MD_XSNS_TOPIC_RES_BODY_NG; } if(count($errors) > 0){ redirect_header(XSNS_URL_TOPIC.'&tid='.$tid, 2, _MD_XSNS_TOPIC_RES_BODY_NG); } $comment_handler =& XsnsTopicCommentHandler::getInstance(); $new_comment =& $comment_handler->create(); $new_comment->setVar('body', $body); $commu_vars = array('id' => $cid, 'name' => $community->getVar('name')); $sess_handler =& XsnsSessionHandler::getInstance(); $sess_handler->setVar('comment_body', $body); $image_handler =& XsnsImageHandler::getInstance(); $file_handler =& XsnsFileHandler::getInstance(); $topic_vars = array( 'id' => $tid, 'name' => $topic->getVar('name'), 'body' => preg_replace('/\[res\]([1-9]\\d*)\[\/res\]/', '>>\1', $new_comment->getVar('body', 'p')), 'images' => $image_handler->uploadImageTemp('images'), 'files' => $file_handler->uploadFileTemp('files'), ); $this->context->setAttribute('topic', $topic_vars); $this->context->setAttribute('commu', $commu_vars); }
function dispatch() { if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $token_handler = new XoopsMultiTokenHandler(); $token = new XoopsFormToken($token_handler->create('COMMUNITY_ADD')); // Hidden $token_tag = '<input type="hidden" name="'.$token->_name.'" value="'.$token->_value.'">'; $this->context->setAttribute('token_tag', $token_tag); $name = $this->getTextRequest('name'); $cat_id = $this->getIntRequest('category'); $public_id = $this->getIntRequest('public'); $info = $this->getTextRequest('info'); $errors = array(); $commu_handler =& XsnsCommunityHandler::getInstance(); if(!$commu_handler->checkParams(0, $name, $info, $cat_id, $public_id)){ $errors = $commu_handler->getErrors(); } if($public_id < 1 || $public_id > 3){ $public_id = 1; } $new_community =& $commu_handler->create(); $new_community->setVars(array( 'name' => $name, 'info' => $info, )); $sess_handler =& XsnsSessionHandler::getInstance(); $commu_vars_temp = array( 'name' => $name, 'cat_id' => $cat_id, 'public_id' => $public_id, 'info' => $info, ); $sess_handler->setVar('community', $commu_vars_temp); $category_handler =& XsnsCategoryHandler::getInstance(); // check input : NG if(count($errors) > 0){ $default = array( 'name' => $new_community->getVar('name', 'f'), 'info' => $new_community->getVar('info', 'f'), 'public'.$public_id => ' checked', ); $category_selector = $category_handler->getSelectorHtml('category', $cat_id, _MD_XSNS_SELBOX_DEFAULT); $this->context->setAttribute('category_selector', $category_selector); $this->context->setAttribute('default', $default); $this->context->setAttribute('errors', $errors); return "add"; // �� index/addView.php } // check input : OK $image_handler =& XsnsImageHandler::getInstance(); $image_handler->setFormLimit(1); $public_desc = array( '1' => _MD_XSNS_INDEX_PUBLIC_L1, '2' => _MD_XSNS_INDEX_PUBLIC_L2, '3' => _MD_XSNS_INDEX_PUBLIC_L3, ); $category =& $category_handler->get($cat_id); $commu_vars = array( 'name' => $new_community->getVar('name', 'p'), 'category_id' => $cat_id, 'category' => $category->getVar('name', 'p'), 'public_id' => $public_id, 'public' => $public_desc[$public_id], 'info' => $new_community->getVar('info', 'p'), 'image' => $image_handler->uploadImageTemp('image'), ); $this->context->setAttribute('commu', $commu_vars); }
function dispatch() { if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $token_handler = new XoopsMultiTokenHandler(); $token = new XoopsFormToken($token_handler->create('TOPIC_ADD')); // Hidden $token_tag = '<input type="hidden" name="'.$token->_name.'" value="'.$token->_value.'">'; $this->context->setAttribute('token_tag', $token_tag); $cid = $this->getIntRequest('cid'); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_handler =& XsnsCommunityHandler::getInstance(); $topic_handler =& XsnsTopicHandler::getInstance(); $comment_handler =& XsnsTopicCommentHandler::getInstance(); $sess_handler =& XsnsSessionHandler::getInstance(); $image_handler =& XsnsImageHandler::getInstance(); $file_handler =& XsnsFileHandler::getInstance(); // コミュニティの取得 $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $param = array( 'number' => 0, 'name' => $this->getTextRequest('name'), 'body' => $this->getTextRequest('body'), ); $errors = array(); $this->checkParam(&$param, &$errors); $new_topic =& $topic_handler->create(); $new_topic->setVar('name', $param['name']); $new_comment =& $comment_handler->create(); $new_comment->setVar('body', $param['body']); $commu_vars = array('id' => $cid, 'name' => $community->getVar('name')); // 入力エラー if(count($errors) > 0){ $default = array( 'name' => $new_topic->getVar('name', 'f'), 'body' => $new_comment->getVar('body', 'f'), ); $this->context->setAttribute('commu', $commu_vars); $this->context->setAttribute('default', $default); $this->context->setAttribute('errors', $errors); return "add"; // → topic/addView.php } $topic_vars_temp = array( 'name' => $param['name'], 'body' => $param['body'], ); $sess_handler->setVar('topic', $topic_vars_temp); $topic_vars = array( 'name' => $new_topic->getVar('name', 'p'), 'body' => $new_comment->getVar('body', 'p'), 'images' => $image_handler->uploadImageTemp('images'), 'files' => $file_handler->uploadFileTemp('files'), ); $this->context->setAttribute('topic', $topic_vars); $this->context->setAttribute('commu', $commu_vars); }
function dispatch() { $limit = 10; $sess_handler =& XsnsSessionHandler::getInstance(); $sess_handler->clearVars(); $cid = $this->getIntRequest('cid', XSNS_REQUEST_GET); if($cid > 0){ $commu_detail = $this->getCommunityDetail($cid); $this->context->setAttribute('commu', $commu_detail); return "detail"; } $start = $this->getIntRequest('s', XSNS_REQUEST_GET); if(!isset($start) || $start<0){ $start = 0; } $cat_id = $this->getIntRequest('cat_id', XSNS_REQUEST_GET); $keyword = $this->getTextRequest('keyword', XSNS_REQUEST_GET); $sort_method = $this->getTextRequest('sort', XSNS_REQUEST_GET); $commu_handler =& XsnsCommunityHandler::getInstance(); $criteria = new CriteriaCompo(); $criteria->setLimit($limit); $criteria->setStart($start); if($cat_id > 0){ $criteria->add(new Criteria('c_commu_category_id', $cat_id)); } if($keyword != ''){ $kw_criteria = new CriteriaCompo(new Criteria('name', '%'.$keyword.'%', 'LIKE')); $kw_criteria->add(new Criteria('info', '%'.$keyword.'%', 'LIKE'), 'OR'); $criteria->add($kw_criteria); } switch($sort_method){ case 'date': default: $criteria->setSort('cc.r_datetime'); $criteria->setOrder('DESC'); break; case 'member': $criteria->setSort('member_count'); $criteria->setOrder('DESC'); break; case 'pop': $criteria->setSort('cc.popularity'); $criteria->setOrder('DESC'); break; case 'up': $criteria->setSort('cc.update_freq'); $criteria->setOrder('DESC'); break; } $commu_list =& $commu_handler->getList($criteria); $commu_total = $commu_handler->getCount($criteria); $base_url = XSNS_URL_COMMU.'?'; if($cat_id > 0){ $base_url .= "&cat_id=".$cat_id; } if($keyword != ''){ $base_url .= "&keyword=".rawurlencode($keyword); } if($sort_method=='member' || $sort_method=='date' || $sort_method=='pop' || $sort_method=='up'){ $base_url .= '&sort='.$sort_method; } $category_handler =& XsnsCategoryHandler::getInstance(); $category_parent_handler =& XsnsCategoryParentHandler::getInstance(); $category_selector = $category_handler->getSelectorHtml('cat_id', 0, _MD_XSNS_INDEX_CATEGORY_NO); $category_list =& $category_parent_handler->getList(); $pager = $this->getPageSelector($base_url, $start, $limit, count($commu_list), $commu_total); if(count($commu_list)==0){ $pager['description'] = _MD_XSNS_INDEX_COMMU_COUNT0; } $keyword_option = empty($keyword)? '' : '&keyword='.rawurlencode($keyword); $cat_id_option = empty($cat_id)? '' : '&cat_id='.$cat_id; $url = array( 'sort_member' => XSNS_URL_COMMU.'?sort=member'. $keyword_option. $cat_id_option, 'sort_date' => XSNS_URL_COMMU.'?sort=date'. $keyword_option. $cat_id_option, 'sort_pop' => XSNS_URL_COMMU.'?sort=pop'. $keyword_option. $cat_id_option, 'sort_up' => XSNS_URL_COMMU.'?sort=up'. $keyword_option. $cat_id_option, ); $this->context->setAttribute('is_guest', $this->isGuest()); $this->context->setAttribute('keyword', $keyword); $this->context->setAttribute('url', $url); $this->context->setAttribute('category_selector', $category_selector); $this->context->setAttribute('category_list', $category_list); $this->context->setAttribute('pager', $pager); $this->context->setAttribute('commu_list', $commu_list); }
function dispatch() { global $xoopsUser; if($this->isGuest() || !$this->validateToken('TOPIC_ADD')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $cid = $this->getIntRequest('cid'); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $sess_handler =& XsnsSessionHandler::getInstance(); $topic = $sess_handler->getVar('topic'); if(!is_array($topic) || !isset($topic['name']) || !isset($topic['body'])){ redirect_header(XOOPS_URL, 2, _NOPERM); } $r_datetime = date('Y-m-d H:i:s'); $r_date = date('Y-m-d'); $topic_handler =& XsnsTopicHandler::getInstance(); $new_topic =& $topic_handler->create(); $new_topic->setVars(array( 'c_commu_id' => $cid, 'name' => $topic['name'], 'r_datetime' => $r_datetime, 'r_date' => $r_date, 'uid' => $own_uid, )); if($tid = $topic_handler->insert($new_topic)){ $comment_handler =& XsnsTopicCommentHandler::getInstance(); $new_comment =& $comment_handler->create(); $new_comment->setVars(array( 'c_commu_topic_id' => $tid, 'c_commu_id' => $cid, 'uid' => $own_uid, 'body' => $topic['body'], 'r_datetime' => $r_datetime, 'r_date' => $r_date, 'number' => 0, )); if($tcid = $comment_handler->insert($new_comment)){ // トピックのコメントに対して画像を添付 $image_handler =& XsnsImageHandler::getInstance(); $image_ids = $image_handler->uploadImage('t', 2, $tcid); // トピックのコメントに対してファイルを添付 $file_handler =& XsnsFileHandler::getInstance(); $file_ids = $file_handler->uploadFile('t', 2, $tcid); // イベント通知 if(include_once(XSNS_TRUST_PATH.'/include/notification.php')){ $tags = array( 'COMMU_NAME' => $community->getVar('name'), 'TOPIC_NAME' => $new_topic->getVar('name'), 'TOPIC_BODY' => $new_comment->getVar('body', 'e'), // disallow HTML 'AUTHOR_NAME' => $xoopsUser->getVar('uname'), 'TOPIC_URI' => XSNS_URL_TOPIC.'&tid='.$tid, ); // コミュニティメンバー以外には送信しない $c_member_obj_list =& $community->getMemberObjects(); $c_member_ids = array(); foreach($c_member_obj_list as $c_member_obj){ $c_member_ids[] = $c_member_obj->getVar('uid'); } xsns_main_trigger_event('topic', $cid, 'create', $tags, $c_member_ids); } $xoopsUser->incrementPost(); $sess_handler->clearVars(); redirect_header(XSNS_URL_TOPIC.'&tid='.$tid, 2, _MD_XSNS_TOPIC_ADD_OK); } } redirect_header(XSNS_URL_TOPIC.'&'.XSNS_ACTION_ARG.'=add&cid='.$cid, 2, _MD_XSNS_TOPIC_ADD_NG); }