本文整理汇总了PHP中Topic::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::getId方法的具体用法?PHP Topic::getId怎么用?PHP Topic::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSubscribe
/**
* A request to subscribe to a topic has been made.
*
* @param \Ratchet\ConnectionInterface $conn
* @param string|Topic $topic The topic to subscribe to
*/
public function onSubscribe(ConnectionInterface $conn, $topic)
{
$this->console->info("onSubscribe: {$conn->WAMP->sessionId} topic: {$topic} {$topic->count()}");
if (!array_key_exists($topic->getId(), $this->subscribedTopics)) {
$this->subscribedTopics[$topic->getId()] = $topic;
$this->console->info("subscribed to topic {$topic}");
}
}
示例2: delete
public function delete(Topic $topic)
{
$id = $topic->getId();
$query = "DELETE FROM topic WHERE id='" . $id . "'";
$res = mysqli_query($this->db, $query);
if ($res) {
return true;
} else {
return "Internal Server Error";
}
}
示例3: update
public function update(Topic $topic)
{
$id = $topic->getId();
$title = $this->db->quote($title->getTitle());
$idAuthor = $_SESSION['id'];
$query = ' UPDATE topic
SET title =' . $title . ',
$idAuthor =' . $idAuthor . '
WHERE id=' . $id;
$res = $this->db->exec($query);
if ($res) {
$id = $this->db->lastInsertId();
if ($id) {
return $this->findById($id);
} else {
throw new Exception('Internal server Error');
}
}
}
示例4: lookup
static function lookup($id)
{
return $id && is_numeric($id) && ($t = new Topic($id)) && $t->getId() == $id ? $t : null;
}
示例5: or
$email=null;
$errors['err']='Unable to fetch info on email ID#'.$id;
}
}
$page=($email or ($_REQUEST['a']=='new' && !$emailID))?'email.inc.php':'emails.inc.php';
}
break;
case 'topics':
require_once(INCLUDE_DIR.'class.topic.php');
$topic=null;
$nav->setTabActive('topics');
$nav->addSubMenu(array('desc'=>'Help Topics','href'=>'admin.php?t=topics','iconclass'=>'helpTopics'));
$nav->addSubMenu(array('desc'=>'Add New Topic','href'=>'admin.php?t=topics&a=new','iconclass'=>'newHelpTopic'));
if(($id=$_REQUEST['id']?$_REQUEST['id']:$_POST['topic_id']) && is_numeric($id)) {
$topic= new Topic($id);
if(!$topic->load() && $topic->getId()==$id) {
$topic=null;
$errors['err']='Unable to fetch info on topic #'.$id;
}
}
$page=($topic or ($_REQUEST['a']=='new' && !$topicID))?'topic.inc.php':'helptopics.inc.php';
break;
//Staff (users, groups and teams)
case 'grp':
case 'groups':
case 'staff':
$group=null;
//Tab and Nav options.
$nav->setTabActive('staff');
$nav->addSubMenu(array('desc'=>'Staff Members','href'=>'admin.php?t=staff','iconclass'=>'users'));
$nav->addSubMenu(array('desc'=>'Add New User','href'=>'admin.php?t=staff&a=new','iconclass'=>'newuser'));
示例6: create
function create($var, &$errors, $origin, $autorespond = true, $alertstaff = true)
{
global $cfg, $thisclient, $_FILES;
/* Coders never code so fully and joyfully as when they do it for free - Peter Rotich */
$id = 0;
$fields = array();
$fields['name'] = array('type' => 'string', 'required' => 1, 'error' => 'Name required');
$fields['email'] = array('type' => 'email', 'required' => 1, 'error' => 'Valid email required');
$fields['subject'] = array('type' => 'string', 'required' => 1, 'error' => 'Subject required');
$fields['message'] = array('type' => 'text', 'required' => 1, 'error' => 'Message required');
if (strcasecmp($origin, 'web') == 0) {
//Help topic only applicable on web tickets.
$fields['topicId'] = array('type' => 'int', 'required' => 1, 'error' => 'Select help topic');
} elseif (strcasecmp($origin, 'staff') == 0) {
//tickets created by staff...e.g on callins.
$fields['deptId'] = array('type' => 'int', 'required' => 1, 'error' => 'Dept. required');
$fields['source'] = array('type' => 'string', 'required' => 1, 'error' => 'Indicate source');
$fields['duedate'] = array('type' => 'date', 'required' => 0, 'error' => 'Invalid date - must be MM/DD/YY');
} else {
//Incoming emails
$fields['emailId'] = array('type' => 'int', 'required' => 1, 'error' => 'Email unknown');
}
$fields['pri'] = array('type' => 'int', 'required' => 0, 'error' => 'Invalid Priority');
$fields['phone'] = array('type' => 'phone', 'required' => 0, 'error' => 'Valid phone # required');
$validate = new Validator($fields);
if (!$validate->validate($var)) {
$errors = array_merge($errors, $validate->errors());
}
//Make sure the email is not banned
if (!$errors && BanList::isbanned($var['email'])) {
$errors['err'] = 'Ticket denied. Error #403';
//We don't want to tell the user the real reason...Psssst.
Sys::log(LOG_WARNING, 'Ticket denied', 'Banned email - ' . $var['email']);
//We need to let admin know which email got banned.
}
if (!$errors && $thisclient && strcasecmp($thisclient->getEmail(), $var['email'])) {
$errors['email'] = 'Email mismatch.';
}
//Make sure phone extension is valid
if ($var['phone_ext']) {
if (!is_numeric($var['phone_ext']) && !$errors['phone']) {
$errors['phone'] = 'Invalid phone ext.';
} elseif (!$var['phone']) {
//make sure they just didn't enter ext without phone #
$errors['phone'] = 'Phone number required';
}
}
//Make sure the due date is valid
if ($var['duedate']) {
if (!$var['time'] || strpos($var['time'], ':') === false) {
$errors['time'] = 'Select time';
} elseif (strtotime($var['duedate'] . ' ' . $var['time']) === false) {
$errors['duedate'] = 'Invalid duedate';
} elseif (strtotime($var['duedate'] . ' ' . $var['time']) <= time()) {
$errors['duedate'] = 'Due date must be in the future';
}
}
//check attachment..if any is set ...only set on webbased tickets..
if ($_FILES['attachment']['name'] && $cfg->allowOnlineAttachments()) {
if (!$cfg->canUploadFileType($_FILES['attachment']['name'])) {
$errors['attachment'] = 'Invalid file type [ ' . Format::htmlchars($_FILES['attachment']['name']) . ' ]';
} elseif ($_FILES['attachment']['size'] > $cfg->getMaxFileSize()) {
$errors['attachment'] = 'File is too big. Max ' . $cfg->getMaxFileSize() . ' bytes allowed';
}
}
//check ticket limits..if limit set is >0
//TODO: Base ticket limits on SLA...
if ($var['email'] && !$errors && $cfg->getMaxOpenTickets() > 0 && strcasecmp($origin, 'staff')) {
$openTickets = Ticket::getOpenTicketsByEmail($var['email']);
if ($openTickets >= $cfg->getMaxOpenTickets()) {
$errors['err'] = "You've reached the maximum open tickets allowed.";
//Send the notice only once (when the limit is reached) incase of autoresponders at client end.
if ($cfg->getMaxOpenTickets() == $openTickets && $cfg->sendOverlimitNotice()) {
if ($var['deptId']) {
$dept = new Dept($var['deptId']);
}
if (!$dept || !($tplId = $dept->getTemplateId())) {
$tplId = $cfg->getDefaultTemplateId();
}
$sql = 'SELECT ticket_overlimit_subj,ticket_overlimit_body FROM ' . EMAIL_TEMPLATE_TABLE . ' WHERE cfg_id=' . db_input($cfg->getId()) . ' AND tpl_id=' . db_input($tplId);
$resp = db_query($sql);
if (db_num_rows($resp) && (list($subj, $body) = db_fetch_row($resp))) {
$body = str_replace("%name", $var['name'], $body);
$body = str_replace("%email", $var['email'], $body);
$body = str_replace("%url", $cfg->getBaseUrl(), $body);
$body = str_replace('%signature', $dept && $dept->isPublic() ? $dept->getSignature() : '', $body);
if (!$dept || !($email = $dept->getAutoRespEmail())) {
$email = $cfg->getDefaultEmail();
}
if ($email) {
$email->send($var['email'], $subj, $body);
}
}
//Alert admin...this might be spammy (no option to disable)...but it is helpful..I think.
$msg = 'Support ticket request denied for ' . $var['email'] . "\n" . 'Open ticket:' . $openTickets . "\n" . 'Max Allowed:' . $cfg->getMaxOpenTickets() . "\n\nNotice only sent once";
Sys::alertAdmin('Overlimit Notice', $msg);
}
}
}
//Any error above is fatal.
//.........这里部分代码省略.........
示例7: update
function update($var, &$errors)
{
global $cfg, $thisstaff;
$fields = array();
$fields['name'] = array('type' => 'string', 'required' => 1, 'error' => 'Name required');
$fields['email'] = array('type' => 'email', 'required' => 1, 'error' => 'Email is required');
$fields['note'] = array('type' => 'text', 'required' => 1, 'error' => 'Reason for the update required');
$fields['subject'] = array('type' => 'string', 'required' => 1, 'error' => 'Subject required');
$fields['topicId'] = array('type' => 'int', 'required' => 0, 'error' => 'Invalid Selection');
$fields['pri'] = array('type' => 'int', 'required' => 0, 'error' => 'Invalid Priority');
$fields['phone'] = array('type' => 'phone', 'required' => 0, 'error' => 'Valid phone # required');
$fields['duedate'] = array('type' => 'date', 'required' => 0, 'error' => 'Invalid date - must be MM/DD/YY');
$params = new Validator($fields);
if (!$params->validate($var)) {
$errors = array_merge($errors, $params->errors());
}
if ($var['duedate']) {
if ($this->isClosed()) {
$errors['duedate'] = 'Duedate can NOT be set on a closed ticket';
} elseif (!$var['time'] || strpos($var['time'], ':') === false) {
$errors['time'] = 'Select time';
} elseif (strtotime($var['duedate'] . ' ' . $var['time']) === false) {
$errors['duedate'] = 'Invalid duedate';
} elseif (strtotime($var['duedate'] . ' ' . $var['time']) <= time()) {
$errors['duedate'] = 'Due date must be in the future';
}
}
//Make sure phone extension is valid
if ($var['phone_ext']) {
if (!is_numeric($var['phone_ext']) && !$errors['phone']) {
$errors['phone'] = 'Invalid phone ext.';
} elseif (!$var['phone']) {
//make sure they just didn't enter ext without phone #
$errors['phone'] = 'Phone number required';
}
}
$cleartopic = false;
$topicDesc = '';
if ($var['topicId'] && ($topic = new Topic($var['topicId'])) && $topic->getId()) {
$topicDesc = $topic->getName();
} elseif (!$var['topicId'] && $this->getTopicId()) {
$topicDesc = '';
$cleartopic = true;
}
if (!$errors) {
$sql = 'UPDATE ' . TICKET_TABLE . ' SET updated=NOW() ' . ',email=' . db_input($var['email']) . ',name=' . db_input(Format::striptags($var['name'])) . ',subject=' . db_input(Format::striptags($var['subject'])) . ',phone="' . db_input($var['phone'], false) . '"' . ',phone_ext=' . db_input($var['phone_ext'] ? $var['phone_ext'] : NULL) . ',priority_id=' . db_input($var['pri']) . ',topic_id=' . db_input($var['topicId']) . ',duedate=' . ($var['duedate'] ? db_input(date('Y-m-d G:i', Misc::dbtime($var['duedate'] . ' ' . $var['time']))) : 'NULL');
if ($var['duedate']) {
//We are setting new duedate...
$sql .= ',isoverdue=0';
}
if ($topicDesc || $cleartopic) {
//we're overwriting previous topic.
$sql .= ',helptopic=' . db_input($topicDesc);
}
$sql .= ' WHERE ticket_id=' . db_input($this->getId());
//echo $sql;
if (db_query($sql)) {
$this->postNote('Ticket Updated', $var['note']);
$this->reload();
return true;
}
}
return false;
}
示例8: testGetId
public function testGetId()
{
$id = uniqid();
$topic = new Topic($id);
$this->assertEquals($id, $topic->getId());
}
示例9: 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.');
}
示例10: processPostForm
/**
* Process post form action
*
* @param sfWebRequest $request
* @param sfForm $form
*/
protected function processPostForm(sfWebRequest $request, sfForm $form, Topic $topic = null)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
$post = $form->save();
if (null !== $topic) {
$post->id_user = $this->getUser()->getGuardUser()->getId();
$post->id_topic = $topic->getId();
$post->save();
} else {
$topic = $form->getObject()->getTopic();
}
$this->redirect('room_topic_show', $topic);
}
}
示例11: create
function create($var, &$errors, $origin, $autorespond = true, $alertstaff = true)
{
global $cfg, $thisclient, $_FILES;
$id = 0;
$fields = array();
$fields['name'] = array('type' => 'string', 'required' => 1, 'error' => 'Name required');
$fields['email'] = array('type' => 'email', 'required' => 1, 'error' => 'Valid email required');
$fields['subject'] = array('type' => 'string', 'required' => 1, 'error' => 'Subject required');
$fields['message'] = array('type' => 'text', 'required' => 1, 'error' => 'Message required');
if (strcasecmp($origin, 'web') == 0) {
//Help topic only applicable on web tickets.
$fields['topicId'] = array('type' => 'int', 'required' => 1, 'error' => 'Select help topic');
} elseif (strcasecmp($origin, 'staff') == 0) {
//tickets created by staff...e.g on callins.
$fields['deptId'] = array('type' => 'int', 'required' => 1, 'error' => 'Dept. required');
$fields['source'] = array('type' => 'string', 'required' => 1, 'error' => 'Indicate source');
} else {
//Incoming emails (PIPE or POP.
$fields['emailId'] = array('type' => 'int', 'required' => 1, 'error' => 'Email unknown');
}
$fields['pri'] = array('type' => 'int', 'required' => 0, 'error' => 'Invalid Priority');
$fields['phone'] = array('type' => 'phone', 'required' => 0, 'error' => 'Phone # required');
$validate = new Validator($fields);
if (!$validate->validate($var)) {
$errors = array_merge($errors, $validate->errors());
}
//Make sure the email is not banned
if (!$errors && BanList::isbanned($var['email'])) {
$errors['err'] = 'Ticket denied Error #403';
}
if (!$errors && $thisclient && strcasecmp($thisclient->getEmail(), $var['email'])) {
$errors['email'] = 'Email mismatch.';
}
//check attachment..if any is set ...only set on webbased tickets..
if ($_FILES['attachment']['name'] && $cfg->allowOnlineAttachments()) {
if (!$cfg->canUploadFileType($_FILES['attachment']['name'])) {
$errors['attachment'] = 'Invalid file type [ ' . $_FILES['attachment']['name'] . ' ]';
} elseif ($_FILES['attachment']['size'] > $cfg->getMaxFileSize()) {
$errors['attachment'] = 'File is too big. Max ' . $cfg->getMaxFileSize() . ' bytes allowed';
}
}
//check ticket limits..if limit set is >0
//TODO: Base ticket limits on SLA...
if ($var['email'] && !$errors && $cfg->getMaxOpenTickets() > 0) {
$openTickets = Ticket::getOpenTicketsByEmail($var['email']);
if ($openTickets >= $cfg->getMaxOpenTickets()) {
$errors['err'] = "You've reached the maximum open tickets allowed.";
//Send the notice only once (when the limit is reached) incase of autoresponders at client end.
if ($cfg->getMaxOpenTickets() == $openTickets && $cfg->sendOverlimitNotice()) {
$sql = 'SELECT ticket_overlimit_subj,ticket_overlimit_body FROM ' . EMAIL_TEMPLATE_TABLE . ' WHERE cfg_id=' . db_input($cfg->getId()) . ' AND tpl_id=' . db_input($cfg->getDefaultTemplateId());
$resp = db_query($sql);
if (db_num_rows($resp) && (list($subj, $body) = db_fetch_row($resp))) {
$body = str_replace("%name", $var['name'], $body);
$body = str_replace("%email", $var['email'], $body);
$body = str_replace("%url", $cfg->getBaseUrl(), $body);
Misc::sendmail($var['email'], $subj, $body, $cfg->getNoReplyEmail());
}
}
//Alert admin...this might be spammy (no option to disable)...but it is helpful..I think.
$msg = 'Support ticket request denied for ' . $var['email'] . "\n" . 'Open ticket:' . $openTickets . "\n" . 'Max Allowed:' . $cfg->getMaxOpenTickets() . "\n";
Misc::alertAdmin('Overlimit Notice', $msg);
}
}
//Any error above is fatal.
if ($errors) {
return 0;
}
// OK...just do it.
$deptId = $var['deptId'];
//pre-selected Dept if any.
$priorityId = $var['pri'];
$source = ucfirst($var['source']);
// Intenal mapping magic...see if we need to overwrite anything
if (isset($var['topicId']) && !$var['deptId']) {
//Ticket created via web by user
if ($var['topicId'] && ($topic = new Topic($var['topicId'])) && $topic->getId()) {
$deptId = $topic->getDeptId();
$priorityId = $priorityId ? $priorityId : $topic->getPriorityId();
$autorespond = $topic->autoRespond();
}
$topic = null;
$source = 'Web';
} elseif ($var['emailId'] && !$var['deptId']) {
//Emailed Tickets
$email = new Email($var['emailId']);
if ($email && $email->getId()) {
$deptId = $email->getDeptId();
$autorespond = $email->autoRespond();
$priorityId = $priorityId ? $priorityId : $email->getPriorityId();
}
$email = null;
$source = 'Email';
} elseif ($var['deptId']) {
//Opened by staff.
$deptId = $var['deptId'];
$source = ucfirst($var['source']);
}
//Last minute checks
$priorityId = $priorityId ? $priorityId : $cfg->getDefaultPriorityId();
$deptId = $deptId ? $deptId : $cfg->getDefaultDeptId();
//.........这里部分代码省略.........
示例12: Topic
function test_addPromptr()
{
$name = "Writing";
$test_topic = new Topic($name);
$test_topic->save();
$name2 = "Interview";
$test_topic2 = new Topic($name2);
$test_topic2->save();
$promptr_name = "mikes 5 tips";
$topic_id = $test_topic->getId();
$test_promptr = new Promptr($promptr_name, $topic_id);
$test_topic->addPromptr($test_promptr);
$result = $test_topic->getPromptrs();
$end_promptr = new Promptr($promptr_name, $topic_id, 0, 0, $result[0]->getId());
$this->assertEquals([$end_promptr], $result);
}
示例13: addthis
$OG['topic_msg'] = $topic->getSubsumedMsg();
if ($channel->getId()>0)
{
$OG['request'] = 'openchannel';
$OG['channel_name'] = $channel->getName();
$OG['channel_desc'] = $channel->getDescription();
$OG['channel_logo'] = $CONF['url_path'] . $channel->getLogoFile('big');
}
if (isset($_GET['sms_ss'])){
$db = clone $GLOBALS['maindb'];
$_anon=($user->isAnon())?'true':'false';
$_channelid=($channel->getId()>0)?$channel->getId():0;
$db->query("INSERT INTO addthis(channelid,topicid,sms_ss,at_xt,userid,anon,ip) values ('{$_channelid}','{$topic->getId()}','".$_GET['sms_ss']."','".$_GET['at_xt']."','{$user->getId()}','{$_anon}','".$_SERVER['REMOTE_ADDR']."');");
}
$_newcookie=(isset($_COOKIE['autoopentopic']))?$_COOKIE['autoopentopic'].'_':'';
$_newcookie.=$topic->getId();
setcookie("autoopentopic", $_newcookie, time()+60);
}
if (isset($_GET['fromid']))
setcookie("visitnumber", 0, time()-1);
//$header='Location: '.$CONF['url_path'];
//header( $header ) ;
include_once('facebook-redirect.php');
示例14: getAllPostsByTopic
public function getAllPostsByTopic(Topic $topic)
{
$em = $this->getEntityManager();
$posts = $em->getRepository('BlogBundle:Post')->findByTopic(array('topic_id' => $topic->getId()));
return $posts;
}
示例15: setTopic
public function setTopic(Topic $topic)
{
$this->id_topic = $topic->getId();
return true;
}