Exemplo n.º 1
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('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);
}
Exemplo n.º 2
0
function dispatch()
{
	require XSNS_FRAMEWORK_DIR.'/global.php';
	xoops_cp_header();
	
	include $mytrustdirpath.'/mymenu.php';
	
	$file_list = $this->context->getAttribute('file_list');
	$pager = $this->context->getAttribute('pager');
	
	echo "<h4><p style='text-align:center;'>"._AM_XSNS_TITLE_FILE_CONFIG."</p></h4>";
	
	if(count($file_list) > 0){
		
		$header_list = array(
			_AM_XSNS_FILE_NAME,
			_AM_XSNS_FILE_SIZE,
			_AM_XSNS_POST_DATE,
			_AM_XSNS_FILE_AUTHOR,
			_AM_XSNS_FILE_REF,
			_AM_XSNS_FILE_DELETE,
		);
		$header_count = count($header_list);
		
		echo "<div style='width:90%; margin-left:auto; margin-right:auto;'>";
		echo "<table class='outer' style='width:100%; text-align:center;'>";
		echo "<form action='index.php' method='post'>".
			 "<input type='hidden' name='".XSNS_ACTION_ARG."' value='file_del_exec'>";
		
		$pager_html = $this->getPageSelector($pager, $header_count);
		
		echo "<tr>";
		foreach($header_list as $header){
			echo "<th>".$header."</th>";
		}
		echo "</tr>";
		
		echo "<colgroup style='text-align:left;'></colgroup>".
			 "<colgroup style='text-align:right; width:150px;'></colgroup>".
			 "<colgroup style='width:120px;'></colgroup>".
			 "<colgroup style='text-align:left; width:150px;'></colgroup>".
			 "<colgroup style='width:40px;'></colgroup>".
			 "<colgroup style='width:40px;'></colgroup>";
		
		foreach($file_list as $file){
			echo "<tr class='even' style='text-align:center;'>".
					"<td><a href='".$file['url']."'>".$file['filename']."</a></td>".
					"<td>".$file['size']." bytes</td>".
					"<td>".$file['time']."</td>".
					"<td>".$file['author']."</td>".
					"<td>".$file['ref_link']."</td>".
					"<td><input type='checkbox' name='delete[]' value='".$file['id']."'></td>".
				 "</tr>";
		}
		echo $pager_html;
		
		$token_handler = new XoopsMultiTokenHandler();
		$token =& $token_handler->create('FILE_DELETE');
		
		echo "<tr class='foot'>".
			 "<td colspan='".$header_count."' style='text-align:center; padding:15px 0 15px 0;'>".
			 "<input type='submit' value='"._SUBMIT."'>".
			 $token->getHtml().
			 "</td>".
			 "</tr>";
		
		echo "</form>";
		echo "</table>";
		echo "</div>";
	}
	xoops_cp_footer();
}
Exemplo n.º 3
0
function assignFormHeader($form_name, $method='post', $target='', $action='', $upload=false, $hidden_vars=NULL, $token_name=NULL)
{
	$page_html = (empty($target))? 
		"" : "<input type=\"hidden\" name=\"".XSNS_PAGE_ARG."\" value=\"".$target."\">\n";
	$action_html = (empty($action))? 
		"" : "<input type=\"hidden\" name=\"".XSNS_ACTION_ARG."\" value=\"".$action."\">\n";
	$upload_html = ($upload)? " enctype=\"multipart/form-data\"" : "";
	
	$form = "<form action=\"index.php\" method=\"".$method."\"".$upload_html.">\n".
			$page_html. $action_html;
	
	if(is_array($hidden_vars)){
		foreach($hidden_vars as $key => $value){
			$form .= "<input type=\"hidden\" name=\"".$key."\" value=\"".$value."\">\n";
		}
	}
	if(!is_null($token_name)){
		$token_handler = new XoopsMultiTokenHandler();
		$token =& $token_handler->create($token_name);
		$form .= $token->getHtml();
	}
	
	$this->tpl->assign($form_name, $form);
}
Exemplo n.º 4
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);
}
Exemplo n.º 5
0
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);
	}
}
Exemplo n.º 6
0
function xoops_confirm($hiddens, $action, $message, $submit = '', $addToken = true)
{
    //
    // Create token.
    //
    $tokenHandler = new XoopsMultiTokenHandler();
    $token =& $tokenHandler->create(XOOPS_TOKEN_DEFAULT);
    //
    // Register to session. And, set it to own property.
    //
    $tokenHandler->register($token);
    $root =& XCube_Root::getSingleton();
    $renderSystem =& $root->getRenderSystem($root->mContext->mBaseRenderSystemName);
    $renderTarget =& $renderSystem->createRenderTarget('main');
    $renderTarget->setAttribute('legacy_module', 'legacy');
    $renderTarget->setTemplateName('legacy_xoops_confirm.html');
    $renderTarget->setAttribute('action', $action);
    $renderTarget->setAttribute('message', $message);
    $renderTarget->setAttribute('hiddens', $hiddens);
    $renderTarget->setAttribute('submit', $submit);
    $renderTarget->setAttribute('tokenName', $token->getTokenName());
    $renderTarget->setAttribute('tokenValue', $token->getTokenValue());
    $renderSystem->render($renderTarget);
    print $renderTarget->getResult();
}
Exemplo n.º 7
0
 /**
  * static method.
  * This method was created for quick protection of default modules.
  * this method will be deleted in the near future.
  * @deprecated
  * @return bool
  */
 function &quickCreate($name, $timeout = XOOPS_TOKEN_TIMEOUT)
 {
     $handler = new XoopsMultiTokenHandler();
     $ret =& $handler->create($name, $timeout);
     return $ret;
 }
Exemplo n.º 8
0
function dispatch()
{
	require XSNS_FRAMEWORK_DIR.'/global.php';
	xoops_cp_header();
	
	// 中カテゴリ
	$category_p = $this->context->getAttribute('category_p');
	$category = $this->context->getAttribute('category');
	
	include $mytrustdirpath.'/mymenu.php';
	
	echo "<h4><p style='text-align:center;'>"._AM_XSNS_TITLE_CATEGORY_CONFIG."</p></h4><br>";
	
	echo "<div style='width:500px; margin-left:auto; margin-right:auto;'>";
	echo "<div style='text-align:center; font-size:14px; padding-bottom:15px;'><b>"._AM_XSNS_CATEGORY1._AM_XSNS_CATEGORY_LIST."</b></div>";
	echo "<table border='1' cellpadding='8' style='width:100%; text-align:center;'>";
	
	echo "<colgroup style='width:120px;'></colgroup>".
		 "<colgroup style='width:80px;'></colgroup>".
		 "<colgroup span='2' style='width:50px;'></colgroup>".
		 "<colgroup style='width:70px;'></colgroup>";
	
	echo "<th colspan='5'>"._AM_XSNS_CATEGORY1."</th>";
	
	echo "<tr class='head'>".
			"<td>"._AM_XSNS_CATEGORY_NAME."</td>".
			"<td>"._AM_XSNS_CATEGORY_ORDER."</td>".
			"<td colspan='2'>"._AM_XSNS_CATEGORY_OPERATION."</td>".
			"<td>"._AM_XSNS_CATEGORY2."</td>".
		 "</tr>";
		 
	foreach($category_p as $cat_p){
		$pid = $cat_p['c_commu_category_parent_id'];
		
		echo "<form action='index.php' method='post'>";
		echo "<input type='hidden' name='".XSNS_ACTION_ARG."' value='category_edit_exec'>";
		echo "<input type='hidden' name='mode' value='parent'>";
		echo "<input type='hidden' name='pid' value='".$pid."'>";
		
		echo "<tr class='even'>".
				"<td><input type='text' name='title".$pid."' value='".$cat_p['name']."'></td>".
				"<td><input type='text' name='order".$pid."' size='10' value='".$cat_p['sort_order']."'></td>".
				"<td><input type='submit' name='edit' value='"._AM_XSNS_CATEGORY_EDIT."'></td>".
				"<td><input type='submit' name='delete' value='"._AM_XSNS_CATEGORY_DEL."' onclick=\"javascript:return confirm('"._AM_XSNS_CATEGORY_DEL_CONFIRM."');\"></td>".
				"<td><a href='index.php?".XSNS_ACTION_ARG."=category#".$pid."'>"._AM_XSNS_CATEGORY_LIST."</a></td>".
			 "</tr>";
		
		echo "</form>";
	}
	
	echo "<form action='index.php' method='post'>";
	echo "<input type='hidden' name='".XSNS_ACTION_ARG."' value='category_add_exec'>";
	echo "<input type='hidden' name='mode' value='parent'>";
	
	echo "<tr>".
			"<td><input type='text' name='title'></td>".
			"<td><input type='text' name='order' size='10' value='0'></td>".
			"<td colspan='2'><input type='submit' name='add' value='"._AM_XSNS_CATEGORY_ADD."'></td>".
			"<td></td>".
		 "</tr>";
	echo "</form>";
	
	echo "</table>";
	
	echo "</div>";
	
	echo "<br><br><br>";
	
	echo "<div style='width:400px; margin-left:auto; margin-right:auto;'>";
	
	// 小カテゴリ
	echo "<div style='text-align:center; font-size:14px; padding-bottom:15px;'><b>"._AM_XSNS_CATEGORY2._AM_XSNS_CATEGORY_LIST."</b></div>";
	
	$token_handler = new XoopsMultiTokenHandler();
	$token_add =& $token_handler->create('CATEGORY_ADD');
	$token_edit =& $token_handler->create('CATEGORY_EDIT');
	
	foreach($category_p as $cat_p){
		$pid = $cat_p['c_commu_category_parent_id'];
		
		echo "<table border='1' cellpadding='8' style='width:100%; text-align:center;'>";
		
		echo "<tr>".
				"<th colspan='4'><a name='".$pid."'>".$cat_p['name']."</a></th>".
			 "</tr>";
			 
		echo "<colgroup style='width:120px;'></colgroup>".
			 "<colgroup style='width:80px;'></colgroup>".
			 "<colgroup span='2' style='width:50px;'></colgroup>";
		
		echo "<tr class='head'>".
				"<td>"._AM_XSNS_CATEGORY_NAME."</td>".
				"<td>"._AM_XSNS_CATEGORY_ORDER."</td>".
				"<td colspan='2'>"._AM_XSNS_CATEGORY_OPERATION."</td>".
			 "</tr>";
		
		if(isset($category[$pid])){
			foreach($category[$pid] as $cat){
				$id = $cat['c_commu_category_id'];
				
				echo "<form action='index.php' method='post'>";
				echo "<input type='hidden' name='".XSNS_ACTION_ARG."' value='category_edit_exec'>";
				echo "<input type='hidden' name='id' value='".$id."'>";
				echo $token_edit->getHtml();
				echo "<tr class='even'>".
						"<td><input type='text' name='title".$id."' value='".$cat['name']."'></td>".
						"<td><input type='text' name='order".$id."' size='10' value='".$cat['sort_order']."'></td>".
						"<td><input type='submit' name='edit' value='"._AM_XSNS_CATEGORY_EDIT."'></td>".
						"<td><input type='submit' name='delete' value='"._AM_XSNS_CATEGORY_DEL."'></td>".
					 "</tr>";
				echo "</form>";
			}
		}
		
		echo "<form action='index.php' method='post'>";
		echo "<input type='hidden' name='".XSNS_ACTION_ARG."' value='category_add_exec'>";
		echo "<input type='hidden' name='pid' value='".$pid."'>";
		echo $token_add->getHtml();
		echo "<tr>".
				"<td><input type='text' name='title'></td>".
				"<td><input type='text' name='order' size='10' value='0'></td>".
				"<td colspan='2'><input type='submit' name='add' value='"._AM_XSNS_CATEGORY_ADD."'></td>".
			 "</tr>";
		echo "</table>";
		echo "</form>";
		
		echo "<br><br>";
	}
	
	echo "</div>";
	
	xoops_cp_footer();
}
Exemplo n.º 9
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('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);
}
Exemplo n.º 10
0
function dispatch()
{
	global $xoopsUser, $xoopsConfig;
	if($this->isGuest()){
		redirect_header(XOOPS_URL, 2, _NOPERM);
	}
	
	$user_handler =& XsnsUserHandler::getInstance();
	$user =& $user_handler->get($xoopsUser->getVar('uid'));
	if(!is_object($user)){
		redirect_header(XOOPS_URL, 2, _NOPERM);
	}
	
	require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
	require_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/user.php';
	require_once XOOPS_ROOT_PATH.'/include/comment_constants.php';
	
	$config_handler =& xoops_gethandler('config');
	if(defined('XOOPS_CUBE_LEGACY')){
		$xoopsConfigUser =& $config_handler->getConfigsByDirname('user');
		$user_config =& $xoopsConfigUser;
	}
	else{
		$xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
		$user_config =& $xoopsConfig;
	}
	
	require_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php';
	require_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
	
	$elements = array();
	
	$token_handler = new XoopsMultiTokenHandler();
	$token = new XoopsFormToken($token_handler->create('edituser'));
	
	// Hidden
	$elements['hiddens'] = array(
		array('html' => '<input type="hidden" name="'.XSNS_PAGE_ARG.'" value="mypage">'),
		array('html' => '<input type="hidden" name="'.XSNS_ACTION_ARG.'" value="profile_edit_exec">'),
		array('html' => '<input type="hidden" name="uid" value="'.$xoopsUser->getVar('uid').'">'),
		array('html' => '<input type="hidden" name="'.$token->_name.'" value="'.$token->_value.'">'),
	);
	
	// Avatar
	$elements['avatar'] = array(
		'name' => 'user_avatar',
		'value' => $xoopsUser->getVar('user_avatar'),
		'html' => '<img src="'.XOOPS_UPLOAD_URL.'/'.$xoopsUser->getVar('user_avatar').'" alt="'.$xoopsUser->getVar('uname').'" /><br>[<a href="'.XSNS_URL_MYPAGE.'&'.XSNS_ACTION_ARG.'=profile_avatar_up'.'">'._MD_XSNS_PROFILE_AVATAR_EDIT.'</a>]',
	);
	
	// E-mail
	if(@$xoopsConfigUser['allow_chgmail']){
		$email_text = '<input type="text" name="email" size="30" value="'.$xoopsUser->getVar('email', 'e').'">';
	}
	else{
		$email_text = $xoopsUser->getVar('email');
	}
	
	$elements['email'] = array(
		'name' => 'email',
		'value' => $xoopsUser->getVar('email'),
		'html' => $email_text.'<br><input type="checkbox" name="user_viewemail" value="1"'.($xoopsUser->getVar('user_viewemail') ? ' checked' : '') .'>'._US_ALLOWVIEWEMAIL,
	);
	
	// Real name
	$elements['realname'] = array(
		'name' => 'name',
		'value' => $xoopsUser->getVar('name', 'e'),
	);
	
	// Web site URL
	$elements['url'] = array(
		'name' => 'url',
		'value' => $xoopsUser->getVar('url', 'e'),
	);
	
	// ICQ
	$elements['icq'] = array(
		'name' => 'user_icq',
		'value' => $xoopsUser->getVar('user_icq', 'e'),
	);
	
	// AIM
	$elements['aim'] = array(
		'name' => 'user_aim',
		'value' => $xoopsUser->getVar('user_aim', 'e'),
	);
	
	// YIM
	$elements['yim'] = array(
		'name' => 'user_yim',
		'value' => $xoopsUser->getVar('user_yim', 'e'),
	);
	
	// MSNM
	$elements['msnm'] = array(
		'name' => 'user_msnm',
		'value' => $xoopsUser->getVar('user_msnm', 'e'),
	);
	
	// Location
	$elements['location'] = array(
		'name' => 'user_from',
		'value' => $xoopsUser->getVar('user_from', 'e'),
	);
	
	// Occupation
	$elements['occupation'] = array(
		'name' => 'user_occ',
		'value' => $xoopsUser->getVar('user_occ', 'e'),
	);
	
	// Interest
	$elements['interest'] = array(
		'name' => 'user_intrest',
		'value' => $xoopsUser->getVar('user_intrest', 'e'),
	);
	
	// Extra info
	$elements['extra'] = array(
		'name' => 'bio',
		'value' => $xoopsUser->getVar('bio', 'e'),
	);
	
	// Signature
	$sig = $xoopsUser->getVar('user_sig', 'e');
	$this->setXoopsCodeTarea('sig_xoops_codes', $sig, 'user_sig', 50, 5, null, 'sig_xoops_smilies');
	$elements['sig'] = array(
		'name' => 'user_sig',
		'value' => $sig,
	);
	
	$elements['attachsig'] = array(
		'name' => 'attachsig',
		'value' => $xoopsUser->getVar('attachsig') ? 'checked' : '',
	);
	
	// Time zone
	$timezone_offset = $xoopsUser->getVar('timezone_offset');
	$timezone_select = new XoopsFormSelectTimezone(_US_TIMEZONE, 'timezone_offset', $timezone_offset);
	$elements['timezone'] = array(
		'name' => 'timezone_offset',
		'value' => $timezone_offset,
		'html' => XsnsUtils::getSelectBoxHtml('timezone_offset', $timezone_select->_options, $timezone_offset),
	);
	
	// Event notify method
	$not_method = $xoopsUser->getVar('notify_method');
	$not_method_arr = array(
		XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE,
		XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM,
		XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL,
	);
	$elements['notify_method'] = array(
		'name' => 'notify_method',
		'value' => $not_method,
		'html' => XsnsUtils::getSelectBoxHtml('notify_method', $not_method_arr, $not_method),
	);
	
	// Event notify mode
	$not_mode = $xoopsUser->getVar('notify_mode');
	$not_mode_arr = array(
		XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS,
		XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE,
		XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN,
	);
	$elements['notify_mode'] = array(
		'name' => 'notify_mode',
		'value' => $not_mode,
		'html' => XsnsUtils::getSelectBoxHtml('notify_mode', $not_mode_arr, $not_mode),
	);
	
	// Password
	$elements['password'] = array(
		'name' => 'password',
		'html' => '<input type="password" name="password" size="15" maxlength="32">&nbsp;&nbsp;<input type="password" name="vpass" size="15" maxlength="32">',
	);
	
	// Comment mode
	$umode = $xoopsUser->getVar('umode');
	$umode_arr = array(
		'nest' => _NESTED,
		'flat' => _FLAT,
		'thread' => _THREADED,
	);
	$elements['umode'] = array(
		'name' => 'umode',
		'value' => $umode,
		'html' => XsnsUtils::getSelectBoxHtml('umode', $umode_arr, $umode),
	);
	
	// Comment order
	$uorder = $xoopsUser->getVar('uorder');
	$uorder_arr = array(
		XOOPS_COMMENT_OLD1ST => _OLDESTFIRST,
		XOOPS_COMMENT_NEW1ST => _NEWESTFIRST,
	);
	$elements['uorder'] = array(
		'name' => 'uorder',
		'value' => $uorder,
		'html' => XsnsUtils::getSelectBoxHtml('uorder', $uorder_arr, $uorder),
	);
	
	// user cookie
	$usercookie = empty($_COOKIE[@$user_config['usercookie']]) ? 0 : 1;
	$usercookie_arr = array(1 => _YES, 0 => _NO);
	$elements['usercookie'] = array(
		'name' => 'usercookie',
		'value' => $usercookie,
		'html' => XsnsUtils::getRadioHtml('usercookie', $usercookie_arr, $usercookie),
	);
	
	// user mail ok
	$mailok = $xoopsUser->getVar('user_mailok');
	$mailok_arr = array(1 => _YES, 0 => _NO);
	$elements['mailok'] = array(
		'name' => 'user_mailok',
		'value' => $mailok,
		'html' => XsnsUtils::getRadioHtml('user_mailok', $mailok_arr, $mailok),
	);
	
	$this->context->setAttribute('user_menu', $user->getMypageMenu());
	$this->context->setAttribute('elements', $elements);
	$this->context->setAttribute('allow_self_delete', @$xoopsConfigUser['self_delete']);
}
Exemplo n.º 11
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);
}
Exemplo n.º 12
0
	function dispatch()
	{
		require XSNS_FRAMEWORK_DIR.'/global.php';
		
		if($this->isGuest()){
			redirect_header(XOOPS_URL, 2, _NOPERM);
		}
		
		$user_handler =& XsnsUserHandler::getInstance();
		$user =& $user_handler->get($xoopsUser->getVar('uid'));
		if(!is_object($user)){
			redirect_header(XOOPS_URL, 2, _NOPERM);
		}
		
		require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
		require_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/user.php';
		
		$config_handler =& xoops_gethandler('config');
		if(defined('XOOPS_CUBE_LEGACY')){
			$xoopsConfigUser =& $config_handler->getConfigsByDirname('user');
		}
		else{
			$xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
		}
		
		$token_handler = new XoopsMultiTokenHandler();
		
		if ($xoopsConfigUser['avatar_allow_upload'] == 1 && $xoopsUser->getVar('posts') >= $xoopsConfigUser['avatar_minposts']) {
			$form = new XoopsThemeForm(_MD_XSNS_PROFILE_AVATAR_EDIT, 'avatarform', XSNS_URL_MYPAGE_PROFILE);
			$form->setExtra('enctype="multipart/form-data"');
			$form->addElement(new XoopsFormLabel(_US_MAXPIXEL, $xoopsConfigUser['avatar_width'].' x '.$xoopsConfigUser['avatar_height'].' (px)'));
			$form->addElement(new XoopsFormLabel(_US_MAXIMGSZ, number_format($xoopsConfigUser['avatar_maxsize']).' (bytes)'));
			$form->addElement(new XoopsFormFile(_US_SELFILE, 'avatarfile', $xoopsConfigUser['avatar_maxsize']), true);
			$form->addElement(new XoopsFormHidden(XSNS_ACTION_ARG, 'profile_avatar_up_exec'));
			$form->addElement(new XoopsFormToken($token_handler->create('upload')));
			$form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid')));
			$form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
			$this->context->setAttribute('form', $form);
		}
		
		require_once XSNS_USERLIB_DIR.'/avatar.class.php';
		$avatar_handler =& XsnsAvatarHandler::getInstance();
		$avatar_list_temp =& $avatar_handler->getList('S');
		
		foreach($avatar_list_temp as $avatar_temp){
			$avatar_list[] = array(
				'id' => $avatar_temp['id'],
				'name' => $avatar_temp['name'],
				'file' => XOOPS_UPLOAD_URL.'/'.$avatar_temp['file'],
			);
		}
		$mod = count($avatar_list)%4;
		if($mod){
			for($i=0; $i<4-$mod; $i++){
				$avatar_list[] = array();
			}
		}
		
		if(is_array($avatar_list)){
			$form2 = new XoopsThemeForm(_US_CHOOSEAVT, 'uploadavatar', XSNS_URL_MYPAGE);
			$form2->addElement(new XoopsFormHidden(XSNS_ACTION_ARG, 'profile_avatar_sel_exec'));
			$form2->addElement(new XoopsFormToken($token_handler->create('choose')));
			
			$this->context->setAttribute('avatar_list', $avatar_list);
			$this->context->setAttribute('form2', $form2);
		}
		
		$avatar_file = $xoopsUser->getVar('user_avatar');
		if($avatar_file != 'blank.gif'){
			$this->context->setAttribute('old_avatar', XOOPS_UPLOAD_URL.'/'.$avatar_file);
		}
		$this->context->setAttribute('user_menu', $user->getMypageMenu());
	}