コード例 #1
0
ファイル: community.class.php プロジェクト: nunoluciano/uxcl
	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(),
		);
	}
コード例 #2
0
ファイル: del_execAction.php プロジェクト: nunoluciano/uxcl
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);
	}
}
コード例 #3
0
ファイル: res_execAction.php プロジェクト: nunoluciano/uxcl
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);
}
コード例 #4
0
ファイル: fileAction.php プロジェクト: nunoluciano/uxcl
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;
}
コード例 #5
0
ファイル: editAction.php プロジェクト: nunoluciano/uxcl
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);
	}
}
コード例 #6
0
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);
}
コード例 #7
0
ファイル: defaultAction.php プロジェクト: nunoluciano/uxcl
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']));
}
コード例 #8
0
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);
}
コード例 #9
0
ファイル: delAction.php プロジェクト: nunoluciano/uxcl
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);
}
コード例 #10
0
ファイル: edit_execAction.php プロジェクト: nunoluciano/uxcl
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);
}
コード例 #11
0
ファイル: defaultAction.php プロジェクト: nunoluciano/uxcl
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;
}
コード例 #12
0
ファイル: add_execAction.php プロジェクト: nunoluciano/uxcl
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);
}