$this->setError(_('Forum Description Must Be At Least 10 Characters'));
return false;
}
- if (preg_match('[^_\.0-9a-z-]',$forum_name)) {
+ $forum_name = strtolower($forum_name);
+ if (!preg_match('/^([_\.0-9a-z-])*$/',$forum_name)) {
$this->setError(_('Illegal Characters in Forum Name'));
return false;
}
db_begin();
$result = db_query_params('INSERT INTO forum_group_list (group_id,forum_name,is_public,description,send_all_posts_to,allow_anonymous,moderation_level) VALUES ($1,$2,$3,$4,$5,$6,$7)',
array ($this->Group->getID(),
- strtolower($forum_name),
+ $forum_name,
$is_public,
htmlspecialchars($description),
$send_all_posts_to,
}
$this->group_forum_id=db_insertid($result,'forum_group_list','group_forum_id');
$this->fetchData($this->group_forum_id);
+
+ // set the permission for the role's group
+ $roles_group = $this->Group->getRolesId();
+ for ($i=0; $i<sizeof($roles_group); $i++) {
+ $role_setting_res = db_query_params ('INSERT INTO role_setting (role_id,section_name,ref_id,value) VALUES ($1,$2,$3,$4)',
+ array ($roles_group[$i],
+ 'forum',
+ $this->group_forum_id,
+ 1)) ;
+ if (!$role_setting_res) {
+ db_rollback();
+ $this->setError('Error: Role setting for forum id ' . $this->group_forum_id . ' for groud id ' . $this->Group->getID() . ' ' .db_error());
+ return false;
+ }
+ }
+
if ($create_default_message) {
$fm=new ForumMessage($this);
// Use the system side default language
*
* @return boolean success.
*/
- function setMonitor() {
- if (!session_loggedin()) {
- $this->setError(_('You can only monitor if you are logged in'));
- return false;
+ function setMonitor ($u = -1) {
+ if ($u == -1) {
+ if (!session_loggedin()) {
+ $this->setError(_('You can only monitor if you are logged in'));
+ return false;
+ }
+ $u = user_getid() ;
}
$result = db_query_params ('SELECT * FROM forum_monitored_forums WHERE user_id=$1 AND forum_id=$2',
- array (user_getid(),
+ array ($u,
$this->getID())) ;
-
if (!$result || db_numrows($result) < 1) {
/*
User is not already monitoring thread, so
insert a row so monitoring can begin
*/
$sql="INSERT INTO forum_monitored_forums (forum_id,user_id)
- VALUES ('".$this->getID()."','".user_getid()."')";
+ VALUES ('".$this->getID()."','$u')";
$result = db_query_params ('INSERT INTO forum_monitored_forums (forum_id,user_id) VALUES ($1,$2)',
array ($this->getID(),
*
* @return boolean success.
*/
- function stopMonitor() {
- if (!session_loggedin()) {
- $this->setError(_('You can only monitor if you are logged in'));
- return false;
+ function stopMonitor ($u = -1) {
+ if ($u == -1) {
+ if (!session_loggedin()) {
+ $this->setError(_('You can only monitor if you are logged in'));
+ return false;
+ }
+ $u = user_getid() ;
}
return db_query_params ('DELETE FROM forum_monitored_forums WHERE user_id=$1 AND forum_id=$2',
- array (user_getid(),
+ array ($u,
$this->getID())) ;
}
$this->setError(_('Forum Description Must Be At Least 10 Characters'));
return false;
}
- if (eregi('[^_\.0-9a-z-]',$forum_name)) {
+ $forum_name = strtolower($forum_name);
+ if (!preg_match('/^([_\.0-9a-z-])*$/',$forum_name)) {
$this->setError(_('Illegal Characters in Forum Name'));
return false;
}
if ($send_all_posts_to) {
+ $send_all_posts_to = str_replace(';', ',', $send_all_posts_to);
$invalid_mails = validate_emails($send_all_posts_to);
if (count($invalid_mails) > 0) {
$this->setInvalidEmailError();
allow_anonymous=$4,
moderation_level=$5,
is_public=$6
- WHERE group_id=$7,
+ WHERE group_id=$7
AND group_forum_id=$8',
- array (strtolower($forum_name),
+ array ($forum_name,
htmlspecialchars($description),
$send_all_posts_to,
$allow_anonymous,
db_query_params ('DELETE FROM forum_group_list WHERE group_forum_id=$1',
array ($this->getID())) ;
//echo '5'.db_error();
+ //delete forum's role setting
+ db_query_params ('DELETE FROM role_setting WHERE section_name=$1 AND ref_id=$2',
+ array ('forum',
+ $this->getID())) ;
db_commit();
return true;
}