Example #1
0
 protected function execute()
 {
     $this->state->set('plugins', $this->state->get('plugins', false));
     $app = new Sp4kAppsProductApp(new Joomla\Registry\Registry($this->state->toObject()));
     $items = new Registry($app->getItems());
     if ($this->state->get('nest', false)) {
         $this->items[] = (array) $this->create_tree($items->toArray());
     } else {
         $this->items = $items->toArray();
     }
 }
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         if (!empty($item->params)) {
             // Convert the params field to an array.
             $registry = new Registry();
             $registry->loadString($item->params);
             $item->params = $registry->toArray();
         }
         if (!empty($item->metadata)) {
             // Convert the metadata field to an array.
             $registry = new Registry();
             $registry->loadString($item->metadata);
             $item->metadata = $registry->toArray();
         }
         if (!empty($item->interventions)) {
             // JSON Decode interventions.
             $item->interventions = json_decode($item->interventions);
         }
         if (!empty($item->id)) {
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_costbenefitprojection.intervention');
         }
     }
     return $item;
 }
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         if (!empty($item->params)) {
             // Convert the params field to an array.
             $registry = new Registry();
             $registry->loadString($item->params);
             $item->params = $registry->toArray();
         }
         if (!empty($item->metadata)) {
             // Convert the metadata field to an array.
             $registry = new Registry();
             $registry->loadString($item->metadata);
             $item->metadata = $registry->toArray();
         }
         if (!empty($item->template)) {
             // base64 Decode template.
             $item->template = base64_decode($item->template);
         }
         if (!empty($item->php_view)) {
             // base64 Decode php_view.
             $item->php_view = base64_decode($item->php_view);
         }
         if (!empty($item->id)) {
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_componentbuilder.template');
         }
     }
     return $item;
 }
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         if (!empty($item->params)) {
             // Convert the params field to an array.
             $registry = new Registry();
             $registry->loadString($item->params);
             $item->params = $registry->toArray();
         }
         if (!empty($item->metadata)) {
             // Convert the metadata field to an array.
             $registry = new Registry();
             $registry->loadString($item->metadata);
             $item->metadata = $registry->toArray();
         }
         if (!empty($item->groups)) {
             // JSON Decode groups.
             $item->groups = json_decode($item->groups, true);
         }
         if (!empty($item->id)) {
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_componentbuilder.help_document');
         }
     }
     return $item;
 }
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         if (!empty($item->params)) {
             // Convert the params field to an array.
             $registry = new Registry();
             $registry->loadString($item->params);
             $item->params = $registry->toArray();
         }
         if (!empty($item->metadata)) {
             // Convert the metadata field to an array.
             $registry = new Registry();
             $registry->loadString($item->metadata);
             $item->metadata = $registry->toArray();
         }
         if (!empty($item->testcompanies)) {
             // JSON Decode testcompanies.
             $item->testcompanies = json_decode($item->testcompanies);
         }
         if (!empty($item->id)) {
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_costbenefitprojection.service_provider');
         }
     }
     $this->service_providervvvx = $item->id;
     return $item;
 }
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         if (!empty($item->params)) {
             // Convert the params field to an array.
             $registry = new Registry();
             $registry->loadString($item->params);
             $item->params = $registry->toArray();
         }
         if (!empty($item->metadata)) {
             // Convert the metadata field to an array.
             $registry = new Registry();
             $registry->loadString($item->metadata);
             $item->metadata = $registry->toArray();
         }
         if (!empty($item->causesrisks)) {
             // JSON Decode causesrisks.
             $item->causesrisks = json_decode($item->causesrisks);
         }
         if (!empty($item->id)) {
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_costbenefitprojection.country');
         }
     }
     $this->countryvvvy = $item->id;
     $this->countryvvvz = $item->id;
     $this->countryvvwa = $item->id;
     return $item;
 }
Example #7
0
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     parent::prepareExecute();
     $this->app->setUserState("com_userxtd.edit.field.data", $this->input->getVar('jform'));
     $attrs = $this->app->getUserState("com_userxtd.edit.field.attrs", array());
     $postAttrs = $this->input->getVar('attrs', array());
     $attrs = new Registry($attrs);
     $attrs->loadArray($postAttrs);
     $this->app->setUserState("com_userxtd.edit.field.attrs", $attrs->toArray());
 }
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         if (!empty($item->params)) {
             // Convert the params field to an array.
             $registry = new Registry();
             $registry->loadString($item->params);
             $item->params = $registry->toArray();
         }
         if (!empty($item->metadata)) {
             // Convert the metadata field to an array.
             $registry = new Registry();
             $registry->loadString($item->metadata);
             $item->metadata = $registry->toArray();
         }
         if (!empty($item->php_after_getitem)) {
             // base64 Decode php_after_getitem.
             $item->php_after_getitem = base64_decode($item->php_after_getitem);
         }
         if (!empty($item->php_before_getitems)) {
             // base64 Decode php_before_getitems.
             $item->php_before_getitems = base64_decode($item->php_before_getitems);
         }
         if (!empty($item->php_before_getitem)) {
             // base64 Decode php_before_getitem.
             $item->php_before_getitem = base64_decode($item->php_before_getitem);
         }
         if (!empty($item->php_getlistquery)) {
             // base64 Decode php_getlistquery.
             $item->php_getlistquery = base64_decode($item->php_getlistquery);
         }
         if (!empty($item->php_after_getitems)) {
             // base64 Decode php_after_getitems.
             $item->php_after_getitems = base64_decode($item->php_after_getitems);
         }
         if (!empty($item->php_calculation)) {
             // base64 Decode php_calculation.
             $item->php_calculation = base64_decode($item->php_calculation);
         }
         if (!empty($item->php_custom_get)) {
             // base64 Decode php_custom_get.
             $item->php_custom_get = base64_decode($item->php_custom_get);
         }
         if (!empty($item->id)) {
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_componentbuilder.dynamic_get');
         }
     }
     return $item;
 }
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         // Convert the images field to an array.
         $registry = new Registry();
         $registry->loadString($item->images);
         $item->images = $registry->toArray();
         //Convert the sensors field to an array
         $registry = new Registry();
         $registry->loadString($item->sensors);
         $item->sensors = $registry->toArray();
     }
     return $item;
 }
Example #10
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         if (!empty($item->params)) {
             // Convert the params field to an array.
             $registry = new Registry();
             $registry->loadString($item->params);
             $item->params = $registry->toArray();
         }
         if (!empty($item->metadata)) {
             // Convert the metadata field to an array.
             $registry = new Registry();
             $registry->loadString($item->metadata);
             $item->metadata = $registry->toArray();
         }
         if (!empty($item->xml)) {
             // JSON Decode xml.
             $item->xml = json_decode($item->xml);
         }
         if (!empty($item->css_view)) {
             // base64 Decode css_view.
             $item->css_view = base64_decode($item->css_view);
         }
         if (!empty($item->css_views)) {
             // base64 Decode css_views.
             $item->css_views = base64_decode($item->css_views);
         }
         if (!empty($item->javascript_view_footer)) {
             // base64 Decode javascript_view_footer.
             $item->javascript_view_footer = base64_decode($item->javascript_view_footer);
         }
         if (!empty($item->javascript_views_footer)) {
             // base64 Decode javascript_views_footer.
             $item->javascript_views_footer = base64_decode($item->javascript_views_footer);
         }
         if (!empty($item->id)) {
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_componentbuilder.field');
         }
     }
     return $item;
 }
Example #11
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         if (!empty($item->params)) {
             // Convert the params field to an array.
             $registry = new Registry();
             $registry->loadString($item->params);
             $item->params = $registry->toArray();
         }
         if (!empty($item->metadata)) {
             // Convert the metadata field to an array.
             $registry = new Registry();
             $registry->loadString($item->metadata);
             $item->metadata = $registry->toArray();
         }
         if (!empty($item->id)) {
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_demo.look');
         }
     }
     return $item;
 }
Example #12
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         // Convert the params field to an array.
         $registry = new Registry();
         $registry->loadString($item->attribs);
         $item->attribs = $registry->toArray();
         // Convert the metadata field to an array.
         $registry = new Registry();
         $registry->loadString($item->metadata);
         $item->metadata = $registry->toArray();
         // Convert the images field to an array.
         $registry = new Registry();
         $registry->loadString($item->images);
         $item->images = $registry->toArray();
         // Convert the urls field to an array.
         $registry = new Registry();
         $registry->loadString($item->urls);
         $item->urls = $registry->toArray();
         $item->articletext = trim($item->fulltext) != '' ? $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext : $item->introtext;
         if (!empty($item->id)) {
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_content.article');
         }
     }
     // Load associated content items
     $app = JFactory::getApplication();
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         $item->associations = array();
         if ($item->id != null) {
             $associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $item->id);
             foreach ($associations as $tag => $association) {
                 $item->associations[$tag] = $association->id;
             }
         }
     }
     return $item;
 }
Example #13
0
 /**
  * Merge a Registry object into this one
  *
  * @param   Registry  $source     Source Registry object to merge.
  * @param   boolean   $recursive  True to support recursive merge the children values.
  *
  * @return  Registry  Return this object to support chaining.
  *
  * @since   1.0
  */
 public function merge($source, $recursive = false)
 {
     if (!$source instanceof Registry) {
         return false;
     }
     $this->bindData($this->data, $source->toArray(), $recursive, false);
     return $this;
 }
 /**
  * Method to get the profile form data.
  *
  * The base form data is loaded and then an event is fired
  * for users plugins to extend the data.
  *
  * @return  mixed  	Data object on success, false on failure.
  *
  * @since   1.6
  */
 public function getData()
 {
     if ($this->data === null) {
         $userId = $this->getState('user.id');
         // Initialise the table with JUser.
         $this->data = new JUser($userId);
         // Set the base user data.
         $this->data->email1 = $this->data->get('email');
         $this->data->email2 = $this->data->get('email');
         // Override the base user data with any data in the session.
         $temp = (array) JFactory::getApplication()->getUserState('com_users.edit.profile.data', array());
         foreach ($temp as $k => $v) {
             $this->data->{$k} = $v;
         }
         // Unset the passwords.
         unset($this->data->password1);
         unset($this->data->password2);
         $registry = new Registry($this->data->params);
         $this->data->params = $registry->toArray();
         // Get the dispatcher and load the users plugins.
         $dispatcher = JEventDispatcher::getInstance();
         JPluginHelper::importPlugin('user');
         // Trigger the data preparation event.
         $results = $dispatcher->trigger('onContentPrepareData', array('com_users.profile', $this->data));
         // Check for errors encountered while preparing the data.
         if (count($results) && in_array(false, $results, true)) {
             $this->setError($dispatcher->getError());
             $this->data = false;
         }
     }
     return $this->data;
 }
Example #15
0
 /**
  * Method to get a list of teamids.
  *
  * Overriden to inject convert the params fields into an object.
  *
  * @return	mixed	An array of objects on success, false on failure.
  * 
  */
 public function getItems()
 {
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $user = JFactory::getUser();
     $user_id = $user->get('id');
     $guest = $user->get('guest');
     $groups = $user->getAuthorisedViewLevels();
     // Get the global params
     $global_params = JComponentHelper::getParams('com_knvbapi2', true);
     if ($items = parent::getItems()) {
         // Convert the parameter fields into objects.
         foreach ($items as &$item) {
             $query->clear();
             $teamid_params = new Registry();
             $teamid_params->loadString($item->params);
             // Convert the images field to an array.
             $registry = new Registry();
             $registry->loadString($item->images);
             $item->images = $registry->toArray();
             $registry = null;
             //release memory
             // Convert the urls field to an array.
             $registry = new Registry();
             $registry->loadString($item->urls);
             $item->urls = $registry->toArray();
             $registry = null;
             //release memory
             $item->introdescription = trim($item->intro) != '' ? $item->intro . $item->description : $item->description;
             // Unpack readmore and layout params
             $item->teamid_alternative_readmore = $teamid_params->get('teamid_alternative_readmore');
             $item->layout = $teamid_params->get('layout');
             if (!is_object($this->getState('params'))) {
                 $item->params = $teamid_params;
             } else {
                 $item->params = clone $this->getState('params');
                 // Teamid params override menu item params only if menu param = 'use_teamid'
                 // Otherwise, menu item params control the layout
                 // If menu item is 'use_teamid' and there is no teamid param, use global
                 // create an array of just the params set to 'use_teamid'
                 $menu_params_array = $this->getState('params')->toArray();
                 $teamid_array = array();
                 foreach ($menu_params_array as $key => $value) {
                     if ($value === 'use_teamid') {
                         // if the teamid has a value, use it
                         if ($teamid_params->get($key) != '') {
                             // get the value from the teamid
                             $teamid_array[$key] = $teamid_params->get($key);
                         } else {
                             // otherwise, use the global value
                             $teamid_array[$key] = $global_params->get($key);
                         }
                     }
                 }
                 // merge the selected teamid params
                 if (count($teamid_array) > 0) {
                     $teamid_params = new Registry();
                     $teamid_params->loadArray($teamid_array);
                     $item->params->merge($teamid_params);
                 }
                 // get display date
                 switch ($item->params->get('list_show_teamid_date')) {
                     case 'modified':
                         $item->display_date = $item->modified;
                         break;
                     case 'publish_up':
                         $item->display_date = $item->publish_up;
                         if ($item->publish_up == 0) {
                             $item->display_date = $item->created;
                         }
                         break;
                     case 'created':
                         $item->display_date = $item->created;
                         break;
                     default:
                         $item->display_date = 0;
                         break;
                 }
             }
             // Compute the asset access permissions.
             // Technically guest could edit an teamid, but lets not check that to improve performance a little.
             if (!$guest) {
                 $asset = 'com_knvbapi2.teamid.' . $item->id;
                 // Check general edit permission first.
                 if ($user->authorise('core.edit', $asset)) {
                     $item->params->set('access-edit', true);
                 } else {
                     if (!empty($user_id) and $user->authorise('core.edit.own', $asset)) {
                         // Check for a valid user and that they are the owner.
                         if ($user_id == $item->created_by) {
                             $item->params->set('access-edit', true);
                         }
                     }
                 }
                 if ($user->authorise('core.create', $asset)) {
                     $item->params->set('access-create', true);
                 }
                 if ($user->authorise('core.delete', $asset)) {
                     $item->params->set('access-delete', true);
                 } else {
                     if (!empty($user_id) and $user->authorise('core.delete.own', $asset)) {
                         // Check for a valid user and that they are the owner.
                         if ($user_id == $item->created_by) {
                             $item->params->set('access-delete', true);
                         }
                     }
                 }
             }
             $access = $this->getState('filter.access');
             if ($access) {
                 // If the access filter has been set, we already have only the teamids this user can view.
                 $item->params->set('access-view', true);
             } else {
                 // If no access filter is set, the layout takes some responsibility for display of limited information.
                 $item->params->set('access-view', in_array($item->access, $groups));
             }
             // Get the tags
             $item->tags = new JHelperTags();
             $item->tags->getItemTags('com_knvbapi2.teamid', $item->id);
         }
     }
     return $items;
 }
Example #16
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? $pk : (int) $this->getState('style.id');
     if (!isset($this->_cache[$pk])) {
         // Get a row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
         // Convert to the JObject before adding other data.
         $properties = $table->getProperties(1);
         $this->_cache[$pk] = JArrayHelper::toObject($properties, 'JObject');
         // Convert the params field to an array.
         $registry = new Registry();
         $registry->loadString($table->params);
         $this->_cache[$pk]->params = $registry->toArray();
         // Get the template XML.
         $client = JApplicationHelper::getClientInfo($table->client_id);
         $path = JPath::clean($client->path . '/templates/' . $table->template . '/templateDetails.xml');
         if (file_exists($path)) {
             $this->_cache[$pk]->xml = simplexml_load_file($path);
         } else {
             $this->_cache[$pk]->xml = null;
         }
     }
     return $this->_cache[$pk];
 }
Example #17
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         // Convert the metadata field to an array.
         $registry = new Registry();
         $registry->loadString($item->metadata);
         $item->metadata = $registry->toArray();
         // Convert the images field to an array.
         $registry = new Registry();
         $registry->loadString($item->images);
         $item->images = $registry->toArray();
         if (!empty($item->id)) {
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_htraininglogs.htraininglog');
             $item->metadata['tags'] = $item->tags;
         }
     }
     return $item;
 }
Example #18
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         // Convert the params field to an array.
         $registry = new Registry();
         $registry->loadString($item->metadata);
         $item->metadata = $registry->toArray();
         // Convert the images field to an array.
         $registry = new Registry();
         $registry->loadString($item->images);
         $item->images = $registry->toArray();
     }
     // Load associated newsfeeds items
     $app = JFactory::getApplication();
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         $item->associations = array();
         if ($item->id != null) {
             $associations = JLanguageAssociations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', $item->id);
             foreach ($associations as $tag => $association) {
                 $item->associations[$tag] = $association->id;
             }
         }
     }
     if (!empty($item->id)) {
         $item->tags = new JHelperTags();
         $item->tags->getTagIds($item->id, 'com_newsfeeds.newsfeed');
         $item->metadata['tags'] = $item->tags;
     }
     return $item;
 }
Example #19
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;
     }
     $input = new Registry($data);
     $output = new Registry();
     // 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) {
         $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);
         $key = $group ? $group . '.' . $name : $name;
         // Filter the value if it exists.
         if ($input->exists($key)) {
             $output->set($key, $this->filterField($field, $input->get($key, (string) $field['default'])));
         }
     }
     return $output->toArray();
 }
 /**
  * Return the parameters of the object.
  *
  * <code>
  * $notification   = new Gamification\Notification(\JFactory::getDbo());
  *
  * $params = $notification->getParams();
  * </code>
  *
  * @return  array
  */
 public function getParams()
 {
     return $this->params->toArray();
 }
Example #21
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed    Object on success, false on failure.
  *
  * @since   12.2
  */
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties(1);
     $item = JArrayHelper::toObject($properties, 'JObject');
     if (property_exists($item, 'params')) {
         $registry = new Registry();
         $registry->loadString($item->params);
         $item->params = $registry->toArray();
     }
     return $item;
 }
Example #22
0
 /**
  * Method to get a category.
  *
  * @param   integer  $pk  An optional id of the object to get, otherwise the id from the model state is used.
  *
  * @return  mixed    Category data object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($result = parent::getItem($pk)) {
         // Prime required properties.
         if (empty($result->id)) {
             $result->parent_id = $this->getState('category.parent_id');
             $result->extension = $this->getState('category.extension');
         }
         // Convert the metadata field to an array.
         $registry = new Registry();
         $registry->loadString($result->metadata);
         $result->metadata = $registry->toArray();
         // Convert the created and modified dates to local user time for display in the form.
         $tz = new DateTimeZone(JFactory::getApplication()->get('offset'));
         if ((int) $result->created_time) {
             $date = new JDate($result->created_time);
             $date->setTimezone($tz);
             $result->created_time = $date->toSql(true);
         } else {
             $result->created_time = null;
         }
         if ((int) $result->modified_time) {
             $date = new JDate($result->modified_time);
             $date->setTimezone($tz);
             $result->modified_time = $date->toSql(true);
         } else {
             $result->modified_time = null;
         }
         if (!empty($result->id)) {
             $result->tags = new JHelperTags();
             $result->tags->getTagIds($result->id, $result->extension . '.category');
         }
     }
     $assoc = $this->getAssoc();
     if ($assoc) {
         if ($result->id != null) {
             $result->associations = CategoriesHelper::getAssociations($result->id, $result->extension);
             JArrayHelper::toInteger($result->associations);
         } else {
             $result->associations = array();
         }
     }
     return $result;
 }
Example #23
0
 /**
  * Method to get teamnaam data.
  *
  * @param	integer	$item_id	The id of the teamnaam.
  *
  * @return	mixed	Teamnaam item data object on success, false on failure.
  */
 public function getItem($item_id = null)
 {
     $item_id = (int) (!empty($item_id)) ? $item_id : $this->getState('teamnaam.id');
     // Get a row instance.
     $table = $this->getTable();
     // Attempt to load the row.
     $return = $table->load($item_id);
     // Check for a table object error.
     if ($return === false and $table->getError()) {
         $this->setError($table->getError());
         return false;
     }
     $properties = $table->getProperties(1);
     $item = JArrayHelper::toObject($properties, 'JObject');
     // Convert params field to Registry.
     $item->params = new Registry();
     $item->params->loadString($item->params);
     // Include any manipulation of the data on the record e.g. expand out Registry fields
     // NB The params registry field - if used - is done automatcially in the JAdminModel parent class
     // Convert the images field to an array.
     $registry = new Registry();
     $registry->loadString($item->images);
     $item->images = $registry->toArray();
     $registry = null;
     //release memory
     // Convert the urls field to an array.
     $registry = new Registry();
     $registry->loadString($item->urls);
     $item->urls = $registry->toArray();
     $registry = null;
     //release memory
     $item->introdescription = trim($item->intro) != '' ? $item->intro . "<hr id=\"system-readmore\" />" . $item->description : $item->description;
     // Compute selected asset permissions.
     $user = JFactory::getUser();
     $user_id = $user->get('id');
     // Get user name.
     if ($item_id) {
         $db = $this->getDbo();
         $query = $db->getQuery(true);
         // Retrieve user name(s)
         $query->select($db->quoteName('id') . ', ' . $db->quoteName('name'));
         $query->from($db->quoteName('#__users'));
         $query->where($db->quoteName('id') . ' = ' . $item->created_by);
         // Setup the query
         $db->setQuery($query->__toString());
         // Return the result
         $created_by_user = $db->loadObjectList();
         $item->created_by_name = $created_by_user ? $created_by_user[0]->name : $item->created_by;
         $query->clear();
         $query->select($db->quoteName('id') . ', ' . $db->quoteName('name'));
         $query->from($db->quoteName('#__users'));
         $query->where($db->quoteName('id') . ' = ' . $item->modified_by);
         // Setup the query
         $db->setQuery($query->__toString());
         // Return the result
         $modified_by_user = $db->loadObjectList();
         $item->modified_by_name = $modified_by_user ? $modified_by_user[0]->name : $item->modified_by;
     } else {
         // New item.
         $item->created_by_name = $user->name;
         $item->modified_by_name = $user->name;
     }
     $asset = 'com_knvbapi2.teamnaam.' . $item->id;
     // Check general edit permission first.
     if ($user->authorise('core.edit', $asset)) {
         $item->params->set('access-edit', true);
     } else {
         if (!empty($user_id) and $user->authorise('core.edit.own', $asset)) {
             // Check for a valid user and that they are the owner.
             if ($user_id == $item->created_by) {
                 $item->params->set('access-edit', true);
             }
         }
     }
     if ($user->authorise('core.create', $asset)) {
         $item->params->set('access-create', true);
     }
     if ($user->authorise('core.delete', $asset)) {
         $item->params->set('access-delete', true);
     } else {
         if (!empty($user_id) and $user->authorise('core.delete.own', $asset)) {
             // Check for a valid user and that they are the owner.
             if ($user_id == $item->created_by) {
                 $item->params->set('access-delete', true);
             }
         }
     }
     // Check edit state permission.
     if ($item_id) {
         // Existing item
         $item->params->set('access-change', $user->authorise('core.edit.state', $asset));
     } else {
         // New item.
         $cat_id = (int) $this->getState('teamnaam.catid');
         if ($cat_id) {
             $item->params->set('access-change', $user->authorise('core.edit.state', 'com_knvbapi2.category.' . $cat_id));
             $item->catid = $cat_id;
         } else {
             $item->params->set('access-change', $user->authorise('core.edit.state', 'com_knvbapi2'));
         }
     }
     if ($item_id) {
         $item->tags = new JHelperTags();
         $item->tags->getTagIds($item->id, 'com_knvbapi2.teamnaam');
     }
     return $item;
 }
Example #24
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? (int) $pk : (int) $this->getState('module.id');
     $db = $this->getDbo();
     if (!isset($this->_cache[$pk])) {
         // Get a row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && ($error = $table->getError())) {
             $this->setError($error);
             return false;
         }
         // Check if we are creating a new extension.
         if (empty($pk)) {
             if ($extensionId = (int) $this->getState('extension.id')) {
                 $query = $db->getQuery(true)->select('element, client_id')->from('#__extensions')->where('extension_id = ' . $extensionId)->where('type = ' . $db->quote('module'));
                 $db->setQuery($query);
                 try {
                     $extension = $db->loadObject();
                 } catch (RuntimeException $e) {
                     $this->setError($e->getMessage());
                     return false;
                 }
                 if (empty($extension)) {
                     $this->setError('COM_MODULES_ERROR_CANNOT_FIND_MODULE');
                     return false;
                 }
                 // Extension found, prime some module values.
                 $table->module = $extension->element;
                 $table->client_id = $extension->client_id;
             } else {
                 $app = JFactory::getApplication();
                 $app->redirect(JRoute::_('index.php?option=com_modules&view=modules', false));
                 return false;
             }
         }
         // Convert to the JObject before adding other data.
         $properties = $table->getProperties(1);
         $this->_cache[$pk] = JArrayHelper::toObject($properties, 'JObject');
         // Convert the params field to an array.
         $registry = new Registry();
         $registry->loadString($table->params);
         $this->_cache[$pk]->params = $registry->toArray();
         // Determine the page assignment mode.
         $query = $db->getQuery(true)->select($db->quoteName('menuid'))->from($db->quoteName('#__modules_menu'))->where($db->quoteName('moduleid') . ' = ' . (int) $pk);
         $db->setQuery($query);
         $assigned = $db->loadColumn();
         if (empty($pk)) {
             // If this is a new module, assign to all pages.
             $assignment = 0;
         } elseif (empty($assigned)) {
             // For an existing module it is assigned to none.
             $assignment = '-';
         } else {
             if ($assigned[0] > 0) {
                 $assignment = 1;
             } elseif ($assigned[0] < 0) {
                 $assignment = -1;
             } else {
                 $assignment = 0;
             }
         }
         $this->_cache[$pk]->assigned = $assigned;
         $this->_cache[$pk]->assignment = $assignment;
         // Get the module XML.
         $client = JApplicationHelper::getClientInfo($table->client_id);
         $path = JPath::clean($client->path . '/modules/' . $table->module . '/' . $table->module . '.xml');
         if (file_exists($path)) {
             $this->_cache[$pk]->xml = simplexml_load_file($path);
         } else {
             $this->_cache[$pk]->xml = null;
         }
     }
     return $this->_cache[$pk];
 }
Example #25
0
 /**
  * Retrieves all variables from the session store
  *
  * @return  array
  *
  * @since   4.0
  */
 public function all()
 {
     return $this->data->toArray();
 }
Example #26
0
 /**
  * Method to get Selectie data.
  *
  * @param	integer	$pk	The id of the selectie.
  *
  * @return	mixed	Menu item data object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     // Get current user for authorisation checks
     $user = JFactory::getUser();
     $pk = !empty($pk) ? $pk : (int) $this->getState('selectie.id');
     // Get the global params
     $global_params = JComponentHelper::getParams('com_knvbapi2', true);
     if ($this->_item === null) {
         $this->_item = array();
     }
     if (!isset($this->_item[$pk])) {
         try {
             $db = $this->getDbo();
             $query = $db->getQuery(true);
             $query->select($this->getState('item.select', 'a.*'));
             $query->from($db->quoteName('#__knvbapi2_selecties') . ' AS a');
             // Join on user table.
             $query->select($db->quoteName('ua.name') . ' AS created_by_name');
             $query->join('LEFT', $db->quoteName('#__users') . ' AS ua on ' . $db->quoteName('ua.id') . ' = ' . $db->quoteName('a.created_by'));
             $query->select($db->quoteName('uam.name') . ' AS modified_by_name');
             $query->join('LEFT', $db->quoteName('#__users') . ' AS uam on ' . $db->quoteName('uam.id') . ' = ' . $db->quoteName('a.modified_by'));
             // Join over the language
             $query->select($db->quoteName('l.title') . ' AS language_title');
             $query->join('LEFT', $db->quoteName('#__languages') . ' AS l ON ' . $db->quoteName('l.lang_code') . ' = ' . $db->quoteName('a.language'));
             // Filter by language
             if ($this->getState('filter.language')) {
                 $query->where($db->quoteName('a.language') . ' IN (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
             }
             $query->where($db->quoteName('a.id') . ' = ' . (int) $pk);
             // Join on vote rating table
             $query->select('ROUND(' . $db->quoteName('v.rating_sum') . ' / ' . $db->quoteName('v.rating_count') . ', 0) AS rating, ' . $db->quoteName('v.rating_count') . ' as rating_count');
             $query->join('LEFT', $db->quoteName('#__knvbapi2_rating') . ' AS v ON ' . $db->quoteName('a.id') . ' = ' . $db->quoteName('v.content_id') . ' AND ' . $db->quoteName('v.content_type') . ' = ' . $db->quote('selecties'));
             $can_publish = $user->authorise('core.edit.state', 'com_knvbapi2.selectie.' . $pk);
             //  Do not show unless today's date is within the publish up and down dates (or they are empty)
             if (!$can_publish) {
                 $null_date = $db->quote($db->getNullDate());
                 $now_date = $db->quote(JFactory::getDate()->toSQL());
                 $query->where('(' . $db->quoteName('a.publish_up') . ' = ' . $null_date . ' OR ' . $db->quoteName('a.publish_up') . ' <= ' . $now_date . ')');
                 $query->where('(' . $db->quoteName('a.publish_down') . ' = ' . $null_date . ' OR ' . $db->quoteName('a.publish_down') . ' >= ' . $now_date . ')');
             }
             // Filter by published status.
             $published = $this->getState('filter.published');
             $archived = $this->getState('filter.archived');
             if (is_numeric($published) and !$can_publish) {
                 $query->where('(' . $db->quoteName('a.state') . ' = ' . (int) $published . ' OR ' . $db->quoteName('a.state') . ' = ' . (int) $archived . ')');
             }
             $query->select($db->quoteName('vl.title') . ' AS access_title');
             $query->join('LEFT', $db->quoteName('#__viewlevels') . ' AS vl on ' . $db->quoteName('vl.id') . ' = ' . $db->quoteName('a.access'));
             $db->setQuery($query);
             $item = $db->loadObject();
             if (empty($item)) {
                 return JError::raiseError(404, JText::_('COM_KNVBAPI2_SELECTIES_ERROR_ITEM_NOT_FOUND'));
             }
             // Include any manipulation of the data on the record e.g. expand out Registry fields
             // NB The params registry field - if used - is done automatcially in the JAdminModel parent class
             // Convert the images field to an array.
             $registry = new Registry();
             $registry->loadString($item->images);
             $item->images = $registry->toArray();
             $registry = null;
             //release memory
             // Convert the urls field to an array.
             $registry = new Registry();
             $registry->loadString($item->urls);
             $item->urls = $registry->toArray();
             $registry = null;
             //release memory
             $item->tags = new JHelperTags();
             $item->tags->getItemTags('com_knvbapi2.selectie', $item->id);
             // Check for published state if filter set.
             if ((is_numeric($published) or is_numeric($archived)) and ($item->state != $published and $item->state != $archived)) {
                 return JError::raiseError(404, JText::_('COM_KNVBAPI2_SELECTIES_ERROR_ITEM_NOT_FOUND'));
             }
             $item->introdescription = trim($item->intro) != '' ? $item->intro . $item->description : $item->description;
             // Convert parameter fields to objects.
             $selectie_params = new Registry();
             $selectie_params->loadString($item->params);
             // Unpack readmore and layout params
             $item->selectie_alternative_readmore = $selectie_params->get('selectie_alternative_readmore');
             $item->layout = $selectie_params->get('layout');
             $item->params = clone $this->getState('params');
             // Selectie params override menu item params only if menu param = 'use_selectie'
             // Otherwise, menu item params control the layout
             // If menu item is 'use_selectie' and there is no selectie param, use global
             // create an array of just the params set to 'use_selectie'
             $menu_params_array = $this->getState('params')->toArray();
             $selectie_array = array();
             foreach ($menu_params_array as $key => $value) {
                 if ($value === 'use_selectie') {
                     // if the selectie has a value, use it
                     if ($selectie_params->get($key) != '') {
                         // get the value from the selectie
                         $selectie_array[$key] = $selectie_params->get($key);
                     } else {
                         // otherwise, use the global value
                         $selectie_array[$key] = $global_params->get($key);
                     }
                 }
             }
             // merge the selected selectie params
             if (count($selectie_array) > 0) {
                 $selectie_params = new Registry();
                 $selectie_params->loadArray($selectie_array);
                 $item->params->merge($selectie_params);
             }
             // Compute selected asset permissions.
             // Technically guest could edit an selectie, but lets not check that to improve performance a little.
             if (!$user->get('guest')) {
                 $user_id = $user->get('id');
                 $asset = 'com_knvbapi2.selectie.' . $item->id;
                 // Check general edit permission first.
                 if ($user->authorise('core.edit', $asset)) {
                     $item->params->set('access-edit', true);
                 } else {
                     if (!empty($user_id) and $user->authorise('core.edit.own', $asset)) {
                         // Check for a valid user and that they are the owner.
                         if ($user_id == $item->created_by) {
                             $item->params->set('access-edit', true);
                             // If owner allow them to edit state in front end
                             $item->params->set('access-change', true);
                         }
                     }
                 }
                 if ($user->authorise('core.create', $asset)) {
                     $item->params->set('access-create', true);
                 }
                 if ($user->authorise('core.delete', $asset)) {
                     $item->params->set('access-delete', true);
                 } else {
                     if (!empty($user_id) and $user->authorise('core.delete.own', $asset)) {
                         // Check for a valid user and that they are the owner.
                         if ($user_id == $item->created_by) {
                             $item->params->set('access-delete', true);
                         }
                     }
                 }
                 // Check edit state permission.
                 if ($user->authorise('core.edit.state', $asset)) {
                     $item->params->set('access-change', true);
                 }
             }
             // Compute view access permissions.
             if ($access = $this->getState('filter.access')) {
                 // If the access filter has been set, we already know this user can view.
                 $item->params->set('access-view', true);
             } else {
                 // If no access filter is set, the layout takes some responsibility for display of limited information.
                 $groups = $user->getAuthorisedViewLevels();
                 $item->params->set('access-view', in_array($item->access, $groups));
             }
             $this->_item[$pk] = $item;
         } catch (Exception $e) {
             if ($e->getCode() == 404) {
                 // Need to go thru the error handler to allow Redirect to work.
                 JError::raiseError(404, $e->getMessage());
             } else {
                 $this->setError($e);
                 $this->_item[$pk] = false;
             }
         }
     }
     return $this->_item[$pk];
 }
Example #27
0
 /**
  * Method to get the config
  *
  * @return  array  config values
  *
  * @since  1.6
  */
 public function &getConfig()
 {
     if (!is_null($this->config)) {
         return $this->config;
     }
     $registry = new Registry(new JConfig());
     $this->config = $registry->toArray();
     $hidden = array('host', 'user', 'password', 'ftp_user', 'ftp_pass', 'smtpuser', 'smtppass');
     foreach ($hidden as $key) {
         $this->config[$key] = 'xxxxxx';
     }
     return $this->config;
 }
Example #28
0
 /**
  * Method to get a menu item.
  *
  * @param   integer  $pk  An optional id of the object to get, otherwise the id from the model state is used.
  *
  * @return  mixed  Menu item data object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? $pk : (int) $this->getState('item.id');
     // Get a level row instance.
     $table = $this->getTable();
     // Attempt to load the row.
     $table->load($pk);
     // Check for a table object error.
     if ($error = $table->getError()) {
         $this->setError($error);
         return false;
     }
     // Prime required properties.
     if ($type = $this->getState('item.type')) {
         $table->type = $type;
     }
     if (empty($table->id)) {
         $table->parent_id = $this->getState('item.parent_id');
         $table->menutype = $this->getState('item.menutype');
         $table->params = '{}';
     }
     // If the link has been set in the state, possibly changing link type.
     if ($link = $this->getState('item.link')) {
         // Check if we are changing away from the actual link type.
         if (MenusHelper::getLinkKey($table->link) != MenusHelper::getLinkKey($link)) {
             $table->link = $link;
         }
     }
     switch ($table->type) {
         case 'alias':
             $table->component_id = 0;
             $args = array();
             parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
             break;
         case 'separator':
         case 'heading':
             $table->link = '';
             $table->component_id = 0;
             break;
         case 'url':
             $table->component_id = 0;
             $args = array();
             parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
             break;
         case 'component':
         default:
             // Enforce a valid type.
             $table->type = 'component';
             // Ensure the integrity of the component_id field is maintained, particularly when changing the menu item type.
             $args = array();
             parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
             if (isset($args['option'])) {
                 // Load the language file for the component.
                 $lang = JFactory::getLanguage();
                 $lang->load($args['option'], JPATH_ADMINISTRATOR, null, false, true) || $lang->load($args['option'], JPATH_ADMINISTRATOR . '/components/' . $args['option'], null, false, true);
                 // Determine the component id.
                 $component = JComponentHelper::getComponent($args['option']);
                 if (isset($component->id)) {
                     $table->component_id = $component->id;
                 }
             }
             break;
     }
     // We have a valid type, inject it into the state for forms to use.
     $this->setState('item.type', $table->type);
     // Convert to the JObject before adding the params.
     $properties = $table->getProperties(1);
     $result = JArrayHelper::toObject($properties);
     // Convert the params field to an array.
     $registry = new Registry();
     $registry->loadString($table->params);
     $result->params = $registry->toArray();
     // Merge the request arguments in to the params for a component.
     if ($table->type == 'component') {
         // Note that all request arguments become reserved parameter names.
         $result->request = $args;
         $result->params = array_merge($result->params, $args);
         // Special case for the Login menu item.
         // Display the login or logout redirect URL fields if not empty
         if ($table->link == 'index.php?option=com_users&view=login') {
             if (!empty($result->params['login_redirect_url'])) {
                 $result->params['loginredirectchoice'] = '0';
             }
             if (!empty($result->params['logout_redirect_url'])) {
                 $result->params['logoutredirectchoice'] = '0';
             }
         }
     }
     if ($table->type == 'alias') {
         // Note that all request arguments become reserved parameter names.
         $result->params = array_merge($result->params, $args);
     }
     if ($table->type == 'url') {
         // Note that all request arguments become reserved parameter names.
         $result->params = array_merge($result->params, $args);
     }
     // Load associated menu items
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         if ($pk != null) {
             $result->associations = MenusHelper::getAssociations($pk);
         } else {
             $result->associations = array();
         }
     }
     $result->menuordering = $pk;
     return $result;
 }
Example #29
0
 /**
  * Method to get a single record.
  *
  * @param	integer	The id of the primary key.
  *
  * @return	mixed	Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         // Include any manipulation of the data on the record e.g. expand out Registry fields
         // NB The params registry field - if used - is done automatically in the JAdminModel parent class
         // Convert the images field to an array.
         $registry = new Registry();
         $registry->loadString($item->images);
         $item->images = $registry->toArray();
         $registry = null;
         //release memory
         // Convert the urls field to an array.
         $registry = new Registry();
         $registry->loadString($item->urls);
         $item->urls = $registry->toArray();
         $registry = null;
         //release memory
         $item->introdescription = trim($item->intro) != '' ? $item->intro . "<hr id=\"system-readmore\" />" . $item->description : $item->description;
         if (!empty($item->id)) {
             $item->tags = new JHelperTags();
             $item->tags->getTagIds($item->id, 'com_knvbapi2.teamnaam');
         }
     }
     // Load associated content items
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         $item->associations = array();
         if ($item->id != null) {
             $associations = JLanguageAssociations::getAssociations('com_knvbapi2', '#__knvbapi2_teamnaams', 'com_knvbapi2.teamnaam.item', $item->id, 'id', 'alias', 'catid');
             foreach ($associations as $tag => $association) {
                 $item->associations[$tag] = $association->id;
             }
         }
     }
     return $item;
 }
Example #30
0
 /**
  * @todo refactor
  *
  * @return array
  */
 public function getExcludedItems()
 {
     static $excluded_items;
     if (!isset($excluded_items)) {
         $excluded_items = array();
         $registry = new Registry();
         $registry->loadString($this->sitemap->excluded_items);
         $excluded_items = $registry->toArray();
     }
     return $excluded_items;
 }