diff --git a/main/wiki/index.php b/main/wiki/index.php index 774b69e014..994e345c79 100755 --- a/main/wiki/index.php +++ b/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= ''.get_lang('FullNotifyByEmail').''.get_lang('NotNotifyChanges').''; + $notify_all= ''.get_lang('FullNotifyByEmail').''.get_lang('NotNotifyChanges'); + $lock_unlock_notify_all='unlocknotifyall'; } else { - $notify_all= ''.get_lang('FullCancelNotifyByEmail').''.get_lang('NotifyChanges').''; + $notify_all= ''.get_lang('FullCancelNotifyByEmail').''.get_lang('NotifyChanges'); + $lock_unlock_notify_all='locknotifyall'; } } - echo '
'.$notify_all.''.get_lang('RecentChanges').'
'; + echo '
'; + echo ''.$notify_all.''; + echo ''.get_lang('RecentChanges').'
'; @@ -2196,16 +2200,18 @@ if ($_GET['action']=='discuss') echo ''; //discussion action: email notification - if (check_notify_discuss($page)) + if (check_notify_discuss($page)==1) { $notify_disc= ''.get_lang('NotifyDiscussByEmail').''; + $lock_unlock_notify_disc='unlocknotifydisc'; } else { $notify_disc= ''.get_lang('CancelNotifyDiscussByEmail').''; + $lock_unlock_notify_disc='locknotifydisc'; } echo ''; - echo ''.$notify_disc.''; + echo ''.$notify_disc.''; echo ''; echo $icon_assignment.'   '.$row['title']; diff --git a/main/wiki/wiki.inc.php b/main/wiki/wiki.inc.php index 8cef2c77e5..bce9eda23e 100755 --- a/main/wiki/wiki.inc.php +++ b/main/wiki/wiki.inc.php @@ -881,15 +881,19 @@ function display_wiki_entry() echo ''; //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= ''.get_lang('NotifyByEmail').''; + $lock_unlock_notify_page='unlocknotify'; } else { $notify_page= ''.get_lang('CancelNotifyByEmail').''; + $lock_unlock_notify_page='locknotify'; + } } echo ''; - echo ''.$notify_page.''; + echo ''.$notify_page.''; echo ''; //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 + * 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; }