Exemple #1
0
 protected function updateUser($userinfo)
 {
     $locked = 0;
     if (!empty($userinfo['block']) || !empty($userinfo['activation'])) {
         if ($userinfo['block'] == 1 || $userinfo['activation'] == 1) {
             $locked = 1;
         }
     }
     $password = sha1(strtoupper($userinfo['username']) . ':' . strtoupper($userinfo['password_clear']));
     $sql = "UPDATE " . $this->dbaccount . ".account SET email='" . $userinfo['email'] . "', locked=" . $locked . ", sha_pass_hash='" . $password . "' WHERE UPPER(username)=UPPER('" . $userinfo['username'] . "')";
     $db = JTrinityCoreDBHelper::getDB();
     $db->setQuery($sql);
     if (!$db->query()) {
         JLog::add('Error updating account in trinity db. SQL= ' . $sql, JLog::ERROR, $this->logcat);
         return false;
     } else {
         // Get joomla user groups
         $jgroups = JUserHelper::getUserGroups($userinfo['id']);
         $dbo = JFactory::getDbo();
         $query = $dbo->getQuery(true);
         $query->select($dbo->quoteName('id') . ', ' . $dbo->quoteName('title'));
         $query->from($dbo->quoteName('#__usergroups'));
         $query->where($dbo->quoteName('id') . ' = ' . implode(' OR ' . $dbo->quoteName('id') . ' = ', $jgroups));
         $dbo->setQuery($query);
         $results = $dbo->loadObjectList();
         // Update account_access table
         $groups = JTrinityCoreDBHelper::getWowGroups();
         $gmlevel = 0;
         foreach ($groups as $v) {
             foreach ($results as $g) {
                 if (strtoupper($g->title) == strtoupper($v['name'])) {
                     $gmlevel = $v['id'];
                 }
             }
         }
         $sql = "UPDATE " . $this->dbaccount . ".account_access SET gmlevel=" . $gmlevel;
         $db->setQuery($sql);
         if (!$db->query()) {
             JLog::add('Error updating account_access in trinity db. SQL= ' . $sql, JLog::ERROR, $this->logcat);
             return false;
         }
     }
     return true;
 }
Exemple #2
0
 /**
  * method to run after an install/update/uninstall method
  *
  * @return void
  */
 function postflight($type, $parent)
 {
     // $parent is the class calling this method
     // $type is the type of change (install, update or discover_install)
     //echo '<p>' . JText::_('POSTFLIGHT_' . $type . '_TEXT') . '</p>';
     if ($type == 'install') {
         $db = JFactory::getDbo();
         // Check if already exist group
         $sql = "SELECT * FROM #__usergroups WHERE title LIKE 'Wow%' ";
         $db->setQuery($sql);
         if (!$db->loadObject()) {
             //JLoader::register('JTrinityCoreDBHelper', dirname(__FILE__) . DS . 'helpers' . DS . 'jtrinitycoredb.php');
             require_once JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_jtrinitycore' . DS . 'helpers' . DS . 'jtrinitycoredb.php';
             // Install the groups
             $groups = JTrinityCoreDBHelper::getWowGroups();
             // Add groups
             foreach ($groups as $v) {
                 $obj = new stdClass();
                 $obj->id = NULL;
                 $obj->parent_id = 2;
                 // Registered Users Id
                 //Jerror::raiseWarning(null, 'name='.$v['name']);
                 $obj->title = $v['name'];
                 if (!$db->insertObject('#__usergroups', $obj, 'id')) {
                     throw new Exception('Error inserting in usergroups. name=' . $v['name']);
                 }
                 $this->rebuild();
             }
         }
     }
 }