Permalink
Browse files

Convert UserService query to ModelServices

  • Loading branch information...
Amy Stephen Amy Stephen
Amy Stephen authored and Amy Stephen committed Apr 28, 2012
1 parent 4b4f45b commit 4198151b4b7f3d83cb66e493d69a12b498b2fad1
@@ -40,6 +40,8 @@
<custom_field name="gender" filter="char" null="1" default="" values="M,F"/>
<custom_field name="about_me" filter="text" null="1" default=""/>
<custom_field name="twitter" filter="url" null="1" default=""/>
+ <custom_field name="editor" filter="int" null="0" default="1"/>
+ <custom_field name="language" filter="char" null="0" default="en-GB" values="en-GB"/>
<custom_field name="date_of_birth" filter="date" null="1" default=""/>
</custom_fields>
<parameters>
@@ -6,6 +6,8 @@
*/
namespace Molajo\MVC\Model;
+use Molajo\Service\Services;
+
defined('MOLAJO') or die;
/**
@@ -142,7 +144,7 @@ protected function getLoadAdditionalData()
$name = (string)$child['name'];
- $a = new TableModel($name);
+ $a = Services::Model()->connect($name);
$join = (string)$child['join'];
$joinArray = explode(';', $join);
@@ -154,16 +156,16 @@ protected function getLoadAdditionalData()
$targetField = $whereArray[1];
$sourceField = $whereArray[0];
- $a->query->where($a->db->qn($targetField)
+ $a->model->query->where($a->model->db->qn($targetField)
. ' = '
. (int)$this->query_results[$sourceField]);
}
- $this->query_results['Model\\' . $name] = $a->loadObjectList();
+ $this->query_results['Model\\' . $name] = $a->execute('loadObjectList');
}
}
- /** return array of primary query and additional data elements */
+ /** return array containing primary query and additional data elements */
return $this;
}
@@ -13,7 +13,7 @@
/**
* Configuration
*
- * @package Molajo
+ * @package Molajo
* @subpackage Service
* @since 1.0
*/
@@ -188,7 +188,7 @@ public function setSitePaths()
if (defined('SITE_TEMP_FOLDER')) {
} else {
define('SITE_TEMP_FOLDER', SITE_FOLDER_PATH . '/'
- . Services::Registry()->get('Configuration', 'temp_path', SITE_FOLDER_PATH . '/temp'));
+ . Services::Registry()->get('Configuration', 'temp_path', SITE_FOLDER_PATH . '/temp'));
}
if (defined('SITE_TEMP_URL')) {
} else {
@@ -142,12 +142,13 @@ public function connect ($table = 'Content')
$this->model->set('db', Services::$dbDriver()->get('db'));
$this->model->set('query', Services::$dbDriver()->getQuery());
- Services::$dbDriver()->getQuery()->clear();
$this->model->set('nullDate', Services::$dbDriver()->get('db')->getNullDate());
$this->model->set('now', Services::$dbDriver()->get('db')->getDateFormat());
$this->model->set('query_results', array());
$this->model->set('pagination', array());
+ Services::$dbDriver()->getQuery()->clear();
+
return $this;
}
@@ -8,8 +8,6 @@
use Molajo\Service\Services;
-use Molajo\MVC\Model\ItemModel;
-
defined('MOLAJO') or die;
/**
@@ -71,21 +69,15 @@ protected function __construct($id = 0)
*/
protected function load()
{
+ $m = Services::Model()->connect('Users');
-/**
- get the editor and language
- and session?
- $user =& JFactory::getUser();
- $editor = $user->getParam('editor', $this->getCfg('editor'));
- $editor = JTriggerHelper::isEnabled('editors', $editor) ? $editor : $this->getCfg('editor');
- $config->setValue('config.editor', $editor);
-getUserState , setUserState , getUserStateFromRequest
-login and logout
-registration
-
-*/
- $m = new ItemModel ('Users', $this->id);
- $results = $m->load();
+ $m->model->set('id', $this->id);
+
+ $results = $m->execute('load');
+
+ if ($results === false) {
+ throw new \RuntimeException ('Application setSiteData() query problem');
+ }
$first_name = '';
$last_name = '';
@@ -97,10 +89,14 @@ protected function load()
|| $name == 'metadata'
|| substr($name, 0, 5) == 'Model'
) {
+
} else {
+
Services::Registry()->set('User', $name, $value);
+
if ($name == 'first_name') {
$first_name = $value;
+
} elseif ($name == 'last_name') {
$last_name = $value;
}
@@ -188,18 +184,13 @@ protected function load()
if (count($temp) == 0) {
$temp = array(SYSTEM_GROUP_PUBLIC, SYSTEM_GROUP_GUEST);
}
+
Services::Registry()->set('User', 'ViewGroups', $temp);
/** User Activity */
-/**
- $temp = array();
$activity = $results['Model\\UserActivity'];
- if (count($activity > 0)) {
- foreach ($activity as $act) {
- $temp[] = $app->application_id;
- }
- }
- Services::Registry()->set('User', 'Activity', $temp);
- */
+ Services::Registry()->set('User', 'UserActivity', $activity);
+
+ return $this;
}
}

0 comments on commit 4198151

Please sign in to comment.