/** * Add user's viewable roles to gdn.meta if user is logged in. * @param $sender * @param $args */ public function gdn_dispatcher_afterControllerCreate_handler($sender, $args) { // Function addDefinition returns the value of the definition if you pass only one argument. if (!gdn::controller()->addDefinition('Roles')) { if (Gdn::session()->isValid()) { $roleModel = new RoleModel(); gdn::controller()->addDefinition("Roles", $roleModel->getPublicUserRoles(gdn::session()->UserID, "Name")); } } }
/** * * * @return bool */ public function insertUserTable() { $CurrentUser = $this->SQL->getWhere('User', array('UserID' => Gdn::session()->UserID))->firstRow(DATASET_TYPE_ARRAY); $CurrentPassword = $CurrentUser['Password']; $CurrentHashMethod = $CurrentUser['HashMethod']; $CurrentTransientKey = gdn::session()->transientKey(); // Delete the current user table. $this->SQL->Truncate('User'); // Load the new user table. $UserTableInfo =& $this->Data['Tables']['User']; if (!$this->importExists('User', 'HashMethod')) { $this->_InsertTable('User', array('HashMethod' => $this->GetPasswordHashMethod())); } else { $this->_InsertTable('User'); } $UserTableInfo['Inserted'] = true; $AdminEmail = val('OverwriteEmail', $this->Data); $SqlArgs = array(':Email' => $AdminEmail); $SqlSet = ''; $SqlArgs[':Password'] = $CurrentPassword; $SqlArgs[':HashMethod'] = $CurrentHashMethod; $SqlSet = ', Password = :Password, HashMethod = :HashMethod'; // If doing a password reset, save out the new admin password: if (strcasecmp($this->GetPasswordHashMethod(), 'reset') == 0) { if (!isset($SqlArgs[':Password'])) { $PasswordHash = new Gdn_PasswordHash(); $Hash = $PasswordHash->HashPassword(val('OverwritePassword', $this->Data)); $SqlSet .= ', Password = :Password, HashMethod = :HashMethod'; $SqlArgs[':Password'] = $Hash; $SqlArgs[':HashMthod'] = 'Vanilla'; } // Write it out. $this->query("update :_User set Admin = 1{$SqlSet} where Email = :Email", $SqlArgs); } else { // Set the admin user flag. $this->query("update :_User set Admin = 1{$SqlSet} where Email = :Email", $SqlArgs); } // Start the new session. $User = Gdn::userModel()->GetByEmail(val('OverwriteEmail', $this->Data)); if (!$User) { $User = Gdn::userModel()->GetByUsername(val('OverwriteEmail', $this->Data)); } Gdn::session()->start(val('UserID', $User), true); gdn::session()->transientKey($CurrentTransientKey); return true; }
?> </th> <th class="options column-checkbox"></th> </tr> </thead> <tbody> <?php foreach ($this->data('Log') as $Row) { $RecordLabel = valr('Data.Type', $Row); if (!$RecordLabel) { $RecordLabel = $Row['RecordType']; } $RecordLabel = Gdn_Form::LabelCode($RecordLabel); $user = userBuilder($Row, 'Insert'); $user = Gdn::userModel()->getByUsername(val('Name', $user)); $viewPersonalInfo = gdn::session()->checkPermission('Garden.PersonalInfo.View'); $userBlock = new MediaItemModule(val('Name', $user), userUrl($user)); $userBlock->setView('media-sm')->setImage(userPhotoUrl($user))->addMetaIf($viewPersonalInfo, Gdn_Format::Email($user->Email)); $Url = FALSE; if (in_array($Row['Operation'], array('Edit', 'Moderate'))) { switch (strtolower($Row['RecordType'])) { case 'discussion': $Url = "/discussion/{$Row['RecordID']}/x/p1"; break; case 'comment': $Url = "/discussion/comment/{$Row['RecordID']}#Comment_{$Row['RecordID']}"; } } elseif ($Row['Operation'] === 'Delete') { switch (strtolower($Row['RecordType'])) { case 'comment': $Url = "/discussion/{$Row['ParentRecordID']}/x/p1";