Source for file note.php

Documentation is available at note.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_users
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * User note model.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_users
  17.  * @since       2.5
  18.  */
  19. class UsersModelNote extends JModelAdmin
  20. {
  21.  
  22.     /**
  23.      * The type alias for this content type.
  24.      *
  25.      * @var      string 
  26.      * @since    3.2
  27.      */
  28.     public $typeAlias = 'com_users.note';
  29.  
  30.     /**
  31.      * Method to get the record form.
  32.      *
  33.      * @param   array    $data      Data for the form.
  34.      * @param   boolean  $loadData  True if the form is to load its own data (default case), false if not.
  35.      *
  36.      * @return  mixed  A JForm object on success, false on failure
  37.      *
  38.      * @since   2.5
  39.      */
  40.     public function getForm($data array()$loadData true)
  41.     {
  42.         // Get the form.
  43.         $form $this->loadForm('com_users.note''note'array('control' => 'jform''load_data' => $loadData));
  44.         if (empty($form))
  45.         {
  46.             return false;
  47.         }
  48.  
  49.         return $form;
  50.     }
  51.  
  52.     /**
  53.      * Method to get a single record.
  54.      *
  55.      * @param   integer  $pk  The id of the primary key.
  56.      *
  57.      * @return  mixed  Object on success, false on failure.
  58.      *
  59.      * @since   2.5
  60.      */
  61.     public function getItem($pk null)
  62.     {
  63.         $result parent::getItem($pk);
  64.  
  65.         // Get the dispatcher and load the users plugins.
  66.         $dispatcher    JEventDispatcher::getInstance();
  67.         JPluginHelper::importPlugin('user');
  68.  
  69.         // Trigger the data preparation event.
  70.         $dispatcher->trigger('onContentPrepareData'array('com_users.note'$result));
  71.  
  72.         return $result;
  73.     }
  74.  
  75.     /**
  76.      * Method to get a table object, load it if necessary.
  77.      *
  78.      * @param   string  $name     The table name. Optional.
  79.      * @param   string  $prefix   The class prefix. Optional.
  80.      * @param   array   $options  Configuration array for model. Optional.
  81.      *
  82.      * @return  JTable  The table object
  83.      *
  84.      * @since   2.5
  85.      */
  86.     public function getTable($name 'Note'$prefix 'UsersTable'$options array())
  87.     {
  88.         return JTable::getInstance($name$prefix$options);
  89.     }
  90.  
  91.     /**
  92.      * Method to get the data that should be injected in the form.
  93.      *
  94.      * @return  mixed  The data for the form.
  95.      *
  96.      * @since   1.6
  97.      */
  98.     protected function loadFormData()
  99.     {
  100.         // Get the application
  101.         $app JFactory::getApplication();
  102.  
  103.         // Check the session for previously entered form data.
  104.         $data $app->getUserState('com_users.edit.note.data'array());
  105.  
  106.         if (empty($data))
  107.         {
  108.             $data $this->getItem();
  109.  
  110.             // Prime some default values.
  111.             if ($this->getState('note.id'== 0)
  112.             {
  113.                 $data->set('catid'$app->input->get('catid'$app->getUserState('com_users.notes.filter.category_id')'int'));
  114.             }
  115.  
  116.             $userId $app->input->get('u_id'0'int');
  117.  
  118.             if ($userId != 0)
  119.             {
  120.                 $data->user_id $userId;
  121.             }
  122.         }
  123.  
  124.         $this->preprocessData('com_users.note'$data);
  125.  
  126.         return $data;
  127.     }
  128.  
  129.     /**
  130.      * Method to auto-populate the model state.
  131.      *
  132.      * Note. Calling getState in this method will result in recursion.
  133.      *
  134.      * @return  void 
  135.      *
  136.      * @since   2.5
  137.      */
  138.     protected function populateState()
  139.     {
  140.         parent::populateState();
  141.  
  142.         $userId JFactory::getApplication()->input->get('u_id'0'int');
  143.         $this->setState('note.user_id'$userId);
  144.     }
  145.  
  146.     /**
  147.      * Method to save the form data.
  148.      *
  149.      * @param   array  $data  The form data.
  150.      *
  151.      * @return  boolean  True on success.
  152.      *
  153.      * @since   2.5
  154.      */
  155.     /*public function save($data)
  156.     {
  157.         $pk        = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('note.id');
  158.         $table    = $this->getTable();
  159.         $isNew    = empty($pk);
  160.  
  161.         if (!$table->bind($data))
  162.         {
  163.             $this->setError($table->getError());
  164.  
  165.             return false;
  166.         }
  167.  
  168.         // JTableCategory doesn't bind the params, so we need to do that by hand.
  169.         if (isset($data['params']) && is_array($data['params']))
  170.         {
  171.             $registry = new JRegistry();
  172.             $registry->loadArray($data['params']);
  173.             $table->params = $registry->toString();
  174.             // This will give us INI format.
  175.         }
  176.  
  177.         if (!$table->check())
  178.         {
  179.             $this->setError($table->getError());
  180.  
  181.             return false;
  182.         }
  183.  
  184.         if (!$table->store())
  185.         {
  186.             $this->setError($table->getError());
  187.  
  188.             return false;
  189.         }
  190.  
  191.         $this->setState('note.id', $table->id);
  192.  
  193.         return true;
  194.     }*/
  195. }

Documentation generated on Tue, 19 Nov 2013 15:09:37 +0100 by phpDocumentor 1.4.3