function deletetopic() { global $CONF; $user = $_SESSION['user']; if (!isset($_GET['topicid_deletetopic']) || empty($_GET['topicid_deletetopic'])) return array('ok'=>'false','error'=>'no id'); elseif ($user->isAnon()) return array('ok'=>false,'error'=>'anon cannot delete topic'); else { $topic = new Topic(); $topic->setId($_GET['topicid_deletetopic']); $topic->load(); if ( (!$topic->getUser()->isAnon() && $topic->getUser()->getId() == $user->getId()) || ($topic->getChannel()->getUser()->getId() == $user->getId()) ) { $topic->delete(); return array('ok'=>true,'error'=>''); } return array('ok'=>false,'error'=>'you cannot delete this 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'); }
public function load($iCategoryID) { $oCon = new Connection(); $sSQL = 'SELECT CategoryID,CategoryName,CategoryDesc,Active FROM tbcategory WHERE CategoryID=' . $iCategoryID; $oResultSet = $oCon->query($sSQL); $aRow = $oCon->fetchArray($oResultSet); $this->iCategoryID = $aRow['CategoryID']; $this->sCategoryName = $aRow['CategoryName']; $this->sCategoryDesc = $aRow['CategoryDesc']; $this->iActive = $aRow['Active']; $sSQL = 'SELECT TopicID FROM tbtopics WHERE CategoryID=' . $iCategoryID . ' AND Active = 1'; $oResultSet = $oCon->query($sSQL); while ($aRow = $oCon->fetchArray($oResultSet)) { $iTopicID = $aRow['TopicID']; $oTopic = new Topic(); $oTopic->load($iTopicID); $this->aTopics[] = $oTopic; } $oCon->close(); }
$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'));
<?php require_once 'includes/header.php'; require_once 'includes/topics.php'; $oTopic = new Topic(); $oTopic->load($_GET["TopicID"]); if (isset($_SESSION["MemberID"]) != 2) { header("Location:viewCategories.php"); } else { $oTopic->Active = 0; $oTopic->save(); $sHTML = '<div class= "mainBackground"><h3>Topic ' . $oTopic->TopicID . ' has been successfully deleted!</h3> <a href="viewCategories.php">Continue</a></div>'; echo $sHTML; } require_once 'includes/footer.php';