protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addBoolean(self::CONFIRMED); parent::_addForeignKeyColumn(self::USER_ID, TBGUsersTable::getTable(), TBGUsersTable::ID); parent::_addForeignKeyColumn(self::GROUP_ID, TBGGroupsTable::getTable(), TBGGroupsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addVarchar(self::MODULE_NAME, 50); parent::_addBoolean(self::ALLOWED); parent::_addForeignKeyColumn(self::UID, TBGUsersTable::getTable(), TBGUsersTable::ID); parent::_addForeignKeyColumn(self::GID, TBGGroupsTable::getTable(), TBGGroupsTable::ID); parent::_addForeignKeyColumn(self::TID, Core::getTable('TBGTeamsTable'), TBGTeamsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addVarchar(self::MODULE_NAME, 50); parent::_addBoolean(self::ALLOWED); parent::_addForeignKeyColumn(self::UID, TBGUsersTable::getTable(), TBGUsersTable::ID); parent::_addForeignKeyColumn(self::GID, TBGGroupsTable::getTable(), TBGGroupsTable::ID); parent::_addForeignKeyColumn(self::TID, B2DB::getTable('TBGTeamsTable'), TBGTeamsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
public static function getAll() { if (self::$_groups === null) { self::$_groups = array(); if ($res = TBGGroupsTable::getTable()->getAll()) { while ($row = $res->getNextRow()) { self::$_groups[$row->get(TBGGroupsTable::ID)] = TBGContext::factory()->TBGGroup($row->get(TBGGroupsTable::ID), $row); } } } return self::$_groups; }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addVarchar(self::PERMISSION_TYPE, 100); parent::_addVarchar(self::TARGET_ID, 200, 0); parent::_addBoolean(self::ALLOWED); parent::_addVarchar(self::MODULE, 50); parent::_addForeignKeyColumn(self::UID, TBGUsersTable::getTable()); parent::_addForeignKeyColumn(self::GID, TBGGroupsTable::getTable()); parent::_addForeignKeyColumn(self::TID, TBGTeamsTable::getTable()); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable()); }
public function __construct() { parent::__construct(self::B2DBNAME, self::ID); parent::_addVarchar(self::MODULE_NAME, 50); parent::_addInteger(self::NOTIFY_TYPE, 5); parent::_addInteger(self::TARGET_ID, 10); parent::_addVarchar(self::TITLE, 100); parent::_addText(self::CONTENTS, false); parent::_addInteger(self::STATUS, 5); parent::_addForeignKeyColumn(self::UID, TBGUsersTable::getTable(), TBGUsersTable::ID); parent::_addForeignKeyColumn(self::GID, TBGGroupsTable::getTable(), TBGGroupsTable::ID); parent::_addForeignKeyColumn(self::TID, B2DB::getTable('TBGTeamsTable'), TBGTeamsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addVarchar(self::UNAME, 50); parent::_addVarchar(self::PASSWORD, 50); parent::_addVarchar(self::BUDDYNAME, 50); parent::_addVarchar(self::REALNAME, 100); parent::_addVarchar(self::EMAIL, 200); parent::_addBoolean(self::CUSTOMSTATE); parent::_addVarchar(self::HOMEPAGE, 250, ''); parent::_addVarchar(self::LANGUAGE, 100, ''); parent::_addInteger(self::LASTSEEN, 10); parent::_addInteger(self::QUOTA); parent::_addBoolean(self::ACTIVATED); parent::_addBoolean(self::ENABLED); parent::_addBoolean(self::DELETED); parent::_addVarchar(self::AVATAR, 30, ''); parent::_addBoolean(self::USE_GRAVATAR, true); parent::_addBoolean(self::PRIVATE_EMAIL); parent::_addInteger(self::JOINED, 10); parent::_addForeignKeyColumn(self::USERSTATE, TBGUserStateTable::getTable(), TBGUserStateTable::ID); parent::_addForeignKeyColumn(self::GROUP_ID, TBGGroupsTable::getTable(), TBGGroupsTable::ID); parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID); }
public function runAddUser(TBGRequest $request) { try { if (!TBGContext::getScope()->hasUsersAvailable()) { throw new Exception($this->getI18n()->__('This instance of The Bug Genie cannot add more users')); } if ($username = trim($request['username'])) { if (!TBGUser::isUsernameAvailable($username)) { if ($request->getParameter('mode') == 'import') { $user = TBGUser::getByUsername($username); $user->addScope(TBGContext::getScope()); return $this->renderJSON(array('imported' => true, 'message' => $this->getI18n()->__('The user was successfully added to this scope (pending user confirmation)'))); } elseif (TBGContext::getScope()->isDefault()) { throw new Exception($this->getI18n()->__('This username already exists')); } else { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('allow_import' => true)); } } $user = new TBGUser(); $user->setUsername($username); $user->setRealname($request->getParameter('realname', $username)); $user->setBuddyname($request->getParameter('buddyname', $username)); $user->setEmail($request->getParameter('email')); $user->setGroup(TBGGroupsTable::getTable()->selectById((int) $request->getParameter('group_id', TBGSettings::get(TBGSettings::SETTING_USER_GROUP)))); $user->setEnabled(); $user->setActivated(); if ($request->hasParameter('password') && !(empty($request['password']) && empty($request['password_repeat']))) { if (empty($request['password']) || $request['password'] != $request['password_repeat']) { throw new Exception($this->getI18n()->__('Please enter the same password twice')); } $password = $request['password']; $user->setPassword($password); } else { $password = TBGUser::createPassword(); $user->setPassword($password); } $user->setJoined(); $user->save(); foreach ((array) $request['teams'] as $team_id) { $user->addToTeam(TBGTeamsTable::getTable()->selectById((int) $team_id)); } TBGEvent::createNew('core', 'config.createuser.save', $user, array('password' => $password))->trigger(); } else { throw new Exception($this->getI18n()->__('Please enter a username')); } $this->getResponse()->setTemplate('configuration/findusers'); $this->too_short = false; $this->created_user = true; $this->users = array($user); $this->total_results = 1; $this->title = $this->getI18n()->__('User %username created', array('%username' => $username)); $this->total_count = TBGUser::getUsersCount(); $this->more_available = TBGContext::getScope()->hasUsersAvailable(); } catch (Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $e->getMessage())); } }