Example #1
0
 function setPreferences($prefs, $id_only = false)
 {
     // if the prefs are changed
     if ($count = _AnonUser::setPreferences($prefs, 1)) {
         $this->getAuthDbh();
         $packed = $this->_prefs->store();
         if (!$id_only and isset($this->_prefs->_update)) {
             $dbh =& $this->_auth_dbi;
             try {
                 $sth = $dbh->prepare($this->_prefs->_update);
                 $sth->bindParam("prefs", $packed);
                 $sth->bindParam("user", $this->_userid);
                 $sth->execute();
             } catch (PDOException $e) {
                 trigger_error("SQL Error: " . $e->getMessage(), E_USER_WARNING);
                 return false;
             }
             //delete pageprefs:
             if ($this->_HomePagehandle and $this->_HomePagehandle->get('pref')) {
                 $this->_HomePagehandle->set('pref', '');
             }
         } else {
             //store prefs in homepage, not in cookie
             if ($this->_HomePagehandle and !$id_only) {
                 $this->_HomePagehandle->set('pref', $packed);
             }
         }
         return $count;
     }
     return 0;
 }
Example #2
0
 function setPreferences($prefs, $id_only = false)
 {
     // if the prefs are changed
     if (_AnonUser::setPreferences($prefs, 1)) {
         global $request;
         $packed = $this->_prefs->store();
         //$user = $request->_user;
         //unset($user->_auth_dbi);
         if (!$id_only and isset($this->_prefs->_update)) {
             $this->getAuthDbh();
             $dbh =& $this->_auth_dbi;
             // check if the user already exists (not needed with mysql REPLACE)
             $rs = $dbh->Execute(sprintf($this->_prefs->_select, $dbh->qstr($this->_userid)));
             if ($rs->EOF) {
                 $rs->Close();
                 $prefs_blob = false;
             } else {
                 $prefs_blob = @$rs->fields['prefs'];
                 $rs->Close();
             }
             if ($prefs_blob) {
                 $db_result = $dbh->Execute(sprintf($this->_prefs->_update, $dbh->qstr($packed), $dbh->qstr($this->_userid)));
             } else {
                 // Otherwise, insert a record for them and set it to the defaults.
                 $dbi = $request->getDbh();
                 $this->_prefs->_insert = $this->prepare($dbi->getAuthParam('pref_insert'), array("pref_blob", "userid"));
                 $db_result = $dbh->Execute(sprintf($this->_prefs->_insert, $dbh->qstr($packed), $dbh->qstr($this->_userid)));
             }
             $db_result->Close();
             // delete pageprefs:
             if ($this->_HomePagehandle and $this->_HomePagehandle->get('pref')) {
                 $this->_HomePagehandle->set('pref', '');
             }
         } else {
             //store prefs in homepage, not in cookie
             if ($this->_HomePagehandle and !$id_only) {
                 $this->_HomePagehandle->set('pref', $packed);
             }
         }
         return count($this->_prefs->unpack($packed));
     }
     return 0;
 }
Example #3
0
 function setPreferences($prefs, $id_only = false)
 {
     // if the prefs are changed
     if ($count = _AnonUser::setPreferences($prefs, 1)) {
         //global $request;
         //$user = $request->_user;
         //unset($user->_auth_dbi);
         // this must be done in $request->_setUser, not here!
         //$request->setSessionVar('wiki_user', $user);
         $this->getAuthDbh();
         $packed = $this->_prefs->store();
         if (!$id_only and isset($this->_prefs->_update)) {
             $dbh =& $this->_auth_dbi;
             // check if the user already exists (not needed with mysql REPLACE)
             $db_result = $dbh->query(sprintf($this->_prefs->_select, $dbh->quote($this->_userid)));
             $prefs = $db_result->fetchRow();
             $prefs_blob = @$prefs["prefs"];
             // If there are prefs for the user, update them.
             if ($prefs_blob != "") {
                 $dbh->simpleQuery(sprintf($this->_prefs->_update, $dbh->quote($packed), $dbh->quote($this->_userid)));
             } else {
                 // Otherwise, insert a record for them and set it to the defaults.
                 // johst@deakin.edu.au
                 $dbi = $GLOBALS['request']->getDbh();
                 $this->_prefs->_insert = $this->prepare($dbi->getAuthParam('pref_insert'), array("pref_blob", "userid"));
                 $dbh->simpleQuery(sprintf($this->_prefs->_insert, $dbh->quote($packed), $dbh->quote($this->_userid)));
             }
             //delete pageprefs:
             if (isset($this->_HomePagehandle) && $this->_HomePagehandle and $this->_HomePagehandle->get('pref')) {
                 $this->_HomePagehandle->set('pref', '');
             }
         } else {
             //store prefs in homepage, not in cookie
             if (isset($this->_HomePagehandle) && $this->_HomePagehandle and !$id_only) {
                 $this->_HomePagehandle->set('pref', $packed);
             }
         }
         return $count;
         //count($this->_prefs->unpack($packed));
     }
     return 0;
 }
Example #4
0
 function setPreferences($prefs, $id_only = false)
 {
     if (!empty($this->_prefs->_method)) {
         if ($this->_prefs->_method == 'ADODB') {
             // FIXME: strange why this should be needed...
             include_once "lib/WikiUser/Db.php";
             include_once "lib/WikiUser/AdoDb.php";
             return _AdoDbPassUser::setPreferences($prefs, $id_only);
         } elseif ($this->_prefs->_method == 'SQL') {
             include_once "lib/WikiUser/Db.php";
             include_once "lib/WikiUser/PearDb.php";
             return _PearDbPassUser::setPreferences($prefs, $id_only);
         } elseif ($this->_prefs->_method == 'PDO') {
             include_once "lib/WikiUser/Db.php";
             include_once "lib/WikiUser/PdoDb.php";
             return _PdoDbPassUser::setPreferences($prefs, $id_only);
         }
     }
     if ($updated = _AnonUser::setPreferences($prefs, $id_only)) {
         // Encode only the _prefs array of the UserPreference object
         // If no DB method exists to store the prefs we must store it in the page, not in the cookies.
         if (empty($this->_HomePagehandle)) {
             $this->_HomePagehandle = $GLOBALS['request']->getPage($this->_userid);
         }
         if (!$this->_HomePagehandle->exists()) {
             $this->createHomePage();
         }
         if (!empty($this->_HomePagehandle) and !$id_only) {
             $this->_HomePagehandle->set('pref', $this->_prefs->store());
         }
     }
     return $updated;
 }
Example #5
0
 function setPreferences($prefs, $id_only = false)
 {
     if (!empty($this->_prefs->_method)) {
         if ($this->_prefs->_method == 'ADODB') {
             // FIXME: strange why this should be needed...
             include_once "lib/WikiUser/Db.php";
             include_once "lib/WikiUser/AdoDb.php";
             _AdoDbPassUser::_AdoDbPassUser($this->_userid, $prefs);
             return _AdoDbPassUser::setPreferences($prefs, $id_only);
         } elseif ($this->_prefs->_method == 'SQL') {
             include_once "lib/WikiUser/Db.php";
             include_once "lib/WikiUser/PearDb.php";
             _PearDbPassUser::_PearDbPassUser($this->_userid, $prefs);
             return _PearDbPassUser::setPreferences($prefs, $id_only);
         } elseif ($this->_prefs->_method == 'PDO') {
             include_once "lib/WikiUser/Db.php";
             include_once "lib/WikiUser/PdoDb.php";
             _PdoDbPassUser::_PdoDbPassUser($this->_userid, $prefs);
             return _PdoDbPassUser::setPreferences($prefs, $id_only);
         }
     }
     if ($updated = _AnonUser::setPreferences($prefs, $id_only)) {
         // Encode only the _prefs array of the UserPreference object
         if (!empty($this->_HomePagehandle) and !$id_only) {
             $this->_HomePagehandle->set('pref', $this->_prefs->store());
         }
     }
     return $updated;
 }
Example #6
0
 function setPreferences($prefs, $id_only = false)
 {
     if (!empty($this->_prefs->_method)) {
         if ($this->_prefs->_method == 'ADODB') {
             // FIXME: strange why this should be needed...
             include_once "lib/WikiUser/Db.php";
             include_once "lib/WikiUser/AdoDb.php";
             _AdoDbPassUser::_AdoDbPassUser($this->_userid, $prefs);
             return _AdoDbPassUser::setPreferences($prefs, $id_only);
         } elseif ($this->_prefs->_method == 'SQL') {
             include_once "lib/WikiUser/Db.php";
             include_once "lib/WikiUser/PearDb.php";
             _PearDbPassUser::_PearDbPassUser($this->_userid, $prefs);
             return _PearDbPassUser::setPreferences($prefs, $id_only);
         } elseif ($this->_prefs->_method == 'PDO') {
             include_once "lib/WikiUser/Db.php";
             include_once "lib/WikiUser/PdoDb.php";
             _PdoDbPassUser::_PdoDbPassUser($this->_userid, $prefs);
             return _PdoDbPassUser::setPreferences($prefs, $id_only);
         }
     }
     if ($num = _AnonUser::setPreferences($prefs, $id_only)) {
         // Codendi specific: We have to load the home page here because since
         // the user page is not systematicaly created, the home page handle
         // is not passed as user argument on _PassUser call. BTW, this
         // method is called without test because it's only used because it
         // load the '$this->_HomePagehandle' param.
         $this->hasHomePage();
         // Encode only the _prefs array of the UserPreference object
         if (!empty($this->_HomePagehandle) and !$id_only) {
             $this->_HomePagehandle->set('pref', $this->_prefs->store());
         }
     }
     return $num;
 }