Browse Source

Merge with 0b9a306b0afa8221f8841041919466dc859c845b

Ivan Tcholakov 15 years ago
parent
commit
c77dda3838
2 changed files with 57 additions and 95 deletions
  1. 14 8
      main/wiki/index.php
  2. 43 87
      main/wiki/wiki.inc.php

+ 14 - 8
main/wiki/index.php

@@ -352,7 +352,7 @@ if ($_GET['view'])
 
 			if($PassEdit) //show editor if edit is allowed
 			{
-				if (check_protect_page() && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false))
+				if ($row['editlock']==1 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false))
 				{
 					   Display::display_normal_message(get_lang('PageLockedExtra'));
 				}
@@ -1333,7 +1333,7 @@ if ($_GET['action']=='edit')
 
 	 	if($PassEdit) //show editor if edit is allowed
 		 {
-	 		if (check_protect_page() && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false))
+	 		if ($row['editlock']==1 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false))
   	   	    {
     		       Display::display_normal_message(get_lang('PageLockedExtra'));
 		    }
@@ -1893,18 +1893,22 @@ if ($_GET['action']=='recentchanges')
 	$_clean['group_id']=(int)$_SESSION['_gid'];
 
 	if ( api_is_allowed_to_session_edit(false,true) ) {
-		if (check_notify_all())
+		if (check_notify_all()==1)
 		{
-			$notify_all= '<a href="index.php?action=recentchanges&amp;actionpage=notify_all&amp;title='.$page.'"><img src="../img/wiki/send_mail_checked.gif" title="'.get_lang('FullNotifyByEmail').'" alt="'.get_lang('FullNotifyByEmail').'" style="vertical-align:middle;" />'.get_lang('NotNotifyChanges').'</a>';
+			$notify_all= '<img src="../img/wiki/send_mail_checked.gif" title="'.get_lang('FullNotifyByEmail').'" alt="'.get_lang('FullNotifyByEmail').'" style="vertical-align:middle;" />'.get_lang('NotNotifyChanges');
+			$lock_unlock_notify_all='unlocknotifyall';			
 		}
 		else
 		{
-			$notify_all= '<a href="index.php?action=recentchanges&amp;actionpage=notify_all&amp;title='.$page.'"><img src="../img/wiki/send_mail.gif" title="'.get_lang('FullCancelNotifyByEmail').'" alt="'.get_lang('FullCancelNotifyByEmail').'"  style="vertical-align:middle;"/>'.get_lang('NotifyChanges').'</a>';
+			$notify_all= '<img src="../img/wiki/send_mail.gif" title="'.get_lang('FullCancelNotifyByEmail').'" alt="'.get_lang('FullCancelNotifyByEmail').'"  style="vertical-align:middle;"/>'.get_lang('NotifyChanges');
+			$lock_unlock_notify_all='locknotifyall';
 		}
 
 	}
 
-	echo '<div class="actions"><span style="float: right;">'.$notify_all.'</span>'.get_lang('RecentChanges').'</div>';
+	echo '<div class="actions"><span style="float: right;">';	
+	echo '<a href="index.php?action=recentchanges&amp;actionpage='.$lock_unlock_notify_all.'&amp;title='.$page.'">'.$notify_all.'</a>';	
+	echo '</span>'.get_lang('RecentChanges').'</div>';
 
 
 
@@ -2196,16 +2200,18 @@ if ($_GET['action']=='discuss')
 			echo '</span>';
 
 			//discussion action: email notification
-			if (check_notify_discuss($page))
+			if (check_notify_discuss($page)==1)
 			{
 				$notify_disc= '<img src="../img/wiki/send_mail_checked.gif" title="'.get_lang('NotifyDiscussByEmail').'" alt="'.get_lang('NotifyDiscussByEmail').'" />';
+				$lock_unlock_notify_disc='unlocknotifydisc';
 			}
 			else
 			{
 				$notify_disc= '<img src="../img/wiki/send_mail.gif" title="'.get_lang('CancelNotifyDiscussByEmail').'" alt="'.get_lang('CancelNotifyDiscussByEmail').'" />';
+				$lock_unlock_notify_disc='locknotifydisc';
 			}
 			echo '<span style="float:right">';
-			echo '<a href="index.php?action=discuss&amp;actionpage=notify_disc&amp;title='.$page.'">'.$notify_disc.'</a>';
+			echo '<a href="index.php?action=discuss&amp;actionpage='.$lock_unlock_notify_disc.'&amp;title='.$page.'">'.$notify_disc.'</a>';
 			echo '</span>';
 
 			echo $icon_assignment.'&nbsp;&nbsp;&nbsp;'.$row['title'];

+ 43 - 87
main/wiki/wiki.inc.php

@@ -881,15 +881,19 @@ function display_wiki_entry()
 		echo '</span>';
 
 		//page action: notification
-		if (api_is_allowed_to_session_edit() ) {
-			if (check_notify_page($page)) {
+		if (api_is_allowed_to_session_edit())
+		{
+			if (check_notify_page($page)==1) {
 				$notify_page= '<img src="../img/wiki/send_mail_checked.gif" title="'.get_lang('NotifyByEmail').'" alt="'.get_lang('NotifyByEmail').'" />';
+				$lock_unlock_notify_page='unlocknotify';
 			} else {
 				$notify_page= '<img src="../img/wiki/send_mail.gif" title="'.get_lang('CancelNotifyByEmail').'" alt="'.get_lang('CancelNotifyByEmail').'" />';
+				$lock_unlock_notify_page='locknotify';
+				
 			}
 		}
 		echo '<span style="float:right">';
-		echo '<a href="index.php?action=showpage&amp;actionpage=notify&amp;title='.$page.'">'.$notify_page.'</a>';
+		echo '<a href="index.php?action=showpage&amp;actionpage='.$lock_unlock_notify_page.'&amp;title='.$page.'">'.$notify_page.'</a>';
 		echo '</span>';
 
 		//page action: export to pdf
@@ -1369,41 +1373,31 @@ function check_notify_page($reflink)
 	}
 
 	//change status
-	if ($_GET['actionpage']=='notify')
+	if ($_GET['actionpage']=='locknotify' && $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']."')";
+		Database::query($sql,__FILE__,__LINE__);
 
-		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']."')";
-			Database::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
-			Database::query($sql,__FILE__,__LINE__);
+	    $status_notify=1;
+	}
+	if ($_GET['actionpage']=='unlocknotify' && $status_notify==1)
+	{
+		$sql='DELETE FROM '.$tbl_wiki_mailcue.' WHERE id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="P"'; //$_clean['group_id'] not necessary
+		Database::query($sql,__FILE__,__LINE__);
 
-		    $status_notify=0;
-	    }
+		$status_notify=0;
 	}
 
 	//show status
-	if ($status_notify==0)
-	{
-		return false;
-	}
-	else
-	{
-		return true;
-	}
+
+		return $status_notify;
 }
 
 
 /**
  * Notify discussion changes
  * @author Juan Carlos Raña <herodoto@telefonica.net>
+ * Return current database status of rating discuss and change it if get action
  */
 function check_notify_discuss($reflink)
 {
@@ -1427,7 +1421,6 @@ function check_notify_discuss($reflink)
 	if (empty($idm))
 	{
 		$status_notify_disc=0;
-
 	}
 	else
 	{
@@ -1435,50 +1428,24 @@ function check_notify_discuss($reflink)
 	}
 
 	//change status
-	if ($_GET['actionpage']=='notify_disc')
+	if ($_GET['actionpage']=='locknotifydisc' && $status_notify_disc==0)
 	{
+		$sql="INSERT INTO ".$tbl_wiki_mailcue." (id, user_id, type, group_id) VALUES ('".$id."','".api_get_user_id()."','D','".$_clean['group_id']."')";
+		Database::query($sql,__FILE__,__LINE__);
+		$status_notify_disc=1;
 
-		if ($status_notify_disc==0)
-	    {
-
-			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']."')";
-				Database::query($sql,__FILE__,__LINE__);
-
-				$status_notify_disc=1;
-			}
-			else
-			{
-				$status_notify_disc=0;
-			}
-	    }
-	    else
-		{
-			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
-				Database::query($sql,__FILE__,__LINE__);
-
-				$status_notify_disc=0;
-			}
-			else
-			{
-				$status_notify_disc=1;
-			}
-	    }
-	}
-
-	//show status
-	if ($status_notify_disc==0)
+	 }
+	if ($_GET['actionpage']=='unlocknotifydisc' && $status_notify_disc==1)
 	{
-		return false;
-	}
-	else
-	{
-		return true;
+		$sql='DELETE FROM '.$tbl_wiki_mailcue.' WHERE id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D"'; //$_clean['group_id'] not necessary
+		Database::query($sql,__FILE__,__LINE__);
+		$status_notify_disc=0;
 	}
+	
+	//show status
+
+		return $status_notify_disc;
+
 }
 
 
@@ -1510,34 +1477,23 @@ function check_notify_all()
 	}
 
 	//change status
-	if ($_GET['actionpage']=='notify_all')
+	if ($_GET['actionpage']=='locknotifyall' && $status_notify_all==0)
 	{
-
-		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']."')";
 			Database::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'].'"';
-			Database::query($sql,__FILE__,__LINE__);
-
-			$status_notify_all=0;
-	    }
-	}
-
-	//show status
-	if ($status_notify_all==0)
-	{
-		return false;
 	}
-	else
+	if ($_GET['actionpage']=='unlocknotifyall' && $status_notify_all==1)
 	{
-		return true;
+		$sql='DELETE FROM '.$tbl_wiki_mailcue.' WHERE user_id="'.api_get_user_id().'" AND type="F" AND group_id="'.$_clean['group_id'].'"';
+		Database::query($sql,__FILE__,__LINE__);
+		$status_notify_all=0;
 	}
+
+	//show status
+
+		return $status_notify_all;
 }