public function Save($Values, $SaveGlobal = FALSE) {
      // Figure out how to find the existing permission.
      if(array_key_exists('PermissionID', $Values)) {
         $Where = array('PermissionID' => $Values['PermissionID']);
         unset($Values['PermissionID']);
         
         $this->SQL->Update('Permission', $this->_Backtick($Values), $Where)->Put();
      } else {
         $Where = array();
         
         if(array_key_exists('RoleID', $Values)) {
            $Where['RoleID'] = $Values['RoleID'];
            unset($Values['RoleID']);
         } elseif (array_key_exists('Role', $Values)) {
            // Get the RoleID.
            $RoleID = $this->SQL->GetWhere('Role', array('Name' => $Values['Role']))->Value('RoleID');
            if (!$RoleID)
               return;
            $Where['RoleID'] = $RoleID;
            unset($Values['Role']);
         } else {
            $Where['RoleID'] = 0; // default role.
         }
         
         if(array_key_exists('JunctionTable', $Values)) {
            $Where['JunctionTable'] = $Values['JunctionTable'];

            // If the junction table was given then so must the other values.
            if(array_key_exists('JunctionColumn', $Values))
               $Where['JunctionColumn'] = $Values['JunctionColumn'];
            $Where['JunctionID'] = $Values['JunctionID'];
            
            unset($Values['JunctionTable'], $Values['JunctionColumn'], $Values['JunctionID']);
         } else {
            $Where['JunctionTable'] = NULL; // no junction table.
            $Where['JunctionColumn'] = NULL;
            $Where['JunctionID'] = NULL;
         }
         
         $this->SQL->Replace('Permission', $this->_Backtick($Values), $Where, TRUE);

			if($SaveGlobal && !is_null($Where['JunctionTable'])) {
				// Save these permissions with the global permissions.
				$Where['JunctionTable'] = NULL; // no junction table.
            $Where['JunctionColumn'] = NULL;
            $Where['JunctionID'] = NULL;

				$this->SQL->Replace('Permission', $this->_Backtick($Values), $Where, TRUE);
			}
      }

      $this->ClearPermissions();
   }