Example #1
0
 /**
  * Test the JReigstry::exists method.
  */
 public function testExists()
 {
     $a = new JRegistry();
     $a->set('foo', 'bar1');
     $a->set('config.foo', 'bar2');
     $a->set('deep.level.foo', 'bar3');
     $this->assertThat($a->exists('foo'), $this->isTrue(), 'Line: ' . __LINE__ . ' The path should exist, returning true.');
     $this->assertThat($a->exists('config.foo'), $this->isTrue(), 'Line: ' . __LINE__ . ' The path should exist, returning true.');
     $this->assertThat($a->exists('deep.level.foo'), $this->isTrue(), 'Line: ' . __LINE__ . ' The path should exist, returning true.');
     $this->assertThat($a->exists('deep.level.bar'), $this->isFalse(), 'Line: ' . __LINE__ . ' The path should not exist, returning false.');
     $this->assertThat($a->exists('bar.foo'), $this->isFalse(), 'Line: ' . __LINE__ . ' The path should not exist, returning false.');
 }
Example #2
0
 private function setRegistrationField($name, $value)
 {
     $app = JFactory::getApplication();
     $cs = $app->getUserState('com_users.registration.data');
     $state = new JRegistry();
     $state->loadArray($cs);
     if (!$state->exists($name)) {
         JFactory::getApplication()->setUserState('com_users.registration.data.' . $name, $value);
     }
 }
Example #3
0
 /**
  * Method to send the PATCH command to the server.
  *
  * @param   string   $url      Path to the resource.
  * @param   mixed    $data     Either an associative array or a string to be sent with the request.
  * @param   array    $headers  An array of name-value pairs to include in the header of the request.
  * @param   integer  $timeout  Read timeout in seconds.
  *
  * @return  BDHttpResponse
  *
  * @since   1.0
  */
 public function patch($url, $data, array $headers = null, $timeout = null)
 {
     // Look for headers set in the options.
     $temp = (array) $this->options->get('headers');
     foreach ($temp as $key => $val) {
         if (!isset($headers[$key])) {
             $headers[$key] = $val;
         }
     }
     // Look for timeout set in the options.
     if ($timeout === null && $this->options->exists('timeout')) {
         $timeout = $this->options->get('timeout');
     }
     return $this->transport->request('PATCH', new JUri($url), $data, $headers, $timeout, $this->options->get('userAgent', null));
 }
Example #4
0
 /**
  * Method to filter the form data.
  *
  * @param   array   $data   An array of field values to filter.
  * @param   string  $group  The dot-separated form group path on which to filter the fields.
  *
  * @return  mixed  Array or false.
  *
  * @since   11.1
  */
 public function filter($data, $group = null)
 {
     // Make sure there is a valid JForm XML document.
     if (!$this->xml instanceof SimpleXMLElement) {
         return false;
     }
     // Initialise variables.
     $input = new JRegistry($data);
     $output = new JRegistry();
     // Get the fields for which to filter the data.
     $fields = $this->findFieldsByGroup($group);
     if (!$fields) {
         // PANIC!
         return false;
     }
     // Filter the fields.
     foreach ($fields as $field) {
         // Initialise variables.
         $name = (string) $field['name'];
         // Get the field groups for the element.
         $attrs = $field->xpath('ancestor::fields[@name]/@name');
         $groups = array_map('strval', $attrs ? $attrs : array());
         $group = implode('.', $groups);
         // Get the field value from the data input.
         if ($group) {
             // Filter the value if it exists.
             if ($input->exists($group . '.' . $name)) {
                 $output->set($group . '.' . $name, $this->filterField($field, $input->get($group . '.' . $name, (string) $field['default'])));
             }
         } else {
             // Filter the value if it exists.
             if ($input->exists($name)) {
                 $output->set($name, $this->filterField($field, $input->get($name, (string) $field['default'])));
             }
         }
     }
     return $output->toArray();
 }
Example #5
0
 private function migrateProfilePluginSettings612()
 {
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     // fixed PHP notice from invalid query
     $query->select("setting,value")->from($db->qn("#__jfbconnect_config"))->where($db->qn('setting') . " LIKE " . $db->q("profile_%"))->order('setting');
     $rows = $db->setQuery($query)->loadObjectList();
     if (!empty($rows)) {
         require_once JPATH_ADMINISTRATOR . '/components/com_jfbconnect/models/config.php';
         $configModel = new JFBConnectModelConfig();
         foreach ($rows as $row) {
             $values = explode("_", $row->setting);
             $pluginName = $values[1];
             $settings = new JRegistry();
             $settings->loadString($row->value);
             if ($settings->exists('field_map') && $settings->exists('field_map.facebook')) {
                 $fieldMap = clone $settings->get('field_map');
                 foreach ($fieldMap->facebook as $key => $value) {
                     if ($value == "sex") {
                         $fieldMap->facebook->{$key} = "gender";
                     }
                     if ($value == "profile_url") {
                         $fieldMap->facebook->{$key} = "link";
                     }
                     if ($value == "about_me") {
                         $fieldMap->facebook->{$key} = "bio";
                     }
                     if ($value == "tv") {
                         $fieldMap->facebook->{$key} = "television";
                     }
                     if (in_array($value, array("hometown_location.city", "hometown_location.state", "hometown_location.country"))) {
                         $fieldMap->facebook->{$key} = "hometown.name";
                     }
                     if (in_array($value, array("current_location.city", "current_location.state", "current_location.country"))) {
                         $fieldMap->facebook->{$key} = "location.name";
                     }
                 }
                 $settings->set("field_map", null);
                 $settings->set("field_map", $fieldMap);
                 $configModel->update('profile_' . $pluginName, $settings->toString());
             }
         }
     }
 }