Permalink
Browse files

Initial porting of ArtofUser notes features to Joomla CMS.

  • Loading branch information...
1 parent c953c04 commit f60c9b7a50364b8eeda15820922aa4d501b2055a @eddieajau eddieajau committed Dec 5, 2011
Showing with 1,251 additions and 1 deletion.
  1. +4 −1 .gitignore
  2. +43 −0 administrator/components/com_users/controllers/note.php
  3. +30 −0 administrator/components/com_users/controllers/notes.php
  4. +1 −0 administrator/components/com_users/helpers/html/index.html
  5. +91 −0 administrator/components/com_users/helpers/html/users.php
  6. +5 −0 administrator/components/com_users/helpers/users.php
  7. +111 −0 administrator/components/com_users/models/forms/note.xml
  8. +164 −0 administrator/components/com_users/models/note.php
  9. +237 −0 administrator/components/com_users/models/notes.php
  10. +23 −0 administrator/components/com_users/models/users.php
  11. +58 −0 administrator/components/com_users/tables/note.php
  12. +1 −0 administrator/components/com_users/views/note/index.html
  13. +64 −0 administrator/components/com_users/views/note/tmpl/edit.php
  14. +1 −0 administrator/components/com_users/views/note/tmpl/index.html
  15. +96 −0 administrator/components/com_users/views/note/view.html.php
  16. +1 −0 administrator/components/com_users/views/notes/index.html
  17. +123 −0 administrator/components/com_users/views/notes/tmpl/default.php
  18. +1 −0 administrator/components/com_users/views/notes/tmpl/index.html
  19. +47 −0 administrator/components/com_users/views/notes/tmpl/modal.php
  20. +106 −0 administrator/components/com_users/views/notes/view.html.php
  21. +5 −0 administrator/components/com_users/views/users/tmpl/default.php
  22. +21 −0 installation/sql/mysql/joomla.sql
  23. +18 −0 installation/sql/mysql/joomla_update_173to250.sql
  24. BIN media/system/images/filter_16.png
  25. BIN media/system/images/note_16.png
  26. BIN media/system/images/note_add_16.png
View
5 .gitignore
@@ -1,2 +1,5 @@
*~
-
+/.project
+/.settings
+/.buildpath
+/configuration.php
View
43 administrator/components/com_users/controllers/note.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+jimport('joomla.application.component.controllerform');
+
+/**
+ * Category Subcontroller.
+ *
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @since 2.5.0
+ */
+class UsersControllerNote extends JControllerForm
+{
+ /**
+ * Gets the URL arguments to append to an item redirect.
+ *
+ * @param int $recordId The primary key id for the item.
+ * @param string $key The name of the primary key variable.
+ *
+ * @return string The arguments to append to the redirect URL.
+ * @since 1.6
+ */
+ protected function getRedirectToItemAppend($recordId = null, $key = 'id')
+ {
+ $append = parent::getRedirectToItemAppend($recordId, $key);
+
+ $userId = JRequest::getInt('u_id');
+ if ($userId) {
+ $append .= '&u_id='.$userId;
+ }
+
+ return $append;
+ }
+
+}
View
30 administrator/components/com_users/controllers/notes.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+jimport('joomla.application.component.controlleradmin');
+
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @since 2.5.0
+ */
+class UsersControllerNotes extends JControllerAdmin
+{
+ /**
+ * Proxy for getModel
+ *
+ * @return JModel
+ * @since 1.1
+ */
+ function getModel()
+ {
+ return parent::getModel('Note', 'UsersModel', array('ignore_request' => true));
+ }
+}
View
1 administrator/components/com_users/helpers/html/index.html
@@ -0,0 +1 @@
+<!DOCTYPE html><title></title>
View
91 administrator/components/com_users/helpers/html/users.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+/**
+ * Component HTML Helper
+ *
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ */
+class JHtmlUsers
+{
+ /**
+ * Display an image.
+ *
+ * @param string $image
+ *
+ * @return string
+ * @since 1.1
+ */
+ function image($src)
+ {
+ $src = preg_replace('#[^A-Z0-9\-_\.]#i', '', $src);
+ $file = JPATH_SITE.'/images/stories/'.$src;
+ JPath::check($file);
+
+ if (!file_exists($file)) {
+ return '';
+ }
+
+ return '<img src="'.JUri::root().'images/stories/'.$src.'" alt="Icon" />';
+ }
+
+ /**
+ * Displays an icon to add a note for this user.
+ *
+ * @return string
+ * @since 1.1
+ */
+ function addNote($userId)
+ {
+ $title = JText::_('COM_USERS_ADD_NOTE');
+
+ return '<a href="'.JRoute::_('index.php?option=com_users&task=note.add&u_id='.(int) $userId).'">'.
+ JHtml::image('images/note_add_16.png', 'COM_USERS_NOTES', array('title' => $title), true) . '</a>';
+ }
+
+ /**
+ * Displays an icon to filter the notes list on this user.
+ *
+ * @return string
+ * @since 1.1
+ */
+ function filterNotes($count, $userId)
+ {
+ if (empty($count)) {
+ return '';
+ }
+
+ $title = JText::_('COM_USERS_FITLER_NOTES');
+
+ return '<a href="'.JRoute::_('index.php?option=com_users&view=notes&filter_search=uid:'.(int) $userId).'">'.
+ JHtml::image('images/filter_16.png', 'COM_USERS_NOTES', array('title' => $title), true) . '</a>';
+ }
+
+ /**
+ * Displays a note icon.
+ *
+ * @return string
+ * @since 1.1
+ */
+ function notes($count, $userId)
+ {
+ if (empty($count)) {
+ return '';
+ }
+
+ $title = JText::sprintf('COM_USERS_N_USER_NOTES', $count);
+
+ return
+ '<a class="modal" href="'.JRoute::_('index.php?option=com_users&view=notes&tmpl=component&layout=modal&u_id='.(int) $userId).'">'.
+ JHtml::image('images/note_16.png', 'COM_USERS_NOTES', array('title' => $title), true) .
+ '</a>';
+ }
+}
View
5 administrator/components/com_users/helpers/users.php
@@ -55,6 +55,11 @@ public static function addSubmenu($vName)
'index.php?option=com_users&view=levels',
$vName == 'levels'
);
+ JSubMenuHelper::addEntry(
+ JText::_('COM_USERS_SUBMENU_NOTES'),
+ 'index.php?option=com_users&view=notes',
+ $vName == 'notes'
+ );
}
}
View
111 administrator/components/com_users/models/forms/note.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="utf-8"?>
+<form>
+ <fieldset>
+ <field
+ name="id"
+ type="hidden"
+ class="readonly"
+ size="6"
+ default="0"
+ readonly="true"
+ label="COM_USERS_FIELD_ID_LABEL"
+ />
+
+ <field
+ name="user_id"
+ type="user"
+ size="50"
+ class="inputbox"
+ required="true"
+ label="COM_USERS_FIELD_USER_ID_LABEL"
+ />
+
+ <field
+ name="catid"
+ type="category"
+ class="inputbox"
+ size="1"
+ extension="com_users.notes"
+ label="COM_USERS_FIELD_CATEGORY_ID_LABEL">
+ <option value="">JLIB_FORM_NO_CATEGORY</option>
+ </field>
+
+ <field
+ name="subject"
+ type="text"
+ class="inputbox"
+ size="80"
+ label="COM_USERS_FIELD_SUBJECT_LABEL"
+ description="COM_USERS_FIELD_SUBJECT_DESC"
+ />
+
+ <field
+ name="body"
+ type="editor"
+ class="inputbox"
+ rows="10"
+ cols="80"
+ filter="safehtml"
+ label="COM_USERS_FIELD_NOTEBODY_LABEL"
+ description="COM_USERS_FIELD_NOTEBODY_DESC"
+ />
+
+ <field
+ name="published"
+ type="radio"
+ class="inputbox"
+ default="1"
+ label="COM_USERS_FIELD_PUBLISHED_LABEL"
+ description="COM_USERS_FIELD_PUBLISHED_DESC"
+ >
+ <option value="1">JYES</option>
+ <option value="-2">JTRASHED</option>
+ </field>
+
+ <field
+ name="review_time"
+ type="calendar"
+ class="inputbox"
+ label="COM_USERS_FIELD_REVIEW_TIME_LABEL"
+ description="COM_USERS_FIELD_REVIEW_TIME_DESC"
+ default="0000-00-00"
+ format="%Y-%m-%d"
+ />
+
+ <field
+ name="checked_out"
+ type="hidden"
+ filter="unset"
+ />
+
+ <field
+ name="checked_out_time"
+ type="hidden"
+ filter="unset"
+ />
+
+ <field
+ name="created_user_id"
+ type="hidden"
+ filter="unset"
+ />
+
+ <field
+ name="created_time"
+ type="hidden"
+ filter="unset"
+ />
+
+ <field
+ name="modified_user_id"
+ type="hidden"
+ filter="unset"
+ />
+
+ <field
+ name="modified_time"
+ type="hidden"
+ filter="unset"
+ />
+ </fieldset>
+</form>
View
164 administrator/components/com_users/models/note.php
@@ -0,0 +1,164 @@
+<?php
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+jimport('joomla.application.component.modeladmin');
+
+/**
+ * Category model.
+ *
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @since 2.5.0
+ */
+class UsersModelNote extends JModelAdmin
+{
+ /**
+ * Method to get the record form.
+ *
+ * @param array $data An optional array of data for the form to interogate.
+ * @param boolean $loadData True if the form is to load its own data (default case), false if not.
+ * @return JForm A JForm object on success, false on failure
+ * @since 1.6
+ */
+ public function getForm($data = array(), $loadData = true)
+ {
+ // Initialise variables.
+ $app = JFactory::getApplication();
+
+ // Get the form.
+ $form = $this->loadForm('com_users.note', 'note', array('control' => 'jform', 'load_data' => $loadData));
+ if (empty($form)) {
+ return false;
+ }
+
+ return $form;
+ }
+
+ /**
+ * 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)
+ {
+ $result = parent::getItem($pk);
+
+ // Get the dispatcher and load the users plugins.
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('user');
+
+ // Trigger the data preparation event.
+ $results = $dispatcher->trigger('onContentPrepareData', array('com_users.note', $result));
+
+ return $result;
+ }
+
+ /**
+ * Method to get a table object, load it if necessary.
+ *
+ * @param string $name The table name. Optional.
+ * @param string $prefix The class prefix. Optional.
+ * @param array $options Configuration array for model. Optional.
+ *
+ * @return object The table
+ */
+ public function getTable($name = 'Note', $prefix = 'UsersTable', $options = array())
+ {
+ return parent::getTable($name, $prefix, $options);
+ }
+
+ /**
+ * Method to get the data that should be injected in the form.
+ *
+ * @return mixed The data for the form.
+ * @since 1.6
+ */
+ protected function loadFormData()
+ {
+ // Check the session for previously entered form data.
+ $data = JFactory::getApplication()->getUserState('com_users.edit.note.data', array());
+
+ if (empty($data)) {
+ $data = $this->getItem();
+
+ // Prime some default values.
+ if ($this->getState('note.id') == 0) {
+ $app = JFactory::getApplication();
+ $data->set('catid', JRequest::getInt('catid', $app->getUserState('com_users.notes.filter.category_id')));
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * Method to auto-populate the model state.
+ *
+ * Note. Calling getState in this method will result in recursion.
+ *
+ * @return void
+ * @since 1.1
+ */
+ protected function populateState()
+ {
+ parent::populateState();
+
+ $userId = JRequest::getInt('u_id');
+ $this->setState('note.user_id', $userId);
+ }
+
+ /**
+ * Method to save the form data.
+ *
+ * @param array The form data.
+ *
+ * @return boolean True on success.
+ */
+ public function save($data)
+ {
+ // Initialise variables.
+ $pk = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('note.id');
+ $table = $this->getTable();
+ $isNew = empty($pk);
+
+ if (!$table->bind($data)) {
+ $this->setError($table->getError());
+
+ return false;
+ }
+
+ // JTableCategory doesn't bind the params, so we need to do that by hand.
+ if (isset($data['params']) && is_array($data['params'])) {
+ $registry = new JRegistry();
+ $registry->loadArray($data['params']);
+ $table->params = $registry->toString();
+ // This will give us INI format.
+ }
+
+ if (!$table->check()) {
+ $this->setError($table->getError());
+
+ return false;
+ }
+
+ if (!$table->store()) {
+ $this->setError($table->getError());
+
+ return false;
+ }
+
+ $this->setState('note.id', $table->id);
+
+ return true;
+ }
+}
View
237 administrator/components/com_users/models/notes.php
@@ -0,0 +1,237 @@
+<?php
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+jimport('joomla.application.component.modellist');
+jimport('joomla.database.databasequery');
+
+/**
+ * Categories model.
+ *
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @since 2.5.0
+ */
+class UsersModelNotes extends JModelList
+{
+ /**
+ * Class constructor.
+ *
+ * @param array $config An optional associative array of configuration settings.
+ *
+ * @since 1.1
+ */
+ public function __construct($config = array())
+ {
+ // Set the list ordering fields.
+ if (empty($config['filter_fields']))
+ {
+ $config['filter_fields'] = array(
+ 'id',
+ 'a.id',
+ 'user_id',
+ 'a.user_id',
+ 'user_name',
+ 'subject',
+ 'a.subject',
+ 'catid',
+ 'a.catid',
+ 'category_title',
+ 'review_time',
+ 'a.review_time',
+ );
+ }
+
+ parent::__construct($config);
+ }
+
+ /**
+ * Method to auto-populate the model state.
+ *
+ * Note. Calling getState in this method will result in recursion.
+ *
+ * @return void
+ * @since 1.0
+ */
+ protected function populateState()
+ {
+ // Initialise variables.
+ $app = JFactory::getApplication();
+
+ // Adjust the context to support modal layouts.
+ if ($layout = JRequest::getVar('layout'))
+ {
+ $this->context .= '.' . $layout;
+ }
+
+ $value = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
+ $this->setState('filter.search', $value);
+
+ $value = $app->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
+ $this->setState('filter.published', $value);
+
+ $section = $app->getUserStateFromRequest($this->context . '.filter.section_id', 'filter_category_id');
+ $this->setState('filter.category_id', $section);
+
+ $userId = JRequest::getInt('u_id');
+ $this->setState('filter.user_id', $userId);
+
+ parent::populateState('a.created_time', 'DESC');
+ }
+
+ /**
+ * Method to get a store id based on model configuration state.
+ *
+ * This is necessary because the model is used by the component and
+ * different modules that might need different sets of data or different
+ * ordering requirements.
+ *
+ * @param string $id A prefix for the store id.
+ *
+ * @return string A store id.
+ * @since 1.6
+ */
+ protected function getStoreId($id = '')
+ {
+ // Compile the store id.
+ $id .= ':' . $this->getState('filter.search');
+ $id .= ':' . $this->getState('filter.published');
+ $id .= ':' . $this->getState('filter.category_id');
+
+ return parent::getStoreId($id);
+ }
+
+ /**
+ * Gets a user object if the user filter is set.
+ *
+ * @return JUser
+ *
+ * @since 2.5.0
+ */
+ public function getUser()
+ {
+ $user = new JUser;
+
+ // Filter by search in title
+ $search = $this->getState('filter.search');
+ if (stripos($search, 'uid:') === 0)
+ {
+ $user->load((int) substr($search, 4));
+ }
+
+ return $user;
+ }
+
+ /**
+ * Override the JModelList::getItems method.
+ *
+ * @return array
+ * @since 1.0
+ * @throws Exception on error.
+ */
+ public function getItems()
+ {
+ $items = parent::getItems();
+
+ return $items;
+ }
+
+ /**
+ * Build an SQL query to load the list data.
+ *
+ * @return JDatabaseQuery
+ * @since 1.0
+ */
+ protected function getListQuery()
+ {
+ // Initialise variables.
+ $db = $this->getDbo();
+ $query = $db->getQuery(true);
+ $section = $this->getState('filter.section_id');
+
+ // Select the required fields from the table.
+ $query->select(
+ $this->getState('list.select',
+ 'a.id, a.subject, a.checked_out, a.checked_out_time,' .
+ 'a.catid, a.created_time, a.review_time,' .
+ 'a.state'
+ )
+ );
+ $query->from('#__user_notes AS a');
+
+ // Join over the section
+ $query->select('c.title AS category_title, c.params AS category_params');
+ $query->leftJoin('`#__categories` AS c ON c.id = a.catid');
+
+ // Join over the users for the note user.
+ $query->select('u.name AS user_name');
+ $query->leftJoin('#__users AS u ON u.id = a.user_id');
+
+ // Join over the users for the checked out user.
+ $query->select('uc.name AS editor');
+ $query->leftJoin('#__users AS uc ON uc.id = a.checked_out');
+
+ // Filter by search in title
+ $search = $this->getState('filter.search');
+ if (!empty($search))
+ {
+ if (stripos($search, 'id:') === 0)
+ {
+ $query->where('a.id = ' . (int) substr($search, 3));
+ }
+ else if (stripos($search, 'uid:') === 0)
+ {
+ $query->where('a.user_id = ' . (int) substr($search, 4));
+ }
+ else
+ {
+ $search = $db->Quote('%' . $db->getEscaped($search, true) . '%');
+ $query->where('(a.subject LIKE ' . $search . ') OR (u.name LIKE ' . $search . ') OR (u.username LIKE ' . $search . ')');
+ }
+ }
+
+ // Filter by published state
+ $published = $this->getState('filter.state');
+ if (is_numeric($published))
+ {
+ $query->where('a.state = ' . (int) $published);
+ }
+ elseif ($published === '')
+ {
+ $query->where('(a.state IN (0, 1))');
+ }
+
+ // Filter by a single or group of categories.
+ $categoryId = (int) $this->getState('filter.catid');
+ if ($categoryId)
+ {
+ if (is_scalar($section))
+ {
+ $query->where('a.catid = ' . $categoryId);
+ }
+ }
+
+ // Filter by a single user.
+ $userId = (int) $this->getState('filter.user_id');
+ if ($userId)
+ {
+ // Add the body and where filter.
+ $query->select('a.body')
+ ->where('a.user_id = ' . $userId);
+ }
+
+ // Add the list ordering clause.
+ $orderCol = $this->state->get('list.ordering');
+ $orderDirn = $this->state->get('list.direction');
+ $query->order($db->getEscaped($orderCol . ' ' . $orderDirn));
+
+// echo nl2br(str_replace('#__','jos_',$query));
+ return $query;
+ }
+}
View
23 administrator/components/com_users/models/users.php
@@ -157,6 +157,7 @@ public function getItems()
$userIds[] = (int) $item->id;
$item->group_count = 0;
$item->group_names = '';
+ $item->note_count = 0;
}
// Get the counts from the database only for the users in the list.
@@ -185,13 +186,35 @@ public function getItems()
return false;
}
+ $query->clear()
+ ->select('n.user_id, COUNT(n.id) As note_count')
+ ->from('#__user_notes AS n')
+ ->where('n.user_id IN ('.implode(',', $userIds).')')
+ ->where('n.state >= 0')
+ ->group('n.user_id');
+
+ $db->setQuery((string) $query);
+
+ // Load the counts into an array indexed on the aro.value field (the user id).
+ $userNotes = $db->loadObjectList('user_id');
+
+ $error = $db->getErrorMsg();
+ if ($error) {
+ $this->setError($error);
+
+ return false;
+ }
+
// Second pass: collect the group counts into the master items array.
foreach ($items as &$item)
{
if (isset($userGroups[$item->id])) {
$item->group_count = $userGroups[$item->id]->group_count;
$item->group_names = $userGroups[$item->id]->group_names;
}
+ if (isset($userNotes[$item->id])) {
+ $item->note_count = $userNotes[$item->id]->note_count;
+ }
}
// Add the items to the internal cache.
View
58 administrator/components/com_users/tables/note.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @since 2.5.0
+ */
+class UsersTableNote extends JTable
+{
+ /*
+ * Constructor
+ *
+ * @param object $db Database object
+ *
+ * @since 1.1
+ */
+ function __construct(&$db)
+ {
+ parent::__construct('#__user_notes', 'id', $db);
+ }
+
+ /**
+ * Overload the store method for the Weblinks table.
+ *
+ * @param boolean $updateNulls Toggle whether null values should be updated.
+ *
+ * @return boolean True on success, false on failure.
+ * @since 1.0
+ */
+ public function store($updateNulls = false)
+ {
+ // Initialiase variables.
+ $date = JFactory::getDate()->toMySQL();
+ $userId = JFactory::getUser()->get('id');
+
+ if (empty($this->id)) {
+ // New record.
+ $this->created_time = $date;
+ $this->created_user_id = $userId;
+ }
+ else {
+ // Existing record.
+ $this->modified_time = $date;
+ $this->modified_user_id = $userId;
+ }
+
+ // Attempt to store the data.
+ return parent::store($updateNulls);
+ }
+}
View
1 administrator/components/com_users/views/note/index.html
@@ -0,0 +1 @@
+<html><body bgcolor="#FFFFFF"></body></html>
View
64 administrator/components/com_users/views/note/tmpl/edit.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
+
+JHTML::_('behavior.tooltip');
+JHTML::_('behavior.formvalidation');
+?>
+<script language="javascript" type="text/javascript">
+Joomla.submitbutton = function(task)
+{
+ if (task == 'note.cancel' || document.formvalidator.isValid(document.id('note-form'))) {
+ Joomla.submitform(task, document.getElementById('note-form'));
+ }
+}
+</script>
+<form action="<?php echo JRoute::_('index.php?option=com_users&view=note&id='.(int) $this->item->id);?>" method="post" name="adminForm" id="note-form" class="form-validate">
+ <div class="width-60 fltlft">
+ <fieldset class="adminform">
+ <legend>
+ <?php echo $this->item->id ? JText::sprintf('COM_USERS_EDIT_NOTE_N', $this->item->id) : JText::_('COM_USERS_NEW_NOTE');?>
+ </legend>
+
+ <ul class="adminformlist">
+ <li>
+ <?php echo $this->form->getLabel('subject'); ?>
+ <?php echo $this->form->getInput('subject'); ?>
+ </li>
+ <li>
+ <?php echo $this->form->getLabel('user_id'); ?>
+ <?php echo $this->form->getInput('user_id'); ?>
+ </li>
+ <li>
+ <?php echo $this->form->getLabel('catid'); ?>
+ <?php echo $this->form->getInput('catid'); ?>
+ </li>
+ <li>
+ <?php echo $this->form->getLabel('published'); ?>
+ <?php echo $this->form->getInput('published'); ?>
+ </li>
+ <li>
+ <?php echo $this->form->getLabel('review_time'); ?>
+ <?php echo $this->form->getInput('review_time'); ?>
+ </li>
+ </ul>
+
+ <div>
+ <?php echo $this->form->getLabel('body'); ?>
+ <div class="clr"></div>
+ <?php echo $this->form->getInput('body'); ?>
+ </div>
+
+ <input type="hidden" name="task" value="" />
+ <?php echo JHTML::_('form.token'); ?>
+ </fieldset>
+ </div>
+</form>
View
1 administrator/components/com_users/views/note/tmpl/index.html
@@ -0,0 +1 @@
+<html><body bgcolor="#FFFFFF"></body></html>
View
96 administrator/components/com_users/views/note/view.html.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+jimport('joomla.application.component.view');
+
+/**
+ * Category view.
+ *
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @since 2.5.0
+ */
+class UsersViewNote extends JView
+{
+ protected $form;
+ protected $item;
+ protected $state;
+
+ /**
+ * Override the display method for the view.
+ *
+ * @return void
+ * @since 1.0
+ */
+ public function display($tpl = null)
+ {
+ try
+ {
+ // Initialise view variables.
+ $this->state = $this->get('State');
+ $this->item = $this->get('Item');
+ $this->form = $this->get('Form');
+
+ // Check for errors.
+ if (count($errors = $this->get('Errors'))) {
+ throw new Exception(implode("\n", $errors), 500);
+ return false;
+ }
+
+ parent::display($tpl);
+ $this->_addToolbar();
+ }
+ catch (Exception $e)
+ {
+ JError::raiseError(500, $e->getMessage());
+ }
+ }
+
+ /**
+ * Display the toolbar.
+ *
+ * @return void
+ * @since 1.0
+ */
+ private function _addToolbar()
+ {
+ JRequest::setVar('hidemainmenu', 1);
+
+ $user = JFactory::getUser();
+ $isNew = ($this->item->id == 0);
+ $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
+ $canDo = UsersHelper::getActions($this->state->get('filter.category_id'), $this->item->id);
+
+ JToolBarHelper::title(JText::_('COM_USERS_NOTES'), 'weblinks.png');
+
+ // If not checked out, can save the item.
+ if (!$checkedOut && ($canDo->get('core.edit')||(count($user->getAuthorisedCategories('COM_USERS', 'core.create')))))
+ {
+ JToolBarHelper::apply('note.apply');
+ JToolBarHelper::save('note.save');
+ }
+ if (!$checkedOut && (count($user->getAuthorisedCategories('COM_USERS', 'core.create')))){
+ JToolBarHelper::save2new('note.save2new');
+ }
+ // If an existing item, can save to a copy.
+ if (!$isNew && (count($user->getAuthorisedCategories('COM_USERS', 'core.create')) > 0)) {
+ JToolBarHelper::save2copy('note.save2copy');
+ }
+ if (empty($this->item->id)) {
+ JToolBarHelper::cancel('note.cancel');
+ }
+ else {
+ JToolBarHelper::cancel('note.cancel', 'JTOOLBAR_CLOSE');
+ }
+
+ JToolBarHelper::divider();
+ JToolBarHelper::help('JHELP_COMPONENTS_USERS_NOTES_EDIT');
+ }
+}
View
1 administrator/components/com_users/views/notes/index.html
@@ -0,0 +1 @@
+<html><body bgcolor="#FFFFFF"></body></html>
View
123 administrator/components/com_users/views/notes/tmpl/default.php
@@ -0,0 +1,123 @@
+<?php
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
+JHtml::_('behavior.tooltip');
+
+$user = JFactory::getUser();
+$listOrder = $this->escape($this->state->get('list.ordering'));
+$listDirn = $this->escape($this->state->get('list.direction'));
+$canEdit = $user->authorise('core.edit', 'com_users');
+?>
+<form action="<?php echo JRoute::_('index.php?option=com_users&view=notes');?>" method="post" name="adminForm">
+ <fieldset id="filter-bar">
+ <div class="filter-search fltlft">
+ <label class="filter-search-lbl" for="filter_search"><?php echo JText::_('JSEARCH_FILTER_LABEL'); ?></label>
+ <input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" title="<?php echo JText::_('COM_USERS_SEARCH_IN_NOTE_TITLE'); ?>" />
+ <button type="submit"><?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?></button>
+ <button type="button" onclick="document.id('filter_search').value='';this.form.submit();"><?php echo JText::_('JSEARCH_FILTER_CLEAR'); ?></button>
+ </div>
+
+ <div class="filter-select fltrt">
+ <select name="filter_section_id" id="filter_section_id" class="inputbox" onchange="this.form.submit()">
+ <option value=""><?php echo JText::_('JOPTION_SELECT_CATEGORY');?></option>
+ <?php echo JHtml::_('select.options', JHtml::_('category.options', 'com_users.notes'),
+ 'value', 'text', $this->state->get('filter.category_id'));?>
+ </select>
+
+ <select name="filter_published" id="filter_published" class="inputbox" onchange="this.form.submit()">
+ <option value=""><?php echo JText::_('JOPTION_SELECT_PUBLISHED');?></option>
+ <?php echo JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'),
+ 'value', 'text', $this->state->get('filter.state'), true);?>
+ </select>
+ </div>
+ </fieldset>
+
+ <table class="adminlist">
+ <thead>
+ <tr>
+ <th width="1%">
+ <input type="checkbox" name="toggle" value="" class="checklist-toggle" />
+ </th>
+ <th>
+ <?php echo JHtml::_('grid.sort', 'COM_USERS_USER_HEADING', 'user_name', $listDirn, $listOrder); ?>
+ </th>
+ <th>
+ <?php echo JHtml::_('grid.sort', 'COM_USERS_SUBJECT_HEADING', 'a.subject', $listDirn, $listOrder); ?>
+ </th>
+ <th width="20%">
+ <?php echo JHtml::_('grid.sort', 'COM_USERS_CATEGORY_HEADING', 'category_title', $listDirn, $listOrder); ?>
+ </th>
+ <th width="10%">
+ <?php echo JHtml::_('grid.sort', 'COM_USERS_REVIEW_HEADING', 'a.review_time', $listDirn, $listOrder); ?>
+ </th>
+ <th width="1%" class="nowrap">
+ <?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
+ </th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <td colspan="15">
+ <?php echo $this->pagination->getListFooter(); ?>
+ </td>
+ </tr>
+ </tfoot>
+ <tbody>
+ <?php foreach ($this->items as $i => $item) : ?>
+ <tr class="row<?php echo $i % 2; ?>">
+ <td class="center checklist">
+ <?php echo JHtml::_('grid.id', $i, $item->id); ?>
+ </td>
+ <td>
+ <?php if ($item->checked_out) : ?>
+ <?php echo JHtml::_('jxgrid.checkedout', $item->editor, $item->checked_out_time); ?>
+ <?php endif; ?>
+ <?php if ($canEdit) : ?>
+ <a href="<?php echo JRoute::_('index.php?option=com_users&task=note.edit&id='.$item->id);?>">
+ <?php echo $this->escape($item->user_name); ?></a>
+ <?php else : ?>
+ <?php echo $this->escape($item->user_name); ?>
+ <?php endif; ?>
+ </td>
+ <td>
+ <?php if ($item->subject) : ?>
+ <?php echo $this->escape($item->subject); ?>
+ <?php else : ?>
+ <?php echo JText::_('COM_USERS_EMPTY_SUBJECT'); ?>
+ <?php endif; ?>
+ </td>
+ <td class="center">
+ <?php if ($item->catid) : ?>
+ <?php echo JHtml::_('user.image', $item->category_image); ?>
+ <?php endif; ?>
+ <?php echo $this->escape($item->category_title); ?>
+ </td>
+ <td class="center">
+ <?php if (intval($item->review_time)) : ?>
+ <?php echo $this->escape($item->review_time); ?>
+ <?php else : ?>
+ <?php echo JText::_('COM_USERS_EMPTY_REVIEW'); ?>
+ <?php endif; ?>
+ </td>
+ <td class="center">
+ <?php echo (int) $item->id; ?>
+ </td>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+
+ <input type="hidden" name="task" value="" />
+ <input type="hidden" name="boxchecked" value="0" />
+ <input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
+ <input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
+ <?php echo JHtml::_('form.token'); ?>
+</form>
View
1 administrator/components/com_users/views/notes/tmpl/index.html
@@ -0,0 +1 @@
+<html><body bgcolor="#FFFFFF"></body></html>
View
47 administrator/components/com_users/views/notes/tmpl/modal.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
+JHtml::_('behavior.tooltip');
+?>
+<div class="unotes">
+ <h1><?php echo JText::sprintf('COM_USERS_NOTES_FOR_USER', $this->user->name, $this->user->id); ?></h1>
+<?php if (empty($this->items)) : ?>
+ <?php echo JText::_('COM_USERS_NO_NOTES'); ?>
+<?php else : ?>
+ <ol>
+ <?php foreach ($this->items as $i => $item) : ?>
+ <li class="<?php echo $i % 2 ? 'o' : 'e'; ?>">
+ <div class="fltlft">
+ <?php if ($item->subject) : ?>
+ <h4><?php echo JText::sprintf('COM_USERS_NOTE_N_SUBJECT', $item->id, $this->escape($item->subject)); ?></h4>
+ <?php else : ?>
+ <h4><?php echo JText::sprintf('COM_USERS_NOTE_N_SUBJECT', $item->id, JText::_('COM_USERS_EMPTY_SUBJECT')); ?></h4>
+ <?php endif; ?>
+ </div>
+
+ <div class="fltlft">
+ <?php echo JHtml::date($item->created_time, 'A d B Y H:M'); ?>
+ </div>
+
+ <?php if ($item->catid) : ?>
+ <div class="fltrgt">
+ <?php /*echo JHtml::_('user.image', $item->category_params->get('image'));*/ ?>
+ </div>
+ <?php endif; ?>
+
+ <div class="clr"></div>
+
+ <?php echo $item->body; ?>
+ </li>
+ <?php endforeach; ?>
+ </ol>
+<?php endif; ?>
+</div>
View
106 administrator/components/com_users/views/notes/view.html.php
@@ -0,0 +1,106 @@
+<?php
+/**
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+jimport('joomla.application.component.view');
+
+/**
+ * Categories view.
+ *
+ * @package Joomla.Administrator
+ * @subpackage com_users
+ * @since 2.5.0
+ */
+class UsersViewNotes extends JView
+{
+ protected $items;
+ protected $pagination;
+ protected $state;
+
+ /**
+ * Override the display method for the view.
+ *
+ * @return void
+ * @since 1.0
+ */
+ public function display($tpl = null)
+ {
+ try
+ {
+ // Initialise view variables.
+ $this->items = $this->get('Items');
+ $this->pagination = $this->get('Pagination');
+ $this->state = $this->get('State');
+ $this->user = $this->get('User');
+
+ // Check for errors.
+ if (count($errors = $this->get('Errors')))
+ {
+ throw new Exception(implode("\n", $errors), 500);
+ return false;
+ }
+
+ $this->_setToolbar();
+ parent::display($tpl);
+ }
+ catch (Exception $e)
+ {
+ JError::raiseError(500, $e->getMessage());
+ }
+ }
+
+ /**
+ * Display the toolbar
+ */
+ private function _setToolbar()
+ {
+ $canDo = UsersHelper::getActions();
+ $state = $this->get('State');
+
+ JToolBarHelper::title(JText::_('COM_USERS_VIEW_NOTES_TITLE'), 'logo');
+
+ if ($canDo->get('core.create'))
+ {
+ JToolBarHelper::addNew('notes.add');
+ }
+
+ if ($canDo->get('core.edit'))
+ {
+ JToolBarHelper::editList('notes.edit');
+ }
+
+ if ($canDo->get('core.edit.state'))
+ {
+ JToolBarHelper::divider();
+ JToolBarHelper::publish('notes.publish', 'JTOOLBAR_PUBLISH', true);
+ JToolBarHelper::unpublish('notes.unpublish', 'JTOOLBAR_UNPUBLISH', true);
+
+ JToolBarHelper::divider();
+ JToolBarHelper::archiveList('notes.archive');
+ JToolBarHelper::checkin('notes.checkin');
+ }
+
+ if ($state->get('filter.state') == -2 && $canDo->get('core.delete'))
+ {
+ JToolBarHelper::deleteList('', 'notes.delete', 'JTOOLBAR_EMPTY_TRASH');
+ JToolBarHelper::divider();
+ }
+ elseif ($canDo->get('core.edit.state'))
+ {
+ JToolBarHelper::trash('notes.trash');
+ JToolBarHelper::divider();
+ }
+
+ if ($canDo->get('core.admin'))
+ {
+ JToolBarHelper::preferences('com_users');
+ JToolBarHelper::divider();
+ }
+ }
+}
View
5 administrator/components/com_users/views/users/tmpl/default.php
@@ -113,6 +113,11 @@
<?php endif; ?>
</td>
<td>
+ <div class="fltrt">
+ <?php echo JHtml::_('users.filterNotes', $item->note_count, $item->id); ?>
+ <?php echo JHtml::_('users.notes', $item->note_count, $item->id); ?>
+ <?php echo JHtml::_('users.addNote', $item->id); ?>
+ </div>
<?php if ($canEdit) : ?>
<a href="<?php echo JRoute::_('index.php?option=com_users&task=user.edit&id='.(int) $item->id); ?>" title="<?php echo JText::sprintf('COM_USERS_EDIT_USER', $this->escape($item->name)); ?>">
<?php echo $this->escape($item->name); ?></a>
View
21 installation/sql/mysql/joomla.sql
@@ -994,6 +994,27 @@ CREATE TABLE `#__users` (
# -------------------------------------------------------
+CREATE TABLE IF NOT EXISTS `#__user_notes` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `user_id` int(10) unsigned NOT NULL DEFAULT '0',
+ `catid` int(10) unsigned NOT NULL DEFAULT '0',
+ `subject` varchar(100) NOT NULL DEFAULT '',
+ `body` text NOT NULL,
+ `state` tinyint(3) NOT NULL DEFAULT '0',
+ `checked_out` int(10) unsigned NOT NULL DEFAULT '0',
+ `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `created_user_id` int(10) unsigned NOT NULL DEFAULT '0',
+ `created_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `modified_user_id` int(10) unsigned NOT NULL,
+ `modified_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `review_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`),
+ KEY `idx_user_id` (`user_id`),
+ KEY `idx_category_id` (`catid`)
+) DEFAULT CHARSET=utf8;
+
+# -------------------------------------------------------
+
CREATE TABLE IF NOT EXISTS `#__user_profiles` (
`user_id` int(11) NOT NULL,
`profile_key` varchar(100) NOT NULL,
View
18 installation/sql/mysql/joomla_update_173to250.sql
@@ -0,0 +1,18 @@
+CREATE TABLE IF NOT EXISTS `#__user_notes` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `user_id` int(10) unsigned NOT NULL DEFAULT '0',
+ `catid` int(10) unsigned NOT NULL DEFAULT '0',
+ `subject` varchar(100) NOT NULL DEFAULT '',
+ `body` text NOT NULL,
+ `state` tinyint(3) NOT NULL DEFAULT '0',
+ `checked_out` int(10) unsigned NOT NULL DEFAULT '0',
+ `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `created_user_id` int(10) unsigned NOT NULL DEFAULT '0',
+ `created_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `modified_user_id` int(10) unsigned NOT NULL,
+ `modified_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `review_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`),
+ KEY `idx_user_id` (`user_id`),
+ KEY `idx_category_id` (`catid`)
+) DEFAULT CHARSET=utf8;
View
BIN media/system/images/filter_16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN media/system/images/note_16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN media/system/images/note_add_16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f60c9b7

Please sign in to comment.