Exemplo n.º 1
0
 /**
  * 
  */
 public static function getPref($pref_id, $get_pref_value = true)
 {
     $preferences = self::_getPrefFile();
     $item_key = 'pref:' . $pref_id;
     if (isset($preferences[$item_key])) {
         $ini_node = $preferences[$item_key];
         $p = new jPrefItem();
         $p->setFromIniNode($item_key, $ini_node);
         //current user doesnt have rights to read this pref
         if (!$p->isReadable()) {
             return null;
         }
         if ($get_pref_value) {
             $p->loadValue();
         }
         return $p;
     } else {
         return null;
     }
 }
Exemplo n.º 2
0
 /**
  * @since 1.6.5
  */
 public static function importFromIni($iniFile)
 {
     $ini = jIniFile::read($iniFile);
     if ($ini === false) {
         throw new Exception('Bad ini file: ' . basename($iniFile));
     }
     foreach ($ini as $section => $node) {
         if (strpos($section, 'pref:') === 0) {
             $p = new jPrefItem();
             $p->setFromIniNode($section, $node);
             self::addPreference($p);
         } elseif (strpos($section, 'group:') === 0) {
             $p = new jPrefItemGroup();
             $p->setFromIniNode($section, $node);
             self::addGroup($p);
         }
     }
 }