Ejemplo n.º 1
0
 /**
  * Recursive load all Children
  */
 public function loadChildren()
 {
     $this->children = User_Visibility_Settings::findBySQL("user_id = ? AND parent_id = ? ", array($this->user_id, $this->visibilityid));
     foreach ($this->children as $child) {
         $child->parent = $this;
         $child->loadChildren();
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns all the categorys and it's items
  * @return array categorys and it's items
  */
 public function getProfileSettings()
 {
     if (!isset($this->profileSettings)) {
         // if the default categories have not been created, do this now
         if (User_Visibility_Settings::countBySQL('user_id = ? AND category = 0', array($this->userid)) == 0) {
             Visibility::createDefaultCategories($this->userid);
         }
         $this->profileSettings = User_Visibility_Settings::findBySQL("user_id = ? AND parent_id = 0 AND identifier <> 'plugins'", array($this->userid));
         foreach ($this->profileSettings as $i => $vis) {
             $vis->loadChildren();
             // remap child settings to default categories
             if ($vis->category == 1) {
                 $idmap[$vis->identifier] = $vis;
                 unset($this->profileSettings[$i]);
             }
         }
         $about = new about($GLOBALS['user']->username, '');
         $elements = $about->get_homepage_elements();
         foreach ($elements as $key => $element) {
             foreach ($this->profileSettings as $vis) {
                 if ($vis->name === $element['category']) {
                     foreach ($vis->children as $child) {
                         if ($child->identifier === $key) {
                             $child->name = $element['name'];
                             break 2;
                         }
                     }
                     $child = $idmap[$key] ?: new User_Visibility_Settings();
                     $child->setData(array('user_id' => $this->userid, 'parent_id' => $vis->id, 'category' => 1, 'name' => $element['name'], 'state' => $element['visibility'], 'identifier' => $key));
                     $child->store();
                     $child->parent = $vis;
                     $child->setDisplayed();
                     $vis->children[] = $child;
                     break;
                 }
             }
         }
     }
     return $this->profileSettings;
 }