function plugin(&$link, $attr = null) { global $Itemid, $mtconf; $database =& JFactory::getDBO(); # Load Parameters $params =& new JParameter($link->attribs); $params->def('show_claim', $mtconf->get('show_claim')); $owner = new JTableUser($database); $owner->load($link->user_id); if ($params->get('show_claim') == 1 && strpos(strtolower($owner->usertype), 'administrator') !== false) { $html = ''; // $html = '<img src="images/M_images/indent1.png" width="9" height="9" />'; $html .= '<a href="'; $html .= JRoute::_('index.php?option=com_mtree&task=claim&link_id=' . $link->link_id); $html .= '"'; # Insert attributes if (is_array($attr)) { // from array foreach ($attr as $key => $val) { $key = htmlspecialchars($key); $val = htmlspecialchars($val); $html .= " {$key}=\"{$val}\""; } } elseif (!is_null($attr)) { // from scalar $html .= " {$attr}"; } $html .= '>' . JText::_('Claim') . "</a>"; # Return the claim listing link return $html; } }
/** * Test... * * @covers JTableUser::store * * @return void */ public function testStoreNewUser() { $user = new JTableUser(self::$driver); $user->name = 'Neil Armstrong'; $user->username = '******'; $user->email = '*****@*****.**'; $user->groups = array('Astronauts' => 1, 'Moon walkers' => 2); $this->assertThat($user->store(), $this->isTrue(), 'Checks that the new user stored correctly.'); self::$driver->setQuery('SELECT * FROM #__users WHERE id = ' . (int) $user->id); $stored = self::$driver->loadObject(); $this->assertThat($stored->name, $this->equalTo('Neil Armstrong'), 'Checks that name was stored correctly.'); $this->assertThat($stored->username, $this->equalTo('neil.armstrong'), 'Checks that username was stored correctly.'); $this->assertThat($stored->email, $this->equalTo('*****@*****.**'), 'Checks that email was stored correctly.'); self::$driver->setQuery('SELECT group_id FROM #__user_usergroup_map WHERE user_id = ' . (int) $user->id); $this->assertThat(self::$driver->loadColumn(), $this->equalTo(array(1, 2)), 'Checks that the user group mapping was stored correctly.'); }
public function testGetRowData() { $db = JFactory::getDbo(); $db->setQuery('SELECT * FROM ' . $db->quoteName('#__users') . ' WHERE ' . $db->quoteName('id') . ' = ' . (int) 42); $arrayFromQuery = $db->loadAssoc(); $testTable = new JTableUser(self::$driver); $testTable->load(42); $arrayFromMethod = $this->object->getRowData($testTable); $this->assertEquals($arrayFromQuery, $arrayFromMethod); }
public function __construct() { $db = JFactory::getDBO(); parent::__construct($db); }
function mosUser(&$db) { parent::__construct($db); }