X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=widget.post.perms.php;h=0c9615a6b478712c5103101736718189c225f229;hb=HEAD;hp=1d6e9ce1fc492bb5a1c5418aae8e9336f1acde2c;hpb=f4aeade7d7564374b43f58c5060fc13b7d1d5b62;p=dotclear.git diff --git a/widget.post.perms.php b/widget.post.perms.php index 1d6e9ce..0c9615a 100644 --- a/widget.post.perms.php +++ b/widget.post.perms.php @@ -7,30 +7,42 @@ class xorgPostPermsWidget { 'auth' => array('text' => 'Visible par les X', 'selected' => false)); $pos = 'public'; + global $core; + $type = $core->blog->settings->xorgauth->get('xorg_blog_type'); + if ($type == 'group-admin' || $type == 'group-member') { + $choices['group'] = array('text' => 'Visible par les membres du groupe', + 'selected' => false); + } if (!is_null($post)) { $metas = unserialize($post->field('post_meta')); if (isset($metas['post_xorg_perms'])) { $pos = $metas['post_xorg_perms']; } } else { - global $core; $pos = $core->auth->getOption('post_xorg_perms'); if ($pos && !isset($choices[$pos])) { $pos = 'auth'; } } $choices[$pos]['selected'] = true; - echo '

'; + ?> + + +

+ getField('post_meta'); if (is_string($meta)) { $meta = unserialize($meta); @@ -42,11 +54,11 @@ class xorgPostPermsWidget { $cur->setField('post_meta', serialize($meta)); } - public static function behavior_adminBeforePostCreate(&$cur) { + public static function behavior_adminBeforePostCreate($cur) { self::setPermsMeta($cur); } - public static function behavior_adminBeforePostUpdate(&$cur, $post_id) { + public static function behavior_adminBeforePostUpdate($cur, $post_id) { self::setPermsMeta($cur); } @@ -63,28 +75,35 @@ class xorgPostPermsWidget { $pos = 'public'; } $levels[$pos]['selected'] = true; - echo '

'; + ?> + + (1) Ne concerne que les blogs de groupes X. Equivaut à "Visible par les X" sur les autres blogs" + +

+ getField('user_options'); $opts['post_xorg_perms'] = $_POST['post_xorg_perms']; $cur->setField('user_options', $opts); } - public static function behavior_coreBlogGetPosts(&$rs) { + public static function behavior_coreBlogGetPosts($rs) { $rs->extend('xorgPostPermsFilter'); } -/* public static function behavior_coreBlogGetComments(&$rs) { +/* public static function behavior_coreBlogGetComments($rs) { $rs->extends('xorgCommentPermsFilter'); }*/ } @@ -92,14 +111,14 @@ class xorgPostPermsWidget { if (class_exists('rsExtPostPublic')) { class xorgPostPermsFilter extends rsExtPostPublic { - private static function canRead(&$rs) { + private static function canRead($rs) { $metas = unserialize($rs->field('post_meta')); global $core; if (!isset($metas['post_xorg_perms'])) { return true; } elseif ($metas['post_xorg_perms'] == 'public') { return true; - } elseif ($metas['post_xorg_perms'] == 'auth' && $core->auth->userID()) { + } elseif ($metas['post_xorg_perms'] == 'auth' && $core->auth->checkPassword()) { return true; } elseif ($metas['post_xorg_perms'] == 'group' && $core->auth->getInfo('xorg_group_member')) { return true; @@ -107,22 +126,22 @@ class xorgPostPermsFilter extends rsExtPostPublic { return false; } - private static function showMessage(&$rs) { + private static function showMessage($rs) { $metas = unserialize($rs->field('post_meta')); global $core; $str = '

' - . 'Vous n\'avez pas les droits suffisants pour lire ce billet
'; - if (!$core->auth->userID()) { - $str .= 'Vous devez vous authentifier'; + . 'Vous n\'avez pas les droits suffisants pour lire ce billet :
'; + if (!$core->auth->checkPassword()) { + $str .= 'Vous devez vous authentifier'; } else { $str .= 'Tu dois être membre du groupe pour lire ce message'; } return $str . '

'; } - public static function getContent(&$rs, $absolute_urls = false) { + public static function getContent($rs, $absolute_urls = false) { if (self::canRead($rs)) { - return parent::getContent(&$rs, $absolute_urls); + return parent::getContent($rs, $absolute_urls); } else if (!self::isExtended($rs)) { return self::showMessage($rs); } else { @@ -130,9 +149,9 @@ class xorgPostPermsFilter extends rsExtPostPublic { } } - public static function getExcerpt(&$rs, $absolute_urls = false) { + public static function getExcerpt($rs, $absolute_urls = false) { if (self::canRead($rs)) { - return parent::getContent(&$rs, $absolute_urls); + return parent::getExcerpt($rs, $absolute_urls); } else if (self::isExtended($rs)) { return self::showMessage($rs); } else { @@ -140,15 +159,15 @@ class xorgPostPermsFilter extends rsExtPostPublic { } } - public static function commentsActive(&$rs) { + public static function commentsActive($rs) { return self::canRead($rs) && parent::commentsActive($rs); } - public static function trackbacksActive(&$rs) { + public static function trackbacksActive($rs) { return self::canRead($rs) && parent::trackbacksActive($rs); } - public static function hasComments(&$rs) { + public static function hasComments($rs) { return self::canRead($rs) && parent::hasComments($rs); } }