Beispiel #1
0
function setUpGroups($lang)
{
    if (!file_exists(GROUP_FILE_LOCATION)) {
        $aGroupDB = new Groups();
        $aGroupDB->setFileName(GROUP_FILE_LOCATION);
        $names = ImageTypes::getMenuNames();
        foreach ($names as $name) {
            $aGroup = new Group();
            $aGroup->setType($lang[$name]);
            $aGroup->setGroupImage($name);
            $aGroup->rebuildElementLine();
            $aGroupDB->addElement($aGroup);
        }
        $aGroupDB->save();
    } else {
        // validate we have all the default groups
        $addedElement = false;
        $aGroupDB = new Groups(GROUP_FILE_LOCATION);
        $names = ImageTypes::getMenuNames();
        foreach ($names as $name) {
            if ($aGroupDB->getAGroup($name) == "") {
                $aGroup = new Group();
                $aGroup->setType($lang[$name]);
                $aGroup->setGroupImage($name);
                $aGroup->rebuildElementLine();
                $aGroupDB->addElement($aGroup);
                $addedElement = true;
            }
        }
        if ($addedElement) {
            $aGroupDB->save();
        }
    }
}
Beispiel #2
0
 function &getTypedGroups($reload = false)
 {
     if (isset($this->typedGroups) && !$reload) {
         if ($this->typedGroups->hasFileChanged()) {
             $reload = true;
         }
     }
     if (!isset($this->typedGroups) || $reload) {
         $_SESSION['load_count'] += 1;
         $groupsinstance = new Groups();
         $names = ImageTypes::getModuleNames();
         foreach ($names as $name) {
             $aGroup = new Group();
             $aGroup->setType($this->lang[$name]);
             $aGroup->setGroupImage($name);
             $aGroup->rebuildElementLine();
             $groupsinstance->addElement($aGroup);
         }
         $this->typedGroups =& $groupsinstance;
     }
     return $this->typedGroups;
 }