projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use the new get_profile/get_user smarty modifiers in plviews to be able to handle...
[platal.git]
/
classes
/
profilevisibility.php
diff --git
a/classes/profilevisibility.php
b/classes/profilevisibility.php
index
4b91fcc
..
cf5687d
100644
(file)
--- a/
classes/profilevisibility.php
+++ b/
classes/profilevisibility.php
@@
-1,6
+1,6
@@
<?php
/***************************************************************************
<?php
/***************************************************************************
- * Copyright (C) 2003-201
0
Polytechnique.org *
+ * Copyright (C) 2003-201
1
Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-31,9
+31,13
@@
class ProfileVisibility
private $level;
private $level;
- public function __construct($level = null)
+ public function __construct($level = null
, $force = false
)
{
{
- $this->setLevel($level);
+ if ($force) {
+ $this->forceLevel($level);
+ } else {
+ $this->setLevel($level);
+ }
}
public function setLevel($level = self::VIS_PUBLIC)
}
public function setLevel($level = self::VIS_PUBLIC)
@@
-62,6
+66,15
@@
class ProfileVisibility
}
}
}
}
+ public function forceLevel($level)
+ {
+ if ($level != self::VIS_PRIVATE && $level != self::VIS_AX && $level != self::VIS_PUBLIC) {
+ Platal::page()->kill('Invalid visibility: ' . $level);
+ }
+
+ $this->level = $level;
+ }
+
public function level()
{
if ($this->level == null) {
public function level()
{
if ($this->level == null) {
@@
-80,6
+93,14
@@
class ProfileVisibility
{
return in_array($visibility, $this->levels());
}
{
return in_array($visibility, $this->levels());
}
+
+ static public function comparePublicity($a, $b)
+ {
+ $a_pub = new ProfileVisibility($a['pub'], true);
+ $b_pub = new ProfileVisibility($b['pub'], true);
+
+ return !$a_pub->isVisible($b_pub->level());
+ }
}
}