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); } // コミュニティの取得 $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); } $commu_data = array( 'id' => $cid, 'name' => $community->getVar('name'), 'info' => $community->getVar('info'), ); $this->context->setAttribute('commu', $commu_data); }
function dispatch() { global $xoopsUser; if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $cid = $this->getIntRequest('cid', XSNS_REQUEST_GET); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $perm = XSNS_AUTH_MEMBER | XSNS_AUTH_SUB_ADMIN; $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority($perm) || $community->getVar('uid_admin') == $own_uid){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu = array( 'id' => $cid, 'name' => $community->getVar('name'), ); $this->context->setAttribute('commu', $commu); }
function XsnsCommunity() { // $key, $data_type, $default, $required, $size $this->initVar('c_commu_id', XOBJ_DTYPE_INT); $this->initVar('name', XOBJ_DTYPE_TXTBOX); $this->initVar('uid_admin', XOBJ_DTYPE_INT); $this->initVar('uid_sub_admin', XOBJ_DTYPE_INT); $this->initVar('info', XOBJ_DTYPE_TXTAREA); $this->initVar('c_commu_category_id', XOBJ_DTYPE_INT); $this->initVar('r_datetime', XOBJ_DTYPE_DATETIME); $this->initVar('r_date', XOBJ_DTYPE_DATE); $this->initVar('public_flag', XOBJ_DTYPE_INT); $this->initVar('access_count', XOBJ_DTYPE_INT); $this->initVar('update_freq', XOBJ_DTYPE_FLOAT); $this->initVar('popularity', XOBJ_DTYPE_FLOAT); $this->initVar('up_datetime', XOBJ_DTYPE_DATETIME); $this->handler = array( 'community' => XsnsCommunityHandler::getInstance(), 'user' => XsnsUserHandler::getInstance(), 'member' => XsnsMemberHandler::getInstance(), 'image' => XsnsImageHandler::getInstance(), 'topic' => XsnsTopicHandler::getInstance(), 'comment' => XsnsTopicCommentHandler::getInstance(), 'category' => XsnsCategoryHandler::getInstance(), 'access_log' => XsnsAccessLogHandler::getInstance(), ); }
function dispatch() { global $xoopsUser, $xoopsUserIsAdmin; if($this->isGuest() || !$this->validateToken('MEMBER_EDIT')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $cid = $this->getIntRequest('cid'); $uid = $this->getIntRequest('uid'); if(!$cid || !$uid || $uid == $own_uid){ 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); } // 対象コミュニティメンバーの取得 $c_member_handler =& XsnsMemberHandler::getInstance(); $c_member =& $c_member_handler->getOne($cid, $uid); if(!is_object($c_member)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $c_member_info =& $c_member->getInfo(); // コミュニティメンバーの強制退会 if($c_member_handler->delete($c_member)){ // 既存の依頼を削除 $confirm_handler =& XsnsConfirmHandler::getInstance(); $criteria = new CriteriaCompo(new Criteria('c_commu_id', $cid)); $criteria->add(new Criteria('uid_from', $own_uid)); $criteria->add(new Criteria('uid_to', $uid)); $criteria->add(new Criteria('mode', '(1,2)', 'IN')); // 管理者交代 or 副管理者就任 $confirm_handler->deleteObjects($criteria); // XOOPS管理者による特別な処理 if($xoopsUserIsAdmin){ // 対象が管理者の場合、自分が管理者に代わる if($uid == $community->getVar('uid_admin')){ $community->setVar('uid_admin', $own_uid); } // 対象が副管理者の場合、副管理者は無しにする elseif($uid == $community->getVar('uid_sub_admin')){ $community->setVar('uid_sub_admin', 0); } $commu_handler->insert($community); } redirect_header(XSNS_URL_COMMU.'?cid='.$cid, 2, sprintf(_MD_XSNS_MEMBER_LEAVE_OK, $c_member_info['name'])); } redirect_header(XSNS_URL_COMMU, 2, _MD_XSNS_MEMBER_LEAVE_NG); }
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 XsnsCategoryHandler() { parent::XsnsRootHandler(); $this->obj_class = "XsnsCategory"; $this->table_name = "c_commu_category"; $this->primary_key = "c_commu_category_id"; $this->handler = array( 'cat_parent' => XsnsCategoryParentHandler::getInstance(), 'community' => XsnsCommunityHandler::getInstance(), ); }
function dispatch() { global $xoopsUser; $confirm_id = $this->getIntRequest('confirm_id'); if($confirm_id < 1){ redirect_header(XOOPS_URL, 2, _NOPERM); } if($this->isGuest() || !$this->validateToken('CONFIRM_REJECT_ID'.$confirm_id)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // 依頼情報の取得 $confirm_handler =& XsnsConfirmHandler::getInstance(); $confirm =& $confirm_handler->get($confirm_id); if(!is_object($confirm)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $cid = $confirm->getVar('c_commu_id'); $uid_from = $confirm->getVar('uid_from'); $uid_to = $confirm->getVar('uid_to'); $mode = $confirm->getVar('mode'); if($uid_to != $xoopsUser->getVar('uid')){ redirect_header(XOOPS_URL, 2, _NOPERM); } // ユーザーの取得(依頼者が存在しなくても処理を続行) $user_handler =& XsnsUserHandler::getInstance(); $user_to =& $user_handler->get($uid_to); if(!is_object($user_to)){ redirect_header(XOOPS_URL, 2, _NOPERM); } if($mode < 3){ // コミュニティの取得 $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || $community->getAuthority() < XSNS_AUTH_MEMBER){ redirect_header(XOOPS_URL, 2, _NOPERM); } } // 依頼の削除 if($confirm_handler->delete($confirm)){ $url = ($confirm_handler->getCount(new Criteria('uid_to', $uid_to)) > 0) ? XSNS_URL_MYPAGE.'&'.XSNS_ACTION_ARG.'=confirm' : XSNS_URL_MYPAGE; redirect_header($url, 2, sprintf(_MD_XSNS_CONFIRM_REJECT_OK, $user_to->getVar('uname'))); } redirect_header(XSNS_URL_MYPAGE, 2, _MD_XSNS_CONFIRM_REJECT_NG); }
function XsnsAccessLogHandler() { parent::XsnsRootHandler(); $this->obj_class = "XsnsAccessLog"; $this->table_name = "c_commu_access_log"; $this->primary_key = "c_access_log_id"; $this->handler = array( 'community' => XsnsCommunityHandler::getInstance(), 'user' => XsnsUserHandler::getInstance(), ); }
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 XsnsUser() { $this->XoopsUser(); $this->ts =& XsnsTextSanitizer::getInstance(); $this->handler = array( 'community' => XsnsCommunityHandler::getInstance(), 'member' => XsnsMemberHandler::getInstance(), 'user' => XsnsUserHandler::getInstance(), 'friend' => XsnsFriendHandler::getInstance(), 'confirm' => XsnsConfirmHandler::getInstance(), 'module_config' => XsnsModuleConfigHandler::getInstance(), 'intro' => XsnsIntroductionHandler::getInstance(), ); }
function dispatch() { global $xoopsUser; if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $cid = $this->getIntRequest('cid', XSNS_REQUEST_GET); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $perm = XSNS_AUTH_NON_MEMBER; $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority($perm)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $public_flag = $community->getVar('public_flag'); $is_public = true; if($public_flag > 1){ $is_public = false; // 依頼送信済みかどうかの確認 $uid_admin = $community->getVar('uid_admin'); $confirm_handler =& XsnsConfirmHandler::getInstance(); if($confirm_handler->getOne($cid, $own_uid, $uid_admin, 0)){ redirect_header(XSNS_URL_COMMU.'?cid='.$cid, 2, _MD_XSNS_INDEX_JOIN_REQ_NG_ALREADY); } } $commu = array( 'id' => $cid, 'name' => $community->getVar('name'), 'is_public' => $is_public, ); $this->context->setAttribute('commu', $commu); }
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_EDIT')); // Hidden $token_tag = '<input type="hidden" name="'.$token->_name.'" value="'.$token->_value.'">'; $this->context->setAttribute('token_tag', $token_tag); $cid = $this->getIntRequest('cid', XSNS_REQUEST_GET); 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); } $commu_data = array( 'id' => $cid, 'name' => $community->getVar('name', 'e'), 'info' => $community->getVar('info', 'e'), 'del_enabled' => ($community->getTopicCount()==0)? true : false, 'image' => $community->getImage(XSNS_IMAGE_SIZE_S), ); $category_handler =& XsnsCategoryHandler::getInstance(); $category_selector = $category_handler->getSelectorHtml('category', $community->getVar('c_commu_category_id')); $this->context->setAttribute('commu', $commu_data); $this->context->setAttribute('public_flag', $community->getVar('public_flag')); $this->context->setAttribute('category_selector', $category_selector); }
function dispatch() { global $xoopsUser; if($this->isGuest() || !$this->validateToken('COMMUNITY_LEAVE')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $cid = $this->getIntRequest('cid'); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $perm = XSNS_AUTH_MEMBER | XSNS_AUTH_SUB_ADMIN; $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority($perm) || $community->getVar('uid_admin') == $own_uid){ redirect_header(XOOPS_URL, 2, _NOPERM); } // 対象コミュニティメンバーの取得 $c_member_handler =& XsnsMemberHandler::getInstance(); $c_member =& $c_member_handler->getOne($cid, $own_uid); if(!is_object($c_member)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // 退会処理 if($c_member_handler->delete($c_member)){ if($community->getVar('uid_sub_admin') == $own_uid){ $community->setVar('uid_sub_admin', 0); $commu_handler->insert($community); } redirect_header(XSNS_URL_COMMU.'?cid='.$cid, 2, sprintf(_MD_XSNS_INDEX_LEAVE_OK, $community->getVar('name'))); } redirect_header(XSNS_URL_COMMU, 2, _MD_XSNS_INDEX_LEAVE_NG); }
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() { $limit = 10; $start = $this->getIntRequest('s', XSNS_REQUEST_GET); if(!isset($start) || $start<0){ $start = 0; } $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)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_auth = $community->getAuthority(); if($community->getVar('public_flag') == 3 && $commu_auth < XSNS_AUTH_MEMBER){ redirect_header(XOOPS_URL, 2, _NOPERM); } // 新着トピック一覧の取得 $topic_list =& $community->getTopicList($limit, $start, true); $pager = $this->getPageSelector(XSNS_URL_TOPIC.'&'.XSNS_ACTION_ARG.'=list&cid='.$cid, $start, $limit, count($topic_list), $community->getTopicCount()); $commu_vars = array('id' => $cid, 'name' => $community->getVar('name')); $this->context->setAttribute('commu', $commu_vars); $this->context->setAttribute('topic_list', $topic_list); $this->context->setAttribute('pager', $pager); }
function dispatch() { global $xoopsUser; if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $cid = $this->getIntRequest('cid'); $uid = $this->getIntRequest('uid'); $mode = $this->getIntRequest('mode'); if(!$cid || !$uid || $mode < 0 || $mode > 2 || $uid == $own_uid){ 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); } // 対象コミュニティメンバーの取得 $c_member_handler =& XsnsMemberHandler::getInstance(); $c_member =& $c_member_handler->getOne($cid, $uid); if(!is_object($c_member)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_vars = array('id' => $cid, 'name' => $community->getVar('name')); $this->context->setAttribute('commu', $commu_vars); $this->context->setAttribute('member', $c_member->getInfo()); $this->context->setAttribute('mode', $mode); }
function dispatch() { $limit = 10; $start = $this->getIntRequest('s', XSNS_REQUEST_GET); if(!isset($start) || $start<0){ $start = 0; } $cid = $this->getIntRequest('cid', XSNS_REQUEST_GET); if(!$cid){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティメンバー一覧の取得 $c_member_obj_list =& $community->getMemberObjects($limit, $start); $c_member_list = array(); foreach($c_member_obj_list as $c_member_obj){ $c_member_list[] =& $c_member_obj->getInfo(); } $pager = $this->getPageSelector(XSNS_URL_MEMBER.'&cid='.$cid, $start, $limit, count($c_member_list), $community->getMemberCount()); $commu_vars = array('id' => $cid, 'name' => $community->getVar('name')); $this->context->setAttribute('commu', $commu_vars); $this->context->setAttribute('member_list', $c_member_list); $this->context->setAttribute('pager', $pager); }
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() { global $xoopsUser; if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $confirm_handler =& XsnsConfirmHandler::getInstance(); $user_handler =& XsnsUserHandler::getInstance(); $commu_handler =& XsnsCommunityHandler::getInstance(); $own_user =& $user_handler->get($own_uid); if(!is_object($own_user)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $criteria = new CriteriaCompo(new Criteria('uid_to', $own_uid)); $criteria->setSort('r_datetime'); $criteria->setOrder('DESC'); $confirm_obj_list =& $confirm_handler->getObjects($criteria); $confirm_list_all = array(); if(count($confirm_obj_list) > 0){ $confirm_format = array( 0 => array( 'title' => _MD_XSNS_CONFIRM_JOIN_TITLE, 'desc' => _MD_XSNS_CONFIRM_JOIN_DESC, 'show_commu' => true, 'show_message' => true, 'accept_only' => false, ), 1 => array( 'title' => _MD_XSNS_CONFIRM_ADMIN_TITLE, 'desc' => _MD_XSNS_CONFIRM_ADMIN_DESC, 'show_commu' => true, 'show_message' => true, 'accept_only' => false, ), 2 => array( 'title' => _MD_XSNS_CONFIRM_SUB_ADMIN_TITLE, 'desc' => _MD_XSNS_CONFIRM_SUB_ADMIN_DESC, 'show_commu' => true, 'show_message' => true, 'accept_only' => false, ), 3 => array( 'title' => _MD_XSNS_CONFIRM_FRIEND_TITLE, 'desc' => _MD_XSNS_CONFIRM_FRIEND_DESC, 'show_commu' => false, 'show_message' => true, 'accept_only' => false, ), 4 => array( 'title' => _MD_XSNS_CONFIRM_FRIEND_DEL_TITLE, 'desc' => _MD_XSNS_CONFIRM_FRIEND_DEL_DESC, 'show_commu' => false, 'show_message' => false, 'accept_only' => true, ), ); $confirm_format_count = count($confirm_format); $user_info = $commu_info = array(); foreach($confirm_obj_list as $confirm_obj){ $rows = 2; $id = $confirm_obj->getVar('c_commu_confirm_id'); $uid_from = $confirm_obj->getVar('uid_from'); $mode = $confirm_obj->getVar('mode'); if(!isset($user_info[$uid_from])){ $user =& $user_handler->get($uid_from); if(is_object($user)){ $user_info[$uid_from] =& $user->getInfo(); } unset($user); } $cid = $confirm_obj->getVar('c_commu_id'); if($cid > 0 && !isset($commu_info[$cid])){ $community =& $commu_handler->get($cid); if(is_object($community)){ $commu_info[$cid] =& $community->getInfo(); $commu_info[$cid]['url'] = XSNS_URL_COMMU.'?cid='.$cid; } unset($community); } $form_vars = array('confirm_id' => $id); $form_accept = $this->getFormHeader('post', 'mypage', 'confirm_accept_exec', false, $form_vars, 'CONFIRM_ACCEPT_ID'.$id); $form_reject = !$confirm_format[$mode]['accept_only'] ? $this->getFormHeader('post', 'mypage', 'confirm_reject_exec', false, $form_vars, 'CONFIRM_REJECT_ID'.$id) : NULL; if($confirm_format[$mode]['show_commu']){ $rows++; } if($confirm_format[$mode]['show_message']){ $rows++; } $confirm_list[$mode][$id] = array( 'member' => $user_info[$uid_from], 'commu' => ($cid>0)? $commu_info[$cid] : NULL, 'req_mode' => $mode, 'time' => $confirm_obj->getVar('r_datetime'), 'message' => $confirm_obj->getVar('message'), 'show_commu' => $confirm_format[$mode]['show_commu'], 'show_message' => $confirm_format[$mode]['show_message'], 'accept_only' => $confirm_format[$mode]['accept_only'], 'rows' => $rows, 'form_accept' => $form_accept, 'form_reject' => $form_reject, ); } for($i=0; $i<$confirm_format_count; $i++){ $req_count = isset($confirm_list[$i])? count($confirm_list[$i]) : 0; $confirm_list_all[$i] = array( 'lang_title' => $confirm_format[$i]['title'], 'lang_desc' => $confirm_format[$i]['desc'], 'request_count' => $req_count, 'confirm_list' => ($req_count>0)? $confirm_list[$i] : NULL, ); } } $this->context->setAttribute('user_menu', $own_user->getMypageMenu()); $this->context->setAttribute('confirm_list_all', $confirm_list_all); }
function dispatch() { global $xoopsUser; if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $tcid = $this->getIntRequest('tcid', XSNS_REQUEST_GET); if(!isset($tcid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_handler =& XsnsCommunityHandler::getInstance(); $topic_handler =& XsnsTopicHandler::getInstance(); $comment_handler =& XsnsTopicCommentHandler::getInstance(); $user_handler =& XsnsUserHandler::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); } $author =& $user_handler->get($comment->getVar('uid')); $author_info = is_object($author) ? $author->getInfo() : array('name'=>'', 'page_url'=>''); $target_topic = array( 'tcid' => $tcid, 'tid' => $tid, 'number' => $num, 'title' => $topic->getVar('name'), 'lang_title' => ($num>0) ? _MD_XSNS_TITLE_TOPIC_RES_DEL : _MD_XSNS_TITLE_TOPIC_DEL, 'body' => preg_replace('/\[res\]([1-9]\\d*)\[\/res\]/', '>>\1', $comment->getVar('body', 'p')), 'author_name' => $author_info['name'], 'author_url' => $author_info['page_url'], ); $commu = array('id' => $cid, 'name' => $community->getVar('name')); $message = ($num==0)? _MD_XSNS_TOPIC_DEL_CONFIRM : _MD_XSNS_TOPIC_RES_DEL_CONFIRM; $this->context->setAttribute('topic', $target_topic); $this->context->setAttribute('commu', $commu); $this->context->setAttribute('message', $message); }
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() { 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 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('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() { global $xoopsUser; if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $tcid = $this->getIntRequest('tcid', XSNS_REQUEST_GET); if(!isset($tcid)){ 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_EDIT')); // 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(); $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'); // トピックの取得 $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($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); } $topic_uid = $topic->getVar('uid'); $comment_uid = $comment->getVar('uid'); $comment_number = $comment->getNumber(); if($comment_uid > 0 && ($own_uid == $topic_uid || $own_uid == $comment_uid || $commu_auth >= XSNS_AUTH_SUB_ADMIN)){ $topic_vars = array( 'id' => $tid, 'tcid' => $tcid, 'name' => $topic->getVar('name', 'e'), 'lang_page_title' => ($comment_number > 0) ? _MD_XSNS_TITLE_TOPIC_RES_EDIT : _MD_XSNS_TITLE_TOPIC_EDIT, ); $comment_vars = array( 'number' => $comment_number, 'body' => $comment->getVar('body', 'e'), 'images' => $comment->getImageList(2, XSNS_IMAGE_SIZE_S), 'files' => $comment->getFileList(2), ); $commu_vars = array('id' => $cid, 'name' => $community->getVar('name')); $this->context->setAttribute('commu', $commu_vars); $this->context->setAttribute('topic', $topic_vars); $this->context->setAttribute('comment', $comment_vars); } else{ redirect_header(XOOPS_URL, 2, _NOPERM); } }
function dispatch() { global $xoopsUser; $confirm_id = $this->getIntRequest('confirm_id'); if($confirm_id < 1){ redirect_header(XOOPS_URL, 2, _NOPERM); } if($this->isGuest() || !$this->validateToken('CONFIRM_ACCEPT_ID'.$confirm_id)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // 依頼情報の取得 $confirm_handler =& XsnsConfirmHandler::getInstance(); $confirm =& $confirm_handler->get($confirm_id); if(!is_object($confirm)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $cid = $confirm->getVar('c_commu_id'); $uid_from = $confirm->getVar('uid_from'); $uid_to = $confirm->getVar('uid_to'); $mode = $confirm->getVar('mode'); if($uid_to != $xoopsUser->getVar('uid')){ redirect_header(XOOPS_URL, 2, _NOPERM); } // ユーザーの取得 $user_handler =& XsnsUserHandler::getInstance(); $user_from =& $user_handler->get($uid_from); // 依頼者(他人) $user_to =& $user_handler->get($uid_to); // 自分 if(!is_object($user_from) || !is_object($user_to)){ redirect_header(XOOPS_URL, 2, _NOPERM); } if($mode < 3){ // コミュニティの取得 $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || $community->getAuthority() < XSNS_AUTH_MEMBER){ redirect_header(XOOPS_URL, 2, _NOPERM); } } switch($mode){ case 0: // コミュニティ参加 $ret = $user_from->joinCommunity($cid); $msg = _MD_XSNS_CONFIRM_JOIN; break; case 1: // 管理者交代 $ret = $user_to->setCommunityAdmin($cid); $msg = _MD_XSNS_CONFIRM_ADMIN; break; case 2: // 副管理者就任 $ret = $user_to->setCommunitySubAdmin($cid); $msg = _MD_XSNS_CONFIRM_SUB_ADMIN; break; case 3: // 友達リスト登録 $ret1 = $user_to->setFriend($uid_from); $ret2 = $user_from->setFriend($uid_to); $ret = $ret1 | $ret2; $msg = _MD_XSNS_CONFIRM_FRIEND; break; case 4: // 友達リスト登録解除(確認のみ) if($confirm_handler->delete($confirm)){ header("Location: ".XSNS_URL_MYPAGE); exit; } redirect_header(XOOPS_URL, 2, _NOPERM); break; default: redirect_header(XOOPS_URL, 2, _NOPERM); break; } if($ret && $confirm_handler->delete($confirm)){ $url = ($confirm_handler->getCount(new Criteria('uid_to', $uid_to)) > 0) ? XSNS_URL_MYPAGE.'&'.XSNS_ACTION_ARG.'=confirm' : XSNS_URL_MYPAGE; redirect_header($url, 2, sprintf(_MD_XSNS_CONFIRM_ACCEPT_OK. $msg, $user_from->getVar('uname'))); } redirect_header(XSNS_URL_MYPAGE, 2, _MD_XSNS_CONFIRM_ACCEPT_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() { global $xoopsUser, $xoopsUserIsAdmin; if($this->isGuest() || !$this->validateToken('MEMBER_EDIT')){ redirect_header(XOOPS_URL, 2, _NOPERM); } $own_uid = $xoopsUser->getVar('uid'); $cid = $this->getIntRequest('cid'); $uid = $this->getIntRequest('uid'); $message = $this->getTextRequest('message'); if(!$cid || !$uid || $uid == $own_uid){ 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); } if($xoopsUserIsAdmin && $own_uid != $community->getVar('uid_admin')){ redirect_header(XOOPS_URL, 2, _NOPERM); } // 対象コミュニティメンバーの取得 $c_member_handler =& XsnsMemberHandler::getInstance(); $c_member =& $c_member_handler->getOne($cid, $uid); if(!is_object($c_member)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $c_member_info =& $c_member->getInfo(); // 既存の依頼を削除(重複を防ぐため) $confirm_handler =& XsnsConfirmHandler::getInstance(); $criteria = new CriteriaCompo(new Criteria('c_commu_id', $cid)); $criteria->add(new Criteria('uid_from', $own_uid)); $criteria->add(new Criteria('uid_to', $uid)); $criteria->add(new Criteria('mode', '(1,2)', 'IN')); // 管理者交代 or 副管理者就任 $confirm_handler->deleteObjects($criteria); // 新規依頼の送信 $confirm =& $confirm_handler->create(); $confirm->setVars(array( 'c_commu_id' => $cid, 'uid_from' => $own_uid, 'uid_to' => $uid, 'mode' => 1, // 管理者交代 'r_datetime' => date('Y-m-d H:i:s'), 'message' => $message, )); if($confirm_handler->insert($confirm)){ redirect_header(XSNS_URL_COMMU.'?cid='.$cid, 2, sprintf(_MD_XSNS_MEMBER_ADMIN_OK, $c_member_info['name'])); } redirect_header(XSNS_URL_COMMU, 2, _MD_XSNS_MEMBER_ADMIN_NG); }