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() { 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 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() || !$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() { 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 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() { 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); }
function dispatch() { global $xoopsUser; if($this->isGuest() || !$this->validateToken('COMMUNITY_JOIN')){ 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_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; $name = $community->getVar('name'); $redirect_url = XSNS_URL_COMMU.'?cid='.$cid; if($public_flag > 1){ // 参加の際に管理者の承認が必要なコミュニティ // 依頼送信済みかどうかの確認 $uid_admin = $community->getVar('uid_admin'); $confirm_handler =& XsnsConfirmHandler::getInstance(); if($confirm_handler->getOne($cid, $own_uid, $uid_admin, 0)){ redirect_header($redirect_url, 2, _MD_XSNS_INDEX_JOIN_REQ_NG_ALREADY); } // 依頼の送信 $new_confirm =& $confirm_handler->create(); $new_confirm->setVars(array( 'c_commu_id' => $cid, 'uid_from' => $own_uid, 'uid_to' => $uid_admin, 'mode' => 0, // コミュニティ参加 'r_datetime' => date('Y-m-d H:i:s'), 'message' => $this->getTextRequest('message'), )); if($confirm_handler->insert($new_confirm)){ redirect_header($redirect_url, 2, sprintf(_MD_XSNS_INDEX_JOIN_REQ_OK, $name)); } redirect_header($redirect_url, 2, _MD_XSNS_INDEX_JOIN_REQ_NG); } else{ // 誰でも参加可能なコミュニティ $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)){ redirect_header($redirect_url, 2, sprintf(_MD_XSNS_INDEX_JOIN_OK, $name)); } redirect_header($redirect_url, 2, _MD_XSNS_INDEX_JOIN_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; }