当前位置: 首页>>代码示例>>PHP>>正文


PHP Topic::setChannel方法代码示例

本文整理汇总了PHP中Topic::setChannel方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::setChannel方法的具体用法?PHP Topic::setChannel怎么用?PHP Topic::setChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Topic的用法示例。


在下文中一共展示了Topic::setChannel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_account

function create_account()
{
	global $CONF;
	$user = new RegUser();

	if (!preg_match("/^[".$CONF['nickname_chars']."]+$/i", $_POST['nickname_create_account']))
		return array('ok'=>false, 'error'=>'invalid nickname');

	if (trim($_POST['password_create_account'])=='')
		return array('ok'=>false, 'error'=>'no password');

	$user->setEmail($_POST['email_create_account']);
	$user->setNickname($_POST['nickname_create_account']);
	$user->setPassword($_POST['password_create_account']);
	if (isset($_POST['signature_create_account']))
		$user->setSignature($_POST['signature_create_account']);

	if (isset($_POST['camefrom_create_account']))
		$user->setCameFrom($_POST['camefrom_create_account']);

	$r = $user->save();
	if ($r=='ok')
	{
		$channel=new Channel();
		$channel->setId(1);
		$channel->forceFollow($user);
		$r = $user->sendEmail();
		if (!$r)
			return array('ok'=>false, 'error'=>'we could not send the e-mail.');
		else{
			$GLOBALS['user'] = $user;
			$rc = new RegUser();
			$rc->setNickname("RapidCoffee");
			$rc->load();
			$topic = new Topic();
			$topic->setChannel($channel);
			$topic->setUser($rc);
			$topic->setSubject("Dêem boas vindas ao usuário " . $user->getNickname() . "!");
			$msg = "Seja bem-vindo(a), <b>" . $user->getNickname() . "</b>. Criamos este tópico para que você possa se apresentar e conhecer um pouco dos usuários do site. Boa estadia =)<br /><br />Equipe Rapid Coffee.";
			$msg = str_replace('&nbsp;',' ',$msg);
			$topic->setMsg($msg);
			$topic->save();
			$topic->follow();
			return array('ok'=>true, 'error'=>'');
		}
	}
	return array('ok'=>false, 'error'=>$r);
}
开发者ID:rczeus,项目名称:Rapid-Coffee,代码行数:48,代码来源:create_account.php

示例2: add_topic

function add_topic()
{
	global $CONF;
	$user = $_SESSION['user'];

	if ($user->getBanned()>0){
		return array('ok'=>false, 'error'=>'banned '.$user->getBanned());
	}

	if (isset($_SESSION['topic_last_flood_time'])){

		if ((time() - $_SESSION['topic_last_flood_time']) < $CONF['topic_time_to_wait_flood']){
			$time_to_wait = $CONF['topic_time_to_wait_flood'] - (time() - $_SESSION['topic_last_flood_time']);
			return array('ok'=>false, 'error'=>'flood '.$time_to_wait);
		}

	}

	$user = $_SESSION['user'];	

	$topic = new Topic();

	if (isset($_GET['channelid_add_topic'])){
		$channel = new Channel();
		$channel->setId($_GET['channelid_add_topic']);
		if (!$channel->canITopic())
			return array('ok'=>false, 'error'=>'you cant create topic in this channel');
		$topic->setChannel($channel);
	}

	$topic->setUser($user);

	$subject = strip_tags($_POST['subject']);
	if (strlen(str_replace(' ', '', $subject)) < $CONF['min_msg_chars'])
		return array('ok'=>false, 'error'=>'too short subject');
	$topic->setSubject($subject);

	$msg = $_POST['msg'];
	if (strlen(str_replace(' ', '', strip_tags($msg))) < $CONF['min_msg_chars'])
		return array('ok'=>false, 'error'=>'too short message');

	$msg = strip_tags($msg, $CONF['permitted_tags_msg']);
	//$msg = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a target=\"_BLANK\" href=\"\\0\">\\0</a>", $msg); //detectando URLs
	$msg = text_linkify($msg);
	$msg = str_replace('&nbsp;',' ',$msg);
	$topic->setMsg($msg);

	if ($topic->save()=='ok'){

		$_SESSION['topic_last_flood_time']=time();

		$topic->follow();


		$headers  = "MIME-Version: 1.0\r\n";
		$headers .= "Content-type: text/html; charset=UTF-8\r\n";
		$headers .= "From: {$CONF['email_from']}\r\n";
		$headers .= "To: YOU <you>\r\n";
		$_pretty=Topic::prettyUrl($topic->getSubject());
		$body='Acesse: <a href="http://rapidcoffee.com//'.$topic->getId().'/'.$_pretty.'">http://rapidcoffee.com//'.$topic->getId().'/'.$_pretty.'</a>';
		//system("echo \"".$body."\" > email.html");
		//mail('lucasvendramin85@gmail.com, danilo.horta@gmail.com', "Rapidcoffee-NOVO TOPICO", $body, $headers);
		return array('ok'=>true, 'error'=>'');
	}
	else
		return array('ok'=>false, 'error'=>'Problems with this topic.');
}
开发者ID:rczeus,项目名称:Rapid-Coffee,代码行数:67,代码来源:add_topic.php


注:本文中的Topic::setChannel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。