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 getDeleteImageConfirmFormData($image_id) { global $xoopsModuleConfig; $image_handler =& XsnsImageHandler::getInstance(); $image =& $image_handler->get($image_id); if(!is_object($image)){ return false; } $image_info =& $image->getInfo(2); $filename = $xoopsModuleConfig['file_upload_path']. '/'. $image_info['filename']; if(!file_exists($filename)){ return false; } $ext_to_mime = include(XOOPS_ROOT_PATH.'/class/mimetypes.inc.php'); $path_parts = @pathinfo($filename); $file_stat = @stat($filename); $form_data = array( 'title' => _MD_XSNS_TITLE_IMAGE, 'desc' => _MD_XSNS_FILE_DEL_IMAGE_DESC, 'file_name_desc' => _MD_XSNS_FILE_IMAGE, 'name' => "<img src='".XSNS_IMAGE_URL."?f=".$image_info['filename']."&t=2' alt=''>", 'size' => filesize($filename), 'type' => @$ext_to_mime[$path_parts['extension']], 'time' => xoops_getUserTimestamp($file_stat['mtime']), ); return $form_data; }
function dispatch() { if($this->isGuest() || !$this->validateToken('COMMUNITY_EDIT')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $cid = $this->getIntRequest('cid'); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $perm = XSNS_AUTH_XOOPS_ADMIN | XSNS_AUTH_ADMIN; $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority($perm)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // 入力データのチェック $name = $this->getTextRequest('name'); $info = $this->getTextRequest('info'); $cat_id = $this->getIntRequest('category'); $public_id = $this->getIntRequest('public'); if(!$commu_handler->checkParams($cid, $name, $info, $cat_id, $public_id)){ $errors = $commu_handler->getErrors(); if(count($errors) > 0){ $msg = ""; foreach($errors as $err){ $msg .= $err."<br>"; } redirect_header(XSNS_URL_COMMU.'?'.XSNS_ACTION_ARG.'=edit&cid='.$cid, 3, $msg); } } $old_name = $community->getVar('name'); // コミュニティ情報の更新 $community->setVar('name', $name); $community->setVar('info', $info); $community->setVar('c_commu_category_id', $cat_id); $community->setVar('public_flag', $public_id); $category_handler =& XsnsCategoryHandler::getInstance(); if(($cid = $commu_handler->insert($community)) && $category_handler->updateSelector()){ // 画像のアップロード $image_handler =& XsnsImageHandler::getInstance(); $image_handler->setFormLimit(1); if($image_handler->uploadImageTemp('image')){ $image_handler->uploadImage('c', 1, $cid); } redirect_header(XSNS_URL_COMMU.'?cid='.$cid, 2, sprintf(_MD_XSNS_INDEX_EDIT_OK, $old_name)); } redirect_header(XSNS_URL_COMMU.'?cid='.$cid, 2, _MD_XSNS_INDEX_EDIT_NG); }
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 dispatch() { if($this->isGuest() || !$this->validateToken('COMMUNITY_DELETE')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $cid = $this->getIntRequest('cid'); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $perm = XSNS_AUTH_XOOPS_ADMIN | XSNS_AUTH_ADMIN; $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority($perm) || $community->getTopicCount() > 0){ redirect_header(XOOPS_URL, 2, _NOPERM); } $old_name = $community->getVar('name'); if($commu_handler->delete($community)){ $category_handler =& XsnsCategoryHandler::getInstance(); if($category_handler->updateSelector()){ $criteria = new Criteria('c_commu_id', $cid); // 所属メンバーデータの削除 $c_member_handler =& XsnsMemberHandler::getInstance(); $c_member_handler->deleteObjects($criteria); // 依頼データの削除 $confirm_handler =& XsnsConfirmHandler::getInstance(); $confirm_handler->deleteObjects($criteria); // アクセスログの削除 $access_log_handler =& XsnsAccessLogHandler::getInstance(); $access_log_handler->deleteObjects($criteria); // 画像の削除 $image_criteria = new CriteriaCompo(new Criteria('target', 1)); $image_criteria->add(new Criteria('target_id', $cid)); $image_handler =& XsnsImageHandler::getInstance(); $image_handler->deleteObjects($image_criteria); redirect_header(XSNS_URL_COMMU, 2, sprintf(_MD_XSNS_INDEX_DEL_OK, $old_name)); } } redirect_header(XSNS_URL_COMMU, 2, _MD_XSNS_INDEX_DEL_NG); }
function dispatch() { if(!$this->validateToken('FILE_DELETE')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $image_id = $this->getIntRequest('image_id'); $file_id = $this->getIntRequest('file_id'); if(($image_id > 0 && $file_id > 0) || !$this->checkAuthority($image_id, $file_id)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $url = XSNS_URL_COMMU; if($image_id > 0){ $image_handler =& XsnsImageHandler::getInstance(); $image =& $image_handler->get($image_id); if(is_object($image) && $image_handler->delete($image)){ $msg = _MD_XSNS_FILE_DEL_IMAGE_OK; $url = $this->getRedirectURL($image->getVar('target'), $image->getVar('target_id')); } else{ $msg = _MD_XSNS_FILE_DEL_IMAGE_NG; } } elseif($file_id > 0){ $file_handler =& XsnsFileHandler::getInstance(); $file =& $file_handler->get($file_id); if(is_object($file) && $file_handler->delete($file)){ $msg = _MD_XSNS_FILE_DEL_FILE_OK; $url = $this->getRedirectURL($file->getVar('target'), $file->getVar('target_id')); } else{ $msg = _MD_XSNS_FILE_DEL_FILE_NG; } } else{ redirect_header(XOOPS_URL, 2, _NOPERM); } if(empty($url)){ redirect_header(XOOPS_URL, 2, _NOPERM); } redirect_header($url, 2, $msg); }
function XsnsTopicComment() { // $key, $data_type, $default, $required, $size $this->initVar('c_commu_topic_comment_id', XOBJ_DTYPE_INT); $this->initVar('c_commu_topic_id', XOBJ_DTYPE_INT); $this->initVar('c_commu_id', XOBJ_DTYPE_INT); $this->initVar('uid', XOBJ_DTYPE_INT); $this->initVar('body', XOBJ_DTYPE_TXTAREA); $this->initVar('r_datetime', XOBJ_DTYPE_DATETIME); $this->initVar('r_date', XOBJ_DTYPE_DATE); $this->initVar('number', XOBJ_DTYPE_INT); $this->handler = array( 'image' => XsnsImageHandler::getInstance(), 'file' => XsnsFileHandler::getInstance(), 'comment' => XsnsTopicCommentHandler::getInstance(), ); }
function dispatch() { if(!$this->validateToken('IMAGE_DELETE')){ redirect_header(XSNS_URL_ADMIN, 2, _NOPERM); } $del_id = isset($_POST['delete']) ? $_POST['delete'] : NULL; if(is_null($del_id) || !is_array($del_id)){ redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=image', 2, _AM_XSNS_IMAGE_SELECT_NG); } $image_handler =& XsnsImageHandler::getInstance(); foreach($del_id as $id){ $image =& $image_handler->get($id); $image_handler->delete($image); } redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=image', 2, _AM_XSNS_IMAGE_DELETE_OK); }
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 &getList($criteria = NULL) { $limit = $start = 0; $ret = array(); $sql = "SELECT cc.*,COUNT(ccm.uid) AS member_count FROM ". $this->prefix($this->table_name)." cc". " LEFT JOIN ".$this->prefix('c_commu_member')." ccm". " ON cc.c_commu_id=ccm.c_commu_id"; $sql_order = ""; if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $sql_where = $criteria->render(); if(!empty($sql_where)){ $sql .= " WHERE ".$sql_where; } $limit = $criteria->getLimit(); $start = $criteria->getStart(); if ($criteria->getSort() != '') { $sql_order .= " ORDER BY ".$criteria->getSort()." ".$criteria->getOrder(); } } $sql .= " GROUP BY ccm.c_commu_id". $sql_order; $result = $this->db->query($sql, $limit, $start); if (!$result) { return $ret; } $obj_list = array(); $cids = array(); $cat_ids = array(); $image_handler =& XsnsImageHandler::getInstance(); $image_handler->setFormLimit(1); $category_handler =& XsnsCategoryHandler::getInstance(); while ($row = $this->db->fetchArray($result)) { $obj = new $this->obj_class(); $obj->assignVars($row); $cid = $obj->getVar('c_commu_id'); $obj_list[$cid] = $obj; $cids[] = $cid; } $image_list =& $image_handler->getListByIds(1, $cids, XSNS_IMAGE_SIZE_S); $category_list =& $category_handler->getNameList(); foreach($obj_list as $cid => $obj){ if(!is_object($obj)){ continue; } $cat_id = $obj->getVar('c_commu_category_id'); $ret[] = array( 'c_commu_id' => $cid, 'name' => $obj->getVar('name'), // 'info' => $obj->getVar('info', 'x'), // stripXoopsCode 'info' => strip_tags($obj->getVar('info')), // naao 'category_name' => isset($category_list[$cat_id]) ? $category_list[$cat_id] : "", 'member_count' => $obj->getMemberCount(), // != $row['member_count'] 'page_url' => XSNS_BASE_URL.'/?cid='.$cid, 'image' => isset($image_list[$cid][0]) ? $image_list[$cid][0] : array(), ); } return $ret; }
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() { global $xoopsModuleConfig; $err = $this->checkPermission(); if(!is_array($err) || count($err) > 0){ $this->context->setAttribute('perm_error', $err); return "default"; } $limit = 10; $start = $this->getIntRequest('s', XSNS_REQUEST_GET); if(!isset($start) || $start<0){ $start = 0; } $criteria = new CriteriaCompo(NULL); $criteria->setLimit($limit); $criteria->setStart($start); $criteria->setSort('c_image_id'); $criteria->setOrder('DESC'); $image_handler =& XsnsImageHandler::getInstance(); $image_obj_list =& $image_handler->getObjects($criteria); $image_list = array(); $user_handler =& xoops_gethandler('user'); $comment_handler =& XsnsTopicCommentHandler::getInstance(); $comment = array(); foreach($image_obj_list as $image_obj){ $image_id = $image_obj->getVar('c_image_id'); $filename = $image_obj->getVar('filename'); $image_path = $xoopsModuleConfig['file_upload_path']. '/'. $filename; $width = $height = 0; if($imagesize = @getimagesize($image_path)){ $width = $imagesize[0]; $height = $imagesize[1]; } $file_info = @stat($image_path); $author_obj =& $user_handler->get($image_obj->getVar('uid')); $author_name = is_object($author_obj) ? $author_obj->getVar('uname') : ""; $page_url = ""; $target = $image_obj->getVar('target'); $target_id = $image_obj->getVar('target_id'); if($target==1){ $page_url = XSNS_URL_COMMU.'?cid='.$target_id; } elseif($target==2){ if(!isset($comment[$target_id])){ $comment[$target_id] =& $comment_handler->get($target_id); } if(is_object($comment[$target_id])){ $page_url = XSNS_URL_TOPIC.'&tid='.$comment[$target_id]->getVar('c_commu_topic_id'); } } $image_list[$image_id] = array( 'id' => $image_id, 'author' => $author_name, 'url' => XSNS_IMAGE_URL."?f=".$filename, 'ref_link' => empty($page_url) ? "-" : "<a href='".$page_url."' target='_blank'>URL</a>", 'link' => XSNS_IMAGE_URL."?f=".$filename."&t=1", 'width' => $width, 'height' => $height, 'size' => number_format($file_info['size']), 'time' => str_replace(" ", "<br><br>", date('Y-m-d H:i:s', $file_info['mtime'])), 'active' => "checked", ); unset($author_obj); } $pager = $this->getPageSelector('index.php?'.XSNS_ACTION_ARG.'=image', $start, $limit, count($image_list), $image_handler->getCount(), "#FFCCCC"); $this->context->setAttribute('image_list', $image_list); $this->context->setAttribute('pager', $pager); }
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); }
function getCommunityDetail($cid) { global $xoopsUser; $topic_limit = 10; $commu_handler =& XsnsCommunityHandler::getInstance(); $c_member_handler =& XsnsMemberHandler::getInstance(); $user_handler =& XsnsUserHandler::getInstance(); $image_handler =& XsnsImageHandler::getInstance(); $topic_handler =& XsnsTopicHandler::getInstance(); $comment_handler =& XsnsTopicCommentHandler::getInstance(); // コミュニティの取得 $community =& $commu_handler->get($cid); if(!is_object($community)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $community->setStatistics(); // コミュニティメンバー一覧の取得 $c_member_obj_list =& $community->getMemberObjects(9, 0, true); $c_member_list = array(); foreach($c_member_obj_list as $c_member_obj){ $c_member_list[] =& $c_member_obj->getInfo(); } $c_member_count = count($c_member_obj_list); if($c_member_count < 9){ for($i=0; $i<9-$c_member_count; $i++){ $c_member_list[] = array(); } } $uid_admin = $community->getVar('uid_admin'); $own_uid = ($this->isXoopsUser()) ? $xoopsUser->getVar('uid') : 0; if($c_member_handler->getOne($cid, $own_uid)){ $is_member = true; $is_admin = ($own_uid == $uid_admin)? true : false; } else{ $is_member = $is_admin = false; } $commu_auth = $community->getAuthority(); $public_flag = $community->getVar('public_flag'); $admin_obj =& $user_handler->get($uid_admin); $admin_name = is_object($admin_obj) ? $admin_obj->getVar('uname') : ""; $public_flag_desc = array( 1 => _MD_XSNS_INDEX_DETAIL_PUBLIC_L1, 2 => _MD_XSNS_INDEX_DETAIL_PUBLIC_L2, 3 => _MD_XSNS_INDEX_DETAIL_PUBLIC_L3, ); $ret = array( 'id' => $cid, 'name' => $community->getVar('name'), 'info' => $community->getVar('info'), 'time' => $community->getVar('r_datetime'), 'image' => $community->getImage(XSNS_IMAGE_SIZE_L), 'category' => $community->getCategoryName(), 'public' => $public_flag_desc[$public_flag], 'admin_name' => $admin_name, 'admin_url' => XSNS_URL_MYPAGE.'&uid='.$uid_admin, 'statistics' => $community->getStatistics(), 'member_list' => $c_member_list, 'member_count' => $community->getMemberCount(), 'topic_list' => $community->getTopicList($topic_limit), 'topic_count' => $community->getTopicCount(), 'show_commu_join' => (!$is_member && $commu_auth > XSNS_AUTH_GUEST) ? true : false, 'show_commu_leave' => ($is_member && !$is_admin) ? true : false, 'show_commu_notify' => ($is_member) ? true : false, 'show_commu_config' => ($commu_auth >= XSNS_AUTH_ADMIN) ? true : false, 'show_topic_list' => ($public_flag!=3 || $commu_auth>=XSNS_AUTH_MEMBER) ? true : false, 'show_topic_add' => ($commu_auth >= XSNS_AUTH_MEMBER) ? true : false, 'show_send_message' => ($commu_auth >= XSNS_AUTH_MEMBER) ? true : false, 'show_member_config' => ($commu_auth >= XSNS_AUTH_ADMIN) ? true : false, ); return $ret; }
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; if($this->isGuest() || !$this->validateToken('TOPIC_EDIT')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $tcid = $this->getIntRequest('tcid'); $commu_handler =& XsnsCommunityHandler::getInstance(); $topic_handler =& XsnsTopicHandler::getInstance(); $comment_handler =& XsnsTopicCommentHandler::getInstance(); $image_handler =& XsnsImageHandler::getInstance(); $file_handler =& XsnsFileHandler::getInstance(); // コメントの取得 $comment =& $comment_handler->get($tcid); if(!is_object($comment)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $tid = $comment->getVar('c_commu_topic_id'); // トピックの取得 $topic =& $topic_handler->get($tid); if(!is_object($topic)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $cid = $topic->getVar('c_commu_id'); // コミュニティの取得 $community =& $commu_handler->get($topic->getVar('c_commu_id')); if(!is_object($community)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_auth = $community->getAuthority(); if($commu_auth < XSNS_AUTH_MEMBER){ redirect_header(XOOPS_URL, 2, _NOPERM); } $param = array( 'number' => $comment->getNumber(), 'name' => $this->getTextRequest('name'), 'body' => $this->getTextRequest('body'), ); $errors = array(); $this->checkParam(&$param, &$errors); $temp_topic =& $topic_handler->create(); $temp_topic->setVars(array( 'name' => $param['name'], )); $temp_comment =& $comment_handler->create(); $temp_comment->setVar('body', $param['body']); if(count($errors) > 0){ $topic_name = $temp_topic->getVar('name', 'e'); $topic_vars = array( 'id' => $tid, 'tcid' => $tcid, 'name' => empty($topic_name) ? $topic->getVar('name', 'e') : $topic_name, ); $comment_body = $temp_comment->getVar('body', 'e'); $comment_vars = array( 'number' => $param['number'], 'body' => empty($comment_body) ? $comment->getVar('body', 'e') : $comment_body, 'images' => $comment->getImageList(2, XSNS_IMAGE_SIZE_S), 'files' => $comment->getFileList(2), ); $commu_vars = array( 'id' => $cid, 'name' => $community->getVar('name'), ); $this->context->setAttribute('topic', $topic_vars); $this->context->setAttribute('commu', $commu_vars); $this->context->setAttribute('comment', $comment_vars); $this->context->setAttribute('errors', $errors); return "edit"; // → topic/editView.php } $topic_uid = $topic->getVar('uid'); $comment_uid = $comment->getVar('uid'); if($comment_uid > 0 && ($own_uid == $topic_uid || $own_uid == $comment_uid || $commu_auth >= XSNS_AUTH_SUB_ADMIN)){ $r_datetime = date('Y-m-d H:i:s'); // $r_date = date('Y-m-d'); $topic->setVars(array( 'name' => $param['name'], // 'r_datetime' => $r_datetime, // naao 編集時に、トピ日時を更新しない // 'r_date' => $r_date, )); if($topic_handler->insert($topic)){ $tcid = $comment->getVar('c_commu_topic_comment_id'); if($image_handler->uploadImageTemp('images')){ $image_handler->uploadImage('t', 2, $tcid); } if($file_handler->uploadFileTemp('files')){ $file_handler->uploadFile('t', 2, $tcid); } $comment->setVars(array( 'body' => $param['body'], 'number' => $param['number'], // 'r_datetime' => $r_datetime, // naao 編集時に、トピ日時を更新しない // 'r_date' => $r_date, )); if($comment_handler->insert($comment)){ $msg = ($param['number']==0)? _MD_XSNS_TOPIC_EDIT_OK : _MD_XSNS_TOPIC_EDIT_RES_OK; } else{ $msg = ($param['number']==0)? _MD_XSNS_TOPIC_EDIT_NG : _MD_XSNS_TOPIC_EDIT_RES_NG; } } else{ $msg = _MD_XSNS_TOPIC_EDIT_NG; } redirect_header(XSNS_URL_TOPIC.'&tid='.$tid, 2, $msg); } redirect_header(XOOPS_URL, 2, _NOPERM); }
function &getListForCommunity($cid, $limit=0, $start=0, $get_body=false) { $ts =& XsnsTextSanitizer::getInstance(); $image_handler =& XsnsImageHandler::getInstance(); $file_handler =& XsnsFileHandler::getInstance(); $ret = array(); $base_url = XSNS_URL_TOPIC.'&tid='; $sql = "SELECT ". "ct.c_commu_topic_id AS tid,". "ct.name AS tname,". "MAX(ctc.r_datetime) AS max_r_datetime,". "ctc.c_commu_topic_comment_id AS tcid,". "COUNT(*) AS comment_count". " FROM ". $this->prefix('c_commu_topic_comment'). " ctc". " INNER JOIN ". $this->prefix('c_commu_topic'). " ct". " USING(c_commu_topic_id)". " WHERE ct.c_commu_id='".intval($cid)."'". " GROUP BY ctc.c_commu_topic_id". " ORDER BY max_r_datetime DESC"; $rs = $this->db->query($sql, $limit, $start); if(!$rs){ return $ret; } if($get_body){ $comment_handler =& XsnsTopicCommentHandler::getInstance(); while($row = $this->db->fetchArray($rs)){ $comment =& $comment_handler->getByNumber($row['tid'], 0); $ret[] = array( 'name' => $ts->makeTboxData4Show($row['tname']), 'time' => XsnsUtils::getUserTimestamp($row['max_r_datetime']), 'page_url' => $base_url. intval($row['tid']), 'comment_count' => intval($row['comment_count'])-1, // except comment No.0 'body' => $comment->getVar('body'), 'images' => $image_handler->getList(2, intval($row['tcid'])), 'files' => $file_handler->getList(2, intval($row['tcid'])), ); unset($comment); } } else{ while($row = $this->db->fetchArray($rs)){ $ret[] = array( 'name' => $ts->makeTboxData4Show($row['tname']), 'time' => XsnsUtils::getUserTimestamp($row['max_r_datetime']), 'page_url' => $base_url. intval($row['tid']), 'comment_count' => intval($row['comment_count'])-1, // except comment No.0 'body' => '', ); unset($comment); } } return $ret; }
function checkAuthority($image_id, $file_id) { global $xoopsUser, $xoopsUserIsAdmin; if($xoopsUserIsAdmin){ return true; } if($this->isGuest()){ return false; } $own_uid = $xoopsUser->getVar('uid'); if($image_id > 0){ $image_handler =& XsnsImageHandler::getInstance(); $data =& $image_handler->get($image_id); } elseif($file_id > 0){ $file_handler =& XsnsFileHandler::getInstance(); $data =& $file_handler->get($file_id); } else{ return false; } if(!is_object($data)){ return false; } $target = $data->getVar('target'); $target_id = $data->getVar('target_id'); $commu_handler =& XsnsCommunityHandler::getInstance(); $c_member_handler =& XsnsMemberHandler::getInstance(); if($target == 1){ // for community $community =& $commu_handler->get($target_id); if(!is_object($community)){ return false; } $c_member =& $c_member_handler->getOne($target_id, $own_uid); if(!is_object($c_member)){ return false; } if($own_uid == $community->getVar('uid_admin')){ // admin only return true; } } elseif($target == 2){ // for topic/comment $comment_handler =& XsnsTopicCommentHandler::getInstance(); $comment =& $comment_handler->get($target_id); if(!is_object($comment)){ return false; } $tid = $comment->getVar('c_commu_topic_id'); $topic_handler =& XsnsTopicHandler::getInstance(); $topic =& $topic_handler->get($tid); if(!is_object($topic)){ return false; } $cid = $comment->getVar('c_commu_id'); $community =& $commu_handler->get($cid); if(!is_object($community)){ return false; } $c_member =& $c_member_handler->getOne($cid, $own_uid); if(!is_object($c_member)){ return false; } if($own_uid == $comment->getVar('uid') || $own_uid == $topic->getVar('uid') || $own_uid == $community->getVar('uid_admin') || $own_uid == $community->getVar('uid_sub_admin')){ return true; } } return false; }
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() { global $xoopsUser; if($this->isGuest() || !$this->validateToken('TOPIC_DELETE')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $tcid = $this->getIntRequest('tcid'); if(!isset($tcid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_handler =& XsnsCommunityHandler::getInstance(); $topic_handler =& XsnsTopicHandler::getInstance(); $comment_handler =& XsnsTopicCommentHandler::getInstance(); // コメントの取得 $comment =& $comment_handler->get($tcid); if(!is_object($comment)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $tid = $comment->getVar('c_commu_topic_id'); $num = $comment->getNumber(); // トピックの取得 $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)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_auth = $community->getAuthority(); if($commu_auth < XSNS_AUTH_MEMBER){ redirect_header(XOOPS_URL, 2, _NOPERM); } $comment_uid = $comment->getVar('uid'); if($comment_uid < 1 || ($commu_auth < XSNS_AUTH_SUB_ADMIN && $own_uid != $comment_uid && $own_uid != $topic_uid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } if($num > 0){ // コメントの削除 ・・・ 投稿者・本文データのみ削除する $comment->setVar('uid', 0); $comment->setVar('body', ''); if($comment_handler->insert($comment)){ // コメントに添付された画像・ファイルを削除 $criteria = new CriteriaCompo(new Criteria('target', 2)); $criteria->add(new Criteria('target_id', $tcid)); $image_handler =& XsnsImageHandler::getInstance(); $image_handler->deleteObjects($criteria); $file_handler =& XsnsFileHandler::getInstance(); $file_handler->deleteObjects($criteria); redirect_header(XSNS_URL_TOPIC.'&tid='.$tid, 2, _MD_XSNS_TOPIC_DEL_RES_OK); } redirect_header(XSNS_URL_TOPIC.'&tid='.$tid, 2, _MD_XSNS_TOPIC_DEL_RES_NG); } else{ // トピックの削除 ・・・ トピックおよびコメントを完全に削除する if($topic->deleteCommentsAll() && $topic_handler->delete($topic)){ redirect_header(XSNS_URL_COMMU.'?cid='.$cid, 2, _MD_XSNS_TOPIC_DEL_OK); } redirect_header(XSNS_URL_TOPIC.'&tid='.$tid, 2, _MD_XSNS_TOPIC_DEL_NG); } }
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); }