<commit_before><?php

	/**
	 * Team members table
	 *
	 * @author <NAME> <<EMAIL>>
	 ** @version 3.0
	 * @license http://www.opensource.org/licenses/mozilla1.1.php Mozilla Public License 1.1 (MPL 1.1)
	 * @package thebuggenie
	 * @subpackage tables
	 */

	/**
	 * Team members table
	 *
	 * @package thebuggenie
	 * @subpackage tables
	 */
	class TBGTeamMembersTable extends TBGB2DBTable 
	{

		const B2DBNAME = 'teammembers';
		const ID = 'teammembers.id';
		const SCOPE = 'teammembers.scope';
		const UID = 'teammembers.uid';
		const TID = 'teammembers.tid';
		
		/**
		 * Return an instance of this table
		 *
		 * @return TBGTeamMembersTable
		 */
		public static function getTable()
		{
			return B2DB::getTable('TBGTeamMembersTable');
		}

		public function __construct()
		{
			parent::__construct(self::B2DBNAME, self::ID);
			
			parent::_addForeignKeyColumn(self::UID, TBGUsersTable::getTable(), TBGUsersTable::ID);
			parent::_addForeignKeyColumn(self::TID, B2DB::getTable('TBGTeamsTable'), TBGTeamsTable::ID);
			parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID);
		}

		public function getUIDsForTeamID($team_id)
		{
			$crit = $this->getCriteria();
			$crit->addWhere(self::TID, $team_id);

			$uids = array();
			if ($res = $this->doSelect($crit))
			{
				while ($row = $res->getNextRow())
				{
					$uids[$row->get(self::UID)] = $row->get(self::UID);
				}
			}

			return $uids;
		}
		
		public function clearTeamsByUserID($user_id)
		{
			$crit = $this->getCriteria();
			$crit->addWhere(self::UID, $user_id);
			$crit->addJoin(TBGTeamsTable::getTable(), TBGTeamsTable::ID, self::TID);
			$crit->addWhere(TBGTeamsTable::ONDEMAND, $ondemand);
			$res = $this->doDelete($crit);
		}

		public function getNumberOfMembersByTeamID($team_id)
		{
			$crit = $this->getCriteria();
			$crit->addWhere(self::TID, $team_id);
			$count = $this->doCount($crit);

			return $count;
		}

		public function cloneTeamMemberships($cloned_team_id, $new_team_id)
		{
			$crit = $this->getCriteria();
			$crit->addWhere(self::TID, $cloned_team_id);
			$memberships_to_add = array();
			if ($res = $this->doSelect($crit))
			{
				while ($row = $res->getNextRow())
				{
					$memberships_to_add[] = $row->get(self::UID);
				}
			}

			foreach ($memberships_to_add as $uid)
			{
				$crit = $this->getCriteria();
				$crit->addInsert(self::UID, $uid);
				$crit->addInsert(self::TID, $new_team_id);
				$crit->addInsert(self::SCOPE, TBGContext::getScope()->getID());
				$this->doInsert($crit);
			}
		}
		
		public function getTeamIDsForUserID($user_id, $ondemand = false)
		{
			$crit = $this->getCriteria();
			$crit->addWhere(self::UID, $user_id);
			return $this->doSelect($crit);
		}
		
	}
<commit_msg>Remove addWhere to a column that does not exist, fixes editing users (fixes #793)<commit_after><?php

	/**
	 * Team members table
	 *
	 * @author <NAME> <<EMAIL>>
	 ** @version 3.0
	 * @license http://www.opensource.org/licenses/mozilla1.1.php Mozilla Public License 1.1 (MPL 1.1)
	 * @package thebuggenie
	 * @subpackage tables
	 */

	/**
	 * Team members table
	 *
	 * @package thebuggenie
	 * @subpackage tables
	 */
	class TBGTeamMembersTable extends TBGB2DBTable 
	{

		const B2DBNAME = 'teammembers';
		const ID = 'teammembers.id';
		const SCOPE = 'teammembers.scope';
		const UID = 'teammembers.uid';
		const TID = 'teammembers.tid';
		
		/**
		 * Return an instance of this table
		 *
		 * @return TBGTeamMembersTable
		 */
		public static function getTable()
		{
			return B2DB::getTable('TBGTeamMembersTable');
		}

		public function __construct()
		{
			parent::__construct(self::B2DBNAME, self::ID);
			
			parent::_addForeignKeyColumn(self::UID, TBGUsersTable::getTable(), TBGUsersTable::ID);
			parent::_addForeignKeyColumn(self::TID, B2DB::getTable('TBGTeamsTable'), TBGTeamsTable::ID);
			parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID);
		}

		public function getUIDsForTeamID($team_id)
		{
			$crit = $this->getCriteria();
			$crit->addWhere(self::TID, $team_id);

			$uids = array();
			if ($res = $this->doSelect($crit))
			{
				while ($row = $res->getNextRow())
				{
					$uids[$row->get(self::UID)] = $row->get(self::UID);
				}
			}

			return $uids;
		}
		
		public function clearTeamsByUserID($user_id)
		{
			$crit = $this->getCriteria();
			$crit->addWhere(self::UID, $user_id);
			$crit->addJoin(TBGTeamsTable::getTable(), TBGTeamsTable::ID, self::TID);
			//$crit->addWhere(TBGTeamsTable::ONDEMAND, $ondemand);
			$res = $this->doDelete($crit);
		}

		public function getNumberOfMembersByTeamID($team_id)
		{
			$crit = $this->getCriteria();
			$crit->addWhere(self::TID, $team_id);
			$count = $this->doCount($crit);

			return $count;
		}

		public function cloneTeamMemberships($cloned_team_id, $new_team_id)
		{
			$crit = $this->getCriteria();
			$crit->addWhere(self::TID, $cloned_team_id);
			$memberships_to_add = array();
			if ($res = $this->doSelect($crit))
			{
				while ($row = $res->getNextRow())
				{
					$memberships_to_add[] = $row->get(self::UID);
				}
			}

			foreach ($memberships_to_add as $uid)
			{
				$crit = $this->getCriteria();
				$crit->addInsert(self::UID, $uid);
				$crit->addInsert(self::TID, $new_team_id);
				$crit->addInsert(self::SCOPE, TBGContext::getScope()->getID());
				$this->doInsert($crit);
			}
		}
		
		public function getTeamIDsForUserID($user_id, $ondemand = false)
		{
			$crit = $this->getCriteria();
			$crit->addWhere(self::UID, $user_id);
			return $this->doSelect($crit);
		}
		
	}

{'fraction_non_alphanumeric': 0.17397555715312724, 'fraction_numerical': 0.005212077641984184, 'mean_word_length': 3.9335106382978724, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6880619', 'n_tokens_mistral': 2384, 'n_tokens_neox': 2017, 'n_words': 335}