* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-class ProfileVisibility
-{
- static private $v_values = array(self::VIS_PUBLIC => array(self::VIS_PUBLIC),
- self::VIS_AX => array(self::VIS_AX, self::VIS_PUBLIC),
- self::VIS_PRIVATE => array(self::VIS_PRIVATE, self::VIS_AX, self::VIS_PUBLIC));
-
- const VIS_PUBLIC = 'public';
- const VIS_AX = 'ax';
- const VIS_PRIVATE = 'private';
-
- private $level;
-
- public function __construct($level = null)
- {
- $this->setLevel($level);
- }
-
- public function setLevel($level = self::VIS_PUBLIC)
- {
- if ($level != null && $level != self::VIS_PRIVATE && $level != self::VIS_AX && $level != self::VIS_PUBLIC) {
- Platal::page()->kill("Invalid visibility: " . $level);
- }
-
- if (!S::logged()) {
- $level = self::VIS_PUBLIC;
- } else if ($level == null) {
- $level = self::VIS_PRIVATE;
- }
-
- if ($this->level == null || $this->level == self::VIS_PRIVATE) {
- $this->level = $level;
- } else if ($this->level == self::VIS_AX && $level == self::VIS_PRIVATE) {
- return;
- } else {
- $this->level = self::VIS_PUBLIC;
- }
- }
-
- public function level()
- {
- if ($this->level == null) {
- return self::VIS_PUBLIC;
- } else {
- return $this->level;
- }
- }
-
- public function levels()
- {
- return self::$v_values[$this->level()];
- }
-
- public function isVisible($visibility)
- {
- return in_array($visibility, $this->levels());
- }
-}
-
class Profile
{
$this->fetched_fields = $fields;
}
+ /** Have we already fetched this field ?
+ */
private function fetched($field)
{
- if (($fields | self::FETCH_ALL) != self::FETCH_ALL) {
- Platal::page()->kill("Invalid fetched fields: $fields");
+ if (!array_key_exists($field, ProfileField::$fields)) {
+ Platal::page()->kill("Invalid field: $field");
}
return ($this->fetched_fields & $field);
*/
private function consolidateFields()
{
+ // Link phones to addresses
if ($this->phones != null) {
if ($this->addresses != null) {
$this->addresses->addPhones($this->phones);
}
}
+ // Link addresses to jobs
if ($this->addresses != null && $this->jobs != null) {
$this->jobs->addAddresses($this->addresses);
}
+
+ // Link jobterms to jobs
if ($this->jobs != null && $this->jobterms != null) {
$this->jobs->addJobTerms($this->jobterms);
}