本文整理汇总了PHP中Topic::setMsg方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::setMsg方法的具体用法?PHP Topic::setMsg怎么用?PHP Topic::setMsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic::setMsg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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(' ',' ',$msg);
$topic->setMsg($msg);
$topic->save();
$topic->follow();
return array('ok'=>true, 'error'=>'');
}
}
return array('ok'=>false, 'error'=>$r);
}
示例2: update_topic
function update_topic()
{
global $user;
global $CONF;
// 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);
// }
//
// }
$_SESSION['topic_last_flood_time']=time();
$user = $_SESSION['user'];
$topic = new Topic();
if (isset($_GET['topicid_update_topic'])){
$topic->setId($_GET['topicid_update_topic']);
$topic->load();
if ( ($user->getId()!=$topic->getUser()->getId()) || ($user->isAnon()!=$topic->getUser()->isAnon()) )
return array('ok'=>false, 'error'=>'you are not the owner');
} else {
return array('ok'=>false, 'error'=>'no id');
}
//$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 = unescape_ampersand($_POST['msg_update_topic']);
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']);
$topic->setMsg($msg);
if ($topic->save()=='ok'){
//$topic->follow();
return array('ok'=>true, 'error'=>'');
}
else
return array('ok'=>false, 'error'=>'problems with this topic');
}
示例3: 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(' ',' ',$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.');
}