$sql="SELECT * FROM `$tbl_wiki_discuss` reviews, $user_table user WHERE reviews.publication_id='".$id."' AND user.user_id='".$wuid."' ORDER BY id DESC";
$sql="SELECT * FROM $tbl_wiki_discuss reviews, $user_table user WHERE reviews.publication_id='".$id."' AND user.user_id='".$wuid."' ORDER BY id DESC";
$result=api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error());
@ -1389,7 +1376,7 @@ if ($_GET['action']=='discuss')
echo '<hrnoshadesize="1">';
}
echo"</div>";
// echo"</div>";
}
else
{
@ -1573,7 +1560,7 @@ function make_wiki_link_clickable($input)
else
{
$input_array[$key]='<ahref="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq='.$_course[id].'&action=showpage&title='.strtolower(str_replace(' ','',$link)).'&group_id='.$_clean['group_id'].'"class="wiki_link">'.$title.$titleg_ex.'</a>'; // juan esto recoge la posibilidad de que el titulo sea diferente a la url
@ -2337,7 +2329,7 @@ function check_ratinglock_discuss()
$status_ratinglock_disc=1;
}
$sql='UPDATE '.$tbl_wiki.' SET ratinglock_disc="'.Database::escape_string($status_ratinglock_disc).'" WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter; //juan carlos da valor de visible o no a todos los registros de la pagina, no solo al primero como antes
$sql='UPDATE '.$tbl_wiki.' SET ratinglock_disc="'.Database::escape_string($status_ratinglock_disc).'" WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter; //Visibility. Value to all,not only for the first
api_sql_query($sql,__FILE__,__LINE__);
//Although the value now is assigned to all (not only the first), these three lines remain necessary. They do that by changing the page state is made when you press the button and not have to wait to change his page
@ -2364,47 +2356,58 @@ function check_ratinglock_discuss()
* Notify page changes
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function check_notify_page()
function check_notify_page($reflink)
{
global $tbl_wiki;
global $page;
global $groupfilter;
global $tbl_wiki_mailcue;
$_clean['group_id']=(int)$_SESSION['_gid'];
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.$reflink.'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$status_notify=$row['notify'];
$id=$row['id'];
$sql='SELECT * FROM '.$tbl_wiki_mailcue.'WHERE id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="P"';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$idm=$row['id'];
if (empty($idm))
{
$status_notify=0;
}
else
{
$status_notify=1;
}
//change status
if ($_GET['actionpage']=='notify')
{
if ($row['notify']==0)
if ($status_notify==0)
{
$sql="INSERT INTO ".$tbl_wiki_mailcue." (id, user_id, type, group_id) VALUES ('".$id."','".api_get_user_id()."','P','".$_clean['group_id']."')";
api_sql_query($sql,__FILE__,__LINE__);
$status_notify=1;
}
else
{
$sql='DELETE FROM '.$tbl_wiki_mailcue.' WHERE id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="P"'; //$_clean['group_id'] not necessary
api_sql_query($sql,__FILE__,__LINE__);
$status_notify=0;
}
$sql='UPDATE '.$tbl_wiki.' SET notify="'.Database::escape_string($status_notify).'" WHERE id="'.$id.'"';
api_sql_query($sql,__FILE__,__LINE__);
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$sql="INSERT INTO ".$tbl_wiki_mailcue." (id, user_id) VALUES ('".$id."','".api_get_user_id()."')";
$result=api_sql_query($sql);
}
//show status
if ($row['notify']==0 || ($row['content']=='' AND $row['title']=='' AND $page='index'))
if ($status_notify==0)
{
return false;
}
@ -2415,52 +2418,135 @@ function check_notify_page()
}
/**
* Notify discussion changes
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function check_notify_discuss()
function check_notify_discuss($reflink)
{
global $tbl_wiki;
global $page;
global $groupfilter;
global $tbl_wiki_mailcue;
$_clean['group_id']=(int)$_SESSION['_gid'];
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.$reflink.'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$id=$row['id'];
$sql='SELECT * FROM '.$tbl_wiki_mailcue.'WHERE id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D"';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$status_notify_disc=$row['notify_disc'];
$id=$row['id']; //need ? check. to do
$idm=$row['id'];
///change status
if (empty($idm))
{
$status_notify_disc=0;
}
else
{
$status_notify_disc=1;
}
//change status
if ($_GET['actionpage']=='notify_disc')
{
if ($row['notify_disc']=="0")
if ($status_notify_disc==0)
{
$status_notify_disc="1";
if (!$_POST['Submit'])
{
$sql="INSERT INTO ".$tbl_wiki_mailcue." (id, user_id, type, group_id) VALUES ('".$id."','".api_get_user_id()."','D','".$_clean['group_id']."')";
api_sql_query($sql,__FILE__,__LINE__);
$status_notify_disc=1;
}
else
{
$status_notify_disc=0;
}
}
else
{
$status_notify_disc="0";
if (!$_POST['Submit'])
{
$sql='DELETE FROM '.$tbl_wiki_mailcue.' WHERE id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D"'; //$_clean['group_id'] not necessary
api_sql_query($sql,__FILE__,__LINE__);
$status_notify_disc=0;
}
else
{
$status_notify_disc=1;
}
}
}
$sql='UPDATE '.$tbl_wiki.' SET notify_disc="'.Database::escape_string($status_notify_disc).'" WHERE id="'.$id.'"';
api_sql_query($sql,__FILE__,__LINE__);
//show status
if ($status_notify_disc==0)
{
return false;
}
else
{
return true;
}
}
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$sql="INSERT INTO ".$tbl_wiki_mailcue." (id, user_id) VALUES ('".$id."','".api_get_user_id()."')";
$result=api_sql_query($sql);
/**
* Notify all changes
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function check_notify_all()
{
global $tbl_wiki_mailcue;
$_clean['group_id']=(int)$_SESSION['_gid'];
$sql='SELECT * FROM '.$tbl_wiki_mailcue.'WHERE user_id="'.api_get_user_id().'" AND type="F" AND group_id="'.$_clean['group_id'].'"';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$idm=$row['user_id'];
if (empty($idm))
{
$status_notify_all=0;
}
else
{
$status_notify_all=1;
}
//change status
if ($_GET['actionpage']=='notify_all')
{
if ($status_notify_all==0)
{
$sql="INSERT INTO ".$tbl_wiki_mailcue." (user_id, type, group_id) VALUES ('".api_get_user_id()."','F','".$_clean['group_id']."')";
api_sql_query($sql,__FILE__,__LINE__);
$status_notify_all=1;
}
else
{
$sql='DELETE FROM '.$tbl_wiki_mailcue.' WHERE user_id="'.api_get_user_id().'" AND type="F" AND group_id="'.$_clean['group_id'].'"';
api_sql_query($sql,__FILE__,__LINE__);
$status_notify_all=0;
}
}
//show status
if ($row['notify_disc']=="0" || ($row['content']=='' AND $row['title']=='' AND $page='index'))
if ($status_notify_all==0)
{
return false;
}
@ -2470,17 +2556,92 @@ function check_notify_discuss()
}
}
/**
* Function check emailcue
* TO DO
* Function check emailcue and send email when a page change
* @author Juan Carlos Raña <herodoto@telefonica.net>
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.$id_or_ref.'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$id=$row['id'];
$sql='SELECT * FROM '.$tbl_wiki_mailcue.'WHERE id="'.$id.'" AND type="'.$type.'" OR type="F" AND group_id="'.$_clean['group_id'].'"'; //type: P=page, D=discuss, F=full
$result=api_sql_query($sql,__LINE__,__FILE__);
$emailtext=get_lang('EmailWikipageModified');
}
elseif ($type=='D')
{
//if added a post to discuss
$id=$id_or_ref;
$sql='SELECT * FROM '.$tbl_wiki_mailcue.'WHERE id="'.$id.'" AND type="'.$type.'" OR type="F" AND group_id="'.$_clean['group_id'].'"'; //type: P=page, D=discuss, F=full
$result=api_sql_query($sql,__LINE__,__FILE__);
$emailtext=get_lang('EmailWikiPageDiscAdded');
}
elseif($type=='A')
{
//for added pages
$id=0;
$sql='SELECT * FROM '.$tbl_wiki_mailcue.'WHERE id="'.$id.'" AND type="F" AND group_id="'.$_clean['group_id'].'"'; //type: P=page, D=discuss, F=full
$result=api_sql_query($sql,__LINE__,__FILE__);
$emailtext=get_lang('EmailWikiPageAdded');
}
elseif($type=='E')
{
$id=0;
$sql='SELECT * FROM '.$tbl_wiki_mailcue.'WHERE id="'.$id.'" AND type="F" AND group_id="'.$_clean['group_id'].'"'; //type: P=page, D=discuss, F=wiki