Exemple #1
0
 /**
  * Get param from user storage
  * @param string $key
  * @param mixed  $default
  * @return mixed
  */
 public function getParam($key, $default = null)
 {
     $params = (array) $this->_user->getParam(self::PARAM_NAMESPACE, array());
     if (isset($params[$key])) {
         return $params[$key];
     }
     return $default;
 }
Exemple #2
0
 /**
  * Tests JUser Parameter setting and retrieval.
  *
  * @return  void
  *
  * @since   12.1
  *
  * @covers JUser::defParam
  * @covers JUser::getParam
  * @covers JUser::setParam
  */
 public function testParameter()
 {
     $this->assertThat($this->object->getParam('holy', 'fred'), $this->equalTo('fred'));
     $this->object->defParam('holy', 'batman');
     $this->assertThat($this->object->getParam('holy', 'fred'), $this->equalTo('batman'));
     $this->object->setParam('holy', 'batman');
     $this->assertThat($this->object->getParam('holy', 'fred'), $this->equalTo('batman'));
 }
Exemple #3
0
 /**
  * Method to get a parameter value from CMS user object
  *
  * @param   string  $key      Parameter key
  * @param   mixed   $default  Parameter default value
  * @param   string  $type     [optional] Default: GetterInterface::RAW. Or const int GetterInterface::COMMAND|GetterInterface::INT|... or array( const ) or array( $key => const )
  * @return  mixed             The value or the default if it did not exist
  */
 public function getParam($key, $default = null, $type = GetterInterface::RAW)
 {
     return Get::clean($this->cmsOwnUser->getParam($key, $default), $type);
 }
Exemple #4
0
 function published($publish)
 {
     $db = JFactory::getDBO();
     $ids = JRequest::getVar('cid', array());
     $ids = implode(',', $ids);
     $query = "UPDATE #__jav_items" . " SET published = " . intval($publish) . " WHERE id IN ( {$ids} )";
     $db->setQuery($query);
     if (!$db->query()) {
         return false;
     }
     foreach (JRequest::getVar('cid', array()) as $id) {
         $item = $this->getItem(array($id));
         $logs = $this->getLogs(" and item_id={$id}");
         if ($logs) {
             foreach ($logs as $log) {
                 $user = JFactory::getUser($log->user_id);
                 $user_no_session = new JUser($log->user_id);
                 $total_voted = (int) $user_no_session->getParam('total-voted-' . $item->voice_types_id);
                 if ($publish == 0) {
                     $total_voted = (int) ($total_voted - abs($log->votes));
                 } else {
                     $total_voted = (int) ($total_voted + abs($log->votes));
                 }
                 if ($total_voted < 0) {
                     $total_voted = 0;
                 }
                 $user_no_session->setParam('total-voted-' . $item->voice_types_id, $total_voted);
                 $user_no_session->save();
             }
         }
     }
     return true;
 }