Пример #1
0
 /**
  * Create new cpsession for the user and insert it into database or fetch current existing one
  *
  * @param bool $renew Whether to renew cpsession hash (Create a new one and drop the old one)
  *
  * @throws vB_Exception
  * @return string The new cpsession hash
  *
  */
 public function fetchCpsessionHash($renew = false)
 {
     if (!$this->created) {
         throw new vB_Exception_User('session_not_created');
     }
     if ($this->cpsessionHash) {
         if (!$renew) {
             return $this->cpsessionHash;
         } else {
             // Drop the old cp session record
             $this->dBAssertor->delete('cpsession', array('hash' => $this->cpsessionHash));
         }
     }
     $this->cpsessionHash = $this->fetch_sessionhash();
     $this->dBAssertor->insert('cpsession', array('userid' => $this->vars['userid'], 'hash' => $this->cpsessionHash, 'dateline' => vB::getRequest()->getTimeNow()));
     return $this->cpsessionHash;
 }
Пример #2
0
 /**
  * Saves the updated properties to the database.
  */
 function save()
 {
     $bf_ugp_usercsspermissions = vB5_vB::get_datastore()->get_value('bf_ugp_usercsspermissions');
     // First, we want to remove any properties they don't have access to.
     // This is in case they lost some permissions;
     // leaving them around leads to unexpected behavior.
     $prop_del = array();
     foreach ($this->properties as $property => $propertyinfo) {
         if (!($this->permissions['usercsspermissions'] & $bf_ugp_usercsspermissions["{$propertyinfo['permission']}"])) {
             $prop_del[] = $property;
         }
     }
     if ($prop_del) {
         $this->assertor->delete('usercss', array('userid' => $this->userid, 'property' => $prop_del));
     }
     // now go for any entries that we emptied -- these are being removed
     if (!empty($this->delete)) {
         foreach ($this->delete as $selector => $properties) {
             foreach ($properties as $property) {
                 if (!empty($this->existing["{$selector}"]["{$property}"])) {
                     $this->assertor->delete('usercss', array('userid' => $this->userid, 'selector' => $selector, 'property' => $property));
                 }
                 unset($this->existing["{$selector}"]["{$property}"]);
             }
         }
     }
     // and for new/changed ones...
     if (!empty($this->store)) {
         $value = array();
         foreach ($this->store as $selector => $properties) {
             foreach ($properties as $property => $value) {
                 $values['userid'] = $this->userid;
                 $values['selector'] = $selector;
                 $values['property'] = $property;
                 $values['value'] = $value;
                 $this->assertor->delete('usercss', array('userid' => $this->userid, 'selector' => $selector, 'property' => $property));
             }
         }
         if ($values) {
             $this->assertor->insert('usercss', $values);
         }
     }
     $this->update_css_cache();
 }